diff options
author | Peter Eisentraut <peter@eisentraut.org> | 2020-05-06 16:25:54 +0200 |
---|---|---|
committer | Peter Eisentraut <peter@eisentraut.org> | 2020-05-08 11:31:57 +0200 |
commit | 086ffddf3656fb3d24d9a73ce36cb1102e42cc90 (patch) | |
tree | e2907fe4913872e4917c0af187b1b70e804e8bc1 /doc/src | |
parent | 501e41dd3cb945287fdcfe25e8906e79872fcc44 (diff) | |
download | postgresql-086ffddf3656fb3d24d9a73ce36cb1102e42cc90.tar.gz postgresql-086ffddf3656fb3d24d9a73ce36cb1102e42cc90.zip |
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
Diffstat (limited to 'doc/src')
-rw-r--r-- | doc/src/sgml/ddl.sgml | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/doc/src/sgml/ddl.sgml b/doc/src/sgml/ddl.sgml index aae5d320309..bdfb221bc98 100644 --- a/doc/src/sgml/ddl.sgml +++ b/doc/src/sgml/ddl.sgml @@ -324,6 +324,32 @@ CREATE TABLE people ( linkend="sql-createforeigntable"/> for details. </para> </listitem> + <listitem> + <para>For inheritance:</para> + <itemizedlist> + <listitem> + <para> + 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 <literal>GENERATED</literal> clause, + as it will be copied from the parent. + </para> + </listitem> + <listitem> + <para> + In case of multiple inheritance, if one parent column is a generated + column, then all parent columns must be generated columns and with the + same expression. + </para> + </listitem> + <listitem> + <para> + If a parent column is not a generated column, a child column may be + defined to be a generated column or not. + </para> + </listitem> + </itemizedlist> + </listitem> </itemizedlist> </para> |