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 <[email protected]> Backpatch-through: 14 Discussion: https://postgr.es/m/[email protected] Branch ------ REL_19_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/ce6e434ceeb05d1aaf64a3f48c5927f46ea3c2e0 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(-)
