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

214 lines
5.1 KiB
Python
Raw Normal View History

2021-04-26 20:07:00 +02:00
#coding:utf-8
#
# id: bugs.core_4487
# title: Maintain package body after ALTER/RECREATE PACKAGE
# decription:
# tracker_id: CORE-4487
# min_versions: ['3.0']
# versions: 3.0
# qmid:
import pytest
from firebird.qa import db_factory, isql_act, Action
# version: 3.0
# resources: None
substitutions_1 = [('HDR_SOURCE.*', ''), ('BODY_SOURCE.*', '')]
init_script_1 = """"""
db_1 = db_factory(sql_dialect=3, init=init_script_1)
test_script_1 = """
create or alter view v_pg_meta as
select
rp.rdb$package_header_source hdr_source
,rp.rdb$package_body_source body_source
,rp.rdb$valid_body_flag body_valid
from rdb$packages rp
where rp.rdb$package_name = upper('pg_test');
set list on;
set blob all;
set term ^;
create or alter package pg_test
as
begin
function fn_test_01 returns smallint;
function fn_test_02 returns smallint;
end
^
recreate package body pg_test
as
begin
function fn_test_01 returns smallint as
begin
return 1;
end
function fn_test_02 returns smallint as
begin
return 2;
end
end
^
set term ;^
commit;
-----------------------------------------
select 1 as step, v.* from v_pg_meta v;
------------------------------------------
set term ^;
create or alter package pg_test
as
begin
function fn_test_01 returns smallint;
function fn_test_02(a_val smallint) returns smallint;
end
^
set term ;^
commit;
-----------------------------------------
set term ^;
create or alter package pg_test
as
begin
function fn_test_01 returns smallint;
-- Adding IN-argument to func must lead package body to invalid state:
function fn_test_02(a_val smallint) returns smallint;
end
^
set term ;^
commit;
-----------------------------------------
select 2 as step, v.* from v_pg_meta v;
------------------------------------------
set term ^;
create or alter package pg_test
as
begin
function fn_test_03 returns bigint;
end
^
set term ;^
commit;
-----------------------------------------
select 3 as step, v.* from v_pg_meta v;
------------------------------------------
set term ^;
create or alter package pg_test
as
begin
-- Restoring exactly the same singnatures of both functions
-- does NOT make package body to VALID state:
function fn_test_01 returns smallint;
function fn_test_02 returns smallint;
end
^
set term ;^
commit;
-----------------------------------------
select 4 as step, v.* from v_pg_meta v;
------------------------------------------
2021-12-22 20:23:11 +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 = """
STEP 1
HDR_SOURCE 2a:1
begin
function fn_test_01 returns smallint;
function fn_test_02 returns smallint;
end
BODY_SOURCE 2a:4
begin
function fn_test_01 returns smallint as
begin
return 1;
end
function fn_test_02 returns smallint as
begin
return 2;
end
end
BODY_VALID 1
STEP 2
HDR_SOURCE 2a:1
begin
function fn_test_01 returns smallint;
-- Adding IN-argument to func must lead package body to invalid state:
function fn_test_02(a_val smallint) returns smallint;
end
BODY_SOURCE 2a:4
begin
function fn_test_01 returns smallint as
begin
return 1;
end
function fn_test_02 returns smallint as
begin
return 2;
end
end
BODY_VALID 0
STEP 3
HDR_SOURCE 2a:2
begin
function fn_test_03 returns bigint;
end
BODY_SOURCE 2a:4
begin
function fn_test_01 returns smallint as
begin
return 1;
end
function fn_test_02 returns smallint as
begin
return 2;
end
end
BODY_VALID 0
STEP 4
HDR_SOURCE 2a:1
begin
-- Restoring exactly the same singnatures of both functions
-- does NOT make package body to VALID state:
function fn_test_01 returns smallint;
function fn_test_02 returns smallint;
end
BODY_SOURCE 2a:4
begin
function fn_test_01 returns smallint as
begin
return 1;
end
function fn_test_02 returns smallint as
begin
return 2;
end
end
BODY_VALID 0
2021-12-22 20:23:11 +01:00
"""
2021-04-26 20:07:00 +02:00
@pytest.mark.version('>=3.0')
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