From 0941aadcd55b58a03af5d06f3374ca168522097f Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Wed, 2 Apr 2025 11:13:01 -0400 Subject: Need to do CommandCounterIncrement after StoreAttrMissingVal. Without this, an additional change to the same pg_attribute row within the same command will fail. This is possible at least with ALTER TABLE ADD COLUMN on a multiple-inheritance-pathway structure. (Another potential hazard is that immediately-following operations might not see the missingval.) Introduced by 95f650674, which split the former coding that used a single pg_attribute update to change both atthasdef and atthasmissing/attmissingval into two updates, but missed that this should entail two CommandCounterIncrements as well. Like that fix, back-patch through v13. Reported-by: Alexander Lakhin Author: Tender Wang Reviewed-by: Tom Lane Discussion: https://postgr.es/m/025a3ffa-5eff-4a88-97fb-8f583b015965@gmail.com Backpatch-through: 13 --- src/backend/commands/tablecmds.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/backend/commands') diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 932cf549564..535c74feb03 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -7345,6 +7345,8 @@ ATExecAddColumn(List **wqueue, AlteredTableInfo *tab, Relation rel, if (!missingIsNull) { StoreAttrMissingVal(rel, attribute->attnum, missingval); + /* Make the additional catalog change visible */ + CommandCounterIncrement(); has_missing = true; } FreeExecutorState(estate); -- cgit v1.2.3