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

21 lines
675 B
Text

statement ok
CREATE TABLE myschema.mytable (one BIGINT NOT NULL, two BIGINT NOT NULL, PRIMARY KEY(one));
statement ok
CREATE UNIQUE INDEX mytable__idx__two ON myschema.mytable (two);
statement ok
INSERT INTO myschema.mytable (one, two) VALUES (1, 2);
statement ok
INSERT INTO myschema.mytable (one, two) VALUES (3, 4);
# TODO better error
#
# Postgres says:
# ```
# ERROR: duplicate key value violates unique constraint "mytable__idx__two"
# DETAIL: Key (two)=(2) already exists.
# ```
statement error ^Execution error: execution/9uzcseehsg8xy: insert into index: table_id=3, index_id=1: conflict on unique index$
INSERT INTO myschema.mytable (one, two) VALUES (2, 2);