From bb812ab0917e153f11bf449d7cb996815c07e387 Mon Sep 17 00:00:00 2001 From: Michael Paquier Date: Wed, 24 Jan 2024 14:20:01 +0900 Subject: Fix ALTER TABLE .. ADD COLUMN with complex inheritance trees This command, when used to add a column on a parent table with a complex inheritance tree, tried to update multiple times the same tuple in pg_attribute for a child table when incrementing attinhcount, causing failures with "tuple already updated by self" because of a missing CommandCounterIncrement() between two updates. This exists for a rather long time, so backpatch all the way down. Reported-by: Alexander Lakhin Author: Tender Wang Reviewed-by: Richard Guo Discussion: https://postgr.es/m/18297-b04cd83a55b51e35@postgresql.org Backpatch-through: 12 --- src/backend/commands/tablecmds.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/backend/commands') diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 2a56a4357c9..5ccd0eec1c7 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -7077,6 +7077,10 @@ ATExecAddColumn(List **wqueue, AlteredTableInfo *tab, Relation rel, colDef->colname, RelationGetRelationName(rel)))); table_close(attrdesc, RowExclusiveLock); + + /* Make the child column change visible */ + CommandCounterIncrement(); + return InvalidObjectAddress; } } -- cgit v1.2.3