Re: BUG #16577: Segfault on altering a table located in a dropped tablespace
Michael Paquier <michael@paquier.xyz>
From: Michael Paquier <michael@paquier.xyz>
To: exclusion@gmail.com, pgsql-bugs@lists.postgresql.org
Date: 2020-08-09T13:20:54Z
Lists: pgsql-bugs
On Sun, Aug 09, 2020 at 11:00:01AM +0000, PG Bug reporting form wrote: > When executing the following query (a modified excerpt from the tablespace > regression test): > CREATE TABLESPACE regress_tblspace LOCATION '@testtablespace@'; > CREATE TABLE test_default_tab_p(id bigint, val bigint) > PARTITION BY LIST (id) TABLESPACE regress_tblspace; > CREATE INDEX test_index2 on test_default_tab_p (val) TABLESPACE > regress_tblspace; > DROP TABLESPACE regress_tblspace; > \d+ test_default_tab_p; > ALTER TABLE test_default_tab_p ALTER val TYPE bigint; Thanks Alexander for the report. Interesting case indeed. For a normal table we would complain that the tablespace is not empty when attempting to drop the tablespace. But here we have only one partitioned table still holding references to the tablespace. Things get even more spicy with stuff like that, once you try to play with the orphaned tablespace reference: CREATE TABLESPACE popo location '/tmp/popo'; CREATE TABLE parent_tab (a int) partition by list (a) tablespace popo; DROP TABLESPACE popo; CREATE TABLE child_tab partition of parent_tab for values in (1); ERROR: 58P01: could not create directory "pg_tblspc/24587/PG_12_201909212/16384": No such file or directory LOCATION: TablespaceCreateDbspace, tablespace.c:161 The issue with indexes is present since 11, but we have more as reltablespace gets also set for partitioned tables since 12. -- Michael
Commits
-
Prevent drop of tablespaces used by partitioned relations
- ebfe2dbd6b62 14.0 landed
- c9b702552acc 12.6 landed
- c442b32c2e6d 11.11 landed
- 5b01a6f13ff7 13.2 landed
-
Don't create relfilenode for relations without storage
- 807ae415c546 12.0 cited