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

104 lines
2.1 KiB
Python
Raw Permalink Normal View History

2021-04-26 20:07:00 +02:00
#coding:utf-8
2022-01-20 17:32:14 +01:00
"""
ID: issue-2141
ISSUE: 2141
TITLE: Wrong variable initialization in recursive procedures
DESCRIPTION:
JIRA: CORE-1716
FBTEST: bugs.core_1716
2022-01-20 17:32:14 +01:00
"""
2021-04-26 20:07:00 +02:00
2022-01-20 17:32:14 +01:00
import pytest
from firebird.qa import *
2021-04-26 20:07:00 +02:00
2022-01-20 17:32:14 +01:00
db = db_factory()
2021-04-26 20:07:00 +02:00
2022-01-20 17:32:14 +01:00
test_script = """
2021-04-26 20:07:00 +02:00
create domain dm_int as integer default 0 not null;
commit;
2021-12-19 22:25:36 +01:00
2021-04-26 20:07:00 +02:00
-- sample with returned variable
set term ^;
create procedure sp_test1(a_cnt int)
returns (o_cnt int, o_ret dm_int)
as
begin
2021-12-19 22:25:36 +01:00
while (a_cnt>0) do
2021-04-26 20:07:00 +02:00
begin
o_cnt = a_cnt;
a_cnt = a_cnt-1;
2021-12-19 22:25:36 +01:00
for
select o_ret
from sp_test1( :a_cnt )
into o_ret
do
2021-04-26 20:07:00 +02:00
suspend;
end
suspend;
end
^
2021-12-19 22:25:36 +01:00
2021-04-26 20:07:00 +02:00
create procedure sp_test2(a_cnt int)
returns (o_cnt int, o_ret dm_int)
as
declare x dm_int;
begin
2021-12-19 22:25:36 +01:00
while (a_cnt>0) do
2021-04-26 20:07:00 +02:00
begin
o_cnt = a_cnt;
a_cnt = a_cnt-1;
2021-12-19 22:25:36 +01:00
for
select o_ret
from sp_test2( :a_cnt )
into o_ret
do begin
o_ret = x;
suspend;
2021-04-26 20:07:00 +02:00
end
end
o_ret=x;
suspend;
end
^
set term ;^
commit;
2021-12-19 22:25:36 +01:00
2021-04-26 20:07:00 +02:00
select * from sp_test1(3);
select * from sp_test2(3);
2021-12-19 22:25:36 +01:00
"""
2021-04-26 20:07:00 +02:00
2022-01-20 17:32:14 +01:00
act = isql_act('db', test_script, substitutions=[('=.*', '')])
2021-04-26 20:07:00 +02:00
2022-01-20 17:32:14 +01:00
expected_stdout = """
2021-04-26 20:07:00 +02:00
O_CNT O_RET
============ ============
3 0
3 0
3 0
3 0
2 0
2 0
1 0
1 0
2021-12-19 22:25:36 +01:00
2021-04-26 20:07:00 +02:00
O_CNT O_RET
============ ============
3 0
3 0
3 0
3 0
2 0
2 0
1 0
1 0
2021-12-19 22:25:36 +01:00
"""
2021-04-26 20:07:00 +02:00
2022-01-20 17:32:14 +01:00
@pytest.mark.version('>=3')
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