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_4233_test.py

74 lines
1.8 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-4557
ISSUE: 4557
TITLE: In PSQL modules with declared cursors engine could assign value to the wrong variable
DESCRIPTION:
JIRA: CORE-4233
FBTEST: bugs.core_4233
2022-01-23 20:41:55 +01:00
"""
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
set term ^;
create or alter procedure hidden_vars
returns (out_a int, out_b1 int, out_b2 int)
as
declare a int;
declare c cursor for
2022-01-23 20:41:55 +01:00
(select
coalesce( (select count(*) from rdb$relations), -1)
2021-04-26 20:07:00 +02:00
-- Aliasing of expression results in derived tables is mandatory in 3.0
-- otherwise get error about metadata updating:
2022-01-23 20:41:55 +01:00
-- -no column name specified for column number 1 in derived table
2021-04-26 20:07:00 +02:00
-- <missing arg #2 - possibly status vector overflow>
as tabs_cnt -- <<<<<<<<<<<<<<< nb <<<<<<<<<<<
from rdb$database
);
declare b int = 0;
begin
out_b1 = b;
2022-01-23 20:41:55 +01:00
2021-04-26 20:07:00 +02:00
open c;
fetch c into :a;
close c;
2022-01-23 20:41:55 +01:00
2021-04-26 20:07:00 +02:00
out_a = a;
out_b2 = b;
b = b + 1;
suspend;
end ^
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
select out_b1, out_b2 from hidden_vars;
select out_b1, out_b2 from hidden_vars;
select out_b1, out_b2 from hidden_vars;
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, substitutions=[('=.*', '')])
2021-04-26 20:07:00 +02:00
2022-01-23 20:41:55 +01:00
expected_stdout = """ OUT_B1 OUT_B2
2021-04-26 20:07:00 +02:00
============ ============
0 0
OUT_B1 OUT_B2
============ ============
0 0
OUT_B1 OUT_B2
============ ============
0 0
2021-12-22 20:23:11 +01:00
"""
2021-04-26 20:07:00 +02:00
2022-01-23 20:41:55 +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