aboutsummaryrefslogtreecommitdiff
path: root/src/backend/executor/execUtils.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/executor/execUtils.c')
-rw-r--r--src/backend/executor/execUtils.c43
1 files changed, 43 insertions, 0 deletions
diff --git a/src/backend/executor/execUtils.c b/src/backend/executor/execUtils.c
index 740e8fb1486..df0223129c4 100644
--- a/src/backend/executor/execUtils.c
+++ b/src/backend/executor/execUtils.c
@@ -526,6 +526,49 @@ ExecGetResultSlotOps(PlanState *planstate, bool *isfixed)
return planstate->ps_ResultTupleSlot->tts_ops;
}
+/*
+ * ExecGetCommonSlotOps - identify common result slot type, if any
+ *
+ * If all the given PlanState nodes return the same fixed tuple slot type,
+ * return the slot ops struct for that slot type. Else, return NULL.
+ */
+const TupleTableSlotOps *
+ExecGetCommonSlotOps(PlanState **planstates, int nplans)
+{
+ const TupleTableSlotOps *result;
+ bool isfixed;
+
+ if (nplans <= 0)
+ return NULL;
+ result = ExecGetResultSlotOps(planstates[0], &isfixed);
+ if (!isfixed)
+ return NULL;
+ for (int i = 1; i < nplans; i++)
+ {
+ const TupleTableSlotOps *thisops;
+
+ thisops = ExecGetResultSlotOps(planstates[i], &isfixed);
+ if (!isfixed)
+ return NULL;
+ if (result != thisops)
+ return NULL;
+ }
+ return result;
+}
+
+/*
+ * ExecGetCommonChildSlotOps - as above, for the PlanState's standard children
+ */
+const TupleTableSlotOps *
+ExecGetCommonChildSlotOps(PlanState *ps)
+{
+ PlanState *planstates[2];
+
+ planstates[0] = outerPlanState(ps);
+ planstates[1] = innerPlanState(ps);
+ return ExecGetCommonSlotOps(planstates, 2);
+}
+
/* ----------------
* ExecAssignProjectionInfo