X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id C9450D1B88D for ; Tue, 6 Apr 2004 16:54:12 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 25617-03 for ; Tue, 6 Apr 2004 16:54:12 -0300 (ADT) Received: from anchor-post-31.mail.demon.net (anchor-post-31.mail.demon.net [194.217.242.89]) by svr1.postgresql.org (Postfix) with ESMTP id B2269D1B4BC for ; Tue, 6 Apr 2004 16:54:10 -0300 (ADT) Received: from mwynhau.demon.co.uk ([193.237.186.96] helo=mainbox.archonet.com) by anchor-post-31.mail.demon.net with esmtp (Exim 3.35 #1) id 1BAweB-000PmP-0V; Tue, 06 Apr 2004 20:54:11 +0100 Received: by mainbox.archonet.com (Postfix, from userid 529) id E987B165A8; Tue, 6 Apr 2004 20:54:10 +0100 (BST) Received: from client17.archonet.com (client17.archonet.com [192.168.1.17]) by mainbox.archonet.com (Postfix) with ESMTP id A8C8F15995; Tue, 6 Apr 2004 20:54:08 +0100 (BST) From: Richard Huxton To: Robert Treat , Tom Lane Subject: Re: partial unique constraint Date: Tue, 6 Apr 2004 20:54:07 +0100 User-Agent: KMail/1.5 Cc: pgsql-sql@postgresql.org References: <1081261772.31785.48.camel@camel> <24888.1081264623@sss.pgh.pa.us> <1081269521.31791.73.camel@camel> In-Reply-To: <1081269521.31791.73.camel@camel> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200404062054.07498.dev@archonet.com> X-Bogosity: No, tests=bogofilter, spamicity=0.000000, version=0.15.3 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200404/50 X-Sequence-Number: 17425 On Tuesday 06 April 2004 17:38, Robert Treat wrote: > On Tue, 2004-04-06 at 11:17, Tom Lane wrote: > > Robert Treat writes: > > > Trying to come up with the proper syntax to meet the following > > > criteria: create table foo (bar integer, baz boolean UNIQUE (bar, baz = > > > true)); > > > > The correct way to do it is with a separate CREATE INDEX command: > > I think I had initially abandoned looking at that type of solution after > having run across this paragraph in the docs while looking for the > proper constraint syntax: > > "Note: The preferred way to add a unique constraint to a table is ALTER > TABLE ... ADD CONSTRAINT. The use of indexes to enforce unique > constraints could be considered an implementation detail that should not > be accessed directly." > > The subliminal mind is a powerful force eh? Perhaps that paragraph > should be modified... but I'm not sure if it should expanded to include > thoughts along the lines of Stephan's response or maybe just drop the > "should not be accessed directly" bit... Anyone know if there is any way to do this in one of the later SQL standards? The CREATE INDEX thing is a bit of a hack, and I certainly wouldn't have thought of it either. -- Richard Huxton Archonet Ltd