Re: bug, ALTER TABLE call ATPostAlterTypeCleanup twice for the same relation

From: jian he <jian(dot)universality(at)gmail(dot)com>
To: Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>
Cc: David Rowley <dgrowleyml(at)gmail(dot)com>, amul sul <sulamul(at)gmail(dot)com>, Peter Eisentraut <peter(at)eisentraut(dot)org>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: bug, ALTER TABLE call ATPostAlterTypeCleanup twice for the same relation
Date: 2025-10-01 03:04:54
Message-ID: CACJufxE10Cfe6-JzPGArL01k0B_n8dacz+fvmUSp9Rcn2Wo+1g@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Sep 29, 2025 at 5:21 PM Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com> wrote:
>
> Hi Jian,
>
> On Mon, Sep 29, 2025 at 3:43 PM jian he <jian(dot)universality(at)gmail(dot)com> wrote:
>>
>>
>> please also check the attached patch.
>> The idea is that if both generation expression and type are being changed,
>> only call ATPostAlterTypeCleanup while the current pass is
>> AT_PASS_SET_EXPRESSION.
>
>
> I think your implementation is similar to my previous dirty fix, the main idea is to postpone the cleanup to after AT_PASS_SET_EXPRESSION.
>
> But I feel we don't need an extra loop to find tabs that have both ALTER TYPE and SET EXPRESSION, and do the if-else check, the logic is a bit difficult to understand.
>
> I am attaching my version and please see if you like it. My version just records tabs to cleanup in an array, then runs the cleanup after the AT_PASS_SET_EXPRESSION pass.
>
hi.

we can simply change from

if (pass == AT_PASS_ALTER_TYPE || pass == AT_PASS_SET_EXPRESSION)
ATPostAlterTypeCleanup(wqueue, tab, lockmode);

to
if (pass == AT_PASS_SET_EXPRESSION)
ATPostAlterTypeCleanup(wqueue, tab, lockmode);
else if (pass == AT_PASS_ALTER_TYPE &&
tab->subcmds[AT_PASS_SET_EXPRESSION] == NIL)
ATPostAlterTypeCleanup(wqueue, tab, lockmode);

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Hayato Kuroda (Fujitsu) 2025-10-01 03:09:26 RE: pg_createsubscriber --dry-run logging concerns
Previous Message Hayato Kuroda (Fujitsu) 2025-10-01 02:56:30 RE: How can end users know the cause of LR slot sync delays?