Skip to content

Commit 087bc7a

Browse files
committed
Added/Updated tests\bugs\gh_8084_test.py: Checked on 6.0.0.325 #f5930a5, 5.0.1.1383 #0e9ef69 (intermediate snapshot) - all OK.
1 parent 043bef6 commit 087bc7a

File tree

1 file changed

+70
-26
lines changed

1 file changed

+70
-26
lines changed

tests/bugs/gh_8084_test.py

Lines changed: 70 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@
33
"""
44
ID: issue-8084
55
ISSUE: https://github.com/FirebirdSQL/firebird/issues/8084
6-
TITLE: Partial index uniqueness violation
6+
TITLE: Partial index uniqueness violation (changes in columns participating in index filtering expression are not properly tracked).
77
DESCRIPTION:
88
NOTES:
9-
[18.04.2024] pzotov
10-
Confirmed bug on 6.0.0.315
11-
Checked on 6.0.0.321 #1d96c10 - all OK.
9+
[19.04.2024] pzotov
10+
Reduced min_version to 5.0.1 after backporting (commit #0e9ef69).
11+
Confirmed bug on 6.0.0.315; confirmed problem noted as second case (see ticket) in 6.0.0.321 #1d96c10.
12+
Checked on 6.0.0.325 #f5930a5, 5.0.1.1383 #0e9ef69 (intermediate snapshot) - all OK.
1213
"""
1314

1415
import pytest
@@ -18,51 +19,94 @@
1819

1920
test_script = """
2021
set list on;
21-
recreate table test (
22-
id bigint primary key
23-
,a bigint not null
24-
,b smallint not null
22+
23+
-- https://github.com/FirebirdSQL/firebird/issues/8084#issue-2247604539
24+
recreate table test1 (
25+
t1_id bigint primary key
26+
,t1_a bigint not null
27+
,t1_b smallint not null
2528
);
2629
27-
create unique index idx_test_a on test(a) where (b = 1);
30+
create unique index test1_idx_a on test1(t1_a) where (t1_b = 1);
2831
29-
insert into test(id, a, b) values (1, 1, 0);
30-
insert into test(id, a, b) values (2, 2, 1);
32+
insert into test1(t1_id, t1_a, t1_b) values (1, 1, 0);
33+
insert into test1(t1_id, t1_a, t1_b) values (2, 2, 1);
3134
commit;
3235
33-
insert into test(id, a, b) values (3, 1, 0); -- must pass
36+
insert into test1(t1_id, t1_a, t1_b) values (3, 1, 0); -- must pass
3437
commit;
35-
insert into test(id, a, b) values (4, 2, 1); -- must fail with "attempt to store duplicate value"
38+
insert into test1(t1_id, t1_a, t1_b) values (4, 2, 1); -- must fail with "attempt to store duplicate value"
3639
rollback;
3740
38-
update test set b = 1 where id = 1; -- must pass
41+
update test1 set t1_b = 1 where t1_id = 1; -- must pass
42+
commit;
43+
44+
update test1 set t1_b = 1 where t1_id = 3; -- BUG was here: passed before fix but must fail.
45+
commit;
46+
47+
select t1_a+0 as t1_a, count(*) as t1_a_cnt from test1 where t1_b+0 = 1 group by t1_a+0;
48+
rollback;
49+
50+
-------------------------------------------------------------------------
51+
52+
-- https://github.com/FirebirdSQL/firebird/issues/8084#issuecomment-2063121843
53+
recreate table test2 (
54+
t2_id bigint not null,
55+
t2_a bigint not null,
56+
t2_b smallint not null,
57+
constraint pk_test2 primary key(t2_id)
58+
);
59+
60+
create unique index test2_idx_a on test2(t2_a) where (t2_b = 1);
61+
62+
insert into test2(t2_id, t2_a, t2_b) values (1, 1, 0);
63+
insert into test2(t2_id, t2_a, t2_b) values (2, 2, 1);
64+
insert into test2(t2_id, t2_a, t2_b) values (3, 1, 0);
3965
commit;
4066
41-
update test set b = 1 where id = 3; -- BUG was here: passed before fix but must fail.
67+
update test2 set t2_b=0;
4268
commit;
4369
44-
select a+0 as a, count(*) as a_cnt from test where b+0 = 1 group by a+0;
70+
insert into test2(t2_id, t2_a, t2_b) values (4, 2, 1); -- must pass
71+
72+
select * from test2;
73+
4574
"""
4675

4776
act = isql_act('db', test_script, substitutions=[('[ \t]+', ' ')])
4877

4978
expected_stdout = """
5079
Statement failed, SQLSTATE = 23000
51-
attempt to store duplicate value (visible to active transactions) in unique index "IDX_TEST_A"
52-
-Problematic key value is ("A" = 2)
53-
80+
attempt to store duplicate value (visible to active transactions) in unique index "TEST1_IDX_A"
81+
-Problematic key value is ("T1_A" = 2)
5482
Statement failed, SQLSTATE = 23000
55-
attempt to store duplicate value (visible to active transactions) in unique index "IDX_TEST_A"
56-
-Problematic key value is ("A" = 1)
83+
attempt to store duplicate value (visible to active transactions) in unique index "TEST1_IDX_A"
84+
-Problematic key value is ("T1_A" = 1)
85+
86+
T1_A 1
87+
T1_A_CNT 1
88+
89+
T1_A 2
90+
T1_A_CNT 1
91+
92+
T2_ID 1
93+
T2_A 1
94+
T2_B 0
95+
96+
T2_ID 2
97+
T2_A 2
98+
T2_B 0
5799
58-
A 1
59-
A_CNT 1
100+
T2_ID 3
101+
T2_A 1
102+
T2_B 0
60103
61-
A 2
62-
A_CNT 1
104+
T2_ID 4
105+
T2_A 2
106+
T2_B 1
63107
"""
64108

65-
@pytest.mark.version('>=6.0.0')
109+
@pytest.mark.version('>=5.0.1')
66110
def test_1(act: Action):
67111
act.expected_stdout = expected_stdout
68112
act.execute(combine_output = True)

0 commit comments

Comments
 (0)