mirror of
https://github.com/postgres/postgres.git
synced 2025-07-30 11:03:19 +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:
@ -1133,6 +1133,16 @@ alter table recur1 add column f2 recur2; -- fails
|
||||
alter table recur1 add column f2 int;
|
||||
alter table recur1 alter column f2 type recur2; -- fails
|
||||
|
||||
-- SET STORAGE may need to add a TOAST table
|
||||
create table test_storage (a text);
|
||||
alter table test_storage alter a set storage plain;
|
||||
alter table test_storage add b int default 0; -- rewrite table to remove its TOAST table
|
||||
alter table test_storage alter a set storage extended; -- re-add TOAST table
|
||||
|
||||
select reltoastrelid <> 0 as has_toast_table
|
||||
from pg_class
|
||||
where oid = 'test_storage'::regclass;
|
||||
|
||||
--
|
||||
-- lock levels
|
||||
--
|
||||
|
Reference in New Issue
Block a user