> On Aug 2, 2026, at 19:52, jian he <[email protected]> wrote:
> 
> Hi.
> 
> ATPostAlterTypeCleanup->performMultipleDeletions drops the
> objects referenced by changedConstraintOids, changedIndexOids, and similar
> fields of the AlteredTableInfo, it makes sense to set those pointers
> to NULL afterward.
> The attached patch implements this approach.
> 
> Another reason why I prefer this approach:
> Imagine some other random ALTER TABLE command that also needs to
> rebuild whole-row dependent objects for the table,
> then ATPostAlterTypeCleanup would also need to be called for that
> AlterTablePass.
> Ideally, we should be able to call ATPostAlterTypeCleanup for any kind
> of AlterTablePass.
> 
> The commit message is below:
> ---------------------------------
> ATPostAlterTypeCleanup() is called twice when a single ALTER TABLE contains 
> both
> ALTER COLUMN SET DATA TYPE and ALTER COLUMN SET EXPRESSION.
> The first call drops the objects listed in tab->changedConstraintOids,
> tab->changedIndexOids and tab->changedStatisticsOids via
> performMultipleDeletions(), but left those lists untouched. The second call
> would drop the same OIDs again, failing with errors like
> "cache lookup failed".
> 
> Fix by resetting the changed-object lists (and the replica identity and 
> CLUSTER
> index markings, which would otherwise queue duplicate subcommands) at the end 
> of
> ATPostAlterTypeCleanup(), so the second invocation only processes objects
> registered by the SET EXPRESSION pass.
> --------------------------------
> 
> 
> 
> --
> jian
> https://www.enterprisedb.com/
> <v6-0001-Fix-ALTER-TABLE-when-ALTER-TYPE-and-SET-EXPRESSION-are-used-toget.patch>

Since my last round of review of this patch, I have done a lot of work on ALTER 
TABLE and thus gained a better understanding of the ALTER TABLE infra. I now 
agree that your approach (as in v6) is correct. The ALTER TYPE pass remembers 
and drops its dependencies, and SET EXPRESSION remembers and drops any 
additional ones.

A small comment on the commit message:
```
The first call drops the objects … but left those lists untouched.
```

I think “left” should be “leaves” to keep the tense consistent with “drops”.

Best regards,
--
Chao Li (Evan)
HighGo Software Co., Ltd.
https://www.highgo.com/






Reply via email to