From eb73e1971d0fd05b6d66c3b79552b396fc5f3b22 Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <peter@eisentraut.org>
Date: Wed, 25 Mar 2026 16:42:18 +0100
Subject: [PATCH] Fixups

---
 src/backend/executor/nodeModifyTable.c       |  9 +--------
 src/backend/parser/analyze.c                 |  3 +--
 src/include/nodes/execnodes.h                |  1 +
 src/test/regress/expected/for_portion_of.out | 18 +++++++++---------
 src/test/regress/sql/for_portion_of.sql      | 18 +++++++++---------
 5 files changed, 21 insertions(+), 28 deletions(-)

diff --git a/src/backend/executor/nodeModifyTable.c b/src/backend/executor/nodeModifyTable.c
index e16299cc2ed..9324bb1a093 100644
--- a/src/backend/executor/nodeModifyTable.c
+++ b/src/backend/executor/nodeModifyTable.c
@@ -135,6 +135,7 @@ typedef struct UpdateContext
 	LockTupleMode lockmode;
 } UpdateContext;
 
+
 static void ExecBatchInsert(ModifyTableState *mtstate,
 							ResultRelInfo *resultRelInfo,
 							TupleTableSlot **slots,
@@ -1588,14 +1589,6 @@ ExecForPortionOfLeftovers(ModifyTableContext *context,
 		leftoverSlot->tts_isnull[forPortionOf->rangeVar->varattno - 1] = false;
 		ExecMaterializeSlot(leftoverSlot);
 
-		/*
-		 * If there are partitions, we must insert into the root table, so we
-		 * get tuple routing. We already set up leftoverSlot with the root
-		 * tuple descriptor.
-		 */
-		if (resultRelInfo->ri_RootResultRelInfo)
-			resultRelInfo = resultRelInfo->ri_RootResultRelInfo;
-
 		/*
 		 * The standard says that each temporal leftover should execute its
 		 * own INSERT statement, firing all statement and row triggers, but
diff --git a/src/backend/parser/analyze.c b/src/backend/parser/analyze.c
index f0e9ebaddd5..9e9b7fb18d2 100644
--- a/src/backend/parser/analyze.c
+++ b/src/backend/parser/analyze.c
@@ -1348,8 +1348,7 @@ transformForPortionOfClause(ParseState *pstate,
 
 	attbasetype = getBaseType(attr->atttypid);
 
-	rangeVar = makeVar(
-					   rtindex,
+	rangeVar = makeVar(rtindex,
 					   range_attno,
 					   attr->atttypid,
 					   attr->atttypmod,
diff --git a/src/include/nodes/execnodes.h b/src/include/nodes/execnodes.h
index 177ded4e5cd..090cfccf65f 100644
--- a/src/include/nodes/execnodes.h
+++ b/src/include/nodes/execnodes.h
@@ -41,6 +41,7 @@
 #include "utils/reltrigger.h"
 #include "utils/typcache.h"
 
+
 /*
  * forward references in this file
  */
diff --git a/src/test/regress/expected/for_portion_of.out b/src/test/regress/expected/for_portion_of.out
index 8a29a19f501..31f772c723d 100644
--- a/src/test/regress/expected/for_portion_of.out
+++ b/src/test/regress/expected/for_portion_of.out
@@ -1636,17 +1636,17 @@ CREATE TABLE for_portion_of_test (
 INSERT INTO for_portion_of_test (id, valid_at, name) VALUES
   ('[1,2)', '[2018-01-01,2020-01-01)', 'one');
 CREATE CONSTRAINT TRIGGER fpo_after_insert_row
-AFTER INSERT ON for_portion_of_test
-DEFERRABLE INITIALLY DEFERRED
-FOR EACH ROW EXECUTE PROCEDURE dump_trigger(false, false);
+  AFTER INSERT ON for_portion_of_test
+  DEFERRABLE INITIALLY DEFERRED
+  FOR EACH ROW EXECUTE PROCEDURE dump_trigger(false, false);
 CREATE CONSTRAINT TRIGGER fpo_after_update_row
-AFTER UPDATE ON for_portion_of_test
-DEFERRABLE INITIALLY DEFERRED
-FOR EACH ROW EXECUTE PROCEDURE dump_trigger(false, false);
+  AFTER UPDATE ON for_portion_of_test
+  DEFERRABLE INITIALLY DEFERRED
+  FOR EACH ROW EXECUTE PROCEDURE dump_trigger(false, false);
 CREATE CONSTRAINT TRIGGER fpo_after_delete_row
-AFTER DELETE ON for_portion_of_test
-DEFERRABLE INITIALLY DEFERRED
-FOR EACH ROW EXECUTE PROCEDURE dump_trigger(false, false);
+  AFTER DELETE ON for_portion_of_test
+  DEFERRABLE INITIALLY DEFERRED
+  FOR EACH ROW EXECUTE PROCEDURE dump_trigger(false, false);
 BEGIN;
 UPDATE for_portion_of_test
   FOR PORTION OF valid_at FROM '2018-01-15' TO '2019-01-01'
diff --git a/src/test/regress/sql/for_portion_of.sql b/src/test/regress/sql/for_portion_of.sql
index 20d7e879c14..d4062acf1d1 100644
--- a/src/test/regress/sql/for_portion_of.sql
+++ b/src/test/regress/sql/for_portion_of.sql
@@ -1037,19 +1037,19 @@ CREATE TABLE for_portion_of_test (
   ('[1,2)', '[2018-01-01,2020-01-01)', 'one');
 
 CREATE CONSTRAINT TRIGGER fpo_after_insert_row
-AFTER INSERT ON for_portion_of_test
-DEFERRABLE INITIALLY DEFERRED
-FOR EACH ROW EXECUTE PROCEDURE dump_trigger(false, false);
+  AFTER INSERT ON for_portion_of_test
+  DEFERRABLE INITIALLY DEFERRED
+  FOR EACH ROW EXECUTE PROCEDURE dump_trigger(false, false);
 
 CREATE CONSTRAINT TRIGGER fpo_after_update_row
-AFTER UPDATE ON for_portion_of_test
-DEFERRABLE INITIALLY DEFERRED
-FOR EACH ROW EXECUTE PROCEDURE dump_trigger(false, false);
+  AFTER UPDATE ON for_portion_of_test
+  DEFERRABLE INITIALLY DEFERRED
+  FOR EACH ROW EXECUTE PROCEDURE dump_trigger(false, false);
 
 CREATE CONSTRAINT TRIGGER fpo_after_delete_row
-AFTER DELETE ON for_portion_of_test
-DEFERRABLE INITIALLY DEFERRED
-FOR EACH ROW EXECUTE PROCEDURE dump_trigger(false, false);
+  AFTER DELETE ON for_portion_of_test
+  DEFERRABLE INITIALLY DEFERRED
+  FOR EACH ROW EXECUTE PROCEDURE dump_trigger(false, false);
 
 BEGIN;
 UPDATE for_portion_of_test
-- 
2.53.0

