pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Alvaro Herrera <alvherre@alvh.no-ip.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Fix tablespace inheritance for partitioned rels
Date: Thu, 25 Apr 2019 14:35:21 +0000
Message-ID: <E1hJfT7-00027i-Fa@gemulon.postgresql.org> (raw)

Fix tablespace inheritance for partitioned rels

Commit ca4103025dfe left a few loose ends.  The most important one
(broken pg_dump output) is already fixed by virtue of commit
3b23552ad8bb, but some things remained:

* When ALTER TABLE rewrites tables, the indexes must remain in the
  tablespace they were originally in.  This didn't work because
  index recreation during ALTER TABLE runs manufactured SQL (yuck),
  which runs afoul of default_tablespace in competition with the parent
  relation tablespace.  To fix, reset default_tablespace to the empty
  string temporarily, and add the TABLESPACE clause as appropriate.

* Setting a partitioned rel's tablespace to the database default is
  confusing; if it worked, it would direct the partitions to that
  tablespace regardless of default_tablespace.  But in reality it does
  not work, and making it work is a larger project.  Therefore, throw
  an error when this condition is detected, to alert the unwary.

Add some docs and tests, too.

Author: Álvaro Herrera
Discussion: https://postgr.es/m/CAKJS1f_1c260nOt_vBJ067AZ3JXptXVRohDVMLEBmudX1YEx-A@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/87259588d0ab0b8e742e30596afa7ae25caadb18

Modified Files
--------------
doc/src/sgml/config.sgml                  |   3 +-
doc/src/sgml/ref/create_table.sgml        |   6 +-
src/backend/bootstrap/bootparse.y         |   2 +
src/backend/commands/indexcmds.c          |  27 ++-
src/backend/commands/matview.c            |   2 +-
src/backend/commands/tablecmds.c          |  34 +--
src/backend/commands/tablespace.c         |  16 +-
src/backend/nodes/copyfuncs.c             |   2 +
src/backend/nodes/equalfuncs.c            |   2 +
src/backend/nodes/outfuncs.c              |   4 +
src/backend/parser/gram.y                 |   2 +
src/backend/parser/parse_utilcmd.c        |   2 +
src/backend/utils/adt/ruleutils.c         |  19 +-
src/include/catalog/catversion.h          |   2 +-
src/include/commands/tablespace.h         |   2 +-
src/include/nodes/parsenodes.h            |   4 +
src/test/regress/input/tablespace.source  |  90 ++++++++
src/test/regress/output/tablespace.source | 334 ++++++++++++++++++++++++++++++
18 files changed, 519 insertions(+), 34 deletions(-)



Message-ID: <E1hJfT7-00027i-Fa@gemulon.postgresql.org>
Permalink:  ../E1hJfT7-00027i-Fa@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1hJfT7-00027i-Fa@gemulon.postgresql.org

 · 

reply

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: alvherre@alvh.no-ip.org
  Subject: Re: pgsql: Fix tablespace inheritance for partitioned rels
  In-Reply-To: <E1hJfT7-00027i-Fa@gemulon.postgresql.org>
  References: <E1hJfT7-00027i-Fa@gemulon.postgresql.org>

* 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