Re: inconsistent behavior with "GENERATED BY DEFAULT AS IDENTITY"

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Himanshu Upadhyaya <upadhyaya(dot)himanshu(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: inconsistent behavior with "GENERATED BY DEFAULT AS IDENTITY"
Date: 2021-08-29 13:40:18
Message-ID: 1124414.1630244418@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Himanshu Upadhyaya <upadhyaya(dot)himanshu(at)gmail(dot)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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2021-08-29 13:51:58 Re: Can we get rid of repeated queries from pg_dump?
Previous Message Alvaro Herrera 2021-08-29 13:13:15 Re: Can we get rid of repeated queries from pg_dump?