Re: Fix ALTER TABLE DROP EXPRESSION with inheritance hierarchy

From: jian he <jian(dot)universality(at)gmail(dot)com>
To: Kirill Reshke <reshkekirill(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Peter Eisentraut <peter(at)eisentraut(dot)org>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Fix ALTER TABLE DROP EXPRESSION with inheritance hierarchy
Date: 2025-12-30 01:35:12
Message-ID: CACJufxG=Sr9sLngB0bKS6VHqB9K7yD6+JUyU1knncXwfiyBGJQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Dec 30, 2025 at 4:56 AM Kirill Reshke <reshkekirill(at)gmail(dot)com> wrote:
>
> Hi!
> I did take another look at this thread. I agree this "recurse and
> recursing" logic is a little confusing.
> Anyway, are you saying that v3 from this thread is a fix you are OK with?
>

Yes.

Maybe we can do something in ATSimpleRecursion.
but ATSimpleRecursion is very generic. adding some ad-hoc code for
AT_DropExpression seems not ideal.

In ATPrepDropExpression
```
if (!recurse && !recursing &&
find_inheritance_children(RelationGetRelid(rel), lockmode))
ereport(ERROR,
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("ALTER TABLE / DROP EXPRESSION must be applied
to child tables too"),
errhint("Do not specify the ONLY keyword."));
```
is correct, i think.

If ONLY is not specified:
For child relations (see ATSimpleRecursion), the code invokes
ATPrepDropExpression(rel, cmd, false, true, lockmode);

For the parent relation, it invokes
ATPrepDropExpression(rel, cmd, true, false, lockmode);

If ONLY is specified:
The ATSimpleRecursion logic is entirely skipped.
ATPrepDropExpression is invoked exactly once as
ATPrepDropExpression(rel, cmd, false, false, lockmode);

--
jian
https://www.enterprisedb.com

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Chao Li 2025-12-30 01:38:19 Re: [PATCH] Add memory usage reporting to VACUUM VERBOSE
Previous Message Henson Choi 2025-12-30 01:21:26 [PATCH] Add missing XLogEnsureRecordSpace() call in LogLogicalMessage