Re: [HACKERS] Serial and NULL values

From: Bruce Momjian <maillist(at)candle(dot)pha(dot)pa(dot)us>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: PostgreSQL-development <pgsql-hackers(at)postgreSQL(dot)org>
Subject: Re: [HACKERS] Serial and NULL values
Date: 1999-10-30 00:20:30
Message-ID: 199910300020.UAA25008@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> Bruce Momjian <maillist(at)candle(dot)pha(dot)pa(dot)us> writes:
> > test=> create table test (x int, y serial);
> > CREATE
> > test=> insert into test values (100, null);
> > ERROR: ExecAppend: Fail to add null value in not null attribute y
>
> gram.y thinks SERIAL is defined to mean NOT NULL:
>
> | ColId SERIAL ColPrimaryKey
> {
> ColumnDef *n = makeNode(ColumnDef);
> n->colname = $1;
> n->typename = makeNode(TypeName);
> n->typename->name = xlateSqlType("integer");
> n->raw_default = NULL;
> n->cooked_default = NULL;
> =================> n->is_not_null = TRUE;
> n->is_sequence = TRUE;
> n->constraints = $3;
>
> $$ = (Node *)n;
> }
>
> 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?

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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Brian Hirt 1999-10-30 01:26:42 Re: [HACKERS] Serial and NULL values
Previous Message Tom Lane 1999-10-29 23:44:44 Re: [HACKERS] Serial and NULL values