Skip to content

Commit cee1209

Browse files
committed
Support for custom slots in the custom executor nodes
Some custom table access method may have their tuple format and use custom executor nodes for their custom scan types. The ability to set a custom slot would save them from tuple format conversion. Other users of custom executor nodes may also benefit. Discussion: https://postgr.es/m/CAPpHfduJUU6ToecvTyRE_yjxTS80FyPpct4OHaLFk3OEheMTNA@mail.gmail.com Author: Alexander Korotkov Reviewed-by: Pavel Borisov
1 parent b7a5ef1 commit cee1209

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

src/backend/executor/nodeCustom.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ CustomScanState *
2929
ExecInitCustomScan(CustomScan *cscan, EState *estate, int eflags)
3030
{
3131
CustomScanState *css;
32+
const TupleTableSlotOps *slotOps;
3233
Relation scan_rel = NULL;
3334
Index scanrelid = cscan->scan.scanrelid;
3435
int tlistvarno;
@@ -63,6 +64,14 @@ ExecInitCustomScan(CustomScan *cscan, EState *estate, int eflags)
6364
css->ss.ss_currentRelation = scan_rel;
6465
}
6566

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+
6675
/*
6776
* Determine the scan tuple type. If the custom scan provider provided a
6877
* targetlist describing the scan tuples, use that; else use base
@@ -73,14 +82,14 @@ ExecInitCustomScan(CustomScan *cscan, EState *estate, int eflags)
7382
TupleDesc scan_tupdesc;
7483

7584
scan_tupdesc = ExecTypeFromTL(cscan->custom_scan_tlist);
76-
ExecInitScanTupleSlot(estate, &css->ss, scan_tupdesc, &TTSOpsVirtual);
85+
ExecInitScanTupleSlot(estate, &css->ss, scan_tupdesc, slotOps);
7786
/* Node's targetlist will contain Vars with varno = INDEX_VAR */
7887
tlistvarno = INDEX_VAR;
7988
}
8089
else
8190
{
8291
ExecInitScanTupleSlot(estate, &css->ss, RelationGetDescr(scan_rel),
83-
&TTSOpsVirtual);
92+
slotOps);
8493
/* Node's targetlist will contain Vars with varno = scanrelid */
8594
tlistvarno = scanrelid;
8695
}

src/include/nodes/execnodes.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1949,6 +1949,7 @@ typedef struct CustomScanState
19491949
List *custom_ps; /* list of child PlanState nodes, if any */
19501950
Size pscan_len; /* size of parallel coordination information */
19511951
const struct CustomExecMethods *methods;
1952+
const struct TupleTableSlotOps *slotOps;
19521953
} CustomScanState;
19531954

19541955
/* ----------------------------------------------------------------

0 commit comments

Comments
 (0)