2021-04-26 20:07:00 +02:00
|
|
|
#coding:utf-8
|
2022-01-30 16:52:03 +01:00
|
|
|
|
|
|
|
"""
|
|
|
|
ID: isql-05
|
|
|
|
ISSUE: 5655
|
|
|
|
TITLE: ISQL should be able to process single statement with length up to 10*1024*1024 chars
|
|
|
|
DESCRIPTION:
|
|
|
|
Source sample see in #5655
|
|
|
|
Test prepares script with two SELECT statements:
|
|
|
|
One of them has length EXACTLY equal to 10*1024*1024 chars (excluding final ';'), another length = 10Mb + 1.
|
|
|
|
First statement should be executed OK, second should fail.
|
|
|
|
Checked on WI-V3.0.2.32625, WI-T4.0.0.440
|
|
|
|
|
|
|
|
PS. Best place of this test in functional folder rather than in 'issues' one.
|
|
|
|
JIRA: CORE-5382
|
|
|
|
"""
|
2021-04-26 20:07:00 +02:00
|
|
|
|
|
|
|
import pytest
|
2021-12-22 20:25:10 +01:00
|
|
|
from pathlib import Path
|
2022-01-30 16:52:03 +01:00
|
|
|
from firebird.qa import *
|
2021-04-26 20:07:00 +02:00
|
|
|
|
2022-01-30 16:52:03 +01:00
|
|
|
init_script = """
|
2021-04-26 20:07:00 +02:00
|
|
|
recreate table dua(i int);
|
|
|
|
insert into dua(i) values(1);
|
|
|
|
commit;
|
2021-12-22 20:25:10 +01:00
|
|
|
"""
|
2021-04-26 20:07:00 +02:00
|
|
|
|
2022-01-30 16:52:03 +01:00
|
|
|
db = db_factory(init=init_script)
|
2021-12-22 20:25:10 +01:00
|
|
|
|
2022-01-30 16:52:03 +01:00
|
|
|
act = python_act('db', substitutions=[('After line .*', ''), ('-At line.*', ''), ('At line.*', '')])
|
2021-04-26 20:07:00 +02:00
|
|
|
|
2022-01-30 16:52:03 +01:00
|
|
|
expected_stdout = """
|
2021-04-26 20:07:00 +02:00
|
|
|
I 10485760
|
2021-12-22 20:25:10 +01:00
|
|
|
"""
|
|
|
|
|
2022-01-30 16:52:03 +01:00
|
|
|
expected_stderr = """
|
2021-04-26 20:07:00 +02:00
|
|
|
Statement failed, SQLSTATE = 54000
|
|
|
|
Dynamic SQL Error
|
|
|
|
-SQL error code = -902
|
|
|
|
-Implementation limit exceeded
|
|
|
|
-SQL statement is too long. Maximum size is 10485760 bytes.
|
2021-12-22 20:25:10 +01:00
|
|
|
"""
|
2021-04-26 20:07:00 +02:00
|
|
|
|
2022-01-30 16:52:03 +01:00
|
|
|
script_file = temp_file('script.sql')
|
2021-04-26 20:07:00 +02:00
|
|
|
|
2021-12-22 20:25:10 +01:00
|
|
|
@pytest.mark.version('>=3.0')
|
2022-01-30 16:52:03 +01:00
|
|
|
def test_1(act: Action, script_file: Path):
|
|
|
|
with script_file.open(mode='w') as f:
|
2021-12-22 20:25:10 +01:00
|
|
|
f.write('set list on;\n')
|
|
|
|
f.write(f"select /*{'-' * 10485720}*/ 10485760 i from rdb$database;\n")
|
|
|
|
f.write(f"select /*{'-' * 10485721}*/ 10485761 i from rdb$database;\n")
|
2022-01-30 16:52:03 +01:00
|
|
|
act.expected_stderr = expected_stderr
|
|
|
|
act.expected_stdout = expected_stdout
|
|
|
|
act.isql(switches=[], input_file=script_file)
|
|
|
|
assert (act.clean_stderr == act.clean_expected_stderr and
|
|
|
|
act.clean_stdout == act.clean_expected_stdout)
|