MCPcopy Create free account
hub / github.com/apache/cloudberry / ParseFuncOrColumn

Function ParseFuncOrColumn

src/backend/parser/parse_func.c:97–958  ·  view source on GitHub ↗

* Parse a function call * * For historical reasons, Postgres tries to treat the notations tab.col * and col(tab) as equivalent: if a single-argument function call has an * argument of complex type and the (unqualified) function name matches * any attribute of the type, we can interpret it as a column projection. * Conversely a function of a single complex-type argument can be written * like

Source from the content-addressed store, hash-verified

95 * also specifies that the argument list includes any OUT-mode arguments.
96 */
97Node *
98ParseFuncOrColumn(ParseState *pstate, List *funcname, List *fargs,
99 Node *last_srf, FuncCall *fn, bool proc_call, int location)
100{
101 bool is_column = (fn == NULL);
102 List *agg_order = (fn ? fn->agg_order : NIL);
103 Expr *agg_filter = NULL;
104 WindowDef *over = (fn ? fn->over : NULL);
105 bool agg_within_group = (fn ? fn->agg_within_group : false);
106 bool agg_star = (fn ? fn->agg_star : false);
107 bool agg_distinct = (fn ? fn->agg_distinct : false);
108 bool func_variadic = (fn ? fn->func_variadic : false);
109 CoercionForm funcformat = (fn ? fn->funcformat : COERCE_EXPLICIT_CALL);
110 bool could_be_projection;
111 Oid rettype;
112 Oid funcid;
113 ListCell *l;
114 Node *first_arg = NULL;
115 int nargs;
116 int nargsplusdefs;
117 Oid actual_arg_types[FUNC_MAX_ARGS];
118 Oid *declared_arg_types;
119 List *argnames;
120 List *argdefaults;
121 Node *retval;
122 bool retset;
123 int nvargs;
124 Oid vatype;
125 FuncDetailCode fdresult;
126 char aggkind = 0;
127 ParseCallbackState pcbstate;
128
129 /*
130 * If there's an aggregate filter, transform it using transformWhereClause
131 */
132 if (fn && fn->agg_filter != NULL)
133 agg_filter = (Expr *) transformWhereClause(pstate, fn->agg_filter,
134 EXPR_KIND_FILTER,
135 "FILTER");
136
137 /*
138 * Most of the rest of the parser just assumes that functions do not have
139 * more than FUNC_MAX_ARGS parameters. We have to test here to protect
140 * against array overruns, etc. Of course, this may not be a function,
141 * but the test doesn't hurt.
142 */
143 if (list_length(fargs) > FUNC_MAX_ARGS)
144 ereport(ERROR,
145 (errcode(ERRCODE_TOO_MANY_ARGUMENTS),
146 errmsg_plural("cannot pass more than %d argument to a function",
147 "cannot pass more than %d arguments to a function",
148 FUNC_MAX_ARGS,
149 FUNC_MAX_ARGS),
150 parser_errposition(pstate, location)));
151
152 /*
153 * Extract arg type info in preparation for function lookup.
154 *

Callers 8

rewriteQueryForIMMVFunction · 0.85
makeIvmAggColumnFunction · 0.85
transformCallStmtFunction · 0.85
transformIndirectionFunction · 0.85
transformColumnRefFunction · 0.85
transformFuncCallFunction · 0.85
sql_fn_post_column_refFunction · 0.85

Calls 15

transformWhereClauseFunction · 0.85
list_lengthFunction · 0.85
parser_errpositionFunction · 0.85
exprTypeFunction · 0.85
lappendFunction · 0.85
exprLocationFunction · 0.85
ParseComplexProjectionFunction · 0.85
func_get_detailFunction · 0.85
func_signature_stringFunction · 0.85
NameListToStringFunction · 0.85

Tested by

no test coverage detected