ALTER TABLE ... SET STORAGE does not propagate to indexes

From: Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>
To: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: ALTER TABLE ... SET STORAGE does not propagate to indexes
Date: 2020-01-06 12:32:53
Message-ID: 9765d72b-37c0-06f5-e349-2a580aafd989@2ndquadrant.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

ALTER TABLE ... SET STORAGE does not propagate to indexes, even though
indexes created afterwards get the new storage setting. So depending on
the order of commands, you can get inconsistent storage settings between
indexes and tables. For example:

create table foo1 (a text);
alter table foo1 alter column a set storage external;
create index foo1i on foo1(a);
insert into foo1 values(repeat('a', 10000));
ERROR: index row requires 10016 bytes, maximum size is 8191

(Storage "external" disables compression.)

but

create table foo1 (a text);
create index foo1i on foo1(a);
alter table foo1 alter column a set storage external;
insert into foo1 values(repeat('a', 10000));
-- no error

Also, this second state cannot be reproduced by pg_dump, so a possible
effect is that such a database would fail to restore.

Attached is a patch that attempts to fix this by propagating the storage
change to existing indexes. This triggers a few regression test
failures (going from no error to error), which I attempted to fix up,
but I haven't analyzed what the tests were trying to do, so it might
need another look.

--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

Attachment Content-Type Size
0001-Propagate-ALTER-TABLE-.-SET-STORAGE-to-indexes.patch text/plain 5.9 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Fabien COELHO 2020-01-06 12:36:23 Re: pgbench - use pg logging capabilities
Previous Message Dean Rasheed 2020-01-06 12:17:43 Re: [Proposal] Global temporary tables