X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 24007DA107 for ; Tue, 4 Oct 2005 20:53:40 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 27404-04 for ; Tue, 4 Oct 2005 23:53:35 +0000 (GMT) Received: from vms046pub.verizon.net (vms046pub.verizon.net [206.46.252.46]) by svr1.postgresql.org (Postfix) with ESMTP id 208B9DA10E for ; Tue, 4 Oct 2005 20:53:36 -0300 (ADT) Received: from [192.168.1.11] ([151.200.41.235]) by vms046.mailsrvcs.net (Sun Java System Messaging Server 6.2 HotFix 0.04 (built Dec 24 2004)) with ESMTPA id <0INV00GSA1196CJL@vms046.mailsrvcs.net> for pgsql-sql@postgresql.org; Tue, 04 Oct 2005 18:53:40 -0500 (CDT) Date: Tue, 04 Oct 2005 19:54:47 -0400 From: Ferindo Middleton Jr Subject: Re: Why doesn't the SERIAL data type automatically have a In-reply-to: <43430EEB.80500@archonet.com> To: Richard Huxton Cc: "Jim C. Nasby" , Scott Marlowe , Tom Lane , pgsql-sql@postgresql.org Reply-To: fmiddleton@verizon.net Message-id: <43431647.1010807@verizon.net> Organization: Sleek Collar MIME-version: 1.0 Content-type: text/plain; charset=ISO-8859-1; format=flowed Content-transfer-encoding: 7bit References: <4338961E.20100@verizon.net> <5899.1127782998@sss.pgh.pa.us> <1127835194.29347.12.camel@state.g2switchworks.com> <20051004225250.GN40138@pervasive.com> <43430EEB.80500@archonet.com> User-Agent: Thunderbird 1.4 (Windows/20050908) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=1.458 required=5 tests=[AWL=-0.292, DNS_FROM_RFC_ABUSE=0.374, DNS_FROM_RFC_POST=1.376] X-Spam-Level: * X-Archive-Number: 200510/16 X-Sequence-Number: 22869 Richard Huxton wrote: > Jim C. Nasby wrote: >>>>> Is there some reason why the SERIAL data type doesn't >>>>> automatically have a UNIQUE CONSTRAINT. >>>> >>>> It used to, and then we decoupled it. > [snip] >> Arguably it would have been better to make the default case add either >> UNIQUE or PRIMARY KEY with a way to over-ride. > > Arguably SERIAL shouldn't be a type at all since it's nothing to do > with defining a set of values. If you were being clean about it you'd > have to have something like "mycol INTEGER SERIAL UNIQUE", then wire > SERIAL to a generator function for the type in question. > >> If newbies are getting burned maybe it would be useful to toss a NOTICE >> or maybe even WARNING when a serial is created without a unique >> constraint of some kind? > > Don't forget the NOT NULL too. Perhaps simpler to have a PGIDENT > pseudo-type that implies "UNIQUE NOT NULL" and then explain the > difference in the docs. > > -- > Richard Huxton > Archonet Ltd > I like Richard's idea. That seems to be the best way to go. Ferindo Sleekcollar