]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Fix several DDL issues of generated columns versus inheritance
authorPeter Eisentraut <peter@eisentraut.org>
Wed, 6 May 2020 14:25:54 +0000 (16:25 +0200)
committerPeter Eisentraut <peter@eisentraut.org>
Fri, 8 May 2020 09:31:46 +0000 (11:31 +0200)
commit14751c340754af9f906a893eb87a894dea3adbc9
treeb45f28bb5d151a82cfb67451b26ef91ecc9b4485
parentbf7233ee4a546219b078b5a0afc654ec02958bee
Fix several DDL issues of generated columns versus inheritance

Several combinations of generated columns and inheritance in CREATE
TABLE were not handled correctly.  Specifically:

- Disallow a child column specifying a generation expression if the
  parent column is a generated column.  The child column definition
  must be unadorned and the parent column's generation expression will
  be copied.

- Prohibit a child column of a generated parent column specifying
  default values or identity.

- Allow a child column of a not-generated parent column specifying
  itself as a generated column.  This previously did not work, but it
  was possible to arrive at the state via other means (involving ALTER
  TABLE), so it seems sensible to support it.

Add tests for each case.  Also add documentation about the rules
involving generated columns and inheritance.

Discussion:
    https://www.postgresql.org/message-id/flat/15830.1575468847%40sss.pgh.pa.us
    https://www.postgresql.org/message-id/flat/2678bad1-048f-519a-ef24-b12962f41807%40enterprisedb.com
    https://www.postgresql.org/message-id/flat/CAJvUf_u4h0DxkCMCeEKAWCuzGUTnDP-G5iVmSwxLQSXn0_FWNQ%40mail.gmail.com
doc/src/sgml/ddl.sgml
src/backend/commands/tablecmds.c
src/test/regress/expected/generated.out
src/test/regress/sql/generated.sql