1996-08-27 21:59:28 -04:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
|
*
|
1999-02-13 18:22:53 -05:00
|
|
|
* fcache.h
|
2000-07-11 22:37:39 -04:00
|
|
|
* Declarations for function cache records.
|
1997-09-07 01:04:48 -04:00
|
|
|
*
|
2000-07-11 22:37:39 -04:00
|
|
|
* The first time any Oper or Func node is evaluated, we compute a cache
|
|
|
|
|
* record for the function being invoked, and save a pointer to the cache
|
|
|
|
|
* record in the Oper or Func node. This saves repeated lookup of info
|
|
|
|
|
* about the function.
|
1996-08-27 21:59:28 -04:00
|
|
|
*
|
2000-01-26 00:58:53 -05:00
|
|
|
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
|
|
|
|
|
* Portions Copyright (c) 1994, Regents of the University of California
|
1996-08-27 21:59:28 -04:00
|
|
|
*
|
2000-08-23 23:29:15 -04:00
|
|
|
* $Id: fcache.h,v 1.14 2000/08/24 03:29:14 tgl Exp $
|
1996-08-27 21:59:28 -04:00
|
|
|
*
|
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
|
*/
|
1997-09-07 01:04:48 -04:00
|
|
|
#ifndef FCACHE_H
|
|
|
|
|
#define FCACHE_H
|
1996-08-27 21:59:28 -04:00
|
|
|
|
1999-07-15 19:04:24 -04:00
|
|
|
#include "fmgr.h"
|
2000-08-23 23:29:15 -04:00
|
|
|
#include "nodes/execnodes.h"
|
1998-01-15 14:46:37 -05:00
|
|
|
|
2000-08-23 23:29:15 -04:00
|
|
|
/*
|
|
|
|
|
* A FunctionCache record is built for all functions regardless of language.
|
|
|
|
|
*
|
|
|
|
|
* We store the fmgr lookup info to avoid recomputing it on each call.
|
|
|
|
|
* We also store a prebuilt FunctionCallInfo struct. When evaluating a
|
|
|
|
|
* function-returning-set, fcinfo holds the argument values across calls
|
|
|
|
|
* so that we need not re-evaluate the arguments for each call. Even for
|
|
|
|
|
* non-set functions, fcinfo saves a few cycles per call by allowing us to
|
|
|
|
|
* avoid redundant setup of its fields.
|
|
|
|
|
*/
|
1996-08-27 21:59:28 -04:00
|
|
|
|
2000-08-23 23:29:15 -04:00
|
|
|
typedef struct FunctionCache
|
1996-08-27 21:59:28 -04:00
|
|
|
{
|
2000-08-23 23:29:15 -04:00
|
|
|
/*
|
|
|
|
|
* Function manager's lookup info for the target function.
|
2000-07-11 22:37:39 -04:00
|
|
|
*/
|
2000-08-23 23:29:15 -04:00
|
|
|
FmgrInfo func;
|
|
|
|
|
/*
|
|
|
|
|
* Per-call info for calling the target function. Unvarying fields
|
|
|
|
|
* are set up by init_fcache(). Argument values are filled in as needed.
|
|
|
|
|
*/
|
|
|
|
|
FunctionCallInfoData fcinfo;
|
|
|
|
|
/*
|
|
|
|
|
* "Resultinfo" node --- used only if target function returns a set.
|
|
|
|
|
*/
|
|
|
|
|
ReturnSetInfo rsinfo;
|
|
|
|
|
/*
|
|
|
|
|
* argsValid 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
|
|
|
|
|
* argument values to the function again (and again, until it returns
|
|
|
|
|
* ExprEndResult).
|
|
|
|
|
*/
|
|
|
|
|
bool argsValid; /* TRUE if fcinfo contains valid arguments */
|
|
|
|
|
/*
|
|
|
|
|
* hasSetArg is true if we found a set-valued argument to the function.
|
|
|
|
|
* This causes the function result to be a set as well.
|
|
|
|
|
*/
|
|
|
|
|
bool hasSetArg; /* some argument returns a set */
|
2000-05-28 13:56:29 -04:00
|
|
|
} FunctionCache;
|
1997-09-07 01:04:48 -04:00
|
|
|
|
2000-08-23 23:29:15 -04:00
|
|
|
|
|
|
|
|
extern FunctionCachePtr init_fcache(Oid foid, int nargs,
|
|
|
|
|
MemoryContext fcacheCxt);
|
1997-09-07 01:04:48 -04:00
|
|
|
|
1998-09-01 00:40:42 -04:00
|
|
|
#endif /* FCACHE_H */
|