Re: pg_dump is broken for partition tablespaces
Alvaro Herrera <alvherre@2ndquadrant.com>
From: Alvaro Herrera <alvherre@2ndquadrant.com>
To: David Rowley <david.rowley@2ndquadrant.com>
Cc: Robert Haas <robertmhaas@gmail.com>, Andres Freund <andres@anarazel.de>, Tom Lane <tgl@sss.pgh.pa.us>, PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2019-04-24T22:40:38Z
Lists: pgsql-hackers
Attachments
- no-db-tablespace.patch (text/x-diff) patch
On 2019-Apr-23, Alvaro Herrera wrote: > I'm not sure yet that 100% of the patch is gone, but yes much of it > would go away thankfully. Of course, the part that fixes the bug that indexes move tablespace when recreated by a rewriting ALTER TABLE is still necessary. Included in the attached patch. (I think it would be good to have the relation being complained about in the error message, though that requires passing the name to GetDefaultTablespace.) > I do suggest we should raise an error if rule a3 hits and it mentions > the database tablespace (I stupidly forgot this critical point in the > previous email). I think astonishment is lesser that way. As in the attached. When pg_default is the database tablespace, these cases fail with the patch, as expected: alvherre=# CREATE TABLE q (a int PRIMARY KEY) PARTITION BY LIST (a) TABLESPACE pg_default; psql: ERROR: cannot specify default tablespace for partitioned relations alvherre=# CREATE TABLE q (a int PRIMARY KEY USING INDEX TABLESPACE pg_default) PARTITION BY LIST (a); psql: ERROR: cannot specify default tablespace for partitioned relations alvherre=# SET default_tablespace TO 'pg_default'; alvherre=# CREATE TABLE q (a int PRIMARY KEY) PARTITION BY LIST (a) ; psql: ERROR: cannot specify default tablespace for partitioned relations alvherre=# CREATE TABLE q (a int PRIMARY KEY) PARTITION BY LIST (a) TABLESPACE foo; psql: ERROR: cannot specify default tablespace for partitioned relations alvherre=# CREATE TABLE q (a int PRIMARY KEY USING INDEX TABLESPACE foo) PARTITION BY LIST (a); psql: ERROR: cannot specify default tablespace for partitioned relations These cases work: alvherre=# CREATE TABLE q (a int PRIMARY KEY USING INDEX TABLESPACE foo) PARTITION BY LIST (a) TABLESPACE foo; alvherre=# SET default_tablespace TO ''; -- the default alvherre=# CREATE TABLE q (a int PRIMARY KEY) PARTITION BY LIST (a); -- Álvaro Herrera https://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
Commits
-
Make pg_dump emit ATTACH PARTITION instead of PARTITION OF (reprise)
- 6a781c4f5fec 11.4 landed
- 33a53130a894 12.0 landed
- 1eb8a5ea463d 10.9 landed
-
Fix tablespace inheritance for partitioned rels
- 87259588d0ab 12.0 landed
-
Make pg_dump emit ATTACH PARTITION instead of PARTITION OF
- a98c48debcd0 11.3 landed
- 5a191f697400 10.8 landed
- 3b23552ad8bb 12.0 landed
-
Make sure ALTER TABLE preserves index tablespaces.
- bd673e8e864a 10.0 cited