v7-0006-ALTER-TABLE-.-MERGE-PARTITIONS-.-make-inherit-par.patch

application/octet-stream

Filename: v7-0006-ALTER-TABLE-.-MERGE-PARTITIONS-.-make-inherit-par.patch
Type: application/octet-stream
Part: 5
Message: Re: Add SPLIT PARTITION/MERGE PARTITIONS commands

Patch

Same data as JSON: GET /api/v1/attachments/:id/patch the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes. API reference →
Format: format-patch
Series: patch v7-0006
Subject: ALTER TABLE ... MERGE PARTITIONS ... make inherit parent's am
File+
src/backend/commands/tablecmds.c 6 0
From 11f4b57db9e381745a107d3f49e796afd5e8924e Mon Sep 17 00:00:00 2001
From: Alexander Korotkov <akorotkov@postgresql.org>
Date: Fri, 19 Apr 2024 14:55:24 +0300
Subject: [PATCH v7 6/7] ALTER TABLE ... MERGE PARTITIONS ... make inherit
 parent's am

Reported-by:
Bug:
Discussion:
Author:
Reviewed-by:
Tested-by:
Backpatch-through:
---
 src/backend/commands/tablecmds.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index 2025e68bdae..575e99509d8 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -21186,6 +21186,11 @@ moveSplitTableRows(Relation rel, Relation splitRel, List *partlist, List *newPar
  *
  * Emulates command: CREATE [TEMP] TABLE <newPartName> (LIKE <modelRel's name>
  * INCLUDING ALL EXCLUDING INDEXES EXCLUDING IDENTITY)
+ *
+ * Also, this function sets the new partition access method same as parent
+ * table access methods (similarly to CREATE TABLE ... PARTITION OF).  It
+ * checks that parent and child tables have compatible persistence.
+ *
  * Function returns the created relation (locked in AccessExclusiveLock mode).
  */
 static Relation
@@ -21213,6 +21218,7 @@ createPartitionTable(RangeVar *newPartName, Relation modelRel,
 	createStmt->oncommit = ONCOMMIT_NOOP;
 	createStmt->tablespacename = NULL;
 	createStmt->if_not_exists = false;
+	createStmt->accessMethod = get_am_name(modelRel->rd_rel->relam);
 
 	tlc = makeNode(TableLikeClause);
 	tlc->relation = makeRangeVar(get_namespace_name(RelationGetNamespace(modelRel)),
-- 
2.39.3 (Apple Git-145)