aboutsummaryrefslogtreecommitdiff
path: root/src/backend/executor/nodeCustom.c
diff options
context:
space:
mode:
authorAlexander Korotkov <akorotkov@postgresql.org>2022-11-24 00:36:11 +0300
committerAlexander Korotkov <akorotkov@postgresql.org>2022-11-24 00:36:11 +0300
commitcee120951427fe39a54ab800abfa2834d85b8771 (patch)
tree2928e3cc7dc57b1e0d2ca86e99799178ddfb6a05 /src/backend/executor/nodeCustom.c
parentb7a5ef17cf75c712b0fe5c5a20133a88da897aab (diff)
downloadpostgresql-cee120951427fe39a54ab800abfa2834d85b8771.tar.gz
postgresql-cee120951427fe39a54ab800abfa2834d85b8771.zip
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
Diffstat (limited to 'src/backend/executor/nodeCustom.c')
-rw-r--r--src/backend/executor/nodeCustom.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/backend/executor/nodeCustom.c b/src/backend/executor/nodeCustom.c
index 8f56bd8a23a..a76ec43b9fe 100644
--- a/src/backend/executor/nodeCustom.c
+++ b/src/backend/executor/nodeCustom.c
@@ -29,6 +29,7 @@ CustomScanState *
ExecInitCustomScan(CustomScan *cscan, EState *estate, int eflags)
{
CustomScanState *css;
+ const TupleTableSlotOps *slotOps;
Relation scan_rel = NULL;
Index scanrelid = cscan->scan.scanrelid;
int tlistvarno;
@@ -64,6 +65,14 @@ ExecInitCustomScan(CustomScan *cscan, EState *estate, int eflags)
}
/*
+ * Use a custom slot if specified in CustomScanState or use virtual slot
+ * otherwise.
+ */
+ slotOps = css->slotOps;
+ if (!slotOps)
+ slotOps = &TTSOpsVirtual;
+
+ /*
* Determine the scan tuple type. If the custom scan provider provided a
* targetlist describing the scan tuples, use that; else use base
* relation's rowtype.
@@ -73,14 +82,14 @@ ExecInitCustomScan(CustomScan *cscan, EState *estate, int eflags)
TupleDesc scan_tupdesc;
scan_tupdesc = ExecTypeFromTL(cscan->custom_scan_tlist);
- ExecInitScanTupleSlot(estate, &css->ss, scan_tupdesc, &TTSOpsVirtual);
+ ExecInitScanTupleSlot(estate, &css->ss, scan_tupdesc, slotOps);
/* Node's targetlist will contain Vars with varno = INDEX_VAR */
tlistvarno = INDEX_VAR;
}
else
{
ExecInitScanTupleSlot(estate, &css->ss, RelationGetDescr(scan_rel),
- &TTSOpsVirtual);
+ slotOps);
/* Node's targetlist will contain Vars with varno = scanrelid */
tlistvarno = scanrelid;
}