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 2B2EEDA0E0 for ; Tue, 4 Oct 2005 20:25:22 -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 18154-05 for ; Tue, 4 Oct 2005 23:25:17 +0000 (GMT) Received: from mail.metronet.co.uk (mail.metronet.co.uk [213.162.97.75]) by svr1.postgresql.org (Postfix) with ESMTP id 09090DA0ED for ; Tue, 4 Oct 2005 20:25:18 -0300 (ADT) Received: from mainbox.archonet.com (84-51-143-99.archon037.adsl.metronet.co.uk [84.51.143.99]) by smtp.metronet.co.uk (MetroNet Mail) with ESMTP id 3CBF1416F54; Wed, 5 Oct 2005 00:25:00 +0100 (BST) Received: from localhost (localhost.localdomain [127.0.0.1]) by mainbox.archonet.com (Postfix) with ESMTP id DA27715EDA; Wed, 5 Oct 2005 00:23:26 +0100 (BST) Received: from mainbox.archonet.com ([127.0.0.1]) by localhost (mainbox [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 03102-05; Wed, 5 Oct 2005 00:23:23 +0100 (BST) Received: from [192.168.1.17] (client17.office.archonet.com [192.168.1.17]) by mainbox.archonet.com (Postfix) with ESMTP id 78F0415ED5; Wed, 5 Oct 2005 00:23:23 +0100 (BST) Message-ID: <43430EEB.80500@archonet.com> Date: Wed, 05 Oct 2005 00:23:23 +0100 From: Richard Huxton User-Agent: Mozilla Thunderbird 1.0.6 (X11/20050912) X-Accept-Language: en-us, en MIME-Version: 1.0 To: "Jim C. Nasby" Cc: Scott Marlowe , Tom Lane , fmiddleton@verizon.net, pgsql-sql@postgresql.org Subject: Re: Why doesn't the SERIAL data type automatically have a References: <4338961E.20100@verizon.net> <5899.1127782998@sss.pgh.pa.us> <1127835194.29347.12.camel@state.g2switchworks.com> <20051004225250.GN40138@pervasive.com> In-Reply-To: <20051004225250.GN40138@pervasive.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.058 required=5 tests=[AWL=0.008, FORGED_RCVD_HELO=0.05] X-Spam-Level: X-Archive-Number: 200510/14 X-Sequence-Number: 22867 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