| 39 | static void CleanupOnePartition(DynamicSeqScanState *node); |
| 40 | |
| 41 | DynamicSeqScanState * |
| 42 | ExecInitDynamicSeqScan(DynamicSeqScan *node, EState *estate, int eflags) |
| 43 | { |
| 44 | DynamicSeqScanState *state; |
| 45 | Oid reloid; |
| 46 | ListCell *lc; |
| 47 | int i; |
| 48 | |
| 49 | Assert((eflags & (EXEC_FLAG_BACKWARD | EXEC_FLAG_MARK)) == 0); |
| 50 | |
| 51 | state = makeNode(DynamicSeqScanState); |
| 52 | state->eflags = eflags; |
| 53 | state->ss.ps.plan = (Plan *) node; |
| 54 | state->ss.ps.state = estate; |
| 55 | state->ss.ps.ExecProcNode = ExecDynamicSeqScan; |
| 56 | state->did_pruning = false; |
| 57 | state->scan_state = SCAN_INIT; |
| 58 | |
| 59 | /* Initialize child expressions. This is needed to find subplans. */ |
| 60 | state->ss.ps.qual = |
| 61 | ExecInitQual(node->seqscan.plan.qual, (PlanState *) state); |
| 62 | |
| 63 | Relation scanRel = ExecOpenScanRelation(estate, node->seqscan.scanrelid, eflags); |
| 64 | ExecInitScanTupleSlot(estate, &state->ss, RelationGetDescr(scanRel), table_slot_callbacks(scanRel)); |
| 65 | |
| 66 | /* Dynamic table/index/bitmap scan can't tell the ops of tupleslot */ |
| 67 | state->ss.ps.scanopsfixed = false; |
| 68 | state->ss.ps.scanopsset = true; |
| 69 | |
| 70 | /* Initialize result tuple type. */ |
| 71 | ExecInitResultTypeTL(&state->ss.ps); |
| 72 | ExecAssignScanProjectionInfo(&state->ss); |
| 73 | |
| 74 | state->ss.ps.resultopsfixed = false; |
| 75 | state->ss.ps.resultopsset = true; |
| 76 | |
| 77 | state->nOids = list_length(node->partOids); |
| 78 | state->partOids = palloc(sizeof(Oid) * state->nOids); |
| 79 | foreach_with_count(lc, node->partOids, i) |
| 80 | state->partOids[i] = lfirst_oid(lc); |
| 81 | state->whichPart = -1; |
| 82 | |
| 83 | reloid = exec_rt_fetch(node->seqscan.scanrelid, estate)->relid; |
| 84 | Assert(OidIsValid(reloid)); |
| 85 | |
| 86 | /* lastRelOid is used to remap varattno for heterogeneous partitions */ |
| 87 | state->lastRelOid = reloid; |
| 88 | |
| 89 | state->scanrelid = node->seqscan.scanrelid; |
| 90 | |
| 91 | state->as_prune_state = NULL; |
| 92 | |
| 93 | /* |
| 94 | * This context will be reset per-partition to free up per-partition |
| 95 | * qual and targetlist allocations |
| 96 | */ |
| 97 | state->partitionMemoryContext = AllocSetContextCreate(CurrentMemoryContext, |
| 98 | "DynamicSeqScanPerPartition", |
no test coverage detected