X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id 8E0AB9DCC32 for ; Thu, 9 Feb 2006 15:59:17 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 24785-01 for ; Thu, 9 Feb 2006 15:59:17 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by postgresql.org (Postfix) with ESMTP id 46C8E9DC9A6 for ; Thu, 9 Feb 2006 15:59:15 -0400 (AST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id k19JxET0004119; Thu, 9 Feb 2006 14:59:14 -0500 (EST) To: Bryce Nesbitt cc: pgsql-sql@postgresql.org Subject: Re: UNIQUE, btree index allows duplicate records, if some fields are null In-reply-to: <43EB9A3B.2080507@obviously.com> References: <43EB9A3B.2080507@obviously.com> Comments: In-reply-to Bryce Nesbitt message dated "Thu, 09 Feb 2006 11:38:35 -0800" Date: Thu, 09 Feb 2006 14:59:14 -0500 Message-ID: <4118.1139515154@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.108 required=5 tests=[AWL=0.108] X-Spam-Score: 0.108 X-Spam-Level: X-Archive-Number: 200602/107 X-Sequence-Number: 24117 Bryce Nesbitt 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