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

106 lines
2.5 KiB
Python
Raw Permalink Normal View History

2021-04-26 20:07:00 +02:00
#coding:utf-8
2022-01-21 18:49:26 +01:00
"""
ID: issue-2469
ISSUE: 2469
TITLE: Stored procedure recursively called by calculated field fails after reconnect
DESCRIPTION:
NOTES:
Confirmed bug on 4.0.0.2353; 3.0.8.33401.
Checked on 4.0.0.2365, 3.0.8.33415 -- all fine.
JIRA: CORE-2032
FBTEST: bugs.core_2032
2022-01-21 18:49:26 +01:00
"""
2021-04-26 20:07:00 +02:00
2022-01-21 18:49:26 +01:00
import pytest
from firebird.qa import *
2021-04-26 20:07:00 +02:00
2022-01-21 18:49:26 +01:00
db = db_factory()
2021-04-26 20:07:00 +02:00
2022-01-21 18:49:26 +01:00
test_script = """
2021-04-26 20:07:00 +02:00
set term ^;
create or alter procedure strange_procedure (
result_to_return float,
reference_id integer)
returns (result float) as
begin
suspend;
end
^
set term ;^
commit;
create table test (
id integer not null,
result_to_return float,
reference_id integer,
calc_fld computed by (
(
select result
from
strange_procedure(
test.result_to_return,
test.reference_id
)
)
)
);
commit;
insert into test (id, result_to_return, reference_id) values (1, 20, 0);
insert into test (id, result_to_return, reference_id) values (0, 10, null);
commit;
set term ^;
create or alter procedure strange_procedure (
result_to_return float,
reference_id integer)
returns (
result float)
as
declare variable sum_of_referenced_items float;
begin
-- initialize variables
result = result_to_return;
sum_of_referenced_items = 0;
-- if reference is null then it
-- must be record id = 0
if (reference_id is null) then
begin
select sum(t.calc_fld)
from test t where t.reference_id = 0
into :sum_of_referenced_items;
if (sum_of_referenced_items > :result)
then
result = sum_of_referenced_items;
end
suspend;
end
^
set term ;^
commit;
set list on;
select calc_fld as value_before_reconnect from test where ID = 0;
commit;
connect '$(DSN)' user 'SYSDBA' password 'masterkey';
select calc_fld as value_after_reconnect from test where ID = 0;
2021-12-22 20:23:11 +01:00
"""
2021-04-26 20:07:00 +02:00
2022-01-21 18:49:26 +01:00
act = isql_act('db', test_script, substitutions=[('[ \t]+', ' ')])
2021-04-26 20:07:00 +02:00
2022-01-21 18:49:26 +01:00
expected_stdout = """
2021-04-26 20:07:00 +02:00
VALUE_BEFORE_RECONNECT 20
VALUE_AFTER_RECONNECT 20
2021-12-22 20:23:11 +01:00
"""
2021-04-26 20:07:00 +02:00
@pytest.mark.version('>=3.0.8')
2022-01-21 18:49:26 +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