Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit b704426

Browse files
committed
Make parser functions static where possible.
1 parent 97ad0b1 commit b704426

18 files changed

+163
-165
lines changed

src/backend/parser/parse_agg.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/parser/parse_agg.c,v 1.2 1997/11/26 01:11:14 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/parser/parse_agg.c,v 1.3 1997/11/26 03:42:37 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -27,6 +27,10 @@
2727
#include "parser/parse_target.h"
2828
#include "utils/syscache.h"
2929

30+
static bool contain_agg_clause(Node *clause);
31+
static bool exprIsAggOrGroupCol(Node *expr, List *groupClause);
32+
static bool tleIsAggOrGroupCol(TargetEntry *tle, List *groupClause);
33+
3034
/*
3135
* AddAggToParseState -
3236
* add the aggregate to the list of unique aggregates in pstate.
@@ -93,7 +97,7 @@ finalizeAggregates(ParseState *pstate, Query *qry)
9397
*
9498
* Returns true if any aggregate found.
9599
*/
96-
bool
100+
static bool
97101
contain_agg_clause(Node *clause)
98102
{
99103
if (clause == NULL)
@@ -151,7 +155,7 @@ contain_agg_clause(Node *clause)
151155
* exprIsAggOrGroupCol -
152156
* returns true if the expression does not contain non-group columns.
153157
*/
154-
bool
158+
static bool
155159
exprIsAggOrGroupCol(Node *expr, List *groupClause)
156160
{
157161
List *gl;
@@ -185,7 +189,7 @@ exprIsAggOrGroupCol(Node *expr, List *groupClause)
185189
* tleIsAggOrGroupCol -
186190
* returns true if the TargetEntry is Agg or GroupCol.
187191
*/
188-
bool
192+
static bool
189193
tleIsAggOrGroupCol(TargetEntry *tle, List *groupClause)
190194
{
191195
Node *expr = tle->expr;

src/backend/parser/parse_clause.c

Lines changed: 43 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/parser/parse_clause.c,v 1.2 1997/11/26 01:11:16 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/parser/parse_clause.c,v 1.3 1997/11/26 03:42:39 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -25,45 +25,9 @@
2525
#include "parser/parse_relation.h"
2626
#include "parser/parse_target.h"
2727

28-
/*
29-
* parseFromClause -
30-
* turns the table references specified in the from-clause into a
31-
* range table. The range table may grow as we transform the expressions
32-
* in the target list. (Note that this happens because in POSTQUEL, we
33-
* allow references to relations not specified in the from-clause. We
34-
* also allow that in our POST-SQL)
35-
*
36-
*/
37-
void
38-
parseFromClause(ParseState *pstate, List *frmList)
39-
{
40-
List *fl;
41-
42-
foreach(fl, frmList)
43-
{
44-
RangeVar *r = lfirst(fl);
45-
RelExpr *baserel = r->relExpr;
46-
char *relname = baserel->relname;
47-
char *refname = r->name;
48-
RangeTblEntry *rte;
49-
50-
if (refname == NULL)
51-
refname = relname;
52-
53-
/*
54-
* marks this entry to indicate it comes from the FROM clause. In
55-
* SQL, the target list can only refer to range variables
56-
* specified in the from clause but we follow the more powerful
57-
* POSTQUEL semantics and automatically generate the range
58-
* variable if not specified. However there are times we need to
59-
* know whether the entries are legitimate.
60-
*
61-
* eg. select * from foo f where f.x = 1; will generate wrong answer
62-
* if we expand * to foo.x.
63-
*/
64-
rte = addRangeTableEntry(pstate, relname, refname, baserel->inh, TRUE);
65-
}
66-
}
28+
static TargetEntry *find_targetlist_entry(ParseState *pstate,
29+
SortGroupBy *sortgroupby, List *tlist);
30+
static void parseFromClause(ParseState *pstate, List *frmList);
6731

6832
/*
6933
* makeRangeTable -
@@ -92,12 +56,6 @@ makeRangeTable(ParseState *pstate, char *relname, List *frmList)
9256
/* will close relation later */
9357
}
9458

95-
/*****************************************************************************
96-
*
97-
* Where Clause
98-
*
99-
*****************************************************************************/
100-
10159
/*
10260
* transformWhereClause -
10361
* transforms the qualification and make sure it is of type Boolean
@@ -123,19 +81,53 @@ transformWhereClause(ParseState *pstate, Node *a_expr)
12381
return qual;
12482
}
12583

126-
/*****************************************************************************
127-
*
128-
* Sort Clause
84+
/*
85+
* parseFromClause -
86+
* turns the table references specified in the from-clause into a
87+
* range table. The range table may grow as we transform the expressions
88+
* in the target list. (Note that this happens because in POSTQUEL, we
89+
* allow references to relations not specified in the from-clause. We
90+
* also allow that in our POST-SQL)
12991
*
130-
*****************************************************************************/
92+
*/
93+
static void
94+
parseFromClause(ParseState *pstate, List *frmList)
95+
{
96+
List *fl;
97+
98+
foreach(fl, frmList)
99+
{
100+
RangeVar *r = lfirst(fl);
101+
RelExpr *baserel = r->relExpr;
102+
char *relname = baserel->relname;
103+
char *refname = r->name;
104+
RangeTblEntry *rte;
105+
106+
if (refname == NULL)
107+
refname = relname;
108+
109+
/*
110+
* marks this entry to indicate it comes from the FROM clause. In
111+
* SQL, the target list can only refer to range variables
112+
* specified in the from clause but we follow the more powerful
113+
* POSTQUEL semantics and automatically generate the range
114+
* variable if not specified. However there are times we need to
115+
* know whether the entries are legitimate.
116+
*
117+
* eg. select * from foo f where f.x = 1; will generate wrong answer
118+
* if we expand * to foo.x.
119+
*/
120+
rte = addRangeTableEntry(pstate, relname, refname, baserel->inh, TRUE);
121+
}
122+
}
131123

132124
/*
133125
* find_targetlist_entry -
134126
* returns the Resdom in the target list matching the specified varname
135127
* and range
136128
*
137129
*/
138-
TargetEntry *
130+
static TargetEntry *
139131
find_targetlist_entry(ParseState *pstate, SortGroupBy *sortgroupby, List *tlist)
140132
{
141133
List *i;

src/backend/parser/parse_expr.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/parser/parse_expr.c,v 1.2 1997/11/26 01:11:17 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/parser/parse_expr.c,v 1.3 1997/11/26 03:42:41 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -22,14 +22,15 @@
2222
#include "nodes/params.h"
2323
#include "nodes/relation.h"
2424
#include "parse.h"
25+
#include "parser/gramparse.h"
2526
#include "parser/parse_expr.h"
2627
#include "parser/parse_func.h"
2728
#include "parser/parse_node.h"
2829
#include "parser/parse_relation.h"
2930
#include "parser/parse_target.h"
3031
#include "utils/builtins.h"
3132

32-
Oid param_type(int t); /* from gram.y */
33+
static Node *parser_typecast(Value *expr, TypeName *typename, int typlen);
3334

3435
/*
3536
* transformExpr -
@@ -397,7 +398,7 @@ handleNestedDots(ParseState *pstate, Attr *attr, int *curr_resno)
397398
return (retval);
398399
}
399400

400-
Node *
401+
static Node *
401402
parser_typecast(Value *expr, TypeName *typename, int typlen)
402403
{
403404
/* check for passing non-ints */

src/backend/parser/parse_func.c

Lines changed: 48 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/parser/parse_func.c,v 1.2 1997/11/26 01:11:21 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/parser/parse_func.c,v 1.3 1997/11/26 03:42:42 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -42,6 +42,37 @@
4242
#include "utils/lsyscache.h"
4343
#include "utils/syscache.h"
4444

45+
static Node *ParseComplexProjection(ParseState *pstate,
46+
char *funcname,
47+
Node *first_arg,
48+
bool *attisset);
49+
static Oid ** argtype_inherit(int nargs, Oid *oid_array);
50+
static bool can_coerce(int nargs, Oid *input_typeids, Oid *func_typeids);
51+
static int find_inheritors(Oid relid, Oid **supervec);
52+
static CandidateList func_get_candidates(char *funcname, int nargs);
53+
static bool func_get_detail(char *funcname,
54+
int nargs,
55+
Oid *oid_array,
56+
Oid *funcid, /* return value */
57+
Oid *rettype, /* return value */
58+
bool *retset, /* return value */
59+
Oid **true_typeids);
60+
static Oid * func_select_candidate(int nargs,
61+
Oid *input_typeids,
62+
CandidateList candidates);
63+
static Oid funcid_get_rettype(Oid funcid);
64+
static Oid **gen_cross_product(InhPaths *arginh, int nargs);
65+
static void make_arguments(int nargs,
66+
List *fargs,
67+
Oid *input_typeids,
68+
Oid *function_typeids);
69+
static int match_argtypes(int nargs,
70+
Oid *input_typeids,
71+
CandidateList function_typeids,
72+
CandidateList *candidates);
73+
static List *setup_tlist(char *attname, Oid relid);
74+
static List *setup_base_tlist(Oid typeid);
75+
4576
#define ISCOMPLEX(type) (typeidTypeRelid(type) ? true : false)
4677

4778
#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)
400431
return (retval);
401432
}
402433

403-
Oid
434+
static Oid
404435
funcid_get_rettype(Oid funcid)
405436
{
406437
HeapTuple func_tuple = NULL;
@@ -422,7 +453,7 @@ funcid_get_rettype(Oid funcid)
422453
* get a list of all argument type vectors for which a function named
423454
* funcname taking nargs arguments exists
424455
*/
425-
CandidateList
456+
static CandidateList
426457
func_get_candidates(char *funcname, int nargs)
427458
{
428459
Relation heapRelation;
@@ -500,7 +531,7 @@ func_get_candidates(char *funcname, int nargs)
500531
/*
501532
* can input_typeids be coerced to func_typeids?
502533
*/
503-
bool
534+
static bool
504535
can_coerce(int nargs, Oid *input_typeids, Oid *func_typeids)
505536
{
506537
int i;
@@ -539,7 +570,7 @@ can_coerce(int nargs, Oid *input_typeids, Oid *func_typeids)
539570
* that match the input typeids (either exactly or by coercion), and
540571
* return the number of such arrays
541572
*/
542-
int
573+
static int
543574
match_argtypes(int nargs,
544575
Oid *input_typeids,
545576
CandidateList function_typeids,
@@ -577,7 +608,7 @@ match_argtypes(int nargs,
577608
* returns the selected argtype array if the conflict can be resolved,
578609
* otherwise returns NULL
579610
*/
580-
Oid *
611+
static Oid *
581612
func_select_candidate(int nargs,
582613
Oid *input_typeids,
583614
CandidateList candidates)
@@ -586,7 +617,7 @@ func_select_candidate(int nargs,
586617
return (NULL);
587618
}
588619

589-
bool
620+
static bool
590621
func_get_detail(char *funcname,
591622
int nargs,
592623
Oid *oid_array,
@@ -731,7 +762,7 @@ func_get_detail(char *funcname,
731762
* not defined. There are lots of these (mostly builtins) in the
732763
* catalogs.
733764
*/
734-
Oid **
765+
static Oid **
735766
argtype_inherit(int nargs, Oid *oid_array)
736767
{
737768
Oid relid;
@@ -745,7 +776,7 @@ argtype_inherit(int nargs, Oid *oid_array)
745776
arginh[i].self = oid_array[i];
746777
if ((relid = typeidTypeRelid(oid_array[i])) != InvalidOid)
747778
{
748-
arginh[i].nsupers = findsupers(relid, &(arginh[i].supervec));
779+
arginh[i].nsupers = find_inheritors(relid, &(arginh[i].supervec));
749780
}
750781
else
751782
{
@@ -762,10 +793,10 @@ argtype_inherit(int nargs, Oid *oid_array)
762793
}
763794

764795
/* return an ordered cross-product of the classes involved */
765-
return (genxprod(arginh, nargs));
796+
return (gen_cross_product(arginh, nargs));
766797
}
767798

768-
int findsupers(Oid relid, Oid **supervec)
799+
static int find_inheritors(Oid relid, Oid **supervec)
769800
{
770801
Oid *relidvec;
771802
Relation inhrel;
@@ -885,8 +916,8 @@ int findsupers(Oid relid, Oid **supervec)
885916
return (nvisited);
886917
}
887918

888-
Oid **
889-
genxprod(InhPaths *arginh, int nargs)
919+
static Oid **
920+
gen_cross_product(InhPaths *arginh, int nargs)
890921
{
891922
int nanswers;
892923
Oid **result,
@@ -946,7 +977,7 @@ genxprod(InhPaths *arginh, int nargs)
946977
** Given the number and types of arguments to a function, and the
947978
** actual arguments and argument types, do the necessary typecasting.
948979
*/
949-
void
980+
static void
950981
make_arguments(int nargs,
951982
List *fargs,
952983
Oid *input_typeids,
@@ -987,7 +1018,7 @@ make_arguments(int nargs,
9871018
** on a tuple parameter or return value. Due to a bug in 4.0,
9881019
** it's not possible to refer to system attributes in this case.
9891020
*/
990-
List *
1021+
static List *
9911022
setup_tlist(char *attname, Oid relid)
9921023
{
9931024
TargetEntry *tle;
@@ -1021,7 +1052,7 @@ setup_tlist(char *attname, Oid relid)
10211052
** Build a tlist that extracts a base type from the tuple
10221053
** returned by the executor.
10231054
*/
1024-
List *
1055+
static List *
10251056
setup_base_tlist(Oid typeid)
10261057
{
10271058
TargetEntry *tle;
@@ -1048,7 +1079,7 @@ setup_base_tlist(Oid typeid)
10481079
* handles function calls with a single argument that is of complex type.
10491080
* This routine returns NULL if it can't handle the projection (eg. sets).
10501081
*/
1051-
Node *
1082+
static Node *
10521083
ParseComplexProjection(ParseState *pstate,
10531084
char *funcname,
10541085
Node *first_arg,

0 commit comments

Comments
 (0)