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

Function print_function_arguments

src/backend/utils/adt/ruleutils.c:3174–3320  ·  view source on GitHub ↗

* Common code for pg_get_function_arguments and pg_get_function_result: * append the desired subset of arguments to buf. We print only TABLE * arguments when print_table_args is true, and all the others when it's false. * We print argument defaults only if print_defaults is true. * Function return value is the number of arguments printed. */

Source from the content-addressed store, hash-verified

3172 * Function return value is the number of arguments printed.
3173 */
3174static int
3175print_function_arguments(StringInfo buf, HeapTuple proctup,
3176 bool print_table_args, bool print_defaults)
3177{
3178 Form_pg_proc proc = (Form_pg_proc) GETSTRUCT(proctup);
3179 int numargs;
3180 Oid *argtypes;
3181 char **argnames;
3182 char *argmodes;
3183 int insertorderbyat = -1;
3184 int argsprinted;
3185 int inputargno;
3186 int nlackdefaults;
3187 List *argdefaults = NIL;
3188 ListCell *nextargdefault = NULL;
3189 int i;
3190
3191 numargs = get_func_arg_info(proctup,
3192 &argtypes, &argnames, &argmodes);
3193
3194 nlackdefaults = numargs;
3195 if (print_defaults && proc->pronargdefaults > 0)
3196 {
3197 Datum proargdefaults;
3198 bool isnull;
3199
3200 proargdefaults = SysCacheGetAttr(PROCOID, proctup,
3201 Anum_pg_proc_proargdefaults,
3202 &isnull);
3203 if (!isnull)
3204 {
3205 char *str;
3206
3207 str = TextDatumGetCString(proargdefaults);
3208 argdefaults = castNode(List, stringToNode(str));
3209 pfree(str);
3210 nextargdefault = list_head(argdefaults);
3211 /* nlackdefaults counts only *input* arguments lacking defaults */
3212 nlackdefaults = proc->pronargs - list_length(argdefaults);
3213 }
3214 }
3215
3216 /* Check for special treatment of ordered-set aggregates */
3217 if (proc->prokind == PROKIND_AGGREGATE)
3218 {
3219 HeapTuple aggtup;
3220 Form_pg_aggregate agg;
3221
3222 aggtup = SearchSysCache1(AGGFNOID, proc->oid);
3223 if (!HeapTupleIsValid(aggtup))
3224 elog(ERROR, "cache lookup failed for aggregate %u",
3225 proc->oid);
3226 agg = (Form_pg_aggregate) GETSTRUCT(aggtup);
3227 if (AGGKIND_IS_ORDERED_SET(agg->aggkind))
3228 insertorderbyat = agg->aggnumdirectargs;
3229 ReleaseSysCache(aggtup);
3230 }
3231

Callers 4

pg_get_functiondefFunction · 0.85
print_function_rettypeFunction · 0.85

Calls 15

get_func_arg_infoFunction · 0.85
SysCacheGetAttrFunction · 0.85
stringToNodeFunction · 0.85
list_headFunction · 0.85
list_lengthFunction · 0.85
SearchSysCache1Function · 0.85
ReleaseSysCacheFunction · 0.85
appendStringInfoCharFunction · 0.85
appendStringInfoStringFunction · 0.85
appendStringInfoFunction · 0.85
format_type_beFunction · 0.85
lnextFunction · 0.85

Tested by

no test coverage detected