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 54C33D1B486 for ; Tue, 6 Apr 2004 13:38:48 -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 25146-10 for ; Tue, 6 Apr 2004 13:38:45 -0300 (ADT) Received: from bramble.mmrd.com (unknown [65.217.53.66]) by svr1.postgresql.org (Postfix) with ESMTP id 94412D1DB87 for ; Tue, 6 Apr 2004 13:38:44 -0300 (ADT) Received: from thorn.mmrd.com (thorn.mmrd.com [172.25.10.100]) by bramble.mmrd.com (8.12.8/8.12.8) with ESMTP id i36GdbcM001543; Tue, 6 Apr 2004 12:39:38 -0400 Received: from gnvex001.mmrd.com (gnvex001.mmrd.com [192.168.3.55]) by thorn.mmrd.com (8.11.6/8.11.6) with ESMTP id i36Gcgl11405; Tue, 6 Apr 2004 12:38:42 -0400 Received: from camel.mmrd.com ([172.25.5.213]) by gnvex001.mmrd.com with SMTP (Microsoft Exchange Internet Mail Service Version 5.5.2657.72) id FVMA7MDJ; Tue, 6 Apr 2004 12:38:40 -0400 Subject: Re: partial unique constraint From: Robert Treat To: Tom Lane Cc: pgsql-sql@postgresql.org In-Reply-To: <24888.1081264623@sss.pgh.pa.us> References: <1081261772.31785.48.camel@camel> <24888.1081264623@sss.pgh.pa.us> Content-Type: text/plain Content-Transfer-Encoding: 7bit X-Mailer: Ximian Evolution 1.0.8 Date: 06 Apr 2004 12:38:41 -0400 Message-Id: <1081269521.31791.73.camel@camel> Mime-Version: 1.0 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200404/48 X-Sequence-Number: 17423 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... Robert Treat -- Build A Brighter Lamp :: Linux Apache {middleware} PostgreSQL