mirror of
https://github.com/FirebirdSQL/firebird-qa.git
synced 2025-01-22 21:43:06 +01:00
Added/Updated tests\bugs\gh_8084_test.py: Checked on 6.0.0.325 #f5930a5, 5.0.1.1383 #0e9ef69 (intermediate snapshot) - all OK.
This commit is contained in:
parent
043bef6a2c
commit
087bc7a87e
@ -3,12 +3,13 @@
|
|||||||
"""
|
"""
|
||||||
ID: issue-8084
|
ID: issue-8084
|
||||||
ISSUE: https://github.com/FirebirdSQL/firebird/issues/8084
|
ISSUE: https://github.com/FirebirdSQL/firebird/issues/8084
|
||||||
TITLE: Partial index uniqueness violation
|
TITLE: Partial index uniqueness violation (changes in columns participating in index filtering expression are not properly tracked).
|
||||||
DESCRIPTION:
|
DESCRIPTION:
|
||||||
NOTES:
|
NOTES:
|
||||||
[18.04.2024] pzotov
|
[19.04.2024] pzotov
|
||||||
Confirmed bug on 6.0.0.315
|
Reduced min_version to 5.0.1 after backporting (commit #0e9ef69).
|
||||||
Checked on 6.0.0.321 #1d96c10 - all OK.
|
Confirmed bug on 6.0.0.315; confirmed problem noted as second case (see ticket) in 6.0.0.321 #1d96c10.
|
||||||
|
Checked on 6.0.0.325 #f5930a5, 5.0.1.1383 #0e9ef69 (intermediate snapshot) - all OK.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
@ -18,51 +19,94 @@ db = db_factory()
|
|||||||
|
|
||||||
test_script = """
|
test_script = """
|
||||||
set list on;
|
set list on;
|
||||||
recreate table test (
|
|
||||||
id bigint primary key
|
-- https://github.com/FirebirdSQL/firebird/issues/8084#issue-2247604539
|
||||||
,a bigint not null
|
recreate table test1 (
|
||||||
,b smallint not null
|
t1_id bigint primary key
|
||||||
|
,t1_a bigint not null
|
||||||
|
,t1_b smallint not null
|
||||||
);
|
);
|
||||||
|
|
||||||
create unique index idx_test_a on test(a) where (b = 1);
|
create unique index test1_idx_a on test1(t1_a) where (t1_b = 1);
|
||||||
|
|
||||||
insert into test(id, a, b) values (1, 1, 0);
|
insert into test1(t1_id, t1_a, t1_b) values (1, 1, 0);
|
||||||
insert into test(id, a, b) values (2, 2, 1);
|
insert into test1(t1_id, t1_a, t1_b) values (2, 2, 1);
|
||||||
commit;
|
commit;
|
||||||
|
|
||||||
insert into test(id, a, b) values (3, 1, 0); -- must pass
|
insert into test1(t1_id, t1_a, t1_b) values (3, 1, 0); -- must pass
|
||||||
commit;
|
commit;
|
||||||
insert into test(id, a, b) values (4, 2, 1); -- must fail with "attempt to store duplicate value"
|
insert into test1(t1_id, t1_a, t1_b) values (4, 2, 1); -- must fail with "attempt to store duplicate value"
|
||||||
rollback;
|
rollback;
|
||||||
|
|
||||||
update test set b = 1 where id = 1; -- must pass
|
update test1 set t1_b = 1 where t1_id = 1; -- must pass
|
||||||
commit;
|
commit;
|
||||||
|
|
||||||
update test set b = 1 where id = 3; -- BUG was here: passed before fix but must fail.
|
update test1 set t1_b = 1 where t1_id = 3; -- BUG was here: passed before fix but must fail.
|
||||||
commit;
|
commit;
|
||||||
|
|
||||||
select a+0 as a, count(*) as a_cnt from test where b+0 = 1 group by a+0;
|
select t1_a+0 as t1_a, count(*) as t1_a_cnt from test1 where t1_b+0 = 1 group by t1_a+0;
|
||||||
|
rollback;
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------
|
||||||
|
|
||||||
|
-- https://github.com/FirebirdSQL/firebird/issues/8084#issuecomment-2063121843
|
||||||
|
recreate table test2 (
|
||||||
|
t2_id bigint not null,
|
||||||
|
t2_a bigint not null,
|
||||||
|
t2_b smallint not null,
|
||||||
|
constraint pk_test2 primary key(t2_id)
|
||||||
|
);
|
||||||
|
|
||||||
|
create unique index test2_idx_a on test2(t2_a) where (t2_b = 1);
|
||||||
|
|
||||||
|
insert into test2(t2_id, t2_a, t2_b) values (1, 1, 0);
|
||||||
|
insert into test2(t2_id, t2_a, t2_b) values (2, 2, 1);
|
||||||
|
insert into test2(t2_id, t2_a, t2_b) values (3, 1, 0);
|
||||||
|
commit;
|
||||||
|
|
||||||
|
update test2 set t2_b=0;
|
||||||
|
commit;
|
||||||
|
|
||||||
|
insert into test2(t2_id, t2_a, t2_b) values (4, 2, 1); -- must pass
|
||||||
|
|
||||||
|
select * from test2;
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
act = isql_act('db', test_script, substitutions=[('[ \t]+', ' ')])
|
act = isql_act('db', test_script, substitutions=[('[ \t]+', ' ')])
|
||||||
|
|
||||||
expected_stdout = """
|
expected_stdout = """
|
||||||
Statement failed, SQLSTATE = 23000
|
Statement failed, SQLSTATE = 23000
|
||||||
attempt to store duplicate value (visible to active transactions) in unique index "IDX_TEST_A"
|
attempt to store duplicate value (visible to active transactions) in unique index "TEST1_IDX_A"
|
||||||
-Problematic key value is ("A" = 2)
|
-Problematic key value is ("T1_A" = 2)
|
||||||
|
|
||||||
Statement failed, SQLSTATE = 23000
|
Statement failed, SQLSTATE = 23000
|
||||||
attempt to store duplicate value (visible to active transactions) in unique index "IDX_TEST_A"
|
attempt to store duplicate value (visible to active transactions) in unique index "TEST1_IDX_A"
|
||||||
-Problematic key value is ("A" = 1)
|
-Problematic key value is ("T1_A" = 1)
|
||||||
|
|
||||||
A 1
|
T1_A 1
|
||||||
A_CNT 1
|
T1_A_CNT 1
|
||||||
|
|
||||||
A 2
|
T1_A 2
|
||||||
A_CNT 1
|
T1_A_CNT 1
|
||||||
|
|
||||||
|
T2_ID 1
|
||||||
|
T2_A 1
|
||||||
|
T2_B 0
|
||||||
|
|
||||||
|
T2_ID 2
|
||||||
|
T2_A 2
|
||||||
|
T2_B 0
|
||||||
|
|
||||||
|
T2_ID 3
|
||||||
|
T2_A 1
|
||||||
|
T2_B 0
|
||||||
|
|
||||||
|
T2_ID 4
|
||||||
|
T2_A 2
|
||||||
|
T2_B 1
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@pytest.mark.version('>=6.0.0')
|
@pytest.mark.version('>=5.0.1')
|
||||||
def test_1(act: Action):
|
def test_1(act: Action):
|
||||||
act.expected_stdout = expected_stdout
|
act.expected_stdout = expected_stdout
|
||||||
act.execute(combine_output = True)
|
act.execute(combine_output = True)
|
||||||
|
Loading…
Reference in New Issue
Block a user