1996-08-28 03:59:28 +02:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
*
|
1999-02-14 00:22:53 +01:00
|
|
|
* fcache.h
|
2000-07-12 04:37:39 +02:00
|
|
|
* Declarations for function cache records.
|
1997-09-07 07:04:48 +02:00
|
|
|
*
|
2000-07-12 04:37:39 +02: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-28 03:59:28 +02:00
|
|
|
*
|
2001-01-24 20:43:33 +01:00
|
|
|
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
|
2000-01-26 06:58:53 +01:00
|
|
|
* Portions Copyright (c) 1994, Regents of the University of California
|
1996-08-28 03:59:28 +02:00
|
|
|
*
|
2002-02-19 00:11:58 +01:00
|
|
|
* $Id: fcache.h,v 1.21 2002/02/18 23:11:46 petere Exp $
|
1996-08-28 03:59:28 +02:00
|
|
|
*
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
1997-09-07 07:04:48 +02:00
|
|
|
#ifndef FCACHE_H
|
|
|
|
#define FCACHE_H
|
1996-08-28 03:59:28 +02:00
|
|
|
|
1999-07-16 01:04:24 +02:00
|
|
|
#include "fmgr.h"
|
2000-08-24 05:29:15 +02:00
|
|
|
#include "nodes/execnodes.h"
|
1998-01-15 20:46:37 +01:00
|
|
|
|
2000-08-24 05:29:15 +02: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.
|
2001-09-21 02:11:31 +02:00
|
|
|
*
|
|
|
|
* We also need to store argument values across calls when evaluating a
|
2001-10-25 07:50:21 +02:00
|
|
|
* function-returning-set. This is pretty ugly (and not re-entrant);
|
2001-09-21 02:11:31 +02:00
|
|
|
* current-evaluation info should be somewhere in the econtext, not in
|
|
|
|
* the querytree. As it stands, a function-returning-set can't safely be
|
|
|
|
* recursive, at least not if it's in plpgsql which will try to re-use
|
2001-10-25 07:50:21 +02:00
|
|
|
* the querytree at multiple execution nesting levels. FIXME someday.
|
2000-08-24 05:29:15 +02:00
|
|
|
*/
|
1996-08-28 03:59:28 +02:00
|
|
|
|
2000-08-24 05:29:15 +02:00
|
|
|
typedef struct FunctionCache
|
1996-08-28 03:59:28 +02:00
|
|
|
{
|
2000-08-24 05:29:15 +02:00
|
|
|
/*
|
|
|
|
* Function manager's lookup info for the target function.
|
2000-07-12 04:37:39 +02:00
|
|
|
*/
|
2000-08-24 05:29:15 +02:00
|
|
|
FmgrInfo func;
|
2001-03-22 05:01:46 +01:00
|
|
|
|
2002-02-19 00:11:58 +01:00
|
|
|
bool permission_ok;
|
|
|
|
|
2000-08-24 05:29:15 +02:00
|
|
|
/*
|
2001-09-21 02:11:31 +02:00
|
|
|
* 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
|
2000-08-24 05:29:15 +02:00
|
|
|
* argument values to the function again (and again, until it returns
|
|
|
|
* ExprEndResult).
|
|
|
|
*/
|
2001-09-21 02:11:31 +02:00
|
|
|
bool setArgsValid;
|
2001-03-22 05:01:46 +01:00
|
|
|
|
2000-08-24 05:29:15 +02:00
|
|
|
/*
|
2001-09-21 02:11:31 +02:00
|
|
|
* Flag to remember whether we found a set-valued argument to the
|
2001-03-22 05:01:46 +01:00
|
|
|
* function. This causes the function result to be a set as well.
|
2001-09-21 02:11:31 +02:00
|
|
|
* Valid only when setArgsValid is true.
|
|
|
|
*/
|
|
|
|
bool setHasSetArg; /* some argument returns a set */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Current argument data for a set-valued function; contains valid
|
|
|
|
* data only if setArgsValid is true.
|
2000-08-24 05:29:15 +02:00
|
|
|
*/
|
2001-09-21 02:11:31 +02:00
|
|
|
FunctionCallInfoData setArgs;
|
2000-05-28 19:56:29 +02:00
|
|
|
} FunctionCache;
|
1997-09-07 07:04:48 +02:00
|
|
|
|
2000-08-24 05:29:15 +02:00
|
|
|
|
|
|
|
extern FunctionCachePtr init_fcache(Oid foid, int nargs,
|
2001-03-22 05:01:46 +01:00
|
|
|
MemoryContext fcacheCxt);
|
2001-10-28 07:26:15 +01:00
|
|
|
|
2001-11-05 18:46:40 +01:00
|
|
|
#endif /* FCACHE_H */
|