From: Bryce Nesbitt <bryce1@obviously.com>
To: pgsql-sql@postgresql.org
Subject: UNIQUE, btree index allows duplicate records, if some fields are null
Date: Thu, 09 Feb 2006 11:38:35 -0800
Message-ID: <43EB9A3B.2080507@obviously.com> (raw)
This threw me for a loop. Is this my fault, or a
problem in postgres?
I have a table with the following:
"eg_vehicle_event_pkey" PRIMARY KEY, btree (event_id)
"no_duplicate_events" UNIQUE, btree (thing, other_thing,
"timestamp", number, other_number)
The "no_duplicate_events" constraint works fine, but if I insert records
where
"other_thing" is null, they all go in without complaint. I can insert as
many duplicates as I want.
I had expected two records, identical in all respects including the
null value, to be rejected by the constraint.
This is with:
PostgreSQL 7.4.1 on i686-pc-linux-gnu, compiled by GCC gcc (GCC) 3.2.3
20030502 (Red Hat Linux 3.2.3-20)
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: bryce1@obviously.com
Subject: Re: UNIQUE, btree index allows duplicate records, if some fields are null
In-Reply-To: <43EB9A3B.2080507@obviously.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