Skip to content

Commit 740d8a4

Browse files
committed
Added/Updated tests\bugs\gh_8653_test.py: Checked on 6.0.0.1042-992bccd; 5.0.3.1683-7bd32d4; 4.0.6.3221; 3.0.13.33813
1 parent 4c25949 commit 740d8a4

File tree

1 file changed

+80
-0
lines changed

1 file changed

+80
-0
lines changed

tests/bugs/gh_8653_test.py

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
#coding:utf-8
2+
3+
"""
4+
ID: n/a
5+
ISSUE: https://github.com/FirebirdSQL/firebird/issues/8653
6+
TITLE: TRANSACTION_ROLLBACK missing in the trace log when appropriate DB-level trigger fires
7+
DESCRIPTION:
8+
NOTES:
9+
[20.07.2024] zotov
10+
::: ACHTUNG :::
11+
One need to set 'time_threshold = 0' otherwise trigger_finish can be missed because of too fast execution!
12+
13+
Separated expected output for FB major versions prior/since 6.x.
14+
No substitutions are used to suppress schema and quotes. Discussed with dimitr, 24.06.2025 12:39.
15+
Checked on 6.0.0.1042-992bccd; 5.0.3.1683-7bd32d4; 4.0.6.3221; 3.0.13.33813
16+
"""
17+
18+
import re
19+
import pytest
20+
from firebird.qa import *
21+
22+
db = db_factory()
23+
24+
act = python_act('db')
25+
26+
allowed_patterns = [ r'\)\s+ERROR ', r'(Trigger\s+)?("PUBLIC".)?(")?TRG_TX_ROLLBACK(")?', ]
27+
allowed_patterns = [ re.compile(r, re.IGNORECASE) for r in allowed_patterns]
28+
29+
@pytest.mark.trace
30+
@pytest.mark.version('>=3.0')
31+
def test_1(act: Action, capsys):
32+
33+
init_script = f"""
34+
set term ^;
35+
create or alter trigger trg_tx_rollback active on transaction rollback as
36+
begin
37+
end
38+
^
39+
set term ;^
40+
commit;
41+
"""
42+
act.isql(switches = ['-q', '-nod'], input = init_script, combine_output = True)
43+
assert act.clean_stdout == ''
44+
act.reset()
45+
46+
trace = [
47+
'log_errors = true',
48+
'time_threshold = 0', # <<<<<<<<<<<<<< ::: A.C.H.T.U.N.G ::: <<<<<<<<<<<<<<
49+
'log_trigger_start = true',
50+
'log_trigger_finish = true',
51+
]
52+
53+
with act.trace(db_events = trace, encoding = 'utf8', encoding_errors = 'utf8'):
54+
with act.db.connect() as con:
55+
cur = con.cursor()
56+
cur.execute('select 1 from rdb$database')
57+
con.rollback()
58+
59+
for line in act.trace_log:
60+
if act.match_any(line, allowed_patterns):
61+
print(line)
62+
63+
expected_stdout_4x = f"""
64+
TRG_TX_ROLLBACK (ON TRANSACTION_ROLLBACK)
65+
TRG_TX_ROLLBACK (ON TRANSACTION_ROLLBACK)
66+
"""
67+
68+
expected_stdout_5x = f"""
69+
Trigger TRG_TX_ROLLBACK (ON TRANSACTION_ROLLBACK):
70+
Trigger TRG_TX_ROLLBACK (ON TRANSACTION_ROLLBACK):
71+
"""
72+
73+
expected_stdout_6x = f"""
74+
Trigger "PUBLIC"."TRG_TX_ROLLBACK" (ON TRANSACTION_ROLLBACK):
75+
Trigger "PUBLIC"."TRG_TX_ROLLBACK" (ON TRANSACTION_ROLLBACK):
76+
"""
77+
78+
act.expected_stdout = expected_stdout_4x if act.is_version('<5') else expected_stdout_5x if act.is_version('<6') else expected_stdout_6x
79+
act.stdout = capsys.readouterr().out
80+
assert act.clean_stdout == act.clean_expected_stdout

0 commit comments

Comments
 (0)