dbTalk Databases Forums  

[BUGS] UNIQUE not honoured for NULL

mailing.database.pgsql-bugs mailing.database.pgsql-bugs


Discuss [BUGS] UNIQUE not honoured for NULL in the mailing.database.pgsql-bugs forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
David Newall
 
Posts: n/a

Default [BUGS] UNIQUE not honoured for NULL - 07-07-2004 , 02:17 PM






PostgreSQL version: 7.4.3 (RPMs from ftp.au.postgresql.org)

Operating Sysem: Fedora Core 1

CREATE TABLE t(i integer UNIQUE);
INSERT INTO t VALUES (null);
INSERT INTO t VALUES (null);
SELECT coalesce(i,-999) FROM t;
coalesce
----------
-999
-999
(2 rows)



---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo (AT) postgresql (DOT) org so that your
message can get through to the mailing list cleanly

Reply With Quote
  #2  
Old   
Peter Eisentraut
 
Posts: n/a

Default Re: [BUGS] UNIQUE not honoured for NULL - 07-07-2004 , 02:34 PM






David Newall wrote:
Quote:
PostgreSQL version: 7.4.3 (RPMs from ftp.au.postgresql.org)

Operating Sysem: Fedora Core 1

CREATE TABLE t(i integer UNIQUE);
INSERT INTO t VALUES (null);
INSERT INTO t VALUES (null);
SELECT coalesce(i,-999) FROM t;
coalesce
----------
-999
-999
(2 rows)
NULL = NULL is not true, so the rows are not equal.


---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to majordomo (AT) postgresql (DOT) org


Reply With Quote
  #3  
Old   
Stephan Szabo
 
Posts: n/a

Default Re: [BUGS] UNIQUE not honoured for NULL - 07-07-2004 , 02:48 PM



On Tue, 6 Jul 2004, David Newall wrote:

Quote:
PostgreSQL version: 7.4.3 (RPMs from ftp.au.postgresql.org)

Operating Sysem: Fedora Core 1

CREATE TABLE t(i integer UNIQUE);
INSERT INTO t VALUES (null);
INSERT INTO t VALUES (null);
SELECT coalesce(i,-999) FROM t;
coalesce
----------
-999
-999
(2 rows)
NULL values are explicitly allowed to be duplicated in unique constraints
by spec AFAICS. The unique constraint is defined in terms of the unique
predicate which says: "If there are no two rows in T such that the value
of each column in one row is non-null and is equal to the value of the
corresponding column in the other row according to Subclause 8.2,
"<comparison predicate>", then the result of the <unique predicate> is
true; otherwise, the result of the <unique predicate> is false."



---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to majordomo (AT) postgresql (DOT) org)


Reply With Quote
  #4  
Old   
Gaetano Mendola
 
Posts: n/a

Default Re: [BUGS] UNIQUE not honoured for NULL - 07-12-2004 , 08:04 AM



David Newall wrote:

Quote:
PostgreSQL version: 7.4.3 (RPMs from ftp.au.postgresql.org)

Operating Sysem: Fedora Core 1

CREATE TABLE t(i integer UNIQUE);
INSERT INTO t VALUES (null);
INSERT INTO t VALUES (null);
SELECT coalesce(i,-999) FROM t;
coalesce
----------
-999
-999
(2 rows)
As someone says NULL = NULL is false
so that two rows are different. If you want enforce
only one null value for that column you have to write
you own trigger.



Regards
Gaetano Mendola



---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to majordomo (AT) postgresql (DOT) org


Reply With Quote
  #5  
Old   
Bruno Wolff III
 
Posts: n/a

Default Re: [BUGS] UNIQUE not honoured for NULL - 07-12-2004 , 09:45 AM



On Mon, Jul 12, 2004 at 14:47:34 +0200,
Gaetano Mendola <mendola (AT) bigfoot (DOT) com> wrote:
Quote:
As someone says NULL = NULL is false
As someone else pointed out, NULL = NULL is NULL which is not TRUE.

---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend


Reply With Quote
  #6  
Old   
Gaetano Mendola
 
Posts: n/a

Default Re: [BUGS] UNIQUE not honoured for NULL - 07-12-2004 , 10:00 AM



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Bruno Wolff III wrote:

Quote:
On Mon, Jul 12, 2004 at 14:47:34 +0200,
Gaetano Mendola <mendola (AT) bigfoot (DOT) com> wrote:

As someone says NULL = NULL is false


As someone else pointed out, NULL = NULL is NULL which is not TRUE.
Yes, that it's better.


Regards
Gaetano Mendola



-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (MingW32)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFA8qXV7UpzwH2SGd4RAuENAKCxQGdRV59L9f6fqRiSm4 qHC3DOJACeJ/QL
P2u0s/SyFrBalPIgVXoOClI=
=u0Ny
-----END PGP SIGNATURE-----


---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend


Reply With Quote
  #7  
Old   
Andreas Pflug
 
Posts: n/a

Default Re: [BUGS] UNIQUE not honoured for NULL - 07-12-2004 , 10:28 AM



Gaetano Mendola wrote:
Quote:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Bruno Wolff III wrote:

| On Mon, Jul 12, 2004 at 14:47:34 +0200,
| Gaetano Mendola <mendola (AT) bigfoot (DOT) com> wrote:
|
|>As someone says NULL = NULL is false
|
|
| As someone else pointed out, NULL = NULL is NULL which is not TRUE.

Yes, that it's better.
Still not precise.

NULL = NULL
is NULL (which is neither TRUE nor FALSE)

while
(NULL = NULL) IS NULL
is TRUE...


Regards,
Andreas

---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.