diff options
Diffstat (limited to 'src/backend/executor/nodeGatherMerge.c')
-rw-r--r-- | src/backend/executor/nodeGatherMerge.c | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/src/backend/executor/nodeGatherMerge.c b/src/backend/executor/nodeGatherMerge.c index d81462e72b4..166f2064ff7 100644 --- a/src/backend/executor/nodeGatherMerge.c +++ b/src/backend/executor/nodeGatherMerge.c @@ -116,10 +116,19 @@ ExecInitGatherMerge(GatherMerge *node, EState *estate, int eflags) outerPlanState(gm_state) = ExecInitNode(outerNode, estate, eflags); /* + * Store the tuple descriptor into gather merge state, so we can use it + * while initializing the gather merge slots. + */ + if (!ExecContextForcesOids(outerPlanState(gm_state), &hasoid)) + hasoid = false; + tupDesc = ExecTypeFromTL(outerNode->targetlist, hasoid); + gm_state->tupDesc = tupDesc; + + /* * Initialize result tuple type and projection info. */ ExecAssignResultTypeFromTL(&gm_state->ps); - ExecAssignProjectionInfo(&gm_state->ps, NULL); + ExecConditionalAssignProjectionInfo(&gm_state->ps, tupDesc, OUTER_VAR); /* * initialize sort-key information @@ -151,15 +160,6 @@ ExecInitGatherMerge(GatherMerge *node, EState *estate, int eflags) } } - /* - * Store the tuple descriptor into gather merge state, so we can use it - * while initializing the gather merge slots. - */ - if (!ExecContextForcesOids(outerPlanState(gm_state), &hasoid)) - hasoid = false; - tupDesc = ExecTypeFromTL(outerNode->targetlist, hasoid); - gm_state->tupDesc = tupDesc; - /* Now allocate the workspace for gather merge */ gather_merge_setup(gm_state); @@ -257,6 +257,10 @@ ExecGatherMerge(PlanState *pstate) if (TupIsNull(slot)) return NULL; + /* If no projection is required, we're done. */ + if (node->ps.ps_ProjInfo == NULL) + return slot; + /* * Form the result tuple using ExecProject(), and return it. */ |