Re: Fix ALTER TABLE DROP EXPRESSION with inheritance hierarchy - Mailing list pgsql-hackers

From jian he
Subject Re: Fix ALTER TABLE DROP EXPRESSION with inheritance hierarchy
Date
Msg-id CACJufxG=Sr9sLngB0bKS6VHqB9K7yD6+JUyU1knncXwfiyBGJQ@mail.gmail.com
Whole thread Raw
In response to Re: Fix ALTER TABLE DROP EXPRESSION with inheritance hierarchy  (Kirill Reshke <reshkekirill@gmail.com>)
List pgsql-hackers
On Tue, Dec 30, 2025 at 4:56 AM Kirill Reshke <reshkekirill@gmail.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



pgsql-hackers by date:

Previous
From: Henson Choi
Date:
Subject: [PATCH] Add missing XLogEnsureRecordSpace() call in LogLogicalMessage
Next
From: Chao Li
Date:
Subject: Re: [PATCH] Add memory usage reporting to VACUUM VERBOSE