Skip to content

Commit 4222fdd

Browse files
committed
Added/Updated tests\bugs\gh_8020_test.py: Checked on 6.0.0.269. NOTE: DROP-statements are intentionally enclosed in PSQL block with begin/end and suppressing any error. See notes.
1 parent 52424e9 commit 4222fdd

File tree

1 file changed

+91
-0
lines changed

1 file changed

+91
-0
lines changed

tests/bugs/gh_8020_test.py

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
#coding:utf-8
2+
3+
"""
4+
ID: issue-8020
5+
ISSUE: https://github.com/FirebirdSQL/firebird/issues/8020
6+
TITLE: AV when both function and dependent table are dropped in the same transaction
7+
DESCRIPTION:
8+
NOTES:
9+
[12.03.2024] pzotov
10+
1. Crash occured only when connection is done via TCP protocol.
11+
2. Another bug currently *remains* in FB 6.x if DROP-statements are in DSQL form, i.e are not 'enclosed' in PSQL and begin/end blocks:
12+
==========
13+
Statement failed, SQLSTATE = 39000
14+
unsuccessful metadata update
15+
-DROP TABLE T_FN failed
16+
-invalid request BLR at offset 1
17+
-function F is not defined
18+
==========
19+
See https://github.com/FirebirdSQL/firebird/issues/8021 (currently not fixed).
20+
Because of this, it was decided to run DROP statements within PSQL code.
21+
3. Test checks whether MON$SERVER_PID remains the same after execution of DROP statements. In case of crash this is not so.
22+
23+
Confirmed bug on 6.0.0.268
24+
Checked on 6.0.0.269
25+
"""
26+
27+
import pytest
28+
from firebird.qa import *
29+
30+
db = db_factory()
31+
32+
expected_stdout = """
33+
IS_SERVER_PID_THE_SAME <true>
34+
Statement failed, SQLSTATE = 38000
35+
unsuccessful metadata update
36+
-cannot delete
37+
-Function F
38+
-there are 1 dependencies
39+
"""
40+
41+
act = python_act('db')
42+
43+
@pytest.mark.version('>=6.0')
44+
def test_1(act: Action):
45+
test_script = f"""
46+
set list on;
47+
48+
set term ^;
49+
create function f(x int)
50+
returns int
51+
as
52+
begin
53+
return x;
54+
end
55+
^
56+
create table t_fn (x int, fx computed by (f(x)))
57+
^
58+
commit
59+
^
60+
set term ;^
61+
commit;
62+
63+
connect '{act.db.dsn}' user {act.db.user} password '{act.db.password}';
64+
set autoddl off;
65+
set bail on;
66+
commit;
67+
set term ^;
68+
execute block returns(is_server_pid_the_same boolean) as
69+
declare v_server_pid_init int;
70+
declare v_server_pid_curr int;
71+
begin
72+
select mon$server_pid from mon$attachments where mon$attachment_id = current_connection into v_server_pid_init;
73+
begin
74+
execute statement 'drop function f';
75+
execute statement 'drop table t_fn';
76+
when any do
77+
begin
78+
end
79+
end
80+
select mon$server_pid from mon$attachments where mon$attachment_id = current_connection into v_server_pid_curr;
81+
is_server_pid_the_same = (v_server_pid_init = v_server_pid_curr);
82+
suspend;
83+
end
84+
^
85+
set term ;^
86+
commit;
87+
"""
88+
89+
act.expected_stdout = expected_stdout
90+
act.isql(switches=['-q'], input = test_script, combine_output = True)
91+
assert act.clean_stdout == act.clean_expected_stdout

0 commit comments

Comments
 (0)