From: Michael Fuhr <mike@fuhr.org>
To: Chris Hoover <revoohc@gmail.com>
Cc: pgsql-admin@postgresql.org <pgsql-admin@postgresql.org>
Subject: Re: 8.1 Unique Index Issue/Bug???
Date: Thu, 13 Jul 2006 10:15:46 -0600
Message-ID: <20060713161546.GA86489@winnie.fuhr.org> (raw)
In-Reply-To: <1d219a6f0607130740g7fe13967t48c77a64fde977aa@mail.gmail.com>
References: <1d219a6f0607130740g7fe13967t48c77a64fde977aa@mail.gmail.com>
On Thu, Jul 13, 2006 at 10:40:43AM -0400, Chris Hoover wrote:
> Why is PostgreSQL not enforcing this index? This appears to be a pretty
> major a bug? It would seem that you could have a unique index across
> columns that might have a null in them.
This comes up frequently due to a misunderstanding of how NULL
comparison works.
http://www.postgresql.org/docs/8.1/interactive/ddl-constraints.html#AEN2016
"In general, a unique constraint is violated when there are two or
more rows in the table where the values of all of the columns
included in the constraint are equal. However, null values are not
considered equal in this comparison. That means even in the presence
of a unique constraint it is possible to store duplicate rows that
contain a null value in at least one of the constrained columns.
This behavior conforms to the SQL standard, but we have heard that
other SQL databases may not follow this rule. So be careful when
developing applications that are intended to be portable."
--
Michael Fuhr
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-admin@postgresql.org
Cc: mike@fuhr.org, revoohc@gmail.com
Subject: Re: 8.1 Unique Index Issue/Bug???
In-Reply-To: <20060713161546.GA86489@winnie.fuhr.org>
References: <1d219a6f0607130740g7fe13967t48c77a64fde977aa@mail.gmail.com> <20060713161546.GA86489@winnie.fuhr.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
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