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

Commit 5ec8474

Browse files
committed
New comment. This func/column things has always confused me.
/* * parse function * This code is confusing because the database can accept * relation.column, column.function, or relation.column.function. * In these cases, funcname is the last parameter, and fargs are * the rest. * * It can also be called as func(col) or func(col,col). * In this case, Funcname is the part before parens, and fargs * are the part in parens. * */ Node * ParseFuncOrColumn(ParseState *pstate, char *funcname, List *fargs, bool agg_star, bool agg_distinct, int precedence)
1 parent f61d70c commit 5ec8474

File tree

3 files changed

+19
-15
lines changed

3 files changed

+19
-15
lines changed

src/backend/parser/parse_expr.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/parser/parse_expr.c,v 1.94 2001/05/18 22:35:50 momjian Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/parser/parse_expr.c,v 1.95 2001/05/19 00:33:20 momjian Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -173,7 +173,7 @@ transformExpr(ParseState *pstate, Node *expr, int precedence)
173173
a->lexpr,
174174
precedence);
175175

176-
result = ParseColumnOrFunc(pstate,
176+
result = ParseFuncOrColumn(pstate,
177177
"nullvalue",
178178
makeList1(lexpr),
179179
false, false,
@@ -186,7 +186,7 @@ transformExpr(ParseState *pstate, Node *expr, int precedence)
186186
a->lexpr,
187187
precedence);
188188

189-
result = ParseColumnOrFunc(pstate,
189+
result = ParseFuncOrColumn(pstate,
190190
"nonnullvalue",
191191
makeList1(lexpr),
192192
false, false,
@@ -273,7 +273,7 @@ transformExpr(ParseState *pstate, Node *expr, int precedence)
273273
lfirst(args) = transformExpr(pstate,
274274
(Node *) lfirst(args),
275275
precedence);
276-
result = ParseColumnOrFunc(pstate,
276+
result = ParseFuncOrColumn(pstate,
277277
fn->funcname,
278278
fn->args,
279279
fn->agg_star,

src/backend/parser/parse_func.c

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/parser/parse_func.c,v 1.105 2001/05/18 22:54:23 momjian Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/parser/parse_func.c,v 1.106 2001/05/19 00:33:20 momjian Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -75,7 +75,7 @@ ParseNestedFuncOrColumn(ParseState *pstate, Attr *attr, int precedence)
7575
(Node *) attr->paramNo,
7676
EXPR_RELATION_FIRST);
7777

78-
retval = ParseColumnOrFunc(pstate, strVal(lfirst(attr->attrs)),
78+
retval = ParseFuncOrColumn(pstate, strVal(lfirst(attr->attrs)),
7979
makeList1(param),
8080
false, false,
8181
precedence);
@@ -86,7 +86,7 @@ ParseNestedFuncOrColumn(ParseState *pstate, Attr *attr, int precedence)
8686

8787
ident->name = attr->relname;
8888
ident->isRel = TRUE;
89-
retval = ParseColumnOrFunc(pstate, strVal(lfirst(attr->attrs)),
89+
retval = ParseFuncOrColumn(pstate, strVal(lfirst(attr->attrs)),
9090
makeList1(ident),
9191
false, false,
9292
precedence);
@@ -95,7 +95,7 @@ ParseNestedFuncOrColumn(ParseState *pstate, Attr *attr, int precedence)
9595
/* Do more attributes follow this one? */
9696
foreach(mutator_iter, lnext(attr->attrs))
9797
{
98-
retval = ParseColumnOrFunc(pstate, strVal(lfirst(mutator_iter)),
98+
retval = ParseFuncOrColumn(pstate, strVal(lfirst(mutator_iter)),
9999
makeList1(retval),
100100
false, false,
101101
precedence);
@@ -236,14 +236,18 @@ agg_select_candidate(Oid typeid, CandidateList candidates)
236236

237237
/*
238238
* parse function
239-
* This code is confusing code because the database can accept
239+
* This code is confusing because the database can accept
240240
* relation.column, column.function, or relation.column.function.
241+
* In these cases, funcname is the last parameter, and fargs are
242+
* the rest.
243+
*
241244
* It can also be called as func(col) or func(col,col).
245+
* In this case, Funcname is the part before parens, and fargs
246+
* are the part in parens.
242247
*
243-
* Funcname is the first parameter, and fargs are the rest.
244248
*/
245249
Node *
246-
ParseColumnOrFunc(ParseState *pstate, char *funcname, List *fargs,
250+
ParseFuncOrColumn(ParseState *pstate, char *funcname, List *fargs,
247251
bool agg_star, bool agg_distinct,
248252
int precedence)
249253
{
@@ -491,7 +495,7 @@ ParseColumnOrFunc(ParseState *pstate, char *funcname, List *fargs,
491495
}
492496
else
493497
{
494-
elog(ERROR, "ParseColumnOrFunc: unexpected node type %d",
498+
elog(ERROR, "ParseFuncOrColumn: unexpected node type %d",
495499
nodeTag(rteorjoin));
496500
rte = NULL; /* keep compiler quiet */
497501
}
@@ -1540,7 +1544,7 @@ make_arguments(ParseState *pstate,
15401544
/*
15411545
** setup_field_select
15421546
** Build a FieldSelect node that says which attribute to project to.
1543-
** This routine is called by ParseColumnOrFunc() when we have found
1547+
** This routine is called by ParseFuncOrColumn() when we have found
15441548
** a projection on a function result or parameter.
15451549
*/
15461550
static FieldSelect *

src/include/parser/parse_func.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $Id: parse_func.h,v 1.30 2001/05/18 22:35:51 momjian Exp $
10+
* $Id: parse_func.h,v 1.31 2001/05/19 00:33:20 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -40,7 +40,7 @@ typedef struct _CandidateList
4040

4141
extern Node *ParseNestedFuncOrColumn(ParseState *pstate, Attr *attr,
4242
int precedence);
43-
extern Node *ParseColumnOrFunc(ParseState *pstate,
43+
extern Node *ParseFuncOrColumn(ParseState *pstate,
4444
char *funcname, List *fargs,
4545
bool agg_star, bool agg_distinct,
4646
int precedence);

0 commit comments

Comments
 (0)