pg.ddx.io pgsql-bugs@postgresql.org mailing list archive
help / color / mirror / Atom feedBUG #7501: Unique index fails to check uniqueness on nulls
2+ messages / 2 participants
[nested] [flat]
* BUG #7501: Unique index fails to check uniqueness on nulls
@ 2012-08-23 09:38 matthew.p.kusnierz@jpmorgan.com
2012-08-23 16:45 ` Re: BUG #7501: Unique index fails to check uniqueness on nulls Jeff Davis <pgsql@j-davis.com>
0 siblings, 1 reply; 2+ messages in thread
From: matthew.p.kusnierz@jpmorgan.com @ 2012-08-23 09:38 UTC (permalink / raw)
To: pgsql-bugs
The following bug has been logged on the website:
Bug reference: 7501
Logged by: Matt Kusnierz
Email address: matthew.p.kusnierz@jpmorgan.com
PostgreSQL version: 9.0.4
Operating system: Windows XP
Description:
Multi-column unique indexes allow duplicate rows to be inserted if any of
the indexed columns are inserted with a null.
For example:
create table foo (a varchar(10) null, b varchar(10) null);
create unique index uix on foo (a, b);
insert into foo (a, b) values ('abc', null);
insert into foo (a, b) values ('abc', null);
Clearly the second insert should fail with an ERROR: duplicate key value
violates unique constraint "uix"
But this does not occur!
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: BUG #7501: Unique index fails to check uniqueness on nulls
2012-08-23 09:38 BUG #7501: Unique index fails to check uniqueness on nulls matthew.p.kusnierz@jpmorgan.com
@ 2012-08-23 16:45 ` Jeff Davis <pgsql@j-davis.com>
0 siblings, 0 replies; 2+ messages in thread
From: Jeff Davis @ 2012-08-23 16:45 UTC (permalink / raw)
To: matthew.p.kusnierz@jpmorgan.com; +Cc: pgsql-bugs
On Thu, 2012-08-23 at 09:38 +0000, matthew.p.kusnierz@jpmorgan.com
wrote:
> Multi-column unique indexes allow duplicate rows to be inserted if any of
> the indexed columns are inserted with a null.
That is mandated in the SQL spec, and is documented here:
"For the purpose of a unique constraint, null values are not considered
equal."
-- http://www.postgresql.org/docs/9.2/static/sql-createtable.html
NULLs can be confusing, I know.
Regards,
Jeff Davis
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2012-08-23 16:45 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2012-08-23 09:38 BUG #7501: Unique index fails to check uniqueness on nulls matthew.p.kusnierz@jpmorgan.com
2012-08-23 16:45 ` Jeff Davis <pgsql@j-davis.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox