MCPcopy Create free account
hub / github.com/apache/cloudberry / ExecInitCustomScan

Function ExecInitCustomScan

src/backend/executor/nodeCustom.c:28–105  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

26
27
28CustomScanState *
29ExecInitCustomScan(CustomScan *cscan, EState *estate, int eflags)
30{
31 CustomScanState *css;
32 Relation scan_rel = NULL;
33 Index scanrelid = cscan->scan.scanrelid;
34 Index tlistvarno;
35
36 /*
37 * Allocate the CustomScanState object. We let the custom scan provider
38 * do the palloc, in case it wants to make a larger object that embeds
39 * CustomScanState as the first field. It must set the node tag and the
40 * methods field correctly at this time. Other standard fields should be
41 * set to zero.
42 */
43 css = castNode(CustomScanState,
44 cscan->methods->CreateCustomScanState(cscan));
45
46 /* ensure flags is filled correctly */
47 css->flags = cscan->flags;
48
49 /* fill up fields of ScanState */
50 css->ss.ps.plan = &cscan->scan.plan;
51 css->ss.ps.state = estate;
52 css->ss.ps.ExecProcNode = ExecCustomScan;
53
54 /* create expression context for node */
55 ExecAssignExprContext(estate, &css->ss.ps);
56
57 /*
58 * open the scan relation, if any
59 */
60 if (scanrelid > 0)
61 {
62 scan_rel = ExecOpenScanRelation(estate, scanrelid, eflags);
63 css->ss.ss_currentRelation = scan_rel;
64 }
65
66 /*
67 * Determine the scan tuple type. If the custom scan provider provided a
68 * targetlist describing the scan tuples, use that; else use base
69 * relation's rowtype.
70 */
71 if (cscan->custom_scan_tlist != NIL || scan_rel == NULL)
72 {
73 TupleDesc scan_tupdesc;
74
75 scan_tupdesc = ExecTypeFromTL(cscan->custom_scan_tlist);
76 ExecInitScanTupleSlot(estate, &css->ss, scan_tupdesc, &TTSOpsVirtual);
77 /* Node's targetlist will contain Vars with varno = INDEX_VAR */
78 tlistvarno = INDEX_VAR;
79 }
80 else
81 {
82 ExecInitScanTupleSlot(estate, &css->ss, RelationGetDescr(scan_rel),
83 &TTSOpsVirtual);
84 /* Node's targetlist will contain Vars with varno = scanrelid */
85 tlistvarno = scanrelid;

Callers 1

ExecInitNodeFunction · 0.85

Calls 7

ExecAssignExprContextFunction · 0.85
ExecOpenScanRelationFunction · 0.85
ExecTypeFromTLFunction · 0.85
ExecInitScanTupleSlotFunction · 0.85
ExecInitQualFunction · 0.85

Tested by

no test coverage detected