Re: inconsistent behavior with "GENERATED BY DEFAULT AS IDENTITY" - Mailing list pgsql-hackers

From Himanshu Upadhyaya
Subject Re: inconsistent behavior with "GENERATED BY DEFAULT AS IDENTITY"
Date
Msg-id CAPF61jCDjzrT_pFw4R1Lc9jVRmYhoGjPqGUmUCcMKBYMdHAoew@mail.gmail.com
Whole thread Raw
In response to Re: inconsistent behavior with "GENERATED BY DEFAULT AS IDENTITY"  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
ok, understood.

Thanks Tom.

Regards,
Himanshu

On Sun, Aug 29, 2021 at 7:10 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:
Himanshu Upadhyaya <upadhyaya.himanshu@gmail.com> writes:
> IMHO below query should replace "NULL" value for ID column with the
> GENERATED IDENTITY value (should insert 1,10 for ID and ID1 respectively in
> below's example), similar to what we expect when we have DEFAULT constraint
> on the column.

Why?  Ordinary DEFAULT clauses do not act that way; if you specify NULL
(or any other value) that is what you get.  If you want the default
value, you can omit the column, or write DEFAULT.

> Any reason for disallowing NULL insertion?

Consistency and standards compliance.

                        regards, tom lane

pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: Spelling change in LLVM 14 API
Next
From: Alvaro Herrera
Date:
Subject: Re: Spelling change in LLVM 14 API