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: Andres Freund <andres@anarazel.de>, PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2019-04-09T22:34:35Z
Lists: pgsql-hackers
Attachments
- tbspc-partitioned.patch (text/x-diff) patch
On 2019-Apr-09, Alvaro Herrera wrote: > However, in order to fix the pg_dump behavior for the partitioned rel, > we would need to emit the tablespace differently, i.e. not use SET > default_tablespace, but instead attach the tablespace clause to the > CREATE TABLE line. > > I'll go have a look at what problems are there with doing that. I tried with the attached tbspc-partitioned.patch (on top of the previous patch). It makes several additional cases work correctly, but causes much more pain than it fixes: 1. if a partitioned table is created without a tablespace spec, then pg_dump dumps it with a clause like TABLESPACE "". 2. If you fix that to make pg_dump omit the tablespace clause if the tablespace is default, then there's no SET nor TABLESPACE clauses, so the table is created in the tablespace of the previously dumped table. Useless. 3. You can probably make the above work anyway with enough hacks, but by the time you're finished, the code stinks like months-only fish. 4. Even if you ignore the odor, all the resulting CREATE TABLE commands will fail if you run them in a database that doesn't contain the tablespaces in question. That is, it negates one of the main points of using "SET default_tablespace" in the first place. I therefore decree that this approach is not a solution and never will be. -- Á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