From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Improve handling of inherited GENERATED expressions.
Date: Wed, 11 Jan 2023 20:55:10 +0000
Message-ID: <E1pFi7q-003BDS-DH@gemulon.postgresql.org> (raw)
Improve handling of inherited GENERATED expressions.
In both partitioning and traditional inheritance, require child
columns to be GENERATED if and only if their parent(s) are.
Formerly we allowed the case of an inherited column being
GENERATED when its parent isn't, but that results in inconsistent
behavior: the column can be directly updated through an UPDATE
on the parent table, leading to it containing a user-supplied
value that might not match the generation expression. This also
fixes an oversight that we enforced partition-key-columns-can't-
be-GENERATED against parent tables, but not against child tables
that were dynamically attached to them.
Also, remove the restriction that the child's generation expression
be equivalent to the parent's. In the wake of commit 3f7836ff6,
there doesn't seem to be any reason that we need that restriction,
since generation expressions are always computed per-table anyway.
By removing this, we can also allow a child to merge multiple
inheritance parents with inconsistent generation expressions, by
overriding them with its own expression, much as we've long allowed
for DEFAULT expressions.
Since we're rejecting a case that we used to accept, this doesn't
seem like a back-patchable change. Given the lack of field
complaints about the inconsistent behavior, it's likely that no
one is doing this anyway, but we won't change it in minor releases.
Amit Langote and Tom Lane
Discussion: https://postgr.es/m/2793383.1672944799@sss.pgh.pa.us
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/8bf6ec3ba3a44448817af47a080587f3b71bee08
Modified Files
--------------
doc/src/sgml/ddl.sgml | 47 ++++++++---
src/backend/commands/tablecmds.c | 124 +++++++++++-----------------
src/backend/parser/parse_utilcmd.c | 5 --
src/bin/pg_dump/common.c | 43 ++++++----
src/bin/pg_dump/pg_dump.c | 12 +--
src/test/regress/expected/generated.out | 141 ++++++++++++++++++++------------
src/test/regress/sql/generated.sql | 64 ++++++++-------
7 files changed, 240 insertions(+), 196 deletions(-)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-committers@postgresql.org
Cc: tgl@sss.pgh.pa.us
Subject: Re: pgsql: Improve handling of inherited GENERATED expressions.
In-Reply-To: <E1pFi7q-003BDS-DH@gemulon.postgresql.org>
References: <E1pFi7q-003BDS-DH@gemulon.postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox