Re: BUG #17202: GENERATED BY DEFAULT AS IDENTITY not inherited (but SERIAL is)

From: Erik Huelsmann <ehuels(at)gmail(dot)com>
To: Japin Li <japinli(at)hotmail(dot)com>
Cc: pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #17202: GENERATED BY DEFAULT AS IDENTITY not inherited (but SERIAL is)
Date: 2021-09-24 10:04:31
Message-ID: CACOoB6jyLtX07arsepQvAEjsgf2mH_V8APceY_QgKUrYe7f+pA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Fri, Sep 24, 2021 at 4:32 AM Japin Li <japinli(at)hotmail(dot)com> wrote:

[ snip ]

> > Note that the "id" column of the "invoice_note" table doesn't have the
> > "generated by default as identity". I'm expecting the "invoice_note"
> table's
> > "id" column to have exactly the same definition as the "id" column in the
> > "note" table in both situations because the column isn't repeated in the
> > definition of the "invoice_note" definition.
>
> The documentation for CREATE TABLE [1] INHERITS says:
>
> If a column in the parent table is an identity column, that property is not
> inherited. A column in the child table can be declared identity column if
> desired.
>
> [1] https://www.postgresql.org/docs/13/sql-createtable.html
>
>
Thanks for your reply! I was reading the documentation about Generated
Columns [1] which says:

If a parent column is a generated column, a child column must also be
a generated column using the same expression. In the definition of the
child column, leave off the GENERATED clause, as it will be copied from the
parent.

which I read to indicate that the identity generator in the child should
have been copied from the parent (the "expression" being referred to being
the implied expression of the generator function).

Concluding: It's not a bug and it's also not a functional equivalent of
SERIAL in light of table inheritance.

[1] https://www.postgresql.org/docs/current/ddl-generated-columns.html

--
Bye,

Erik.

http://efficito.com -- Hosted accounting and ERP.
Robust and Flexible. No vendor lock-in.

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Andrew Dunstan 2021-09-24 14:58:52 Re: pg_upgrade test for binary compatibility of core data types
Previous Message Etsuro Fujita 2021-09-24 08:36:06 Re: BUG #16583: merge join on tables with different DB collation behind postgres_fdw fails