Skip to content

Commit 1042f35

Browse files
committed
Added/Updated tests\bugs\core_4315_test.py: Test verifies only first three examples from ticket. Checked on 3.0.0.30834-fc6110d - result is expected. See notes.
1 parent 583f1a8 commit 1042f35

File tree

1 file changed

+79
-224
lines changed

1 file changed

+79
-224
lines changed

tests/bugs/core_4315_test.py

Lines changed: 79 additions & 224 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,16 @@
88
JIRA: CORE-4315
99
FBTEST: bugs.core_4315
1010
NOTES:
11-
[29.06.2025] pzotov
11+
[15.07.2025] pzotov
12+
Confirmed bug on 3.0.0.30830-9c050ab (13-jan-2014), got:
13+
SQLSTATE = 42S22 / ... / -RECREATE VIEW v_test failed / ... / -Column unknown / -T1.N2
14+
Last issue from ticket ("Compile but generates incorrect internal triggers") can not be checked.
15+
Test verifies only first three examples from ticket.
16+
Checked on 3.0.0.30834-fc6110d - result is expected
17+
1218
Separated expected output for FB major versions prior/since 6.x.
1319
No substitutions are used to suppress schema and quotes. Discussed with dimitr, 24.06.2025 12:39.
14-
15-
Checked on 6.0.0.876; 5.0.3.1668; 4.0.6.3214; 3.0.13.33813.
20+
Checked on 6.0.0.970; 5.0.3.1668; 4.0.6.3214; 3.0.13.33813.
1621
"""
1722

1823
import pytest
@@ -21,235 +26,85 @@
2126
db = db_factory()
2227

2328
test_script = """
24-
recreate view v1 as select 1 id from rdb$database;
25-
commit;
26-
recreate table t1 (n1 integer, n2 integer);
27-
-- Compilation error in LI-T3.0.0.30830 (13-jan-2014): "Column unknown":
28-
recreate view v1 as select t1.n1 from t1 t1 where t1.n1 < t1.n2 with check option;
29-
recreate view v1 as select t1.n1 from t1 where t1.n1 < t1.n2 with check option;
30-
recreate view v1 as select x.n1 from t1 x where x.n1 < x.n2 with check option;
31-
32-
-- Compiled without errors but generates incorrect internal triggers
33-
recreate view v1 as select n1 a from t1 where n1 < n2 with check option;
34-
commit;
35-
36-
set blob all;
3729
set list on;
38-
select rdb$trigger_blr
39-
from rdb$triggers
40-
where upper(trim(rdb$relation_name))=upper('v1')
41-
order by rdb$trigger_name;
30+
recreate table t1 (n1 integer, n2 integer);
31+
recreate view v_test as select t1.n1 from t1 as t1 where t1.n1 < t1.n2 with check option;
32+
33+
insert into t1(n1, n2) values(1, 3);
34+
update v_test set n1 = n1 + 1;
35+
update v_test set n1 = n1 + 1; -- must fail
36+
select * from t1;
37+
rollback;
38+
39+
recreate view v_test as select t1.n1 from t1 where t1.n1 < t1.n2 with check option;
40+
insert into t1(n1, n2) values(1, 4);
41+
update v_test set n1 = n1 * 2;
42+
update v_test set n1 = n1 * 2; -- must fail
43+
select * from t1;
44+
rollback;
45+
46+
recreate view v_test as select x.n1 from t1 as x where x.n1 < x.n2 with check option;
47+
insert into t1(n1, n2) values(1, 5);
48+
update v_test set n1 = n1 * 3;
49+
update v_test set n1 = n1 * 3; -- must fail
50+
select * from t1;
51+
rollback;
4252
"""
4353

44-
substitutions = [('[\t ]+', ' '), ('RDB\\$TRIGGER_BLR.*', '')]
54+
substitutions = [('[ \t]+', ' '), ('CHECK_\\d+', 'CHECK_x')]
4555
act = isql_act('db', test_script, substitutions = substitutions)
4656

47-
expected_stdout_5x = """
48-
RDB$TRIGGER_BLR c:2d2
49-
blr_version5,
50-
blr_begin,
51-
blr_for,
52-
blr_rse, 1,
53-
blr_relation, 2, 'T','1', 2,
54-
blr_boolean,
55-
blr_and,
56-
blr_lss,
57-
blr_field, 2, 2, 'N','1',
58-
blr_field, 2, 2, 'N','2',
59-
blr_equiv,
60-
blr_field, 0, 1, 'A',
61-
blr_field, 2, 2, 'N','1',
62-
blr_end,
63-
blr_if,
64-
blr_lss,
65-
blr_field, 1, 1, 'A',
66-
blr_field, 2, 2, 'N','2',
67-
blr_begin,
68-
blr_end,
69-
blr_abort, blr_gds_code, 16, 'c','h','e','c','k','_','c','o','n','s','t','r','a','i','n','t',
70-
blr_end,
71-
blr_eoc
72-
73-
74-
RDB$TRIGGER_BLR c:2d3
75-
blr_version5,
76-
blr_begin,
77-
blr_if,
78-
blr_lss,
79-
blr_field, 1, 1, 'A',
80-
blr_null,
81-
blr_begin,
82-
blr_end,
83-
blr_abort, blr_gds_code, 16, 'c','h','e','c','k','_','c','o','n','s','t','r','a','i','n','t',
84-
blr_end,
85-
blr_eoc
86-
"""
87-
88-
expected_stdout_6x = """
89-
RDB$TRIGGER_BLR c:1e0
90-
blr_version5,
91-
blr_begin,
92-
blr_for,
93-
blr_rse, 1,
94-
blr_relation2, 2, 'T','1',
95-
4, 34,'T','1',34, 2,
96-
blr_boolean,
97-
blr_and,
98-
blr_lss,
99-
blr_field, 2, 2, 'N','1',
100-
blr_field, 2, 2, 'N','2',
101-
blr_equiv,
102-
blr_field, 0, 2, 'N','1',
103-
blr_field, 2, 2, 'N','1',
104-
blr_end,
105-
blr_if,
106-
blr_lss,
107-
blr_field, 1, 2, 'N','1',
108-
blr_field, 2, 2, 'N','2',
109-
blr_begin,
110-
blr_end,
111-
blr_abort, blr_gds_code, 16, 'c','h','e','c','k','_','c','o','n','s','t','r','a','i','n','t',
112-
blr_end,
113-
blr_eoc
114-
115-
116-
RDB$TRIGGER_BLR c:1e1
117-
blr_version5,
118-
blr_begin,
119-
blr_if,
120-
blr_lss,
121-
blr_field, 1, 2, 'N','1',
122-
blr_null,
123-
blr_begin,
124-
blr_end,
125-
blr_abort, blr_gds_code, 16, 'c','h','e','c','k','_','c','o','n','s','t','r','a','i','n','t',
126-
blr_end,
127-
blr_eoc
128-
129-
130-
RDB$TRIGGER_BLR c:1e2
131-
blr_version5,
132-
blr_begin,
133-
blr_for,
134-
blr_rse, 1,
135-
blr_relation, 2, 'T','1', 2,
136-
blr_boolean,
137-
blr_and,
138-
blr_lss,
139-
blr_field, 2, 2, 'N','1',
140-
blr_field, 2, 2, 'N','2',
141-
blr_equiv,
142-
blr_field, 0, 2, 'N','1',
143-
blr_field, 2, 2, 'N','1',
144-
blr_end,
145-
blr_if,
146-
blr_lss,
147-
blr_field, 1, 2, 'N','1',
148-
blr_field, 2, 2, 'N','2',
149-
blr_begin,
150-
blr_end,
151-
blr_abort, blr_gds_code, 16, 'c','h','e','c','k','_','c','o','n','s','t','r','a','i','n','t',
152-
blr_end,
153-
blr_eoc
154-
155-
156-
RDB$TRIGGER_BLR c:1e3
157-
blr_version5,
158-
blr_begin,
159-
blr_if,
160-
blr_lss,
161-
blr_field, 1, 2, 'N','1',
162-
blr_null,
163-
blr_begin,
164-
blr_end,
165-
blr_abort, blr_gds_code, 16, 'c','h','e','c','k','_','c','o','n','s','t','r','a','i','n','t',
166-
blr_end,
167-
blr_eoc
168-
169-
170-
RDB$TRIGGER_BLR c:1e4
171-
blr_version5,
172-
blr_begin,
173-
blr_for,
174-
blr_rse, 1,
175-
blr_relation2, 2, 'T','1',
176-
3, 34,'X',34, 2,
177-
blr_boolean,
178-
blr_and,
179-
blr_lss,
180-
blr_field, 2, 2, 'N','1',
181-
blr_field, 2, 2, 'N','2',
182-
blr_equiv,
183-
blr_field, 0, 2, 'N','1',
184-
blr_field, 2, 2, 'N','1',
185-
blr_end,
186-
blr_if,
187-
blr_lss,
188-
blr_field, 1, 2, 'N','1',
189-
blr_field, 2, 2, 'N','2',
190-
blr_begin,
191-
blr_end,
192-
blr_abort, blr_gds_code, 16, 'c','h','e','c','k','_','c','o','n','s','t','r','a','i','n','t',
193-
blr_end,
194-
blr_eoc
195-
196-
197-
RDB$TRIGGER_BLR c:1e5
198-
blr_version5,
199-
blr_begin,
200-
blr_if,
201-
blr_lss,
202-
blr_field, 1, 2, 'N','1',
203-
blr_null,
204-
blr_begin,
205-
blr_end,
206-
blr_abort, blr_gds_code, 16, 'c','h','e','c','k','_','c','o','n','s','t','r','a','i','n','t',
207-
blr_end,
208-
blr_eoc
209-
210-
211-
RDB$TRIGGER_BLR c:1e6
212-
blr_version5,
213-
blr_begin,
214-
blr_for,
215-
blr_rse, 1,
216-
blr_relation, 2, 'T','1', 2,
217-
blr_boolean,
218-
blr_and,
219-
blr_lss,
220-
blr_field, 2, 2, 'N','1',
221-
blr_field, 2, 2, 'N','2',
222-
blr_equiv,
223-
blr_field, 0, 1, 'A',
224-
blr_field, 2, 2, 'N','1',
225-
blr_end,
226-
blr_if,
227-
blr_lss,
228-
blr_field, 1, 1, 'A',
229-
blr_field, 2, 2, 'N','2',
230-
blr_begin,
231-
blr_end,
232-
blr_abort, blr_gds_code, 16, 'c','h','e','c','k','_','c','o','n','s','t','r','a','i','n','t',
233-
blr_end,
234-
blr_eoc
235-
236-
237-
RDB$TRIGGER_BLR c:1e7
238-
blr_version5,
239-
blr_begin,
240-
blr_if,
241-
blr_lss,
242-
blr_field, 1, 1, 'A',
243-
blr_null,
244-
blr_begin,
245-
blr_end,
246-
blr_abort, blr_gds_code, 16, 'c','h','e','c','k','_','c','o','n','s','t','r','a','i','n','t',
247-
blr_end,
248-
blr_eoc
249-
"""
25057

25158
@pytest.mark.version('>=3.0')
25259
def test_1(act: Action):
60+
61+
expected_stdout_5x = """
62+
Statement failed, SQLSTATE = 23000
63+
Operation violates CHECK constraint on view or table V_TEST
64+
-At trigger 'CHECK_1'
65+
66+
N1 2
67+
N2 3
68+
69+
Statement failed, SQLSTATE = 23000
70+
Operation violates CHECK constraint on view or table V_TEST
71+
-At trigger 'CHECK_3'
72+
73+
N1 2
74+
N2 4
75+
76+
Statement failed, SQLSTATE = 23000
77+
Operation violates CHECK constraint on view or table V_TEST
78+
-At trigger 'CHECK_5111'
79+
80+
N1 3
81+
N2 5
82+
"""
83+
84+
expected_stdout_6x = """
85+
Statement failed, SQLSTATE = 23000
86+
Operation violates CHECK constraint on view or table "PUBLIC"."V_TEST"
87+
-At trigger "PUBLIC"."CHECK_1"
88+
89+
N1 2
90+
N2 3
91+
92+
Statement failed, SQLSTATE = 23000
93+
Operation violates CHECK constraint on view or table "PUBLIC"."V_TEST"
94+
-At trigger "PUBLIC"."CHECK_3"
95+
96+
N1 2
97+
N2 4
98+
99+
Statement failed, SQLSTATE = 23000
100+
Operation violates CHECK constraint on view or table "PUBLIC"."V_TEST"
101+
-At trigger "PUBLIC"."CHECK_5111"
102+
103+
N1 3
104+
N2 5
105+
"""
106+
253107
act.expected_stdout = expected_stdout_5x if act.is_version('<6') else expected_stdout_6x
108+
254109
act.execute(combine_output = True)
255110
assert act.clean_stdout == act.clean_expected_stdout

0 commit comments

Comments
 (0)