agora inbox for pgsql-committers@postgresql.org  
help / color / mirror / Atom feed
pgsql: Fix ALTER COLUMN ... DROP EXPRESSION with subpartitions
7+ messages / 1 participants
[nested] [flat]

* pgsql: Fix ALTER COLUMN ... DROP EXPRESSION with subpartitions
@ 2026-08-04 07:14  Álvaro Herrera <alvherre@kurilemu.de>
  0 siblings, 0 replies; 7+ messages in thread

From: Álvaro Herrera @ 2026-08-04 07:14 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

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(-)



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* pgsql: Fix ALTER COLUMN ... DROP EXPRESSION with subpartitions
@ 2026-08-04 07:14  Álvaro Herrera <alvherre@kurilemu.de>
  0 siblings, 0 replies; 7+ messages in thread

From: Álvaro Herrera @ 2026-08-04 07:14 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

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
------
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(-)



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* pgsql: Fix ALTER COLUMN ... DROP EXPRESSION with subpartitions
@ 2026-08-04 07:14  Álvaro Herrera <alvherre@kurilemu.de>
  0 siblings, 0 replies; 7+ messages in thread

From: Álvaro Herrera @ 2026-08-04 07:14 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

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
------
REL_18_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/c374f2807c236dd8fb4bee9f4ebfe4af300491f9

Modified Files
--------------
src/backend/commands/tablecmds.c               | 15 +++-----
src/test/regress/expected/generated_stored.out | 50 ++++++++++++++++++++++++++
src/test/regress/sql/generated_stored.sql      | 15 ++++++++
3 files changed, 70 insertions(+), 10 deletions(-)



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* pgsql: Fix ALTER COLUMN ... DROP EXPRESSION with subpartitions
@ 2026-08-04 07:14  Álvaro Herrera <alvherre@kurilemu.de>
  0 siblings, 0 replies; 7+ messages in thread

From: Álvaro Herrera @ 2026-08-04 07:14 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

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
------
REL_17_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/18006c1bd664e9d6b2f202131ba3b50c90600629

Modified Files
--------------
src/backend/commands/tablecmds.c        | 17 ++++-------
src/test/regress/expected/generated.out | 50 +++++++++++++++++++++++++++++++++
src/test/regress/sql/generated.sql      | 15 ++++++++++
3 files changed, 71 insertions(+), 11 deletions(-)



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* pgsql: Fix ALTER COLUMN ... DROP EXPRESSION with subpartitions
@ 2026-08-04 07:14  Álvaro Herrera <alvherre@kurilemu.de>
  0 siblings, 0 replies; 7+ messages in thread

From: Álvaro Herrera @ 2026-08-04 07:14 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

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
------
REL_16_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/34785a0d510321ab03a7ddb751341ca52bd21a04

Modified Files
--------------
src/backend/commands/tablecmds.c        | 17 ++++-------
src/test/regress/expected/generated.out | 50 +++++++++++++++++++++++++++++++++
src/test/regress/sql/generated.sql      | 15 ++++++++++
3 files changed, 71 insertions(+), 11 deletions(-)



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* pgsql: Fix ALTER COLUMN ... DROP EXPRESSION with subpartitions
@ 2026-08-04 07:14  Álvaro Herrera <alvherre@kurilemu.de>
  0 siblings, 0 replies; 7+ messages in thread

From: Álvaro Herrera @ 2026-08-04 07:14 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

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
------
REL_15_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/785289de01b02e63475bd6f9802bcddb93c1d468

Modified Files
--------------
src/backend/commands/tablecmds.c        | 17 ++++-------
src/test/regress/expected/generated.out | 50 +++++++++++++++++++++++++++++++++
src/test/regress/sql/generated.sql      | 15 ++++++++++
3 files changed, 71 insertions(+), 11 deletions(-)



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* pgsql: Fix ALTER COLUMN ... DROP EXPRESSION with subpartitions
@ 2026-08-04 07:14  Álvaro Herrera <alvherre@kurilemu.de>
  0 siblings, 0 replies; 7+ messages in thread

From: Álvaro Herrera @ 2026-08-04 07:14 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

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
------
REL_14_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/cad17745edbf1234cd53293260b6e681eb8f6dd3

Modified Files
--------------
src/backend/commands/tablecmds.c        | 17 ++++-------
src/test/regress/expected/generated.out | 50 +++++++++++++++++++++++++++++++++
src/test/regress/sql/generated.sql      | 15 ++++++++++
3 files changed, 71 insertions(+), 11 deletions(-)



^ permalink  raw  reply  [nested|flat] 7+ messages in thread


end of thread, other threads:[~2026-08-04 07:14 UTC | newest]

Thread overview: 7+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2026-08-04 07:14 pgsql: Fix ALTER COLUMN ... DROP EXPRESSION with subpartitions Álvaro Herrera <alvherre@kurilemu.de>
2026-08-04 07:14 pgsql: Fix ALTER COLUMN ... DROP EXPRESSION with subpartitions Álvaro Herrera <alvherre@kurilemu.de>
2026-08-04 07:14 pgsql: Fix ALTER COLUMN ... DROP EXPRESSION with subpartitions Álvaro Herrera <alvherre@kurilemu.de>
2026-08-04 07:14 pgsql: Fix ALTER COLUMN ... DROP EXPRESSION with subpartitions Álvaro Herrera <alvherre@kurilemu.de>
2026-08-04 07:14 pgsql: Fix ALTER COLUMN ... DROP EXPRESSION with subpartitions Álvaro Herrera <alvherre@kurilemu.de>
2026-08-04 07:14 pgsql: Fix ALTER COLUMN ... DROP EXPRESSION with subpartitions Álvaro Herrera <alvherre@kurilemu.de>
2026-08-04 07:14 pgsql: Fix ALTER COLUMN ... DROP EXPRESSION with subpartitions Álvaro Herrera <alvherre@kurilemu.de>

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox