]> granicus.if.org Git - postgresql/blob - src/include/utils/fcache.h
563812c87174aa84488695e908da33f304351d2c
[postgresql] / src / include / utils / fcache.h
1 /*-------------------------------------------------------------------------
2  *
3  * fcache.h
4  *              Declarations for function cache records.
5  *
6  * The first time any Oper or Func node is evaluated, we compute a cache
7  * record for the function being invoked, and save a pointer to the cache
8  * record in the Oper or Func node.  This saves repeated lookup of info
9  * about the function.
10  *
11  * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
12  * Portions Copyright (c) 1994, Regents of the University of California
13  *
14  * $Id: fcache.h,v 1.20 2001/11/05 17:46:36 momjian Exp $
15  *
16  *-------------------------------------------------------------------------
17  */
18 #ifndef FCACHE_H
19 #define FCACHE_H
20
21 #include "fmgr.h"
22 #include "nodes/execnodes.h"
23
24 /*
25  * A FunctionCache record is built for all functions regardless of language.
26  *
27  * We store the fmgr lookup info to avoid recomputing it on each call.
28  *
29  * We also need to store argument values across calls when evaluating a
30  * function-returning-set.      This is pretty ugly (and not re-entrant);
31  * current-evaluation info should be somewhere in the econtext, not in
32  * the querytree.  As it stands, a function-returning-set can't safely be
33  * recursive, at least not if it's in plpgsql which will try to re-use
34  * the querytree at multiple execution nesting levels.  FIXME someday.
35  */
36
37 typedef struct FunctionCache
38 {
39         /*
40          * Function manager's lookup info for the target function.
41          */
42         FmgrInfo        func;
43
44         /*
45          * setArgsValid is true when we are evaluating a set-valued function
46          * and we are in the middle of a call series; we want to pass the same
47          * argument values to the function again (and again, until it returns
48          * ExprEndResult).
49          */
50         bool            setArgsValid;
51
52         /*
53          * Flag to remember whether we found a set-valued argument to the
54          * function. This causes the function result to be a set as well.
55          * Valid only when setArgsValid is true.
56          */
57         bool            setHasSetArg;   /* some argument returns a set */
58
59         /*
60          * Current argument data for a set-valued function; contains valid
61          * data only if setArgsValid is true.
62          */
63         FunctionCallInfoData setArgs;
64 } FunctionCache;
65
66
67 extern FunctionCachePtr init_fcache(Oid foid, int nargs,
68                         MemoryContext fcacheCxt);
69
70 #endif   /* FCACHE_H */