aboutsummaryrefslogtreecommitdiff
path: root/src/backend/parser
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/parser')
-rw-r--r--src/backend/parser/parse_agg.c12
-rw-r--r--src/backend/parser/parse_clause.c94
-rw-r--r--src/backend/parser/parse_expr.c7
-rw-r--r--src/backend/parser/parse_func.c65
-rw-r--r--src/backend/parser/parse_node.c12
-rw-r--r--src/backend/parser/parse_oper.c27
-rw-r--r--src/backend/parser/parse_relation.c7
-rw-r--r--src/backend/parser/parse_target.c15
8 files changed, 149 insertions, 90 deletions
diff --git a/src/backend/parser/parse_agg.c b/src/backend/parser/parse_agg.c
index 33e7f677a99..e552d0aa8c2 100644
--- a/src/backend/parser/parse_agg.c
+++ b/src/backend/parser/parse_agg.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/parser/parse_agg.c,v 1.2 1997/11/26 01:11:14 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/parser/parse_agg.c,v 1.3 1997/11/26 03:42:37 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -27,6 +27,10 @@
#include "parser/parse_target.h"
#include "utils/syscache.h"
+static bool contain_agg_clause(Node *clause);
+static bool exprIsAggOrGroupCol(Node *expr, List *groupClause);
+static bool tleIsAggOrGroupCol(TargetEntry *tle, List *groupClause);
+
/*
* AddAggToParseState -
* add the aggregate to the list of unique aggregates in pstate.
@@ -93,7 +97,7 @@ finalizeAggregates(ParseState *pstate, Query *qry)
*
* Returns true if any aggregate found.
*/
-bool
+static bool
contain_agg_clause(Node *clause)
{
if (clause == NULL)
@@ -151,7 +155,7 @@ contain_agg_clause(Node *clause)
* exprIsAggOrGroupCol -
* returns true if the expression does not contain non-group columns.
*/
-bool
+static bool
exprIsAggOrGroupCol(Node *expr, List *groupClause)
{
List *gl;
@@ -185,7 +189,7 @@ exprIsAggOrGroupCol(Node *expr, List *groupClause)
* tleIsAggOrGroupCol -
* returns true if the TargetEntry is Agg or GroupCol.
*/
-bool
+static bool
tleIsAggOrGroupCol(TargetEntry *tle, List *groupClause)
{
Node *expr = tle->expr;
diff --git a/src/backend/parser/parse_clause.c b/src/backend/parser/parse_clause.c
index 3f419716d80..ad40222ba6d 100644
--- a/src/backend/parser/parse_clause.c
+++ b/src/backend/parser/parse_clause.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/parser/parse_clause.c,v 1.2 1997/11/26 01:11:16 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/parser/parse_clause.c,v 1.3 1997/11/26 03:42:39 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -25,45 +25,9 @@
#include "parser/parse_relation.h"
#include "parser/parse_target.h"
-/*
- * parseFromClause -
- * turns the table references specified in the from-clause into a
- * range table. The range table may grow as we transform the expressions
- * in the target list. (Note that this happens because in POSTQUEL, we
- * allow references to relations not specified in the from-clause. We
- * also allow that in our POST-SQL)
- *
- */
-void
-parseFromClause(ParseState *pstate, List *frmList)
-{
- List *fl;
-
- foreach(fl, frmList)
- {
- RangeVar *r = lfirst(fl);
- RelExpr *baserel = r->relExpr;
- char *relname = baserel->relname;
- char *refname = r->name;
- RangeTblEntry *rte;
-
- if (refname == NULL)
- refname = relname;
-
- /*
- * marks this entry to indicate it comes from the FROM clause. In
- * SQL, the target list can only refer to range variables
- * specified in the from clause but we follow the more powerful
- * POSTQUEL semantics and automatically generate the range
- * variable if not specified. However there are times we need to
- * know whether the entries are legitimate.
- *
- * eg. select * from foo f where f.x = 1; will generate wrong answer
- * if we expand * to foo.x.
- */
- rte = addRangeTableEntry(pstate, relname, refname, baserel->inh, TRUE);
- }
-}
+static TargetEntry *find_targetlist_entry(ParseState *pstate,
+ SortGroupBy *sortgroupby, List *tlist);
+static void parseFromClause(ParseState *pstate, List *frmList);
/*
* makeRangeTable -
@@ -92,12 +56,6 @@ makeRangeTable(ParseState *pstate, char *relname, List *frmList)
/* will close relation later */
}
-/*****************************************************************************
- *
- * Where Clause
- *
- *****************************************************************************/
-
/*
* transformWhereClause -
* transforms the qualification and make sure it is of type Boolean
@@ -123,11 +81,45 @@ transformWhereClause(ParseState *pstate, Node *a_expr)
return qual;
}
-/*****************************************************************************
- *
- * Sort Clause
+/*
+ * parseFromClause -
+ * turns the table references specified in the from-clause into a
+ * range table. The range table may grow as we transform the expressions
+ * in the target list. (Note that this happens because in POSTQUEL, we
+ * allow references to relations not specified in the from-clause. We
+ * also allow that in our POST-SQL)
*
- *****************************************************************************/
+ */
+static void
+parseFromClause(ParseState *pstate, List *frmList)
+{
+ List *fl;
+
+ foreach(fl, frmList)
+ {
+ RangeVar *r = lfirst(fl);
+ RelExpr *baserel = r->relExpr;
+ char *relname = baserel->relname;
+ char *refname = r->name;
+ RangeTblEntry *rte;
+
+ if (refname == NULL)
+ refname = relname;
+
+ /*
+ * marks this entry to indicate it comes from the FROM clause. In
+ * SQL, the target list can only refer to range variables
+ * specified in the from clause but we follow the more powerful
+ * POSTQUEL semantics and automatically generate the range
+ * variable if not specified. However there are times we need to
+ * know whether the entries are legitimate.
+ *
+ * eg. select * from foo f where f.x = 1; will generate wrong answer
+ * if we expand * to foo.x.
+ */
+ rte = addRangeTableEntry(pstate, relname, refname, baserel->inh, TRUE);
+ }
+}
/*
* find_targetlist_entry -
@@ -135,7 +127,7 @@ transformWhereClause(ParseState *pstate, Node *a_expr)
* and range
*
*/
-TargetEntry *
+static TargetEntry *
find_targetlist_entry(ParseState *pstate, SortGroupBy *sortgroupby, List *tlist)
{
List *i;
diff --git a/src/backend/parser/parse_expr.c b/src/backend/parser/parse_expr.c
index 5828fbb9740..0b0f9b5d102 100644
--- a/src/backend/parser/parse_expr.c
+++ b/src/backend/parser/parse_expr.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/parser/parse_expr.c,v 1.2 1997/11/26 01:11:17 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/parser/parse_expr.c,v 1.3 1997/11/26 03:42:41 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -22,6 +22,7 @@
#include "nodes/params.h"
#include "nodes/relation.h"
#include "parse.h"
+#include "parser/gramparse.h"
#include "parser/parse_expr.h"
#include "parser/parse_func.h"
#include "parser/parse_node.h"
@@ -29,7 +30,7 @@
#include "parser/parse_target.h"
#include "utils/builtins.h"
-Oid param_type(int t); /* from gram.y */
+static Node *parser_typecast(Value *expr, TypeName *typename, int typlen);
/*
* transformExpr -
@@ -397,7 +398,7 @@ handleNestedDots(ParseState *pstate, Attr *attr, int *curr_resno)
return (retval);
}
-Node *
+static Node *
parser_typecast(Value *expr, TypeName *typename, int typlen)
{
/* check for passing non-ints */
diff --git a/src/backend/parser/parse_func.c b/src/backend/parser/parse_func.c
index 1583dc56f0c..4d1017b54a0 100644
--- a/src/backend/parser/parse_func.c
+++ b/src/backend/parser/parse_func.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/parser/parse_func.c,v 1.2 1997/11/26 01:11:21 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/parser/parse_func.c,v 1.3 1997/11/26 03:42:42 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -42,6 +42,37 @@
#include "utils/lsyscache.h"
#include "utils/syscache.h"
+static Node *ParseComplexProjection(ParseState *pstate,
+ char *funcname,
+ Node *first_arg,
+ bool *attisset);
+static Oid ** argtype_inherit(int nargs, Oid *oid_array);
+static bool can_coerce(int nargs, Oid *input_typeids, Oid *func_typeids);
+static int find_inheritors(Oid relid, Oid **supervec);
+static CandidateList func_get_candidates(char *funcname, int nargs);
+static bool func_get_detail(char *funcname,
+ int nargs,
+ Oid *oid_array,
+ Oid *funcid, /* return value */
+ Oid *rettype, /* return value */
+ bool *retset, /* return value */
+ Oid **true_typeids);
+static Oid * func_select_candidate(int nargs,
+ Oid *input_typeids,
+ CandidateList candidates);
+static Oid funcid_get_rettype(Oid funcid);
+static Oid **gen_cross_product(InhPaths *arginh, int nargs);
+static void make_arguments(int nargs,
+ List *fargs,
+ Oid *input_typeids,
+ Oid *function_typeids);
+static int match_argtypes(int nargs,
+ Oid *input_typeids,
+ CandidateList function_typeids,
+ CandidateList *candidates);
+static List *setup_tlist(char *attname, Oid relid);
+static List *setup_base_tlist(Oid typeid);
+
#define ISCOMPLEX(type) (typeidTypeRelid(type) ? true : false)
#define MAXFARGS 8 /* max # args to a c or postquel function */
@@ -400,7 +431,7 @@ ParseFunc(ParseState *pstate, char *funcname, List *fargs, int *curr_resno)
return (retval);
}
-Oid
+static Oid
funcid_get_rettype(Oid funcid)
{
HeapTuple func_tuple = NULL;
@@ -422,7 +453,7 @@ funcid_get_rettype(Oid funcid)
* get a list of all argument type vectors for which a function named
* funcname taking nargs arguments exists
*/
-CandidateList
+static CandidateList
func_get_candidates(char *funcname, int nargs)
{
Relation heapRelation;
@@ -500,7 +531,7 @@ func_get_candidates(char *funcname, int nargs)
/*
* can input_typeids be coerced to func_typeids?
*/
-bool
+static bool
can_coerce(int nargs, Oid *input_typeids, Oid *func_typeids)
{
int i;
@@ -539,7 +570,7 @@ can_coerce(int nargs, Oid *input_typeids, Oid *func_typeids)
* that match the input typeids (either exactly or by coercion), and
* return the number of such arrays
*/
-int
+static int
match_argtypes(int nargs,
Oid *input_typeids,
CandidateList function_typeids,
@@ -577,7 +608,7 @@ match_argtypes(int nargs,
* returns the selected argtype array if the conflict can be resolved,
* otherwise returns NULL
*/
-Oid *
+static Oid *
func_select_candidate(int nargs,
Oid *input_typeids,
CandidateList candidates)
@@ -586,7 +617,7 @@ func_select_candidate(int nargs,
return (NULL);
}
-bool
+static bool
func_get_detail(char *funcname,
int nargs,
Oid *oid_array,
@@ -731,7 +762,7 @@ func_get_detail(char *funcname,
* not defined. There are lots of these (mostly builtins) in the
* catalogs.
*/
-Oid **
+static Oid **
argtype_inherit(int nargs, Oid *oid_array)
{
Oid relid;
@@ -745,7 +776,7 @@ argtype_inherit(int nargs, Oid *oid_array)
arginh[i].self = oid_array[i];
if ((relid = typeidTypeRelid(oid_array[i])) != InvalidOid)
{
- arginh[i].nsupers = findsupers(relid, &(arginh[i].supervec));
+ arginh[i].nsupers = find_inheritors(relid, &(arginh[i].supervec));
}
else
{
@@ -762,10 +793,10 @@ argtype_inherit(int nargs, Oid *oid_array)
}
/* return an ordered cross-product of the classes involved */
- return (genxprod(arginh, nargs));
+ return (gen_cross_product(arginh, nargs));
}
-int findsupers(Oid relid, Oid **supervec)
+static int find_inheritors(Oid relid, Oid **supervec)
{
Oid *relidvec;
Relation inhrel;
@@ -885,8 +916,8 @@ int findsupers(Oid relid, Oid **supervec)
return (nvisited);
}
-Oid **
-genxprod(InhPaths *arginh, int nargs)
+static Oid **
+gen_cross_product(InhPaths *arginh, int nargs)
{
int nanswers;
Oid **result,
@@ -946,7 +977,7 @@ genxprod(InhPaths *arginh, int nargs)
** Given the number and types of arguments to a function, and the
** actual arguments and argument types, do the necessary typecasting.
*/
-void
+static void
make_arguments(int nargs,
List *fargs,
Oid *input_typeids,
@@ -987,7 +1018,7 @@ make_arguments(int nargs,
** on a tuple parameter or return value. Due to a bug in 4.0,
** it's not possible to refer to system attributes in this case.
*/
-List *
+static List *
setup_tlist(char *attname, Oid relid)
{
TargetEntry *tle;
@@ -1021,7 +1052,7 @@ setup_tlist(char *attname, Oid relid)
** Build a tlist that extracts a base type from the tuple
** returned by the executor.
*/
-List *
+static List *
setup_base_tlist(Oid typeid)
{
TargetEntry *tle;
@@ -1048,7 +1079,7 @@ setup_base_tlist(Oid typeid)
* handles function calls with a single argument that is of complex type.
* This routine returns NULL if it can't handle the projection (eg. sets).
*/
-Node *
+static Node *
ParseComplexProjection(ParseState *pstate,
char *funcname,
Node *first_arg,
diff --git a/src/backend/parser/parse_node.c b/src/backend/parser/parse_node.c
index 574bce472c2..90e182cb711 100644
--- a/src/backend/parser/parse_node.c
+++ b/src/backend/parser/parse_node.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/parser/parse_node.c,v 1.2 1997/11/26 01:11:22 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/parser/parse_node.c,v 1.3 1997/11/26 03:42:44 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -28,6 +28,12 @@
#include "utils/builtins.h"
#include "utils/syscache.h"
+static void disallow_setop(char *op, Type optype, Node *operand);
+static Node *make_operand(char *opname,
+ Node *tree,
+ Oid orig_typeId,
+ Oid true_typeId);
+
/*
* make_parsestate() --
* allocate and initialize a new ParseState.
@@ -56,7 +62,7 @@ make_parsestate(void)
return (pstate);
}
-Node *
+static Node *
make_operand(char *opname,
Node *tree,
Oid orig_typeId,
@@ -110,7 +116,7 @@ make_operand(char *opname,
}
-void
+static void
disallow_setop(char *op, Type optype, Node *operand)
{
if (operand == NULL)
diff --git a/src/backend/parser/parse_oper.c b/src/backend/parser/parse_oper.c
index e3932806f3d..ddc97a45239 100644
--- a/src/backend/parser/parse_oper.c
+++ b/src/backend/parser/parse_oper.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/parser/parse_oper.c,v 1.2 1997/11/26 01:11:24 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/parser/parse_oper.c,v 1.3 1997/11/26 03:42:45 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -26,6 +26,21 @@
#include "storage/bufmgr.h"
#include "utils/syscache.h"
+static int binary_oper_get_candidates(char *opname,
+ Oid leftTypeId,
+ Oid rightTypeId,
+ CandidateList *candidates);
+static CandidateList binary_oper_select_candidate(Oid arg1,
+ Oid arg2,
+ CandidateList candidates);
+static bool equivalentOpersAfterPromotion(CandidateList candidates);
+static void op_error(char *op, Oid arg1, Oid arg2);
+static int unary_oper_get_candidates(char *op,
+ Oid typeId,
+ CandidateList *candidates,
+ char rightleft);
+
+
Oid
any_ordering_op(int restype)
{
@@ -51,7 +66,7 @@ oprid(Operator op)
* opname exists, such that leftTypeId can be coerced to arg1 and
* rightTypeId can be coerced to arg2
*/
-int
+static int
binary_oper_get_candidates(char *opname,
Oid leftTypeId,
Oid rightTypeId,
@@ -149,7 +164,7 @@ binary_oper_get_candidates(char *opname,
* the all the candidates operate on the same data types after
* promotion (int2, int4, float4 -> float8).
*/
-bool
+static bool
equivalentOpersAfterPromotion(CandidateList candidates)
{
CandidateList result;
@@ -223,7 +238,7 @@ equivalentOpersAfterPromotion(CandidateList candidates)
* given a choice of argument type pairs for a binary operator,
* try to choose a default pair
*/
-CandidateList
+static CandidateList
binary_oper_select_candidate(Oid arg1,
Oid arg2,
CandidateList candidates)
@@ -366,7 +381,7 @@ oper(char *op, Oid arg1, Oid arg2, bool noWarnings)
* a right/left unary operator named opname exists,
* such that typeId can be coerced to it
*/
-int
+static int
unary_oper_get_candidates(char *op,
Oid typeId,
CandidateList *candidates,
@@ -548,7 +563,7 @@ outstr(char *typename, /* Name of type of value */
* Give a somewhat useful error message when the operator for two types
* is not found.
*/
-void
+static void
op_error(char *op, Oid arg1, Oid arg2)
{
Type tp1 = NULL,
diff --git a/src/backend/parser/parse_relation.c b/src/backend/parser/parse_relation.c
index 7f550c6b85e..2b880213d7d 100644
--- a/src/backend/parser/parse_relation.c
+++ b/src/backend/parser/parse_relation.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/parser/parse_relation.c,v 1.2 1997/11/26 01:11:28 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/parser/parse_relation.c,v 1.3 1997/11/26 03:42:48 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -24,6 +24,9 @@
#include "utils/builtins.h"
#include "utils/lsyscache.h"
+static void checkTargetTypes(ParseState *pstate, char *target_colname,
+ char *refname, char *colname);
+
struct
{
char *field;
@@ -415,7 +418,7 @@ handleTargetColname(ParseState *pstate, char **resname,
* checkTargetTypes -
* checks value and target column types
*/
-void
+static void
checkTargetTypes(ParseState *pstate, char *target_colname,
char *refname, char *colname)
{
diff --git a/src/backend/parser/parse_target.c b/src/backend/parser/parse_target.c
index e2aff8c87dc..04739fe5503 100644
--- a/src/backend/parser/parse_target.c
+++ b/src/backend/parser/parse_target.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/parser/parse_target.c,v 1.2 1997/11/26 01:11:30 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/parser/parse_target.c,v 1.3 1997/11/26 03:42:49 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -25,6 +25,13 @@
#include "parser/parse_target.h"
#include "utils/builtins.h"
+static List *expandAllTables(ParseState *pstate);
+static char *figureColname(Node *expr, Node *resval);
+static TargetEntry *make_targetlist_expr(ParseState *pstate,
+ char *colname,
+ Node *expr,
+ List *arrayRef);
+
/*
* transformTargetList -
* turns a list of ResTarget's into a list of TargetEntry's
@@ -310,7 +317,7 @@ transformTargetList(ParseState *pstate, List *targetlist)
*
* arrayRef is a list of transformed A_Indices
*/
-TargetEntry *
+static TargetEntry *
make_targetlist_expr(ParseState *pstate,
char *colname,
Node *expr,
@@ -568,7 +575,7 @@ makeTargetNames(ParseState *pstate, List *cols)
* turns '*' (in the target list) into a list of attributes
* (of all relations in the range table)
*/
-List *
+static List *
expandAllTables(ParseState *pstate)
{
List *target = NIL;
@@ -633,7 +640,7 @@ expandAllTables(ParseState *pstate)
* list, we have to guess.
*
*/
-char *
+static char *
figureColname(Node *expr, Node *resval)
{
switch (nodeTag(expr))