6
0
mirror of https://github.com/FirebirdSQL/firebird-qa.git synced 2025-01-22 13:33:07 +01:00
firebird-qa/tests/bugs/gh_6854_test.py

81 lines
1.7 KiB
Python

#coding:utf-8
"""
ID: issue-6854
ISSUE: 6854
TITLE: Crash occurs when use SIMILAR TO ...
DESCRIPTION:
FBTEST: bugs.gh_6854
NOTES:
[25.11.2023] pzotov
Writing code requires more care since 6.0.0.150: ISQL does not allow to specify THE SAME terminator twice,
i.e.
set term @; select 1 from rdb$database @ set term @; - will not compile ("Unexpected end of command" raises).
"""
import pytest
from firebird.qa import *
db = db_factory()
test_script = """
set list on;
recreate table test(
id int generated by default as identity constraint pk_txt primary key
,txt varchar(1) character set utf8
);
insert into test(txt) values('A');
insert into test(txt) values('B');
set term ^;
execute block returns(
o_id int
,o_gds1 int
,o_gds2 int
) as
declare b boolean;
begin
for select id, txt from test as cursor c
do begin
begin
b = c.txt similar to 'A{0,1}';
when any do
begin
o_gds1 = gdscode;
end
end
begin
b = c.txt similar to 'A{X,1}';
when any do
begin
o_gds2 = gdscode;
end
end
o_id = c.id;
suspend;
end
end
^
set term ;^
"""
act = isql_act('db', test_script)
expected_stdout = """
O_ID 1
O_GDS1 <null>
O_GDS2 335544884
O_ID 2
O_GDS1 <null>
O_GDS2 335544884
"""
@pytest.mark.version('>=3.0.8')
def test_1(act: Action):
act.expected_stdout = expected_stdout
act.execute()
assert act.clean_stdout == act.clean_expected_stdout