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

From Tom Lane
Subject Re: [HACKERS] Serial and NULL values
Date
Msg-id 3695.941240684@sss.pgh.pa.us
Whole thread Raw
In response to Serial and NULL values  (Bruce Momjian <maillist@candle.pha.pa.us>)
Responses Re: [HACKERS] Serial and NULL values  (Bruce Momjian <maillist@candle.pha.pa.us>)
List pgsql-hackers
Bruce Momjian <maillist@candle.pha.pa.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.
        regards, tom lane


pgsql-hackers by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: [HACKERS] MATLAB PostgreSQL interface
Next
From: Bruce Momjian
Date:
Subject: Re: [HACKERS] Serial and NULL values