Skip to content

Commit dc41662

Browse files
committed
Added/Updated tests\bugs\gh_8084_test.py: Checked on 6.0.0.321 #1d96c10 - all OK.
1 parent ad48514 commit dc41662

File tree

1 file changed

+69
-0
lines changed

1 file changed

+69
-0
lines changed

tests/bugs/gh_8084_test.py

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
#coding:utf-8
2+
3+
"""
4+
ID: issue-8084
5+
ISSUE: https://github.com/FirebirdSQL/firebird/issues/8084
6+
TITLE: Partial index uniqueness violation
7+
DESCRIPTION:
8+
NOTES:
9+
[18.04.2024] pzotov
10+
Confirmed bug on 6.0.0.315
11+
Checked on 6.0.0.321 #1d96c10 - all OK.
12+
"""
13+
14+
import pytest
15+
from firebird.qa import *
16+
17+
db = db_factory()
18+
19+
test_script = """
20+
set list on;
21+
recreate table test (
22+
id bigint primary key
23+
,a bigint not null
24+
,b smallint not null
25+
);
26+
27+
create unique index idx_test_a on test(a) where (b = 1);
28+
29+
insert into test(id, a, b) values (1, 1, 0);
30+
insert into test(id, a, b) values (2, 2, 1);
31+
commit;
32+
33+
insert into test(id, a, b) values (3, 1, 0); -- must pass
34+
commit;
35+
insert into test(id, a, b) values (4, 2, 1); -- must fail with "attempt to store duplicate value"
36+
rollback;
37+
38+
update test set b = 1 where id = 1; -- must pass
39+
commit;
40+
41+
update test set b = 1 where id = 3; -- BUG was here: passed before fix but must fail.
42+
commit;
43+
44+
select a+0 as a, count(*) as a_cnt from test where b+0 = 1 group by a+0;
45+
"""
46+
47+
act = isql_act('db', test_script, substitutions=[('[ \t]+', ' ')])
48+
49+
expected_stdout = """
50+
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+
54+
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)
57+
58+
A 1
59+
A_CNT 1
60+
61+
A 2
62+
A_CNT 1
63+
"""
64+
65+
@pytest.mark.version('>=6.0.0')
66+
def test_1(act: Action):
67+
act.expected_stdout = expected_stdout
68+
act.execute(combine_output = True)
69+
assert act.clean_stdout == act.clean_expected_stdout

0 commit comments

Comments
 (0)