1
Fork 0
kantodb/testdata/sql/index_unique_update.slt

21 lines
558 B
Text

statement ok
CREATE TABLE myschema.mytable (one BIGINT NOT NULL, two BIGINT, PRIMARY KEY(one));
statement ok
CREATE UNIQUE INDEX mytable__idx__two ON myschema.mytable (two) NULLS NOT DISTINCT;
statement ok
INSERT INTO myschema.mytable (one, two) VALUES (1, 2);
statement ok
UPDATE myschema.mytable SET two=100 WHERE two=2;
# This can now succeed since the conflicting row was updated to prevent the conflict.
statement ok
INSERT INTO myschema.mytable (one, two) VALUES (3, 2);
query II
SELECT one, two from myschema.mytable ORDER BY one;
----
1 100
3 2