v27-0002-Add-root_parent_relids-to-PartitionPruneResult.patch
application/octet-stream
Filename: v27-0002-Add-root_parent_relids-to-PartitionPruneResult.patch
Type: application/octet-stream
Part: 1
Patch
Format: format-patch
Series: patch v27-0002
Subject: Add root_parent_relids to PartitionPruneResult
| File | + | − |
|---|---|---|
| src/backend/executor/execMain.c | 2 | 0 |
| src/backend/executor/execPartition.c | 11 | 2 |
| src/include/nodes/plannodes.h | 7 | 0 |
From 4ef1d918405a7c7c63a3e7376ccef57cf844796d Mon Sep 17 00:00:00 2001
From: amitlan <amitlangote09@gmail.com>
Date: Fri, 2 Dec 2022 19:32:14 +0900
Subject: [PATCH v27 2/2] Add root_parent_relids to PartitionPruneResult
It's same as the corresponding PartitionPruneInfo's root_parent_relids.
Like PartitionPruneInfo.root_parent_relids, it's there for
cross-checking a PartitionPruneResult found at a given plan node's
part_prune_index actually matches the plan node.
---
src/backend/executor/execMain.c | 2 ++
src/backend/executor/execPartition.c | 13 +++++++++++--
src/include/nodes/plannodes.h | 7 +++++++
3 files changed, 20 insertions(+), 2 deletions(-)
diff --git a/src/backend/executor/execMain.c b/src/backend/executor/execMain.c
index 4d8c8e2e43..3293a65d15 100644
--- a/src/backend/executor/execMain.c
+++ b/src/backend/executor/execMain.c
@@ -147,6 +147,8 @@ ExecutorDoInitialPruning(PlannedStmt *plannedstmt, ParamListInfo params,
PartitionPruneInfo *pruneinfo = lfirst(lc);
PartitionPruneResult *pruneresult = makeNode(PartitionPruneResult);
+ pruneresult->root_parent_relids =
+ bms_copy(pruneinfo->root_parent_relids);
pruneresult->valid_subplan_offs =
ExecPartitionDoInitialPruning(plannedstmt, params, pruneinfo,
scan_leafpart_rtis);
diff --git a/src/backend/executor/execPartition.c b/src/backend/executor/execPartition.c
index b0eb15b982..2eadc30ec8 100644
--- a/src/backend/executor/execPartition.c
+++ b/src/backend/executor/execPartition.c
@@ -1843,8 +1843,17 @@ ExecInitPartitionPruning(PlanState *planstate,
*/
if (estate->es_part_prune_results)
{
- pruneresult = list_nth(estate->es_part_prune_results, part_prune_index);
- Assert(IsA(pruneresult, PartitionPruneResult));
+ pruneresult = list_nth_node(PartitionPruneResult,
+ estate->es_part_prune_results,
+ part_prune_index);
+ if (!bms_equal(root_parent_relids, pruneinfo->root_parent_relids))
+ ereport(ERROR,
+ errcode(ERRCODE_INTERNAL_ERROR),
+ errmsg_internal("mismatching PartitionPruneInfo and PartitionPruneResult at part_prune_index %d",
+ part_prune_index),
+ errdetail_internal("prunresult relids %s, pruneinfo relids %s",
+ bmsToString(pruneresult->root_parent_relids),
+ bmsToString(pruneinfo->root_parent_relids)));
}
if (pruneresult == NULL || pruneinfo->needs_exec_pruning)
diff --git a/src/include/nodes/plannodes.h b/src/include/nodes/plannodes.h
index 714e2cf2c7..ed664c5469 100644
--- a/src/include/nodes/plannodes.h
+++ b/src/include/nodes/plannodes.h
@@ -1580,6 +1580,12 @@ typedef struct PartitionPruneStepCombine
* The result of performing ExecPartitionDoInitialPruning() on a given
* PartitionPruneInfo.
*
+ * root_parent_relids is same as PartitionPruneInfo.root_parent_relids. It's
+ * there for cross-checking in ExecInitPartitionPruning() that the
+ * PartitionPruneResult and the PartitionPruneInfo at a given index in
+ * EState.es_part_prune_results and EState.es_part_prune_infos, respectively,
+ * belong to the same parent plan node.
+ *
* valid_subplans_offs contains the indexes of subplans remaining after
* performing initial pruning by calling ExecFindMatchingSubPlans() on the
* PartitionPruneInfo.
@@ -1597,6 +1603,7 @@ typedef struct PartitionPruneResult
{
NodeTag type;
+ Bitmapset *root_parent_relids;
Bitmapset *valid_subplan_offs;
} PartitionPruneResult;
--
2.35.3