---------------------------------------------------------------- * ExecInitGather * ---------------------------------------------------------------- */
| 55 | * ---------------------------------------------------------------- |
| 56 | */ |
| 57 | GatherState * |
| 58 | ExecInitGather(Gather *node, EState *estate, int eflags) |
| 59 | { |
| 60 | GatherState *gatherstate; |
| 61 | Plan *outerNode; |
| 62 | TupleDesc tupDesc; |
| 63 | |
| 64 | /* Gather node doesn't have innerPlan node. */ |
| 65 | Assert(innerPlan(node) == NULL); |
| 66 | |
| 67 | /* |
| 68 | * create state structure |
| 69 | */ |
| 70 | gatherstate = makeNode(GatherState); |
| 71 | gatherstate->ps.plan = (Plan *) node; |
| 72 | gatherstate->ps.state = estate; |
| 73 | gatherstate->ps.ExecProcNode = ExecGather; |
| 74 | |
| 75 | gatherstate->initialized = false; |
| 76 | gatherstate->need_to_scan_locally = |
| 77 | !node->single_copy && parallel_leader_participation; |
| 78 | gatherstate->tuples_needed = -1; |
| 79 | |
| 80 | /* |
| 81 | * Miscellaneous initialization |
| 82 | * |
| 83 | * create expression context for node |
| 84 | */ |
| 85 | ExecAssignExprContext(estate, &gatherstate->ps); |
| 86 | |
| 87 | /* |
| 88 | * now initialize outer plan |
| 89 | */ |
| 90 | outerNode = outerPlan(node); |
| 91 | outerPlanState(gatherstate) = ExecInitNode(outerNode, estate, eflags); |
| 92 | tupDesc = ExecGetResultType(outerPlanState(gatherstate)); |
| 93 | |
| 94 | /* |
| 95 | * Leader may access ExecProcNode result directly (if |
| 96 | * need_to_scan_locally), or from workers via tuple queue. So we can't |
| 97 | * trivially rely on the slot type being fixed for expressions evaluated |
| 98 | * within this node. |
| 99 | */ |
| 100 | gatherstate->ps.outeropsset = true; |
| 101 | gatherstate->ps.outeropsfixed = false; |
| 102 | |
| 103 | /* |
| 104 | * Initialize result type and projection. |
| 105 | */ |
| 106 | ExecInitResultTypeTL(&gatherstate->ps); |
| 107 | ExecConditionalAssignProjectionInfo(&gatherstate->ps, tupDesc, OUTER_VAR); |
| 108 | |
| 109 | /* |
| 110 | * Without projections result slot type is not trivially known, see |
| 111 | * comment above. |
| 112 | */ |
| 113 | if (gatherstate->ps.ps_ProjInfo == NULL) |
| 114 | { |
no test coverage detected