From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Shay Rojansky <roji(at)roji(dot)org> |
Cc: | Vik Fearing <vik(at)postgresfriends(dot)org>, Amit Langote <amitlangote09(at)gmail(dot)com>, pavel(dot)boev(at)invitae(dot)com, PostgreSQL mailing lists <pgsql-bugs(at)lists(dot)postgresql(dot)org> |
Subject: | Re: BUG #16913: GENERATED AS IDENTITY column nullability is affected by order of column properties |
Date: | 2021-05-14 20:18:02 |
Message-ID: | 2191863.1621023482@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
Shay Rojansky <roji(at)roji(dot)org> writes:
> I can see the PG 13.3 change note about GENERATED ALWAYS AS IDENTITY no
> longer being compatible with an explicit NULL specification. However, it
> seems that GENERATED BY DEFAULT AS IDENTITY also is no longer compatible
> with null:
> CREATE TABLE foo
> (
> id INTEGER NULL GENERATED BY DEFAULT AS IDENTITY
> );
> Results in:
> ERROR: conflicting NULL/NOT NULL declarations for column "id" of table
> "foo"
> Is this intended?
GENERATED BY DEFAULT does create a NOT NULL constraint:
regression=# CREATE TABLE foo(id INTEGER GENERATED BY DEFAULT AS IDENTITY);
CREATE TABLE
regression=# \d foo
Table "public.foo"
Column | Type | Collation | Nullable | Default
--------+---------+-----------+----------+----------------------------------
id | integer | | not null | generated by default as identity
so I think the patch is doing what it was intended to. Whether GENERATED
BY DEFAULT *should* be forcing NOT NULL is a separate question, but
AFAIK it always has.
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2021-05-14 21:18:40 | Re: BUG #16913: GENERATED AS IDENTITY column nullability is affected by order of column properties |
Previous Message | Alex F | 2021-05-14 20:12:58 | Re: BUG #16833: postgresql 13.1 process crash every hour |