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

120 lines
2.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-4816
ISSUE: 4816
TITLE: Regression in 3.0.x: wrong handling in FOR-cursor when NOT EXISTS( select from <VIEW> )
statement is used to check results obtained from SP
2022-01-23 20:41:55 +01:00
DESCRIPTION:
JIRA: CORE-4497
FBTEST: bugs.core_4497
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
create or alter procedure sp_test as begin end;
create or alter procedure z_pget as begin end;
commit;
2022-01-23 20:41:55 +01:00
2021-04-26 20:07:00 +02:00
create or alter view z_vdbg as select 1 as not_handled_agent_id from rdb$database;
commit;
2022-01-23 20:41:55 +01:00
2021-04-26 20:07:00 +02:00
recreate global temporary table z_gtt(id int, agent_id int) on commit delete rows;
recreate table z_doc(id int, agent_id int);
commit;
2022-01-23 20:41:55 +01:00
2021-04-26 20:07:00 +02:00
insert into z_doc(id, agent_id) values (101, 7);
commit;
2022-01-23 20:41:55 +01:00
2021-04-26 20:07:00 +02:00
set term ^;
create or alter procedure z_pget
returns (
clo_doc_id int,
clo_agent_id int)
as
begin
2022-01-23 20:41:55 +01:00
2021-04-26 20:07:00 +02:00
delete from z_gtt;
insert into z_gtt select * from z_doc;
2022-01-23 20:41:55 +01:00
2021-04-26 20:07:00 +02:00
for
select f.id, f.agent_id
from z_gtt f
order by f.id
into clo_doc_id, clo_agent_id
do
suspend;
end
^
2022-01-23 20:41:55 +01:00
2021-04-26 20:07:00 +02:00
create or alter procedure sp_test returns( doc_for_handling int, agent_for_handling int )
as
declare v_agent_id int;
begin
for
select p.clo_doc_id, p.clo_agent_id from z_pget p
into doc_for_handling, v_agent_id
do begin
agent_for_handling = null;
if ( NOT exists(
2022-01-23 20:41:55 +01:00
select *
2021-04-26 20:07:00 +02:00
from z_vdbg v
where v.not_handled_agent_id =
(select h.agent_id
from z_doc h
where h.id= :doc_for_handling
)
)
2022-01-23 20:41:55 +01:00
2021-04-26 20:07:00 +02:00
) then
begin
agent_for_handling = v_agent_id;
end
suspend;
end
end
^
set term ;^
2022-01-23 20:41:55 +01:00
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;
2022-01-23 20:41:55 +01:00
2021-04-26 20:07:00 +02:00
insert into z_doc(id, agent_id) values (100, 1);
select * from sp_test;
rollback;
2022-01-23 20:41:55 +01:00
2021-04-26 20:07:00 +02:00
insert into z_doc(id, agent_id) values (102, 1);
select * from sp_test;
rollback;
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
DOC_FOR_HANDLING 100
AGENT_FOR_HANDLING <null>
2022-01-23 20:41:55 +01:00
2021-04-26 20:07:00 +02:00
DOC_FOR_HANDLING 101
AGENT_FOR_HANDLING 7
2022-01-23 20:41:55 +01:00
2021-04-26 20:07:00 +02:00
DOC_FOR_HANDLING 101
AGENT_FOR_HANDLING 7
2022-01-23 20:41:55 +01:00
2021-04-26 20:07:00 +02:00
DOC_FOR_HANDLING 102
AGENT_FOR_HANDLING <null>
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
2021-04-26 20:07:00 +02:00