diff options
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/catalog/pg_proc.h | 6 | ||||
-rw-r--r-- | src/include/commands/defrem.h | 3 | ||||
-rw-r--r-- | src/include/executor/execFlatten.h | 11 | ||||
-rw-r--r-- | src/include/executor/executor.h | 14 | ||||
-rw-r--r-- | src/include/executor/functions.h | 11 | ||||
-rw-r--r-- | src/include/fmgr.h | 4 | ||||
-rw-r--r-- | src/include/nodes/execnodes.h | 27 | ||||
-rw-r--r-- | src/include/nodes/nodes.h | 6 | ||||
-rw-r--r-- | src/include/nodes/primnodes.h | 7 | ||||
-rw-r--r-- | src/include/utils/builtins.h | 3 | ||||
-rw-r--r-- | src/include/utils/fcache.h | 75 | ||||
-rw-r--r-- | src/include/utils/fcache2.h | 21 | ||||
-rw-r--r-- | src/include/utils/sets.h | 7 |
13 files changed, 109 insertions, 86 deletions
diff --git a/src/include/catalog/pg_proc.h b/src/include/catalog/pg_proc.h index b50f74fdf4f..c7e092c7020 100644 --- a/src/include/catalog/pg_proc.h +++ b/src/include/catalog/pg_proc.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2000, PostgreSQL, Inc * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: pg_proc.h,v 1.163 2000/08/23 06:04:44 thomas Exp $ + * $Id: pg_proc.h,v 1.164 2000/08/24 03:29:08 tgl Exp $ * * NOTES * The script catalog/genbki.sh reads this file and generates .bki @@ -1266,8 +1266,8 @@ DATA(insert OID = 1036 ( aclremove PGUID 12 f t f t 2 f 1034 "1034 1033" 10 DESCR("remove ACL item"); DATA(insert OID = 1037 ( aclcontains PGUID 12 f t f t 2 f 16 "1034 1033" 100 0 0 100 aclcontains - )); DESCR("does ACL contain item?"); -DATA(insert OID = 1038 ( seteval PGUID 12 f t f t 1 f 23 "26" 100 0 0 100 seteval - )); -DESCR(""); +DATA(insert OID = 1038 ( seteval PGUID 12 f t f t 1 t 23 "26" 100 0 0 100 seteval - )); +DESCR("internal function supporting PostQuel-style sets"); DATA(insert OID = 1044 ( bpcharin PGUID 12 f t t t 3 f 1042 "0 26 23" 100 0 0 100 bpcharin - )); DESCR("(internal)"); DATA(insert OID = 1045 ( bpcharout PGUID 12 f t t t 1 f 23 "0" 100 0 0 100 bpcharout - )); diff --git a/src/include/commands/defrem.h b/src/include/commands/defrem.h index f0a1e381e1a..2a7a4bdcfa8 100644 --- a/src/include/commands/defrem.h +++ b/src/include/commands/defrem.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2000, PostgreSQL, Inc * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: defrem.h,v 1.19 2000/02/18 09:29:49 inoue Exp $ + * $Id: defrem.h,v 1.20 2000/08/24 03:29:09 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -44,7 +44,6 @@ extern void CreateFunction(ProcedureStmt *stmt, CommandDest dest); extern void DefineOperator(char *name, List *parameters); extern void DefineAggregate(char *name, List *parameters); extern void DefineType(char *name, List *parameters); -extern void CreateFunction(ProcedureStmt *stmt, CommandDest dest); /* * prototypes in remove.c diff --git a/src/include/executor/execFlatten.h b/src/include/executor/execFlatten.h index c7d85e2e6da..3fa3673b201 100644 --- a/src/include/executor/execFlatten.h +++ b/src/include/executor/execFlatten.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2000, PostgreSQL, Inc * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: execFlatten.h,v 1.11 2000/01/26 05:58:05 momjian Exp $ + * $Id: execFlatten.h,v 1.12 2000/08/24 03:29:10 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -15,11 +15,14 @@ #define EXECFLATTEN_H #include "nodes/execnodes.h" -#include "nodes/relation.h" +#include "nodes/parsenodes.h" -extern Datum ExecEvalIter(Iter *iterNode, ExprContext *econtext, bool *resultIsNull, bool *iterIsDone); -extern void ExecEvalFjoin(TargetEntry *tlist, ExprContext *econtext, bool *isNullVect, bool *fj_isDone); +extern Datum ExecEvalIter(Iter *iterNode, ExprContext *econtext, + bool *isNull, ExprDoneCond *isDone); + +extern void ExecEvalFjoin(TargetEntry *tlist, ExprContext *econtext, + bool *isNullVect, ExprDoneCond *fj_isDone); #endif /* EXECFLATTEN_H */ diff --git a/src/include/executor/executor.h b/src/include/executor/executor.h index ea589e06dd9..e39a60a6a24 100644 --- a/src/include/executor/executor.h +++ b/src/include/executor/executor.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2000, PostgreSQL, Inc * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: executor.h,v 1.48 2000/08/21 20:55:29 tgl Exp $ + * $Id: executor.h,v 1.49 2000/08/24 03:29:10 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -78,14 +78,20 @@ extern char *GetAttributeByNum(TupleTableSlot *slot, AttrNumber attrno, bool *isNull); extern char *GetAttributeByName(TupleTableSlot *slot, char *attname, bool *isNull); +extern Datum ExecMakeFunctionResult(FunctionCachePtr fcache, + List *arguments, + ExprContext *econtext, + bool *isNull, + ExprDoneCond *isDone); extern Datum ExecEvalExpr(Node *expression, ExprContext *econtext, - bool *isNull, bool *isDone); + bool *isNull, ExprDoneCond *isDone); extern Datum ExecEvalExprSwitchContext(Node *expression, ExprContext *econtext, - bool *isNull, bool *isDone); + bool *isNull, ExprDoneCond *isDone); extern bool ExecQual(List *qual, ExprContext *econtext, bool resultForNull); extern int ExecTargetListLength(List *targetlist); extern int ExecCleanTargetListLength(List *targetlist); -extern TupleTableSlot *ExecProject(ProjectionInfo *projInfo, bool *isDone); +extern TupleTableSlot *ExecProject(ProjectionInfo *projInfo, + ExprDoneCond *isDone); /* * prototypes from functions in execScan.c diff --git a/src/include/executor/functions.h b/src/include/executor/functions.h index 0e55be1980e..649e38e142f 100644 --- a/src/include/executor/functions.h +++ b/src/include/executor/functions.h @@ -1,24 +1,21 @@ /*------------------------------------------------------------------------- * * functions.h - * + * Declarations for execution of SQL-language functions. * * * Portions Copyright (c) 1996-2000, PostgreSQL, Inc * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: functions.h,v 1.13 2000/08/08 15:42:39 tgl Exp $ + * $Id: functions.h,v 1.14 2000/08/24 03:29:10 tgl Exp $ * *------------------------------------------------------------------------- */ #ifndef FUNCTIONS_H #define FUNCTIONS_H -#include "nodes/parsenodes.h" -#include "utils/syscache.h" +#include "fmgr.h" -extern Datum postquel_function(FunctionCallInfo fcinfo, - FunctionCachePtr fcache, - bool *isDone); +extern Datum fmgr_sql(PG_FUNCTION_ARGS); #endif /* FUNCTIONS_H */ diff --git a/src/include/fmgr.h b/src/include/fmgr.h index 274f8f959d8..28634262bcc 100644 --- a/src/include/fmgr.h +++ b/src/include/fmgr.h @@ -11,7 +11,7 @@ * Portions Copyright (c) 1996-2000, PostgreSQL, Inc * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: fmgr.h,v 1.9 2000/07/29 03:26:47 tgl Exp $ + * $Id: fmgr.h,v 1.10 2000/08/24 03:29:11 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -41,7 +41,9 @@ typedef struct Oid fn_oid; /* OID of function (NOT of handler, if any) */ short fn_nargs; /* 0..FUNC_MAX_ARGS, or -1 if variable arg count */ bool fn_strict; /* function is "strict" (NULL in => NULL out) */ + bool fn_retset; /* function returns a set (over multiple calls) */ void *fn_extra; /* extra space for use by handler */ + MemoryContext fn_mcxt; /* memory context to store fn_extra in */ } FmgrInfo; /* diff --git a/src/include/nodes/execnodes.h b/src/include/nodes/execnodes.h index 1ec14f4a969..9626dbf8b1c 100644 --- a/src/include/nodes/execnodes.h +++ b/src/include/nodes/execnodes.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2000, PostgreSQL, Inc * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: execnodes.h,v 1.47 2000/08/22 04:06:22 tgl Exp $ + * $Id: execnodes.h,v 1.48 2000/08/24 03:29:13 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -120,6 +120,31 @@ typedef struct ExprContext List *ecxt_range_table; } ExprContext; +/* + * Set-result status returned by ExecEvalExpr() + */ +typedef enum +{ + ExprSingleResult, /* expression does not return a set */ + ExprMultipleResult, /* this result is an element of a set */ + ExprEndResult /* there are no more elements in the set */ +} ExprDoneCond; + +/* + * When calling a function that might return a set (multiple rows), + * a node of this type is passed as fcinfo->resultinfo to allow + * return status to be passed back. A function returning set should + * raise an error if no such resultinfo is provided. + * + * XXX this mechanism is a quick hack and probably needs to be redesigned. + */ +typedef struct ReturnSetInfo +{ + NodeTag type; + ExprDoneCond isDone; +} ReturnSetInfo; + + /* ---------------- * ProjectionInfo node information * diff --git a/src/include/nodes/nodes.h b/src/include/nodes/nodes.h index f05e0a0e1c9..d825c8fe395 100644 --- a/src/include/nodes/nodes.h +++ b/src/include/nodes/nodes.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2000, PostgreSQL, Inc * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: nodes.h,v 1.74 2000/08/11 23:46:54 tgl Exp $ + * $Id: nodes.h,v 1.75 2000/08/24 03:29:13 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -227,7 +227,9 @@ typedef enum NodeTag * TAGS FOR FUNCTION-CALL CONTEXT AND RESULTINFO NODES (cf. fmgr.h) *--------------------- */ - T_TriggerData = 800 /* in commands/trigger.h */ + T_TriggerData = 800, /* in commands/trigger.h */ + T_ReturnSetInfo /* in nodes/execnodes.h */ + } NodeTag; /* diff --git a/src/include/nodes/primnodes.h b/src/include/nodes/primnodes.h index 1ad9a3d082a..0ef350687dc 100644 --- a/src/include/nodes/primnodes.h +++ b/src/include/nodes/primnodes.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2000, PostgreSQL, Inc * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: primnodes.h,v 1.46 2000/08/08 15:42:59 tgl Exp $ + * $Id: primnodes.h,v 1.47 2000/08/24 03:29:13 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -16,7 +16,10 @@ #include "access/attnum.h" #include "nodes/pg_list.h" -#include "utils/fcache.h" + +/* FunctionCache is declared in utils/fcache.h */ +typedef struct FunctionCache *FunctionCachePtr; + /* ---------------------------------------------------------------- * node definitions diff --git a/src/include/utils/builtins.h b/src/include/utils/builtins.h index 1e16af6874f..f1ebe40b590 100644 --- a/src/include/utils/builtins.h +++ b/src/include/utils/builtins.h @@ -7,13 +7,14 @@ * Portions Copyright (c) 1996-2000, PostgreSQL, Inc * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: builtins.h,v 1.133 2000/08/23 06:04:49 thomas Exp $ + * $Id: builtins.h,v 1.134 2000/08/24 03:29:14 tgl Exp $ * *------------------------------------------------------------------------- */ #ifndef BUILTINS_H #define BUILTINS_H +#include "fmgr.h" #include "nodes/relation.h" /* for amcostestimate parameters */ #include "storage/itemptr.h" #include "utils/numeric.h" diff --git a/src/include/utils/fcache.h b/src/include/utils/fcache.h index efae7613959..a30c7283608 100644 --- a/src/include/utils/fcache.h +++ b/src/include/utils/fcache.h @@ -11,7 +11,7 @@ * Portions Copyright (c) 1996-2000, PostgreSQL, Inc * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: fcache.h,v 1.13 2000/08/08 15:43:12 tgl Exp $ + * $Id: fcache.h,v 1.14 2000/08/24 03:29:14 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -19,45 +19,50 @@ #define FCACHE_H #include "fmgr.h" +#include "nodes/execnodes.h" +/* + * 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. + */ -typedef struct +typedef struct FunctionCache { - FmgrInfo func; /* info for fmgr call mechanism */ - Oid foid; /* oid of the function in pg_proc */ - Oid language; /* oid of the language in pg_language */ - int typlen; /* length of the return type */ - bool typbyval; /* true if return type is pass by value */ - - bool returnsTuple; /* true if return type is a tuple */ - bool returnsSet; /* true if func returns a set (multi rows) */ - - bool hasSetArg; /* true if func is part of a nested dot - * expr whose argument is func returning a - * set ugh! */ - - /* If additional info is added to an existing fcache, be sure to - * allocate it in the fcacheCxt. + /* + * Function manager's lookup info for the target function. */ - MemoryContext fcacheCxt; /* context the fcache lives in */ - - int nargs; /* actual number of arguments */ - Oid *argOidVect; /* oids of all the argument types */ - - char *src; /* source code of the function */ - char *bin; /* binary object code ?? */ - char *func_state; /* function_state struct for execution */ - - Pointer funcSlot; /* if one result we need to copy it before - * we end execution of the function and - * free stuff */ - - Datum setArg; /* current argument for nested dot - * execution Nested dot expressions mean - * we have funcs whose argument is a set - * of tuples */ + 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 */ } FunctionCache; -typedef FunctionCache *FunctionCachePtr; + +extern FunctionCachePtr init_fcache(Oid foid, int nargs, + MemoryContext fcacheCxt); #endif /* FCACHE_H */ diff --git a/src/include/utils/fcache2.h b/src/include/utils/fcache2.h deleted file mode 100644 index 984edde4929..00000000000 --- a/src/include/utils/fcache2.h +++ /dev/null @@ -1,21 +0,0 @@ -/*------------------------------------------------------------------------- - * - * fcache2.h - * - * - * - * Portions Copyright (c) 1996-2000, PostgreSQL, Inc - * Portions Copyright (c) 1994, Regents of the University of California - * - * $Id: fcache2.h,v 1.10 2000/01/26 05:58:38 momjian Exp $ - * - *------------------------------------------------------------------------- - */ -#ifndef FCACHE2_H -#define FCACHE2_H - -#include "nodes/execnodes.h" - -extern void setFcache(Node *node, Oid foid, List *argList, ExprContext *econtext); - -#endif /* FCACHE2_H */ diff --git a/src/include/utils/sets.h b/src/include/utils/sets.h index a7b5d6826e2..7f284ac3467 100644 --- a/src/include/utils/sets.h +++ b/src/include/utils/sets.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2000, PostgreSQL, Inc * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: sets.h,v 1.7 2000/06/09 01:11:15 tgl Exp $ + * $Id: sets.h,v 1.8 2000/08/24 03:29:14 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -17,10 +17,11 @@ #include "fmgr.h" -/* Temporary name of set, before SetDefine changes it. */ -#define GENERICSETNAME "zyxset" +/* Temporary name of a set function, before SetDefine changes it. */ +#define GENERICSETNAME "ZYX#Set#ZYX" extern Oid SetDefine(char *querystr, char *typename); + extern Datum seteval(PG_FUNCTION_ARGS); #endif /* SETS_H */ |