]> granicus.if.org Git - postgresql/blob - src/include/utils/fcache.h
Commit to match discussed elog() changes. Only update is that LOG is
[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.21 2002/02/18 23:11:46 petere 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         bool permission_ok;
45
46         /*
47          * setArgsValid is true when we are evaluating a set-valued function
48          * and we are in the middle of a call series; we want to pass the same
49          * argument values to the function again (and again, until it returns
50          * ExprEndResult).
51          */
52         bool            setArgsValid;
53
54         /*
55          * Flag to remember whether we found a set-valued argument to the
56          * function. This causes the function result to be a set as well.
57          * Valid only when setArgsValid is true.
58          */
59         bool            setHasSetArg;   /* some argument returns a set */
60
61         /*
62          * Current argument data for a set-valued function; contains valid
63          * data only if setArgsValid is true.
64          */
65         FunctionCallInfoData setArgs;
66 } FunctionCache;
67
68
69 extern FunctionCachePtr init_fcache(Oid foid, int nargs,
70                         MemoryContext fcacheCxt);
71
72 #endif   /* FCACHE_H */