@@ -29,6 +29,7 @@ CustomScanState *
29
29
ExecInitCustomScan (CustomScan * cscan , EState * estate , int eflags )
30
30
{
31
31
CustomScanState * css ;
32
+ const TupleTableSlotOps * slotOps ;
32
33
Relation scan_rel = NULL ;
33
34
Index scanrelid = cscan -> scan .scanrelid ;
34
35
int tlistvarno ;
@@ -63,6 +64,14 @@ ExecInitCustomScan(CustomScan *cscan, EState *estate, int eflags)
63
64
css -> ss .ss_currentRelation = scan_rel ;
64
65
}
65
66
67
+ /*
68
+ * Use a custom slot if specified in CustomScanState or use virtual slot
69
+ * otherwise.
70
+ */
71
+ slotOps = css -> slotOps ;
72
+ if (!slotOps )
73
+ slotOps = & TTSOpsVirtual ;
74
+
66
75
/*
67
76
* Determine the scan tuple type. If the custom scan provider provided a
68
77
* targetlist describing the scan tuples, use that; else use base
@@ -73,14 +82,14 @@ ExecInitCustomScan(CustomScan *cscan, EState *estate, int eflags)
73
82
TupleDesc scan_tupdesc ;
74
83
75
84
scan_tupdesc = ExecTypeFromTL (cscan -> custom_scan_tlist );
76
- ExecInitScanTupleSlot (estate , & css -> ss , scan_tupdesc , & TTSOpsVirtual );
85
+ ExecInitScanTupleSlot (estate , & css -> ss , scan_tupdesc , slotOps );
77
86
/* Node's targetlist will contain Vars with varno = INDEX_VAR */
78
87
tlistvarno = INDEX_VAR ;
79
88
}
80
89
else
81
90
{
82
91
ExecInitScanTupleSlot (estate , & css -> ss , RelationGetDescr (scan_rel ),
83
- & TTSOpsVirtual );
92
+ slotOps );
84
93
/* Node's targetlist will contain Vars with varno = scanrelid */
85
94
tlistvarno = scanrelid ;
86
95
}
0 commit comments