---------------------------------------------------------------- * ExecInitSetOp * * This initializes the setop node state structures and * the node's subplan. * ---------------------------------------------------------------- */
| 478 | * ---------------------------------------------------------------- |
| 479 | */ |
| 480 | SetOpState * |
| 481 | ExecInitSetOp(SetOp *node, EState *estate, int eflags) |
| 482 | { |
| 483 | SetOpState *setopstate; |
| 484 | TupleDesc outerDesc; |
| 485 | |
| 486 | /* check for unsupported flags */ |
| 487 | Assert(!(eflags & (EXEC_FLAG_BACKWARD | EXEC_FLAG_MARK))); |
| 488 | |
| 489 | /* |
| 490 | * create state structure |
| 491 | */ |
| 492 | setopstate = makeNode(SetOpState); |
| 493 | setopstate->ps.plan = (Plan *) node; |
| 494 | setopstate->ps.state = estate; |
| 495 | setopstate->ps.ExecProcNode = ExecSetOp; |
| 496 | |
| 497 | setopstate->eqfuncoids = NULL; |
| 498 | setopstate->hashfunctions = NULL; |
| 499 | setopstate->setop_done = false; |
| 500 | setopstate->numOutput = 0; |
| 501 | setopstate->pergroup = NULL; |
| 502 | setopstate->grp_firstTuple = NULL; |
| 503 | setopstate->hashtable = NULL; |
| 504 | setopstate->tableContext = NULL; |
| 505 | |
| 506 | /* |
| 507 | * create expression context |
| 508 | */ |
| 509 | ExecAssignExprContext(estate, &setopstate->ps); |
| 510 | |
| 511 | /* |
| 512 | * If hashing, we also need a longer-lived context to store the hash |
| 513 | * table. The table can't just be kept in the per-query context because |
| 514 | * we want to be able to throw it away in ExecReScanSetOp. |
| 515 | */ |
| 516 | if (node->strategy == SETOP_HASHED) |
| 517 | setopstate->tableContext = |
| 518 | AllocSetContextCreate(CurrentMemoryContext, |
| 519 | "SetOp hash table", |
| 520 | ALLOCSET_DEFAULT_SIZES); |
| 521 | |
| 522 | /* |
| 523 | * initialize child nodes |
| 524 | * |
| 525 | * If we are hashing then the child plan does not need to handle REWIND |
| 526 | * efficiently; see ExecReScanSetOp. |
| 527 | */ |
| 528 | if (node->strategy == SETOP_HASHED) |
| 529 | eflags &= ~EXEC_FLAG_REWIND; |
| 530 | outerPlanState(setopstate) = ExecInitNode(outerPlan(node), estate, eflags); |
| 531 | outerDesc = ExecGetResultType(outerPlanState(setopstate)); |
| 532 | |
| 533 | /* |
| 534 | * Initialize result slot and type. Setop nodes do no projections, so |
| 535 | * initialize projection info for this node appropriately. |
| 536 | */ |
| 537 | ExecInitResultTupleSlotTL(&setopstate->ps, |
no test coverage detected