create unique index doesn't work properly
create unique index doesn't work properly
От:
Domingo Alvarez Duarte <domingo@dad-it.com>
Дата:
when executing the code bellow: --- create table test_unique(i1 integer, i2 integer, unique(i1,i2)); insert into test_unique(1,null); insert into test_unique(1,null); insert into test_unique(1,null); --- all "inserts" terminate sucefully, if there isn't "null" values it works fine.
Re: create unique index doesn't work properly
От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
Domingo Alvarez Duarte writes:
> when executing the code bellow:
> create table test_unique(i1 integer, i2 integer, unique(i1,i2));
> insert into test_unique(1,null);
> insert into test_unique(1,null);
> insert into test_unique(1,null);
> all "inserts" terminate sucefully, if there isn't "null" values it works
> fine.
This is not a bug: the UNIQUE test is operating according to the SQL
standard. I direct your attention to section 8.9 of the SQL92 spec
(which is talking about the UNIQUE predicate, but a UNIQUE constraint
on a table is elsewhere defined in terms of the UNIQUE predicate):
::= UNIQUE