summaryrefslogtreecommitdiff
path: root/src/backend/executor/execTuples.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2008-10-28 22:02:06 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2008-10-28 22:02:06 +0000
commite3e3d2a789e34ff6572bdf693beb1516a228c5ff (patch)
treec5c95ccfe1f4cc79e49c572b13681f628a212fe9 /src/backend/executor/execTuples.c
parenta80a12247a99f0bccf47bed5786f28a35fc80845 (diff)
Extend ExecMakeFunctionResult() to support set-returning functions that return
via a tuplestore instead of value-per-call. Refactor a few things to reduce ensuing code duplication with nodeFunctionscan.c. This represents the reasonably noncontroversial part of my proposed patch to switch SQL functions over to returning tuplestores. For the moment, SQL functions still do things the old way. However, this change enables PL SRFs to be called in targetlists (observe changes in plperl regression results).
Diffstat (limited to 'src/backend/executor/execTuples.c')
-rw-r--r--src/backend/executor/execTuples.c29
1 files changed, 28 insertions, 1 deletions
diff --git a/src/backend/executor/execTuples.c b/src/backend/executor/execTuples.c
index 357d99e36fc..7d92f8deff4 100644
--- a/src/backend/executor/execTuples.c
+++ b/src/backend/executor/execTuples.c
@@ -15,7 +15,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/executor/execTuples.c,v 1.102 2008/08/25 22:42:32 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/executor/execTuples.c,v 1.103 2008/10/28 22:02:05 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -767,6 +767,33 @@ ExecFetchSlotMinimalTuple(TupleTableSlot *slot)
}
/* --------------------------------
+ * ExecFetchSlotTupleDatum
+ * Fetch the slot's tuple as a composite-type Datum.
+ *
+ * We convert the slot's contents to local physical-tuple form,
+ * and fill in the Datum header fields. Note that the result
+ * always points to storage owned by the slot.
+ * --------------------------------
+ */
+Datum
+ExecFetchSlotTupleDatum(TupleTableSlot *slot)
+{
+ HeapTuple tup;
+ HeapTupleHeader td;
+ TupleDesc tupdesc;
+
+ /* Make sure we can scribble on the slot contents ... */
+ tup = ExecMaterializeSlot(slot);
+ /* ... and set up the composite-Datum header fields, in case not done */
+ td = tup->t_data;
+ tupdesc = slot->tts_tupleDescriptor;
+ HeapTupleHeaderSetDatumLength(td, tup->t_len);
+ HeapTupleHeaderSetTypeId(td, tupdesc->tdtypeid);
+ HeapTupleHeaderSetTypMod(td, tupdesc->tdtypmod);
+ return PointerGetDatum(td);
+}
+
+/* --------------------------------
* ExecMaterializeSlot
* Force a slot into the "materialized" state.
*