v44-0001-documentation-refactoring-based-on-v44.no-cfbot

application/octet-stream

Filename: v44-0001-documentation-refactoring-based-on-v44.no-cfbot
Type: application/octet-stream
Part: 0
Message: Re: Add SPLIT PARTITION/MERGE PARTITIONS commands
From c752b1c5e555fb0397b9c3a2ac918fa66584e615 Mon Sep 17 00:00:00 2001
From: jian he <jian.universality@gmail.com>
Date: Fri, 13 Jun 2025 14:24:11 +0800
Subject: [PATCH v44 1/1] documentation refactoring based on v44

---
 doc/src/sgml/ref/alter_table.sgml | 38 +++++++++++++++----------------
 src/backend/commands/tablecmds.c  | 10 ++++----
 2 files changed, 24 insertions(+), 24 deletions(-)

diff --git a/doc/src/sgml/ref/alter_table.sgml b/doc/src/sgml/ref/alter_table.sgml
index 855d2ca44db..e49e3362b55 100644
--- a/doc/src/sgml/ref/alter_table.sgml
+++ b/doc/src/sgml/ref/alter_table.sgml
@@ -1155,27 +1155,28 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
 
     <listitem>
      <para>
-      This form merges several partitions into the one partition of the target table.
-      Hash-partitioning is not supported.  If <literal>DEFAULT</literal> partition is not in the
+      This form merges several partitions of the target table into a new partition.
+      Hash-partitioned target table is not supported.
+      If <literal>DEFAULT</literal> partition is not in the
       list of partitions <replaceable class="parameter">partition_name1</replaceable>,
       <replaceable class="parameter">partition_name2</replaceable> [, ...]:
       <itemizedlist>
        <listitem>
         <para>
-         For range-partitioned tables it is necessary that the ranges
-         of the partitions <replaceable class="parameter">partition_name1</replaceable>,
-         <replaceable class="parameter">partition_name2</replaceable> [, ...] can
-         be merged into one range without spaces and overlaps (otherwise an error
-         will be generated).  The combined range will be the range for the partition
-         <replaceable class="parameter">partition_name</replaceable>.
+         For range-partitioned tables, the ranges of the partitions
+         <replaceable class="parameter">partition_name1</replaceable>,
+         <replaceable class="parameter">partition_name2</replaceable>, [...]
+         must be adjacent in order to be merged. Otherwise, an error will be
+         raised. The resulting combined range will be the new partition bound
+         for the partition <replaceable class="parameter">partition_name</replaceable>.
         </para>
        </listitem>
        <listitem>
         <para>
-         For list-partitioned tables the value lists of all partitions
+         For list-partitioned tables, the partition bounds of
          <replaceable class="parameter">partition_name1</replaceable>,
-         <replaceable class="parameter">partition_name2</replaceable> [, ...] are
-         combined and form the list of values of partition
+         <replaceable class="parameter">partition_name2</replaceable>, [...]
+         are combined to form the new partition bound for
          <replaceable class="parameter">partition_name</replaceable>.
         </para>
        </listitem>
@@ -1186,13 +1187,15 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
        <listitem>
         <para>
          The partition <replaceable class="parameter">partition_name</replaceable>
-         will be the <literal>DEFAULT</literal> partition.
+         will be the new <literal>DEFAULT</literal> partition of the target table.
         </para>
        </listitem>
        <listitem>
         <para>
-         For range- and list-partitioned tables the ranges and lists of values
-         of the merged partitions can be any.
+         The partition bound specifications for all partitions-
+         <replaceable class="parameter">partition_name1</replaceable>,
+         <replaceable class="parameter">partition_name2</replaceable>, [...]
+         can be arbitrary.
         </para>
        </listitem>
       </itemizedlist>
@@ -1211,11 +1214,8 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
       into the new partition.
       Extended statistics aren't copied from the parent table, for consistency with
       <command>CREATE TABLE PARTITION OF</command>.
-      The new partition will have the same table access method as the parent.
-      If the parent table is persistent then the new partition is created
-      persistent.  If the parent table is temporary then the new partition
-      is also created temporary.  The new partition will also be created in
-      the same tablespace as the parent.
+      The new partition will inherit the same table access method, persistence
+      type, and tablespace as the parent table.
      </para>
      <para>
       When partitions are merged, any individual objects belonging to those
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index 190ce952ade..c56b43c7fe5 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -22660,14 +22660,14 @@ moveMergedTablesRows(List **wqueue, Relation rel,
 }
 
 /*
- * detachPartitionTable: detach partition "partRel" from partitioned table
- * "rel" with default partition identifier "defaultPartOid"
+ * detachPartitionTable: detach partition "child_rel" from partitioned table
+ * "parent_rel" with default partition identifier "defaultPartOid"
  */
 static void
-detachPartitionTable(Relation partRel, Relation rel, Oid defaultPartOid)
+detachPartitionTable(Relation child_rel, Relation parent_rel, Oid defaultPartOid)
 {
 	/* Remove the pg_inherits row first. */
-	RemoveInheritance(partRel, rel, false);
+	RemoveInheritance(child_rel, parent_rel, false);
 
 	/*
 	 * Detaching the partition might involve TOAST table access, so ensure we
@@ -22676,7 +22676,7 @@ detachPartitionTable(Relation partRel, Relation rel, Oid defaultPartOid)
 	PushActiveSnapshot(GetTransactionSnapshot());
 
 	/* Do the final part of detaching. */
-	DetachPartitionFinalize(rel, partRel, false, defaultPartOid);
+	DetachPartitionFinalize(parent_rel, child_rel, false, defaultPartOid);
 
 	PopActiveSnapshot();
 }
-- 
2.34.1