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

145 lines
3.5 KiB
Python
Raw Permalink Normal View History

2021-04-26 20:07:00 +02:00
#coding:utf-8
2022-01-25 22:55:48 +01:00
"""
ID: issue-5683
ISSUE: 5683
TITLE: Dependencies are not stored when using some type of contructions in subroutines
DESCRIPTION:
JIRA: CORE-5410
FBTEST: bugs.core_5410
2022-01-25 22:55:48 +01:00
"""
2021-04-26 20:07:00 +02:00
2022-01-25 22:55:48 +01:00
import pytest
from firebird.qa import *
2021-04-26 20:07:00 +02:00
2022-01-25 22:55:48 +01:00
db = db_factory()
2021-04-26 20:07:00 +02:00
2022-01-25 22:55:48 +01:00
test_script = """
2021-04-26 20:07:00 +02:00
set list on;
create or alter procedure sp_outer_standalone as begin end;
create or alter package pg_test as begin end;
commit;
recreate table test_1(f01 integer);
insert into test_1(f01) values(100);
insert into test_1(f01) values(1);
insert into test_1(f01) values(10);
commit;
recreate table test_2(f02 integer);
commit;
insert into test_2(f02) values(200);
insert into test_2(f02) values(2);
insert into test_2(f02) values(20);
commit;
recreate table test_3(f02 integer);
commit;
insert into test_3(f02) values(300);
insert into test_3(f02) values(3);
insert into test_3(f02) values(30);
commit;
set term ^;
create or alter procedure sp_outer_standalone returns(max_f01 int) as
declare procedure sp_inner returns(max_f01 int) as
begin
select max(f01) from test_1 into max_f01;
suspend;
end
begin
select max_f01 from sp_inner into max_f01;
suspend;
end;
^
create or alter function fn_outer_standalone returns int as
declare function fn_inner returns int as
begin
return (select min(f01) from test_1);
end
begin
return fn_inner();
end;
^
2022-01-25 22:55:48 +01:00
create or alter package pg_test as
2021-04-26 20:07:00 +02:00
begin
procedure sp_outer_packaged returns(max_f02 int);
function fn_outer_packaged returns int;
end
^
recreate package body pg_test as
begin
procedure sp_outer_packaged returns(max_f02 int) as
declare procedure sp_inner returns(max_f02 int) as
begin
select max(f02) from test_2 into max_f02;
suspend;
end
begin
select max_f02 from sp_inner into max_f02;
suspend;
end
function fn_outer_packaged returns int as
declare function fn_inner returns int as
begin
return (select min(f02) from test_2);
end
begin
return fn_inner();
end
end
^
set term ;^
commit;
-----------------------
drop table test_1; -- should FAIL!
drop table test_2; -- should FAIL!
commit;
select max_f01 from sp_outer_standalone;
select fn_outer_standalone() as min_f01 from rdb$database;
select max_f02 from pg_test.sp_outer_packaged;
select pg_test.fn_outer_packaged() as min_f02 from rdb$database;
2021-12-22 20:23:11 +01:00
"""
2021-04-26 20:07:00 +02:00
2022-01-25 22:55:48 +01:00
act = isql_act('db', test_script)
2021-04-26 20:07:00 +02:00
2022-01-25 22:55:48 +01:00
expected_stdout = """
2021-04-26 20:07:00 +02:00
MAX_F01 100
MIN_F01 1
MAX_F02 200
MIN_F02 2
2021-12-22 20:23:11 +01:00
"""
2022-01-25 22:55:48 +01:00
expected_stderr = """
2021-04-26 20:07:00 +02:00
Statement failed, SQLSTATE = 42000
unsuccessful metadata update
-cannot delete
-COLUMN TEST_1.F01
-there are 2 dependencies
Statement failed, SQLSTATE = 42000
unsuccessful metadata update
-cannot delete
-COLUMN TEST_2.F02
-there are 1 dependencies
2021-12-22 20:23:11 +01:00
"""
2021-04-26 20:07:00 +02:00
@pytest.mark.version('>=3.0.2')
2022-01-25 22:55:48 +01:00
def test_1(act: Action):
act.expected_stdout = expected_stdout
act.expected_stderr = expected_stderr
act.execute()
assert (act.clean_stderr == act.clean_expected_stderr and
act.clean_stdout == act.clean_expected_stdout)
2021-04-26 20:07:00 +02:00