1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-07 00:36:50 +03:00

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
This commit is contained in:
Michael Paquier
2024-01-24 14:20:01 +09:00
parent bcd5b4bcbe
commit bb812ab091
3 changed files with 30 additions and 0 deletions

View File

@ -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;
}
}