2021-04-26 20:07:00 +02:00
|
|
|
#coding:utf-8
|
|
|
|
#
|
|
|
|
# id: bugs.core_1716
|
|
|
|
# title: Wrong variable initialization in recursive procedures
|
2021-12-19 22:25:36 +01:00
|
|
|
# decription:
|
2021-04-26 20:07:00 +02:00
|
|
|
# tracker_id: CORE-1716
|
|
|
|
# min_versions: ['2.1.7']
|
|
|
|
# versions: 2.1.7
|
|
|
|
# qmid: None
|
|
|
|
|
|
|
|
import pytest
|
|
|
|
from firebird.qa import db_factory, isql_act, Action
|
|
|
|
|
|
|
|
# version: 2.1.7
|
|
|
|
# resources: None
|
|
|
|
|
|
|
|
substitutions_1 = [('=.*', '')]
|
|
|
|
|
|
|
|
init_script_1 = """"""
|
|
|
|
|
|
|
|
db_1 = db_factory(page_size=4096, sql_dialect=3, init=init_script_1)
|
|
|
|
|
|
|
|
test_script_1 = """
|
|
|
|
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
|
|
|
|
|
|
|
act_1 = isql_act('db_1', test_script_1, substitutions=substitutions_1)
|
|
|
|
|
|
|
|
expected_stdout_1 = """
|
|
|
|
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
|
|
|
|
|
|
|
@pytest.mark.version('>=2.1.7')
|
2021-04-28 12:42:11 +02:00
|
|
|
def test_1(act_1: Action):
|
2021-04-26 20:07:00 +02:00
|
|
|
act_1.expected_stdout = expected_stdout_1
|
|
|
|
act_1.execute()
|
2021-12-22 20:23:11 +01:00
|
|
|
assert act_1.clean_stdout == act_1.clean_expected_stdout
|
2021-04-26 20:07:00 +02:00
|
|
|
|