6
0
mirror of https://github.com/FirebirdSQL/firebird-qa.git synced 2025-01-22 21:43:06 +01:00
firebird-qa/tests/bugs/core_4375_test.py

81 lines
1.9 KiB
Python
Raw Normal View History

2021-04-26 20:07:00 +02:00
#coding:utf-8
2022-01-23 20:41:55 +01:00
"""
ID: issue-4697
ISSUE: 4697
TITLE: Procedure executes infinitely if contains more than 32767 statements inside any BEGIN/END block
DESCRIPTION:
JIRA: CORE-4375
"""
2021-04-26 20:07:00 +02:00
2022-01-23 20:41:55 +01:00
import pytest
from firebird.qa import *
2021-04-26 20:07:00 +02:00
2022-01-23 20:41:55 +01:00
init_script = """
2021-04-26 20:07:00 +02:00
-- On Alpha2 (WI-T3.0.0.30809):
-- Statement failed, SQLSTATE = 42000
-- Dynamic SQL Error
-- -SQL error code = -104
-- -Invalid command
-- -no column name specified for column number 1 in derived table C
-- On Beta2 (WI-T3.0.0.31807) works OK:
set term ^;
execute block returns (SQL blob sub_type text) as
begin
2022-01-23 20:41:55 +01:00
select
'create or alter procedure test_proc returns(id integer) as
2021-04-26 20:07:00 +02:00
begin '
|| list('
suspend; -- '||id, '')
||'
2022-01-23 20:41:55 +01:00
end'
2021-04-26 20:07:00 +02:00
from (select row_number()over() id from rdb$types a, rdb$types b rows 50000) c
into :SQL;
execute statement :SQL;
--suspend;
2022-01-23 20:41:55 +01:00
end
2021-04-26 20:07:00 +02:00
^
set term ;^
commit;
2021-12-22 20:23:11 +01:00
"""
2021-04-26 20:07:00 +02:00
2022-01-23 20:41:55 +01:00
db = db_factory(init=init_script)
2021-04-26 20:07:00 +02:00
2022-01-23 20:41:55 +01:00
test_script = """
2021-04-26 20:07:00 +02:00
set list on;
select count(*) cnt from test_proc;
set term ^;
execute block returns(cnt int) as
declare v_proc_src blob;
begin
execute statement 'select count(*) cnt from test_proc' into cnt;
suspend;
2022-01-23 20:41:55 +01:00
2021-04-26 20:07:00 +02:00
select rdb$procedure_source from rdb$procedures where rdb$procedure_name = upper('test_proc')
into v_proc_src;
select octet_length(:v_proc_src) - octet_length(replace(:v_proc_src, ascii_char(10), ''))
from rdb$database
into cnt;
suspend;
end
^
set term ;^
2021-12-22 20:23:11 +01:00
"""
2021-04-26 20:07:00 +02:00
2022-01-23 20:41:55 +01:00
act = isql_act('db', test_script)
2021-04-26 20:07:00 +02:00
2022-01-23 20:41:55 +01:00
expected_stdout = """
2021-04-26 20:07:00 +02:00
CNT 50000
CNT 50000
CNT 50001
2021-12-22 20:23:11 +01:00
"""
2021-04-26 20:07:00 +02:00
@pytest.mark.version('>=3.0')
2022-01-23 20:41:55 +01:00
def test_1(act: Action):
act.expected_stdout = expected_stdout
act.execute()
assert act.clean_stdout == act.clean_expected_stdout
2021-04-26 20:07:00 +02:00