mirror of
https://github.com/postgres/postgres.git
synced 2025-06-16 06:01:02 +03:00
Fix toast table creation.
Instead of using slightly-too-clever heuristics to decide when we must create a TOAST table, just check whether one is needed every time the table is altered. Checking whether a toast table is needed is cheap enough that we needn't worry about doing it on every ALTER TABLE command, and the previous coding is apparently prone to accidental breakage: commit04e17bae50
broken ALTER TABLE .. SET STORAGE, which moved some actions from AT_PASS_COL_ATTRS to AT_PASS_MISC, and commit6c57239985
broke ALTER TABLE .. ADD COLUMN by changing the way that adding columns recurses into child tables. Noah Misch, with one comment change by me
This commit is contained in:
@ -3022,18 +3022,12 @@ ATRewriteCatalogs(List **wqueue, LOCKMODE lockmode)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Check to see if a toast table must be added, if we executed any
|
||||
* subcommands that might have added a column or changed column storage.
|
||||
*/
|
||||
/* Check to see if a toast table must be added. */
|
||||
foreach(ltab, *wqueue)
|
||||
{
|
||||
AlteredTableInfo *tab = (AlteredTableInfo *) lfirst(ltab);
|
||||
|
||||
if (tab->relkind == RELKIND_RELATION &&
|
||||
(tab->subcmds[AT_PASS_ADD_COL] ||
|
||||
tab->subcmds[AT_PASS_ALTER_TYPE] ||
|
||||
tab->subcmds[AT_PASS_COL_ATTRS]))
|
||||
if (tab->relkind == RELKIND_RELATION)
|
||||
AlterTableCreateToastTable(tab->relid, (Datum) 0);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user