Re: 8.1 Unique Index Issue/Bug???

Поиск
Список
Период
Сортировка
От Michael Fuhr
Тема Re: 8.1 Unique Index Issue/Bug???
Дата
Msg-id 20060713161546.GA86489@winnie.fuhr.org
обсуждение исходный текст
Ответ на 8.1 Unique Index Issue/Bug???  ("Chris Hoover" <revoohc@gmail.com>)
Список pgsql-admin
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

В списке pgsql-admin по дате отправления:

Предыдущее
От: Chris Browne
Дата:
Сообщение: Re: Where are the temporary work / sort files please
Следующее
От: "Aaron Bono"
Дата:
Сообщение: Re: 8.1 Unique Index Issue/Bug???