X-Original-To: pgsql-admin-postgresql.org@postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 1E8FA9FB2B0 for ; Thu, 13 Jul 2006 13:16:06 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 16689-06 for ; Thu, 13 Jul 2006 13:15:56 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from tigger.fuhr.org (tigger.fuhr.org [63.214.45.158]) by postgresql.org (Postfix) with ESMTP id CBB939FB274 for ; Thu, 13 Jul 2006 13:15:54 -0300 (ADT) Received: from winnie.fuhr.org (winnie.fuhr.org [10.1.0.1]) by tigger.fuhr.org (8.13.7/8.13.7) with ESMTP id k6DGFloG099541 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 13 Jul 2006 10:15:49 -0600 (MDT) Received: from winnie.fuhr.org (localhost [127.0.0.1]) by winnie.fuhr.org (8.13.6/8.13.6) with ESMTP id k6DGFkOT086596; Thu, 13 Jul 2006 10:15:47 -0600 (MDT) (envelope-from mfuhr@winnie.fuhr.org) Received: (from mfuhr@localhost) by winnie.fuhr.org (8.13.6/8.13.6/Submit) id k6DGFkEG086595; Thu, 13 Jul 2006 10:15:46 -0600 (MDT) (envelope-from mfuhr) Date: Thu, 13 Jul 2006 10:15:46 -0600 From: Michael Fuhr To: Chris Hoover Cc: "pgsql-admin@postgresql.org" Subject: Re: 8.1 Unique Index Issue/Bug??? Message-ID: <20060713161546.GA86489@winnie.fuhr.org> References: <1d219a6f0607130740g7fe13967t48c77a64fde977aa@mail.gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1d219a6f0607130740g7fe13967t48c77a64fde977aa@mail.gmail.com> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200607/90 X-Sequence-Number: 22336 On Thu, Jul 13, 2006 at 10:40:43AM -0400, Chris Hoover wrote: > Why is PostgreSQL not enforcing this index? This appears to be a pretty > major a bug? It would seem that you could have a unique index across > columns that might have a null in them. This comes up frequently due to a misunderstanding of how NULL comparison works. http://www.postgresql.org/docs/8.1/interactive/ddl-constraints.html#AEN2016 "In general, a unique constraint is violated when there are two or more rows in the table where the values of all of the columns included in the constraint are equal. However, null values are not considered equal in this comparison. That means even in the presence of a unique constraint it is possible to store duplicate rows that contain a null value in at least one of the constrained columns. This behavior conforms to the SQL standard, but we have heard that other SQL databases may not follow this rule. So be careful when developing applications that are intended to be portable." -- Michael Fuhr