Re: [HACKERS] Serial and NULL values

From: Brian Hirt <bhirt(at)mobygames(dot)com>
To: Bruce Momjian <maillist(at)candle(dot)pha(dot)pa(dot)us>, pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: [HACKERS] Serial and NULL values
Date: 1999-10-30 01:26:42
Message-ID: 19991029212642.A24778@loopy.berkhirt.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 1999-10-30 02:28:40 Re: [HACKERS] Serial and NULL values
Previous Message Bruce Momjian 1999-10-30 00:20:30 Re: [HACKERS] Serial and NULL values