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