set-RootRelation-plain-inheritance.diff

application/octet-stream

Filename: set-RootRelation-plain-inheritance.diff
Type: application/octet-stream
Part: 0
Message: Re: AW: AW: BUG #18147: ERROR: invalid perminfoindex 0 in RTE with relid xxxxx

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: unified
File+
src/backend/optimizer/plan/planner.c 5 1
diff --git a/src/backend/optimizer/plan/planner.c b/src/backend/optimizer/plan/planner.c
index aafef24cf1..c711888073 100644
--- a/src/backend/optimizer/plan/planner.c
+++ b/src/backend/optimizer/plan/planner.c
@@ -1792,6 +1792,7 @@ grouping_planner(PlannerInfo *root, double tuple_fraction)
 			List	   *returningLists = NIL;
 			List	   *mergeActionLists = NIL;
 			List	   *rowMarks;
+			bool		inherited_update = false;
 
 			if (bms_membership(root->all_result_relids) == BMS_MULTIPLE)
 			{
@@ -1800,6 +1801,8 @@ grouping_planner(PlannerInfo *root, double tuple_fraction)
 														   parse->resultRelation);
 				int			resultRelation = -1;
 
+				inherited_update = true;
+
 				/* Add only leaf children to ModifyTable. */
 				while ((resultRelation = bms_next_member(root->leaf_result_relids,
 														 resultRelation)) >= 0)
@@ -1938,7 +1941,8 @@ grouping_planner(PlannerInfo *root, double tuple_fraction)
 			 * If target is a partition root table, we need to mark the
 			 * ModifyTable node appropriately for that.
 			 */
-			if (rt_fetch(parse->resultRelation, parse->rtable)->relkind ==
+			if (inherited_update ||
+				rt_fetch(parse->resultRelation, parse->rtable)->relkind ==
 				RELKIND_PARTITIONED_TABLE)
 				rootRelation = parse->resultRelation;
 			else