From: Alvaro Herrera <alvherre@2ndquadrant.com>
To: Andres Freund <andres@anarazel.de>
Cc: David Rowley <david.rowley@2ndquadrant.com>
Cc: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Subject: Re: pg_dump is broken for partition tablespaces
Date: Tue, 9 Apr 2019 18:58:42 -0400
Message-ID: <20190409225842.GA14993@alvherre.pgsql> (raw)
In-Reply-To: <20190306223741.lolaaimhkkp4kict@alap3.anarazel.de>
On 2019-Mar-06, Andres Freund wrote:
> I don't think the argument that the user intended to explicitly set a
> tablespace holds much water if it was just set via default_tablespace,
> rather than an explicit TABLESPACE. I think iff you really want
> something like this feature, you'd have to mark a partition's
> reltablespace as 0 unless an *explicit* assignment of the tablespace
> happened. In which case you also would need to explicitly emit a
> TABLESPACE for the partitioned table in pg_dump, to restore that.
Thinking more about this, I think you're wrong about the behavior under
nonempty default_tablespace. Quoth the fine manual:
default_tablespace:
[...]
This variable specifies the default tablespace in which to create
objects (tables and indexes) when a CREATE command does not explicitly specify
a tablespace.
The value is either the name of a tablespace, or an empty string to
specify using the default tablespace of the current database. [...]
https://www.postgresql.org/docs/11/runtime-config-client.html#RUNTIME-CONFIG-CLIENT-STATEMENT
What this says to me, if default_tablespace is set, and there is no
TABLESPACE clause, we should regard the default_tablespace just as if it
were an explicitly named tablespace. Note that the default setting of
default_tablespace is empty, meaning that tables are created in the
database tablespace.
Emerging behavior: default_tablespace is set to A, then partitioned
table T is created, then default_tablespace is changed to B. Any
partitions of T created afterwards still appear in tablespace A.
If you really intended for new partitions to be created in
default_tablespace (following future changes to that option), then you
should just leave default_tablespace as empty when creating T.
There is one deficiency that needs to be solved in order for this to
work fully: currently there is no way to reset "reltablespace" to 0.
Does that make sense?
--
Álvaro Herrera https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-hackers@postgresql.org
Cc: alvherre@2ndquadrant.com, andres@anarazel.de, david.rowley@2ndquadrant.com, pgsql-hackers@lists.postgresql.org
Subject: Re: pg_dump is broken for partition tablespaces
In-Reply-To: <20190409225842.GA14993@alvherre.pgsql>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox