pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Ferindo Middleton Jr <fmiddleton@verizon.net>
To: Richard Huxton <dev@archonet.com>
Cc: Jim C. Nasby <jnasby@pervasive.com>
Cc: Scott Marlowe <smarlowe@g2switchworks.com>
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-sql@postgresql.org
Subject: Re: Why doesn't the SERIAL data type automatically have a
Date: Tue, 04 Oct 2005 19:54:47 -0400
Message-ID: <43431647.1010807@verizon.net> (raw)
In-Reply-To: <43430EEB.80500@archonet.com>
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>

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



view thread (10+ messages)  latest in thread

Message-ID: <43431647.1010807@verizon.net>
Permalink:  ../43431647.1010807@verizon.net/
Also on:    postgresql.org/message-id/43431647.1010807@verizon.net

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: fmiddleton@verizon.net, dev@archonet.com, jnasby@pervasive.com, smarlowe@g2switchworks.com, tgl@sss.pgh.pa.us
  Subject: Re: Why doesn't the SERIAL data type automatically have a
  In-Reply-To: <43431647.1010807@verizon.net>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox