diff options
| author | Tom Lane | 2002-05-12 23:43:04 +0000 |
|---|---|---|
| committer | Tom Lane | 2002-05-12 23:43:04 +0000 |
| commit | 3389a110d40a505951e7c7babdfb8681173bb2ca (patch) | |
| tree | 438acebac5cfd161cf920bcda6ad168affcb96a7 /src/include | |
| parent | f9e4f611a18f64fd9106a72ec9af9e2220075780 (diff) | |
Get rid of long-since-vestigial Iter node type, in favor of adding a
returns-set boolean field in Func and Oper nodes. This allows cleaner,
more reliable tests for expressions returning sets in the planner and
parser. For example, a WHERE clause returning a set is now detected
and complained of in the parser, not only at runtime.
Diffstat (limited to 'src/include')
| -rw-r--r-- | src/include/catalog/catversion.h | 4 | ||||
| -rw-r--r-- | src/include/executor/execFlatten.h | 27 | ||||
| -rw-r--r-- | src/include/nodes/makefuncs.h | 7 | ||||
| -rw-r--r-- | src/include/nodes/nodes.h | 3 | ||||
| -rw-r--r-- | src/include/nodes/primnodes.h | 107 | ||||
| -rw-r--r-- | src/include/optimizer/clauses.h | 4 | ||||
| -rw-r--r-- | src/include/parser/parse_coerce.h | 4 | ||||
| -rw-r--r-- | src/include/utils/lsyscache.h | 3 |
8 files changed, 54 insertions, 105 deletions
diff --git a/src/include/catalog/catversion.h b/src/include/catalog/catversion.h index 3120fb5fae0..ca61cb51a76 100644 --- a/src/include/catalog/catversion.h +++ b/src/include/catalog/catversion.h @@ -37,7 +37,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: catversion.h,v 1.130 2002/05/12 20:10:04 tgl Exp $ + * $Id: catversion.h,v 1.131 2002/05/12 23:43:03 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -53,6 +53,6 @@ */ /* yyyymmddN */ -#define CATALOG_VERSION_NO 200205121 +#define CATALOG_VERSION_NO 200205122 #endif diff --git a/src/include/executor/execFlatten.h b/src/include/executor/execFlatten.h deleted file mode 100644 index 1795ed1c487..00000000000 --- a/src/include/executor/execFlatten.h +++ /dev/null @@ -1,27 +0,0 @@ -/*------------------------------------------------------------------------- - * - * execFlatten.h - * prototypes for execFlatten.c. - * - * - * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group - * Portions Copyright (c) 1994, Regents of the University of California - * - * $Id: execFlatten.h,v 1.16 2001/11/05 17:46:33 momjian Exp $ - * - *------------------------------------------------------------------------- - */ -#ifndef EXECFLATTEN_H -#define EXECFLATTEN_H - -#include "nodes/execnodes.h" -#include "nodes/parsenodes.h" - - -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/nodes/makefuncs.h b/src/include/nodes/makefuncs.h index 4096c2d9fb3..e3b6a164377 100644 --- a/src/include/nodes/makefuncs.h +++ b/src/include/nodes/makefuncs.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: makefuncs.h,v 1.35 2002/04/16 23:08:12 tgl Exp $ + * $Id: makefuncs.h,v 1.36 2002/05/12 23:43:04 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -22,8 +22,9 @@ extern A_Expr *makeSimpleA_Expr(int oper, const char *name, Node *lexpr, Node *rexpr); extern Oper *makeOper(Oid opno, - Oid opid, - Oid opresulttype); + Oid opid, + Oid opresulttype, + bool opretset); extern Var *makeVar(Index varno, AttrNumber varattno, diff --git a/src/include/nodes/nodes.h b/src/include/nodes/nodes.h index 492619e194d..7de647d1362 100644 --- a/src/include/nodes/nodes.h +++ b/src/include/nodes/nodes.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: nodes.h,v 1.106 2002/05/12 20:10:04 tgl Exp $ + * $Id: nodes.h,v 1.107 2002/05/12 23:43:04 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -66,7 +66,6 @@ typedef enum NodeTag T_Func, T_FieldSelect, T_ArrayRef, - T_Iter, T_RelabelType, T_RangeTblRef, T_FromExpr, diff --git a/src/include/nodes/primnodes.h b/src/include/nodes/primnodes.h index 6eed89a7042..342ac11bb5b 100644 --- a/src/include/nodes/primnodes.h +++ b/src/include/nodes/primnodes.h @@ -10,7 +10,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: primnodes.h,v 1.62 2002/05/12 20:10:05 tgl Exp $ + * $Id: primnodes.h,v 1.63 2002/05/12 23:43:04 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -151,13 +151,52 @@ typedef struct Expr { NodeTag type; Oid typeOid; /* oid of the type of this expression */ - OpType opType; /* type of this expression */ + OpType opType; /* kind of expression */ Node *oper; /* operator node if needed (Oper, Func, or * SubPlan) */ List *args; /* arguments to this expression */ } Expr; /* + * Oper - Expr subnode for an OP_EXPR + * + * NOTE: in the good old days 'opno' used to be both (or either, or + * neither) the pg_operator oid, and/or the pg_proc oid depending + * on the postgres module in question (parser->pg_operator, + * executor->pg_proc, planner->both), the mood of the programmer, + * and the phase of the moon (rumors that it was also depending on the day + * of the week are probably false). To make things even more postgres-like + * (i.e. a mess) some comments were referring to 'opno' using the name + * 'opid'. Anyway, now we have two separate fields, and of course that + * immediately removes all bugs from the code... [ sp :-) ]. + * + * Note also that opid is not necessarily filled in immediately on creation + * of the node. The planner makes sure it is valid before passing the node + * tree to the executor, but during parsing/planning opid is typically 0. + */ +typedef struct Oper +{ + NodeTag type; + Oid opno; /* PG_OPERATOR OID of the operator */ + Oid opid; /* PG_PROC OID of underlying function */ + Oid opresulttype; /* PG_TYPE OID of result value */ + bool opretset; /* true if operator returns set */ + FunctionCachePtr op_fcache; /* runtime state, else NULL */ +} Oper; + +/* + * Func - Expr subnode for a FUNC_EXPR + */ +typedef struct Func +{ + NodeTag type; + Oid funcid; /* PG_PROC OID of the function */ + Oid funcresulttype; /* PG_TYPE OID of result value */ + bool funcretset; /* true if function returns set */ + FunctionCachePtr func_fcache; /* runtime state, or NULL */ +} Func; + +/* * Var * * Note: during parsing/planning, varnoold/varoattno are always just copies @@ -196,37 +235,6 @@ typedef struct Var AttrNumber varoattno; /* original value of varattno */ } Var; -/*-------------------- - * Oper - * - * NOTE: in the good old days 'opno' used to be both (or either, or - * neither) the pg_operator oid, and/or the pg_proc oid depending - * on the postgres module in question (parser->pg_operator, - * executor->pg_proc, planner->both), the mood of the programmer, - * and the phase of the moon (rumors that it was also depending on the day - * of the week are probably false). To make things even more postgres-like - * (i.e. a mess) some comments were referring to 'opno' using the name - * 'opid'. Anyway, now we have two separate fields, and of course that - * immediately removes all bugs from the code... [ sp :-) ]. - * - * Note also that opid is not necessarily filled in immediately on creation - * of the node. The planner makes sure it is valid before passing the node - * tree to the executor, but during parsing/planning opid is typically 0. - *-------------------- - */ -typedef struct Oper -{ - NodeTag type; - Oid opno; /* PG_OPERATOR OID of the operator */ - Oid opid; /* PG_PROC OID for the operator's - * underlying function */ - Oid opresulttype; - /* PG_TYPE OID of the operator's return value */ - FunctionCachePtr op_fcache; - /* runtime state while running the function */ -} Oper; - - /* * Const */ @@ -283,39 +291,6 @@ typedef struct Param Oid paramtype; /* PG_TYPE OID of the parameter's value */ } Param; - -/* - * Func - */ -typedef struct Func -{ - NodeTag type; - Oid funcid; /* PG_PROC OID of the function */ - Oid functype; /* PG_TYPE OID of the function's return - * value */ - FunctionCachePtr func_fcache; - - /* - * runtime state while running this function. Where we are in the - * execution of the function if it returns more than one value, etc. - * See utils/fcache.h - */ -} Func; - -/* ---------------- - * Iter - * can anyone explain what this is for? Seems to have something to do - * with evaluation of functions that return sets... - * ---------------- - */ -typedef struct Iter -{ - NodeTag type; - Node *iterexpr; - Oid itertype; /* type of the iter expr (use for type - * checking) */ -} Iter; - /* * Aggref */ diff --git a/src/include/optimizer/clauses.h b/src/include/optimizer/clauses.h index 69596c1779a..376e8cc77aa 100644 --- a/src/include/optimizer/clauses.h +++ b/src/include/optimizer/clauses.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: clauses.h,v 1.51 2002/04/05 00:31:35 tgl Exp $ + * $Id: clauses.h,v 1.52 2002/05/12 23:43:04 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -42,7 +42,7 @@ extern List *make_ands_implicit(Expr *clause); extern bool contain_agg_clause(Node *clause); extern List *pull_agg_clause(Node *clause); -extern bool contain_iter_clause(Node *clause); +extern bool expression_returns_set(Node *clause); extern bool contain_subplans(Node *clause); extern List *pull_subplans(Node *clause); diff --git a/src/include/parser/parse_coerce.h b/src/include/parser/parse_coerce.h index 47ce9b61c16..a7eb56a5092 100644 --- a/src/include/parser/parse_coerce.h +++ b/src/include/parser/parse_coerce.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: parse_coerce.h,v 1.42 2002/04/11 20:00:15 tgl Exp $ + * $Id: parse_coerce.h,v 1.43 2002/05/12 23:43:04 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -45,7 +45,7 @@ extern Node *coerce_type(ParseState *pstate, Node *node, Oid inputTypeId, extern Node *coerce_type_typmod(ParseState *pstate, Node *node, Oid targetTypeId, int32 atttypmod); -extern bool coerce_to_boolean(ParseState *pstate, Node **pnode); +extern Node *coerce_to_boolean(Node *node, const char *constructName); extern Oid select_common_type(List *typeids, const char *context); extern Node *coerce_to_common_type(ParseState *pstate, Node *node, diff --git a/src/include/utils/lsyscache.h b/src/include/utils/lsyscache.h index 9f812256737..eaff98448d3 100644 --- a/src/include/utils/lsyscache.h +++ b/src/include/utils/lsyscache.h @@ -6,7 +6,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: lsyscache.h,v 1.51 2002/04/30 01:26:26 tgl Exp $ + * $Id: lsyscache.h,v 1.52 2002/05/12 23:43:04 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -39,6 +39,7 @@ extern RegProcedure get_oprrest(Oid opno); extern RegProcedure get_oprjoin(Oid opno); extern char *get_func_name(Oid funcid); extern Oid get_func_rettype(Oid funcid); +extern bool get_func_retset(Oid funcid); extern char func_volatile(Oid funcid); extern Oid get_relname_relid(const char *relname, Oid relnamespace); extern char *get_rel_name(Oid relid); |
