From: dev@archonet.com
To: Tomasz Myrta <jasiek@klaster.net>
Cc: jimmy.makela@agent25.se, "'pgsql-sql@postgresql.org'" <pgsql-sql@postgresql.org>
Subject: Re: Unique indexes not unique?
Date: Mon, 13 Jan 2003 12:32:05 -0000 (GMT)
Message-ID: <1477.192.168.1.16.1042461125.squirrel@mainbox.archonet.com> (raw)
In-Reply-To: <3E229858.4070509@klaster.net>
References: <D1045567F50DD311AB1B00508B3188E9026546D8@RINGHALS>
<3E229858.4070509@klaster.net>
> Jimmy Mäkelä wrote:
>
>> I found that Postgres isn't behaving like I thought when using a
>> unique index in
>> combination with NULL-values...
>> Is this a bug or specified in the SQL-standard? If its a bug, is it
>> fixed in a
>> recent version? We are using 7.2.3
>> intranet=# insert into "foo" (a, b) values ('apa', null);
>> INSERT 26229706 1
>> intranet=# insert into "foo" (a, b) values ('apa', null);
>> INSERT 26229707 1
>
> I'm not sure unique index works properly for null values. I can't
> explain, why. Maybe it comes from SQL standard - null i a special value
> and can't be compared using default operators to other non null values:
> 1>null =null
> 1<null =null
> 1=null =null
Null is not a value or even a "special" value, it is supposed to represent
the absence of a value. It means either "not applicable" or "not known".
It doesn't make sense to say whether one null is the same as another, a
null is an absence, a hole. As a result, you can't really talk about
comparing two nulls, only testing whether a value is null.
If you are using a null in a situation where it should be unique, you
probably want a value instead. Can't say more without an actual example.
- Richard Huxton
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 using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: dev@archonet.com, jasiek@klaster.net
Subject: Re: Unique indexes not unique?
In-Reply-To: <1477.192.168.1.16.1042461125.squirrel@mainbox.archonet.com>
* 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