Re: [HACKERS] Serial and NULL values - Mailing list pgsql-hackers

From Brian Hirt
Subject Re: [HACKERS] Serial and NULL values
Date
Msg-id 19991029212642.A24778@loopy.berkhirt.com
Whole thread Raw
In response to Re: [HACKERS] Serial and NULL values  (Bruce Momjian <maillist@candle.pha.pa.us>)
List pgsql-hackers
On Fri, Oct 29, 1999 at 08:20:30PM -0400, Bruce Momjian wrote:
> > 
> > Offhand I don't see any fundamental reason why serial columns should
> > be restricted to be nonnull, but evidently someone did at some point.
> 
> The actual null is not the issue.  The issue is that if we have a
> SERIAL column, and we try to put a NULL in there, shouldn't it put the
> default sequence number in there?
> 

It seems logical that if a value was supplied for a serial column that 
it would override the default.  After all, SERIAL is just an int column 
with a default based on a sequence, right?.  If the default is always 
used (even when a value is supplied) then that would be a REAL BIG problem. 

Without making SERIAL a distinctly different datatype, I can't see how 
a default sequence could behave differently for two tables created with 
different syntax.

My 2 cents is that the current behavior is the correct behavior.

As far as the NULL goes, since the SERIAL column is assumed to be a 
key and a unique index is created, having it NOT NULL seems like a
good idea.  I don't know anyone who would have a key value be NULL,
and even if it could be NULL, you would olny be allowd one NULL.

-- 
The world's most ambitious and comprehensive PC game database project.
                     http://www.mobygames.com


pgsql-hackers by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: [HACKERS] Serial and NULL values
Next
From: Tom Lane
Date:
Subject: Re: [HACKERS] Serial and NULL values