partitioned indexes and tablespaces
Alvaro Herrera <alvherre@2ndquadrant.com>
From: Alvaro Herrera <alvherre@2ndquadrant.com>
To: Pg Hackers <pgsql-hackers@postgresql.org>
Date: 2018-11-02T00:31:38Z
Lists: pgsql-hackers
Attachments
Hello A customer reported to us that partitioned indexes are not working consistently with tablespaces: 1. When a CREATE INDEX specifies a tablespace, existing partitions get the index in the correct tablespace; however, the parent index itself does not record the tablespace. So when new partitions are created later, they get the index in the default tablespace instead of the specified tablespace. Fix by saving the tablespace in the pg_class row for the parent index. 2. ALTER TABLE SET TABLESPACE, applied to the partitioned index, would raise an error indicating that it's not the correct relation kind. In order for this to actually work, we need bespoke code for ATExecCmd(); the code for all other relation kinds wants to move storage (and runs in Phase 3, later), but these indexes do not have that. Therefore, write a cut-down version which is invoked directly in ATExecCmd instead. 3. ALTER INDEX ALL IN TABLESPACE, identical problem, is also fixed by the above change. -- Álvaro Herrera https://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
Commits
-
Fix tablespace handling for partitioned indexes
- 33e6c34c3267 11.1 landed
- dfa608141982 12.0 landed