Re: Remove implicit unique index creation on SERIAL columns? - Mailing list pgsql-hackers

From Bruce Momjian
Subject Re: Remove implicit unique index creation on SERIAL columns?
Date
Msg-id 200208200134.g7K1YAo15826@candle.pha.pa.us
Whole thread Raw
In response to Re: Remove implicit unique index creation on SERIAL columns?  (Joe Conway <mail@joeconway.com>)
Responses Re: Remove implicit unique index creation on SERIAL columns?  (Stephan Szabo <sszabo@megazone23.bigpanda.com>)
List pgsql-hackers
Joe Conway wrote:
> Tom Lane wrote:
> > Joe Conway <mail@joeconway.com> writes:
> >>I agree 100%. If you want an index, unique constraint, or primary key on 
> >>a SERIAL, I think you should explicitly add it. SERIAL should give me a 
> >>column that automatically increments -- no more, no less.
> > 
> > Hmm, do you also want to eliminate the implicit NOT NULL constraint?
> > 
> > I think that efficiency and orthogonality are adequate reasons for
> > dissociating UNIQUE from SERIAL.  The efficiency argument is pretty
> > weak in the case of the NOT NULL part, though, so maybe backwards
> > compatibility should win out there.
> 
> To be honest I wasn't thinking about NOT NULL. I'd agree with leaving 
> that in place.
> 
> Maybe I should restate my comment above: SERIAL should give me a column 
> that automatically increments -- no more, no less -- and it should not 
> allow me to override the value that it gives. Hence an implicit NOT 
> NULL, but also an implicit rejection of a manual insert/update of that 
> field (how hard would this be to do?).

If don't understand.  We already have a unique index on the SERIAL
column, so why bother rejecting an insert/update that supplies the
value?  We need the column to be unique, and that is forced, but why
prevent _any_ unique value from being used.

Clearly NULL is not a valid value and should be prevented with NOT NULL.

--  Bruce Momjian                        |  http://candle.pha.pa.us pgman@candle.pha.pa.us               |  (610)
359-1001+  If your life is a hard drive,     |  13 Roberts Road +  Christ can be your backup.        |  Newtown Square,
Pennsylvania19073
 


pgsql-hackers by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: Removing Libraries (Was: Re: Open 7.3 issues)
Next
From: "Christopher Kings-Lynne"
Date:
Subject: Re: @(#) Mordred Labs advisory 0x0001: Buffer overflow in