6
0
mirror of https://github.com/FirebirdSQL/firebird-qa.git synced 2025-01-23 14:03:06 +01:00
firebird-qa/tests/bugs/core_4544_test.py

223 lines
5.2 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-4862
ISSUE: 4862
TITLE: Allow hiding source code of procedures and triggers in FB 3
DESCRIPTION:
JIRA: CORE-4544
FBTEST: bugs.core_4544
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
db = db_factory()
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
recreate table test(id int primary key, x int);
recreate table tlog(id int, x int);
2022-01-23 20:41:55 +01:00
2021-04-26 20:07:00 +02:00
recreate sequence g;
2022-01-23 20:41:55 +01:00
2021-04-26 20:07:00 +02:00
set term ^;
create or alter procedure sp_test1 as
declare c int;
begin
select count(*) from rdb$types into c;
end
^
2022-01-23 20:41:55 +01:00
2021-04-26 20:07:00 +02:00
create or alter function fn_test1 returns int as
begin
return 111;
end
^
2022-01-23 20:41:55 +01:00
2021-04-26 20:07:00 +02:00
create or alter trigger trg_test_1 active before insert on test as
begin
new.id = gen_id(g,1);
end
^
2022-01-23 20:41:55 +01:00
2021-04-26 20:07:00 +02:00
create or alter package pkg_test1 as
begin
procedure sp_test1;
function fn_test1 returns int;
end
^
2022-01-23 20:41:55 +01:00
2021-04-26 20:07:00 +02:00
recreate package body pkg_test1 as
begin
procedure sp_test1 as
declare c int;
begin
select count(*) from rdb$types into c;
end
2022-01-23 20:41:55 +01:00
2021-04-26 20:07:00 +02:00
function fn_test1 returns int as
begin
return 111;
end
end
^
2022-01-23 20:41:55 +01:00
2021-04-26 20:07:00 +02:00
set term ;^
commit;
2022-01-23 20:41:55 +01:00
2021-04-26 20:07:00 +02:00
set blob all;
set list on;
2022-01-23 20:41:55 +01:00
2021-04-26 20:07:00 +02:00
select rdb$procedure_name, rdb$procedure_source as source_blob
from rdb$procedures where rdb$system_flag is distinct from 1;
2022-01-23 20:41:55 +01:00
2021-04-26 20:07:00 +02:00
select rdb$function_name, rdb$function_source as source_blob
from rdb$functions where rdb$system_flag is distinct from 1;
2022-01-23 20:41:55 +01:00
2021-04-26 20:07:00 +02:00
select rdb$trigger_name, rdb$trigger_source as source_blob
from rdb$triggers where rdb$system_flag is distinct from 1;
2022-01-23 20:41:55 +01:00
2021-04-26 20:07:00 +02:00
select rdb$package_name, rdb$package_body_source as source_blob
from rdb$packages where rdb$system_flag is distinct from 1;
2022-01-23 20:41:55 +01:00
2021-04-26 20:07:00 +02:00
set count on;
set echo on;
2022-01-23 20:41:55 +01:00
2021-04-26 20:07:00 +02:00
update rdb$procedures set rdb$procedure_source = null
where
rdb$system_flag is distinct from 1
and rdb$procedure_source is not null
;
2022-01-23 20:41:55 +01:00
2021-04-26 20:07:00 +02:00
update rdb$functions set rdb$function_source = null
where
rdb$system_flag is distinct from 1
and rdb$function_source is not null
;
2022-01-23 20:41:55 +01:00
2021-04-26 20:07:00 +02:00
update rdb$triggers set rdb$trigger_source = null
where
rdb$system_flag is distinct from 1
and rdb$trigger_source is not null
;
2022-01-23 20:41:55 +01:00
2021-04-26 20:07:00 +02:00
update rdb$packages set rdb$package_body_source = null
where
rdb$system_flag is distinct from 1
and rdb$package_body_source is not null
;
2022-01-23 20:41:55 +01:00
2021-04-26 20:07:00 +02:00
set echo off;
commit;
2022-01-23 20:41:55 +01:00
2021-04-26 20:07:00 +02:00
select rdb$procedure_name, rdb$procedure_source as source_blob
from rdb$procedures
where rdb$system_flag is distinct from 1 and rdb$procedure_source is not null;
2022-01-23 20:41:55 +01:00
2021-04-26 20:07:00 +02:00
select rdb$function_name, rdb$function_source as source_blob
from rdb$functions
where rdb$system_flag is distinct from 1 and rdb$function_source is not null;
2022-01-23 20:41:55 +01:00
2021-04-26 20:07:00 +02:00
select rdb$trigger_name, rdb$trigger_source as source_blob
from rdb$triggers
where rdb$system_flag is distinct from 1 and rdb$trigger_source is not null;
2022-01-23 20:41:55 +01:00
2021-04-26 20:07:00 +02:00
select rdb$package_name, rdb$package_body_source as source_blob
from rdb$packages where rdb$system_flag is distinct from 1 and rdb$package_body_source is not 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
act = isql_act('db', test_script, substitutions=[('SOURCE_BLOB.*', '')])
2021-04-26 20:07:00 +02:00
2022-01-23 20:41:55 +01:00
expected_stdout = """
RDB$PROCEDURE_NAME SP_TEST1
2021-04-26 20:07:00 +02:00
SOURCE_BLOB 1a:1e0
declare c int;
begin
select count(*) from rdb$types into c;
end
2022-01-23 20:41:55 +01:00
RDB$PROCEDURE_NAME SP_TEST1
2021-04-26 20:07:00 +02:00
SOURCE_BLOB <null>
2022-01-23 20:41:55 +01:00
RDB$FUNCTION_NAME FN_TEST1
2021-04-26 20:07:00 +02:00
SOURCE_BLOB e:1e0
begin
return 111;
end
2022-01-23 20:41:55 +01:00
RDB$FUNCTION_NAME FN_TEST1
2021-04-26 20:07:00 +02:00
SOURCE_BLOB <null>
2022-01-23 20:41:55 +01:00
RDB$TRIGGER_NAME TRG_TEST_1
2021-04-26 20:07:00 +02:00
SOURCE_BLOB c:3d0
as
begin
new.id = gen_id(g,1);
end
2022-01-23 20:41:55 +01:00
RDB$PACKAGE_NAME PKG_TEST1
2021-04-26 20:07:00 +02:00
SOURCE_BLOB 2a:1
begin
procedure sp_test1 as
declare c int;
begin
select count(*) from rdb$types into c;
end
2022-01-23 20:41:55 +01:00
2021-04-26 20:07:00 +02:00
function fn_test1 returns int as
begin
return 111;
end
end
2022-01-23 20:41:55 +01:00
2021-04-26 20:07:00 +02:00
update rdb$procedures set rdb$procedure_source = null
where
rdb$system_flag is distinct from 1
and rdb$procedure_source is not null
;
Records affected: 1
2022-01-23 20:41:55 +01:00
2021-04-26 20:07:00 +02:00
update rdb$functions set rdb$function_source = null
where
rdb$system_flag is distinct from 1
and rdb$function_source is not null
;
Records affected: 1
2022-01-23 20:41:55 +01:00
2021-04-26 20:07:00 +02:00
update rdb$triggers set rdb$trigger_source = null
where
rdb$system_flag is distinct from 1
and rdb$trigger_source is not null
;
Records affected: 1
2022-01-23 20:41:55 +01:00
2021-04-26 20:07:00 +02:00
update rdb$packages set rdb$package_body_source = null
where
rdb$system_flag is distinct from 1
and rdb$package_body_source is not null
;
Records affected: 1
2022-01-23 20:41:55 +01:00
2021-04-26 20:07:00 +02:00
set echo off;
Records affected: 0
Records affected: 0
Records affected: 0
Records affected: 0
2021-12-22 20:23:11 +01:00
"""
2021-04-26 20:07:00 +02:00
@pytest.mark.version('>=3.0')
2022-01-23 20:41:55 +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