mirror of
https://github.com/postgres/postgres.git
synced 2025-07-08 11:42:09 +03:00
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).
This commit is contained in:
@ -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 $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -766,6 +766,33 @@ ExecFetchSlotMinimalTuple(TupleTableSlot *slot)
|
||||
return slot->tts_mintuple;
|
||||
}
|
||||
|
||||
/* --------------------------------
|
||||
* 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.
|
||||
|
Reference in New Issue
Block a user