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

125 lines
3.1 KiB
Python
Raw Normal View History

2021-04-26 20:07:00 +02:00
#coding:utf-8
2022-01-20 17:32:14 +01:00
"""
ID: issue-2115
ISSUE: 2115
TITLE: 'There are <n> dependencies' error message shows the wrong count of dependent objects.
DESCRIPTION:
JIRA: CORE-1689
FBTEST: bugs.core_1689
2022-01-20 17:32:14 +01:00
"""
2021-04-26 20:07:00 +02:00
import pytest
2022-01-20 17:32:14 +01:00
from firebird.qa import *
2021-04-26 20:07:00 +02:00
# version: 3.0
init_script_1 = """
set term ^;
declare external function UDF30_getExactTimestamp
timestamp
returns parameter 1
entry_point 'getExactTimestamp' module_name 'fbudf'^
create table t(a int)^
create trigger tad for t after delete as declare dummy timestamp; begin dummy = UDF30_getExactTimestamp(); end^
create view vudf(t) as select UDF30_getExactTimestamp() from rdb$database^
create table tudf(a int, c computed by(UDF30_getExactTimestamp()))^
create domain dud int check(value between extract(week from UDF30_getExactTimestamp()) and 25)^
2021-12-22 20:23:11 +01:00
"""
2021-04-26 20:07:00 +02:00
2022-01-20 17:32:14 +01:00
db_1 = db_factory(init=init_script_1)
2021-04-26 20:07:00 +02:00
test_script_1 = """
drop external function UDF30_getExactTimestamp;
2021-12-22 20:23:11 +01:00
"""
2021-04-26 20:07:00 +02:00
2022-01-20 17:32:14 +01:00
act_1 = isql_act('db_1', test_script_1)
2021-04-26 20:07:00 +02:00
expected_stderr_1 = """
Statement failed, SQLSTATE = 38000
unsuccessful metadata update
-cannot delete
-Function UDF30_GETEXACTTIMESTAMP
-there are 4 dependencies
2021-12-22 20:23:11 +01:00
"""
2021-04-26 20:07:00 +02:00
@pytest.mark.version('>=3.0,<4.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_stderr = expected_stderr_1
act_1.execute()
2021-12-22 20:23:11 +01:00
assert act_1.clean_stderr == act_1.clean_expected_stderr
2021-04-26 20:07:00 +02:00
# version: 4.0
2022-01-20 17:32:14 +01:00
db_2 = db_factory()
2021-04-26 20:07:00 +02:00
test_script_2 = """
-- See declaration sample in plugins\\udr\\UdfBackwardCompatibility.sql:
set bail on;
create function UDR40_getExactTimestampUTC
returns timestamp
external name 'udf_compat!UC_getExactTimestampUTC'
engine udr;
2022-01-20 17:32:14 +01:00
2021-04-26 20:07:00 +02:00
create table test_dts(
2022-01-20 17:32:14 +01:00
id int,
dts timestamp check ( datediff(minute from dts to UDR40_getExactTimestampUTC()) < 5 )
2021-04-26 20:07:00 +02:00
);
commit;
2022-01-20 17:32:14 +01:00
2021-04-26 20:07:00 +02:00
set term ^;
create trigger trg_test_dts_ad for test_dts after delete as
2022-01-20 17:32:14 +01:00
declare dummy timestamp;
begin
dummy = UDR40_getExactTimestampUTC();
2021-04-26 20:07:00 +02:00
end
^
set term ;^
commit;
2022-01-20 17:32:14 +01:00
create view v_test as
2021-04-26 20:07:00 +02:00
select UDR40_getExactTimestampUTC() as UTC_stamp -- rdb$N, dep_type=3
from rdb$database
;
2022-01-20 17:32:14 +01:00
2021-04-26 20:07:00 +02:00
create table test_udr(a int, c computed by( UDR40_getExactTimestampUTC() )) -- rdb$N, dep_type=3
;
2022-01-20 17:32:14 +01:00
2021-04-26 20:07:00 +02:00
create domain dm_test int check(value between extract(week from UDR40_getExactTimestampUTC() ) and 25) ;
2022-01-20 17:32:14 +01:00
2021-04-26 20:07:00 +02:00
commit;
drop function UDR40_getExactTimestampUTC;
/*
set count on;
set list on;
select rd.rdb$dependent_name, rd.rdb$dependent_type
from rdb$dependencies rd
where rd.rdb$depended_on_name = upper('UDR40_GETEXACTTIMESTAMPUTC')
order by rd.rdb$dependent_name
;
*/
2021-12-22 20:23:11 +01:00
"""
2021-04-26 20:07:00 +02:00
2022-01-20 17:32:14 +01:00
act_2 = isql_act('db_2', test_script_2)
2021-04-26 20:07:00 +02:00
expected_stderr_2 = """
Statement failed, SQLSTATE = 38000
unsuccessful metadata update
-cannot delete
-Function UDR40_GETEXACTTIMESTAMPUTC
-there are 6 dependencies
2021-12-22 20:23:11 +01:00
"""
2021-04-26 20:07:00 +02:00
@pytest.mark.version('>=4.0')
2021-04-28 12:42:11 +02:00
def test_2(act_2: Action):
2021-04-26 20:07:00 +02:00
act_2.expected_stderr = expected_stderr_2
act_2.execute()
2021-12-22 20:23:11 +01:00
assert act_2.clean_stderr == act_2.clean_expected_stderr
2021-04-26 20:07:00 +02:00