pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Bryce Nesbitt <bryce1@obviously.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: UNIQUE, btree index allows duplicate records, if some fields are null
Date: Thu, 09 Feb 2006 14:59:14 -0500
Message-ID: <4118.1139515154@sss.pgh.pa.us> (raw)
In-Reply-To: <43EB9A3B.2080507@obviously.com>
References: <43EB9A3B.2080507@obviously.com>

Bryce Nesbitt <bryce1@obviously.com> writes:
> 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.

This is per SQL spec.  You're imagining that two nulls are considered
equal, which they are not.

			regards, tom lane



view thread (2+ messages)

Message-ID: <4118.1139515154@sss.pgh.pa.us>
Permalink:  ../4118.1139515154@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/4118.1139515154@sss.pgh.pa.us

 · 

reply

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: tgl@sss.pgh.pa.us, bryce1@obviously.com
  Subject: Re: UNIQUE, btree index allows duplicate records, if some fields are null
  In-Reply-To: <4118.1139515154@sss.pgh.pa.us>

* 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