pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Alexander Korotkov <akorotkov@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Make new partitions with parent's persistence during MERGE/SPLIT
Date: Tue, 30 Apr 2024 09:00:58 +0000
Message-ID: <E1s1jM9-000lFn-Is@gemulon.postgresql.org> (raw)

Make new partitions with parent's persistence during MERGE/SPLIT

The createPartitionTable() function is responsible for creating new partitions
for ALTER TABLE ... MERGE PARTITIONS, and ALTER TABLE ... SPLIT PARTITION
commands.  It emulates the behaviour of CREATE TABLE ... (LIKE ...), where
new table persistence should be specified by the user.  In the table
partitioning persistent of the partition and its parent must match.  So, this
commit makes createPartitionTable() copy the persistence of the parent
partition.

Also, this commit makes createPartitionTable() recheck the persistence after
the new table creation.  This is needed because persistence might be affected
by pg_temp in search_path.

This commit also changes the signature of createPartitionTable() making it
take the parent's Relation itself instead of the name of the parent relation,
and return the Relation of new partition.  That doesn't lead to
complications, because both callers have the parent table open and need to
open the new partition.

Reported-by: Alexander Lakhin
Discussion: https://postgr.es/m/dbc8b96c-3cf0-d1ee-860d-0e491da20485%40gmail.com
Author: Dmitry Koval
Reviewed-by: Alexander Korotkov, Robert Haas, Justin Pryzby, Pavel Borisov

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/fcf80c5d5f0f3787e70fca8fd029d2e08a923f91

Modified Files
--------------
doc/src/sgml/ref/alter_table.sgml             |   6 ++
src/backend/commands/tablecmds.c              |  75 +++++++++-----
src/test/regress/expected/partition_merge.out | 134 ++++++++++++++++++++++----
src/test/regress/expected/partition_split.out |  75 +++++++++++++-
src/test/regress/sql/partition_merge.sql      |  88 +++++++++++++++--
src/test/regress/sql/partition_split.sql      |  43 ++++++++-
6 files changed, 364 insertions(+), 57 deletions(-)



Message-ID: <E1s1jM9-000lFn-Is@gemulon.postgresql.org>
Permalink:  ../E1s1jM9-000lFn-Is@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1s1jM9-000lFn-Is@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 using the --to and --cc options:
  reply via email

  To: pgsql-committers@postgresql.org
  Cc: akorotkov@postgresql.org, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Make new partitions with parent's persistence during MERGE/SPLIT
  In-Reply-To: <E1s1jM9-000lFn-Is@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