diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2008-10-28 22:02:06 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2008-10-28 22:02:06 +0000 |
commit | e3e3d2a789e34ff6572bdf693beb1516a228c5ff (patch) | |
tree | c5c95ccfe1f4cc79e49c572b13681f628a212fe9 /src/include/nodes/execnodes.h | |
parent | a80a12247a99f0bccf47bed5786f28a35fc80845 (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/include/nodes/execnodes.h')
-rw-r--r-- | src/include/nodes/execnodes.h | 31 |
1 files changed, 24 insertions, 7 deletions
diff --git a/src/include/nodes/execnodes.h b/src/include/nodes/execnodes.h index 5b46f6e7087..ccc5963121e 100644 --- a/src/include/nodes/execnodes.h +++ b/src/include/nodes/execnodes.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/nodes/execnodes.h,v 1.191 2008/10/23 14:34:34 tgl Exp $ + * $PostgreSQL: pgsql/src/include/nodes/execnodes.h,v 1.192 2008/10/28 22:02:05 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -538,13 +538,29 @@ typedef struct FuncExprState /* * Function manager's lookup info for the target function. If func.fn_oid - * is InvalidOid, we haven't initialized it yet. + * is InvalidOid, we haven't initialized it yet (nor any of the following + * fields). */ FmgrInfo func; /* - * We also need to store argument values across calls when evaluating a - * function-returning-set. + * For a set-returning function (SRF) that returns a tuplestore, we + * keep the tuplestore here and dole out the result rows one at a time. + * The slot holds the row currently being returned. + */ + Tuplestorestate *funcResultStore; + TupleTableSlot *funcResultSlot; + + /* + * In some cases we need to compute a tuple descriptor for the function's + * output. If so, it's stored here. + */ + TupleDesc funcResultDesc; + bool funcReturnsTuple; /* valid when funcResultDesc isn't NULL */ + + /* + * We need to store argument values across calls when evaluating a SRF + * that uses value-per-call mode. * * setArgsValid is true when we are evaluating a set-valued function and * we are in the middle of a call series; we want to pass the same @@ -556,14 +572,15 @@ typedef struct FuncExprState /* * Flag to remember whether we found a set-valued argument to the * function. This causes the function result to be a set as well. Valid - * only when setArgsValid is true. + * only when setArgsValid is true or funcResultStore isn't NULL. */ bool setHasSetArg; /* some argument returns a set */ /* * Flag to remember whether we have registered a shutdown callback for - * this FuncExprState. We do so only if setArgsValid has been true at - * least once (since all the callback is for is to clear setArgsValid). + * this FuncExprState. We do so only if funcResultStore or setArgsValid + * has been set at least once (since all the callback is for is to release + * the tuplestore or clear setArgsValid). */ bool shutdown_reg; /* a shutdown callback is registered */ |