pgsql: Make pg_dump emit ATTACH PARTITION instead of PARTITION OF

From: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Make pg_dump emit ATTACH PARTITION instead of PARTITION OF
Date: 2019-04-24 19:32:34
Message-ID: E1hJNdC-0004hz-Bn@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Make pg_dump emit ATTACH PARTITION instead of PARTITION OF

Using PARTITION OF can result in column ordering being changed from the
database being dumped, if the partition uses a column layout different
from the parent's. It's not pg_dump's job to editorialize on table
definitions, so this is not acceptable; back-patch all the way back to
pg10, where partitioned tables where introduced.

This change also ensures that partitions end up in the correct
tablespace, if different from the parent's; this is an oversight in
ca4103025dfe (in pg12 only). Partitioned indexes (in pg11) don't have
this problem, because they're already created as independent indexes and
attached to their parents afterwards.

This change also has the advantage that the partition is restorable from
the dump (as a standalone table) even if its parent table isn't
restored.

Author: David Rowley
Reviewed-by: Álvaro Herrera
Discussion: https://postgr.es/m/CAKJS1f_1c260nOt_vBJ067AZ3JXptXVRohDVMLEBmudX1YEx-A@mail.gmail.com
Discussion: https://postgr.es/m/20190423185007.GA27954@alvherre.pgsql

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/3b23552ad8bbb1384381b67f860019d14d5b680e

Modified Files
--------------
src/bin/pg_dump/pg_dump.c | 123 ++++++++++++++++-----------------------
src/bin/pg_dump/t/002_pg_dump.pl | 12 +++-
2 files changed, 60 insertions(+), 75 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Etsuro Fujita 2019-04-25 13:17:12 Re: pgsql: Allow insert and update tuple routing and COPY for foreign table
Previous Message Tom Lane 2019-04-24 18:16:04 pgsql: Fix some minor postmaster-state-machine issues.