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

From Bruce Momjian
Subject Re: [HACKERS] Serial and NULL values
Date
Msg-id 199910311315.IAA29858@candle.pha.pa.us
Whole thread Raw
In response to Re: [HACKERS] Serial and NULL values  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
> Bruce Momjian <maillist@candle.pha.pa.us> writes:
> >> 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?
> 
> No, I wouldn't expect that at all.  A default is inserted when you
> don't supply anything at all for the column.  Inserting an explicit
> NULL means you want a NULL, and barring a NOT NULL constraint on
> the column, that's what the system ought to insert.  I can see no
> possible justification for creating a type-specific exception to
> that behavior.
> 
> If the original asker really wants to substitute something else for
> an explicit null insertion, he could do it with a rule or a trigger.
> But I don't think SERIAL ought to act that way all by itself.

OK, I see now.  In Informix, if you insert 0 into a serial column, you
get the nextval assigned.

However, I can see that is not logical. We have serial which defines a
default for nextval().

Thanks.

--  Bruce Momjian                        |  http://www.op.net/~candle maillist@candle.pha.pa.us            |  (610)
853-3000+  If your life is a hard drive,     |  830 Blythe Avenue +  Christ can be your backup.        |  Drexel Hill,
Pennsylvania19026
 


pgsql-hackers by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: [HACKERS] pgaccess for 6.5.3
Next
From: Bruce Momjian
Date:
Subject: Re: [HACKERS] Serial and NULL values