agora inbox for pgsql-committers@postgresql.org
help / color / mirror / Atom feedFrom: Álvaro Herrera <alvherre@kurilemu.de>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Fix ALTER COLUMN ... DROP EXPRESSION with subpartitions
Date: Tue, 04 Aug 2026 07:14:47 +0000
Message-ID: <E1wr9MN-0000000082p-17BP@gemulon.postgresql.org> (raw)
Fix ALTER COLUMN ... DROP EXPRESSION with subpartitions
Per commit 8bf6ec3ba3a4, a column can be GENERATED only if it is such in
the whole inheritance tree.
For this reason, ATPrepDropExpression refuses to be called with ONLY on
a partitioned table. To detect this, the current implementation checks
whether recurse is set to false and the rel has direct children.
Recursion is implemented with ATSimpleRecursion, which calls ATPrepCmd
with recurse = false for every node in the tree. Inner nodes (for
example a partition which itself has subpartitions) then fail the check,
accidentally preventing the command from working on inheritance trees of
depth > 2.
This commit fixes it by also checking that we're at the top level of the
recursive calls using the recursing parameter, which is always true when
called through ATSimpleRecursion, always false when invoked on the root
rel.
Also, remove a comment claiming that DROP EXPRESSION could be
implemented with some effort. It cannot, as the commit message for
8bf6ec3ba3a4 explains.
Author: Alberto Piai <alberto.piai@gmail.com>
Backpatch-through: 14
Discussion: https://postgr.es/m/DHMT78XOD8BK.341V3H87KZ7NO@gmail.com
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/fef160d8b0ddf72e1089133300d30109293f5a71
Modified Files
--------------
src/backend/commands/tablecmds.c | 15 +++-----
src/test/regress/expected/generated_stored.out | 51 ++++++++++++++++++++++++++
src/test/regress/sql/generated_stored.sql | 15 ++++++++
3 files changed, 71 insertions(+), 10 deletions(-)
view thread (7+ messages) latest in thread
Message-ID: <E1wr9MN-0000000082p-17BP@gemulon.postgresql.org>
Permalink: ../E1wr9MN-0000000082p-17BP@gemulon.postgresql.org/
Also on: postgresql.org/message-id/E1wr9MN-0000000082p-17BP@gemulon.postgresql.org
reply
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 using the --to and --cc options:
reply via email
To: pgsql-committers@postgresql.org
Cc: alvherre@kurilemu.de, pgsql-committers@lists.postgresql.org
Subject: Re: pgsql: Fix ALTER COLUMN ... DROP EXPRESSION with subpartitions
In-Reply-To: <E1wr9MN-0000000082p-17BP@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 agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox