Re: BUG #17202: GENERATED BY DEFAULT AS IDENTITY not inherited (but SERIAL is) - Mailing list pgsql-bugs

From Erik Huelsmann
Subject Re: BUG #17202: GENERATED BY DEFAULT AS IDENTITY not inherited (but SERIAL is)
Date
Msg-id CACOoB6jyLtX07arsepQvAEjsgf2mH_V8APceY_QgKUrYe7f+pA@mail.gmail.com
Whole thread Raw
In response to Re: BUG #17202: GENERATED BY DEFAULT AS IDENTITY not inherited (but SERIAL is)  (Japin Li <japinli@hotmail.com>)
List pgsql-bugs


On Fri, Sep 24, 2021 at 4:32 AM Japin Li <japinli@hotmail.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.



--
Bye,

Erik.

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

pgsql-bugs by date:

Previous
From: Japin Li
Date:
Subject: Re: BUG #17202: GENERATED BY DEFAULT AS IDENTITY not inherited (but SERIAL is)
Next
From: Andrey Borodin
Date:
Subject: Re: CREATE INDEX CONCURRENTLY does not index prepared xact's data