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

31 lines
1.1 KiB
Text

statement ok
CREATE TABLE myschema.mytable (one BIGINT NOT NULL, two BIGINT, PRIMARY KEY(one));
statement error ^External error: unimplemented_sql/w9j8q485anior: CREATE UNIQUE INDEX \.\. \[NULLS DISTINCT\] with null columns$
CREATE UNIQUE INDEX mytable__idx__two ON myschema.mytable (two) NULLS DISTINCT;
#statement ok
#CREATE UNIQUE INDEX mytable__idx__two ON myschema.mytable (two) NULLS DISTINCT;
#
#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);
#
#statement ok
#INSERT INTO myschema.mytable (one, two) VALUES (5, NULL);
#
## Nulls are distinct.
#statement ok
#INSERT INTO myschema.mytable (one, two) VALUES (6, NULL);