29 #include "utils/fmgroids.h"
70 #define FUNCS_PER_USER 128
83 #include "plerrcodes.h"
104 ColumnRef *cref,
bool error_if_no_field);
116 Oid *argtypes,
char *argmodes,
117 Node *call_expr,
bool forValidator,
143 bool function_valid =
false;
144 bool hashkey_valid =
false;
151 elog(
ERROR,
"cache lookup failed for function %u", funcOid);
165 hashkey_valid =
true;
176 function_valid =
true;
224 function =
do_compile(fcinfo, procTup,
function,
225 &hashkey, forValidator);
285 int num_out_args = 0;
289 int *in_arg_varnos = NULL;
308 plerrcontext.
arg = forValidator ? proc_source : NULL;
323 if (
function == NULL)
348 function->fn_tid = procTup->
t_self;
349 function->fn_input_collation = fcinfo->
fncollation;
350 function->fn_cxt = func_cxt;
351 function->out_param_varno = -1;
360 else if (is_event_trigger)
365 function->fn_prokind = procStruct->prokind;
367 function->nstatements = 0;
368 function->requires_procedure_resowner =
false;
395 &argtypes, &argnames, &argmodes);
402 in_arg_varnos = (
int *)
palloc(numargs *
sizeof(
int));
410 for (
i = 0;
i < numargs;
i++)
413 Oid argtypeid = argtypes[
i];
414 char argmode = argmodes ? argmodes[
i] : PROARGMODE_IN;
433 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
434 errmsg(
"PL/pgSQL functions cannot accept type %s",
442 argnames[
i][0] !=
'\0') ?
457 if (argmode == PROARGMODE_IN ||
458 argmode == PROARGMODE_INOUT ||
459 argmode == PROARGMODE_VARIADIC)
460 in_arg_varnos[num_in_args++] = argvariable->
dno;
461 if (argmode == PROARGMODE_OUT ||
462 argmode == PROARGMODE_INOUT ||
463 argmode == PROARGMODE_TABLE)
464 out_arg_variables[num_out_args++] = argvariable;
470 if (argnames && argnames[
i][0] !=
'\0')
481 if (num_out_args > 1 ||
482 (num_out_args == 1 &&
function->fn_prokind == PROKIND_PROCEDURE))
488 function->out_param_varno = row->
dno;
490 else if (num_out_args == 1)
491 function->out_param_varno = out_arg_variables[0]->
dno;
503 rettypeid = procStruct->prorettype;
504 if (IsPolymorphicType(rettypeid))
508 if (rettypeid == ANYARRAYOID ||
509 rettypeid == ANYCOMPATIBLEARRAYOID)
510 rettypeid = INT4ARRAYOID;
511 else if (rettypeid == ANYRANGEOID ||
512 rettypeid == ANYCOMPATIBLERANGEOID)
513 rettypeid = INT4RANGEOID;
514 else if (rettypeid == ANYMULTIRANGEOID)
515 rettypeid = INT4MULTIRANGEOID;
525 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
526 errmsg(
"could not determine actual return type "
527 "for polymorphic function \"%s\"",
535 function->fn_rettype = rettypeid;
536 function->fn_retset = procStruct->proretset;
543 elog(
ERROR,
"cache lookup failed for type %u", rettypeid);
548 if (typeStruct->typtype == TYPTYPE_PSEUDO)
550 if (rettypeid == VOIDOID ||
551 rettypeid == RECORDOID)
553 else if (rettypeid == TRIGGEROID || rettypeid == EVENT_TRIGGEROID)
555 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
556 errmsg(
"trigger functions can only be called as triggers")));
559 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
560 errmsg(
"PL/pgSQL functions cannot return type %s",
565 function->fn_retisdomain = (typeStruct->typtype == TYPTYPE_DOMAIN);
566 function->fn_retbyval = typeStruct->typbyval;
567 function->fn_rettyplen = typeStruct->typlen;
574 if (IsPolymorphicType(procStruct->prorettype) &&
591 function->fn_retbyval =
false;
592 function->fn_retistuple =
true;
593 function->fn_retisdomain =
false;
594 function->fn_retset =
false;
597 if (procStruct->pronargs != 0)
599 (
errcode(ERRCODE_INVALID_FUNCTION_DEFINITION),
600 errmsg(
"trigger functions cannot have declared arguments"),
601 errhint(
"The arguments of the trigger can be accessed through TG_NARGS and TG_ARGV instead.")));
605 function->new_varno = rec->
dno;
609 function->old_varno = rec->
dno;
724 function->fn_rettype = VOIDOID;
725 function->fn_retbyval =
false;
726 function->fn_retistuple =
true;
727 function->fn_retisdomain =
false;
728 function->fn_retset =
false;
731 if (procStruct->pronargs != 0)
733 (
errcode(ERRCODE_INVALID_FUNCTION_DEFINITION),
734 errmsg(
"event trigger functions cannot have declared arguments")));
761 elog(
ERROR,
"unrecognized function typecode: %d",
767 function->fn_readonly = (procStruct->provolatile != PROVOLATILE_VOLATILE);
778 function->found_varno = var->
dno;
785 elog(
ERROR,
"plpgsql parser returned %d", parse_rc);
797 if (num_out_args > 0 ||
function->fn_rettype == VOIDOID ||
804 function->fn_nargs = procStruct->pronargs;
805 for (
i = 0;
i <
function->fn_nargs;
i++)
845 char *func_name =
"inline_code_block";
865 plerrcontext.
arg = proc_source;
882 "PL/pgSQL inline code context",
886 function->fn_signature =
pstrdup(func_name);
889 function->fn_cxt = func_cxt;
890 function->out_param_varno = -1;
898 function->extra_warnings = 0;
899 function->extra_errors = 0;
901 function->nstatements = 0;
902 function->requires_procedure_resowner =
false;
910 function->fn_rettype = VOIDOID;
911 function->fn_retset =
false;
912 function->fn_retistuple =
false;
913 function->fn_retisdomain =
false;
914 function->fn_prokind = PROKIND_FUNCTION;
916 function->fn_retbyval =
true;
917 function->fn_rettyplen =
sizeof(
int32);
923 function->fn_readonly =
false;
934 function->found_varno = var->
dno;
941 elog(
ERROR,
"plpgsql parser returned %d", parse_rc);
950 if (
function->fn_rettype == VOIDOID)
956 function->fn_nargs = 0;
998 errcontext(
"compilation of PL/pgSQL function \"%s\" near line %d",
1020 (
errcode(ERRCODE_INVALID_FUNCTION_DEFINITION),
1021 errmsg(
"parameter name \"%s\" used more than once",
1040 if (
function->action->exceptions != NULL ||
1047 new->stmtid = ++
function->nstatements;
1050 function->action =
new;
1059 new->stmtid = ++
function->nstatements;
1061 new->retvarno =
function->out_param_varno;
1127 if (myvar != NULL && var != NULL)
1134 (
errcode(ERRCODE_AMBIGUOUS_COLUMN),
1135 errmsg(
"column reference \"%s\" is ambiguous",
1137 errdetail(
"It could refer to either a PL/pgSQL variable or a table column."),
1176 ColumnRef *cref,
bool error_if_no_field)
1181 const char *name2 = NULL;
1182 const char *name3 = NULL;
1183 const char *colname = NULL;
1185 int nnames_scalar = 0;
1186 int nnames_wholerow = 0;
1187 int nnames_field = 0;
1214 nnames_wholerow = 1;
1229 nnames_wholerow = 1;
1236 nnames_wholerow = 2;
1254 nnames_wholerow = 2;
1269 name1, name2, name3,
1278 if (nnames == nnames_scalar)
1282 if (nnames == nnames_wholerow)
1284 if (nnames == nnames_field)
1298 if (strcmp(fld->
fieldname, colname) == 0)
1311 if (error_if_no_field)
1313 (
errcode(ERRCODE_UNDEFINED_COLUMN),
1314 errmsg(
"record \"%s\" has no field \"%s\"",
1315 (nnames_field == 1) ? name1 : name2,
1342 Assert(dno >= 0 && dno < estate->ndatums);
1343 datum = estate->
datums[dno];
1358 ¶m->paramtypmod,
1359 ¶m->paramcollid);
1362 return (
Node *) param;
1412 wdatum->
ident = word1;
1413 wdatum->
quoted = (yytxt[0] ==
'"');
1419 elog(
ERROR,
"unrecognized plpgsql itemtype: %d",
1429 word->ident = word1;
1430 word->quoted = (yytxt[0] ==
'"');
1472 wdatum->
ident = NULL;
1499 wdatum->
ident = NULL;
1543 word1, word2, word3,
1577 wdatum->
ident = NULL;
1632 (
errcode(ERRCODE_UNDEFINED_OBJECT),
1633 errmsg(
"variable \"%s\" does not exist",
ident)));
1653 const char *fldname = NULL;
1721 (
errcode(ERRCODE_UNDEFINED_COLUMN),
1722 errmsg(
"column \"%s\" of relation \"%s\" does not exist",
1729 elog(
ERROR,
"cache lookup failed for type %u", attrStruct->atttypid);
1738 attrStruct->atttypmod,
1739 attrStruct->attcollation,
1775 errmsg(
"relation \"%s\" does not exist",
ident)));
1781 (
errcode(ERRCODE_WRONG_OBJECT_TYPE),
1782 errmsg(
"relation \"%s\" does not have a composite type",
1819 (
errcode(ERRCODE_WRONG_OBJECT_TYPE),
1820 errmsg(
"relation \"%s\" does not have a composite type",
1845 switch (dtype->
ttype)
1885 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
1886 errmsg(
"variable \"%s\" has pseudo-type %s",
1937 row->
refname =
"(unnamed row)";
1944 for (
i = 0;
i < numvars;
i++)
1959 typmod = ((
PLpgSQL_var *) var)->datatype->atttypmod;
1960 typcoll = ((
PLpgSQL_var *) var)->datatype->collation;
2010 if (strcmp(fld->
fieldname, fldname) == 0)
2052 elog(
ERROR,
"cache lookup failed for type %u", typeOid);
2072 if (!typeStruct->typisdefined)
2074 (
errcode(ERRCODE_UNDEFINED_OBJECT),
2075 errmsg(
"type \"%s\" is only a shell",
2076 NameStr(typeStruct->typname))));
2081 typ->
typoid = typeStruct->oid;
2082 switch (typeStruct->typtype)
2087 case TYPTYPE_MULTIRANGE:
2090 case TYPTYPE_COMPOSITE:
2093 case TYPTYPE_DOMAIN:
2099 case TYPTYPE_PSEUDO:
2100 if (typ->
typoid == RECORDOID)
2107 (
int) typeStruct->typtype);
2110 typ->
typlen = typeStruct->typlen;
2111 typ->
typbyval = typeStruct->typbyval;
2112 typ->
typtype = typeStruct->typtype;
2113 typ->
collation = typeStruct->typcollation;
2118 if (typeStruct->typtype == TYPTYPE_BASE)
2124 typ->
typisarray = (IsTrueArrayType(typeStruct) &&
2125 typeStruct->typstorage != TYPSTORAGE_PLAIN);
2127 else if (typeStruct->typtype == TYPTYPE_DOMAIN)
2130 typ->
typisarray = (typeStruct->typlen == -1 &&
2131 typeStruct->typstorage != TYPSTORAGE_PLAIN &&
2151 if (typentry->
typtype == TYPTYPE_DOMAIN)
2154 if (typentry->
tupDesc == NULL)
2156 (
errcode(ERRCODE_WRONG_OBJECT_TYPE),
2157 errmsg(
"type %s is not composite",
2192 (
errcode(ERRCODE_UNDEFINED_OBJECT),
2193 errmsg(
"could not find array type for data type %s",
2215 if (strlen(condname) == 5 &&
2216 strspn(condname,
"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ") == 5)
2231 (
errcode(ERRCODE_UNDEFINED_OBJECT),
2232 errmsg(
"unrecognized exception condition \"%s\"",
2260 if (strcmp(condname,
"others") == 0)
2263 new->sqlerrstate = 0;
2264 new->condname = condname;
2276 new->condname = condname;
2284 (
errcode(ERRCODE_UNDEFINED_OBJECT),
2285 errmsg(
"unrecognized exception condition \"%s\"",
2332 Size copiable_size = 0;
2355 function->copiable_size = copiable_size;
2401 *varnos = (
int *)
palloc(
sizeof(
int) * n);
2459 if (hashkey->
isTrigger && !forValidator)
2469 if (procStruct->pronargs > 0)
2472 memcpy(hashkey->
argtypes, procStruct->proargtypes.values,
2473 procStruct->pronargs *
sizeof(
Oid));
2481 NameStr(procStruct->proname));
2499 Oid *argtypes,
char *argmodes,
2500 Node *call_expr,
bool forValidator,
2513 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
2514 errmsg(
"could not determine actual argument "
2515 "type for polymorphic function \"%s\"",
2519 for (
i = 0;
i < numargs;
i++)
2521 char argmode = argmodes ? argmodes[
i] : PROARGMODE_IN;
2523 if (argmode == PROARGMODE_OUT || argmode == PROARGMODE_TABLE)
2525 if (argtypes[
i] == RECORDOID || argtypes[
i] == RECORDARRAYOID)
2531 argtypes[
i] = resolvedtype;
2539 for (
i = 0;
i < numargs;
i++)
2541 switch (argtypes[
i])
2544 case ANYNONARRAYOID:
2546 case ANYCOMPATIBLEOID:
2547 case ANYCOMPATIBLENONARRAYOID:
2548 argtypes[
i] = INT4OID;
2551 case ANYCOMPATIBLEARRAYOID:
2552 argtypes[
i] = INT4ARRAYOID;
2555 case ANYCOMPATIBLERANGEOID:
2556 argtypes[
i] = INT4RANGEOID;
2558 case ANYMULTIRANGEOID:
2559 argtypes[
i] = INT4MULTIRANGEOID;
2637 elog(
WARNING,
"trying to insert a function that already exists");
2658 elog(
WARNING,
"trying to delete function that does not exist");
2661 function->fn_hashkey = NULL;
Bitmapset * bms_add_member(Bitmapset *a, int x)
#define TextDatumGetCString(d)
#define Assert(condition)
#define MemSet(start, val, len)
#define OidIsValid(objectId)
void * hash_search(HTAB *hashp, const void *keyPtr, HASHACTION action, bool *foundPtr)
HTAB * hash_create(const char *tabname, long nelem, const HASHCTL *info, int flags)
int errdetail(const char *fmt,...)
ErrorContextCallback * error_context_stack
int errhint(const char *fmt,...)
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define MAKE_SQLSTATE(ch1, ch2, ch3, ch4, ch5)
#define ereport(elevel,...)
#define CALLED_AS_EVENT_TRIGGER(fcinfo)
Oid get_call_expr_argtype(Node *expr, int argnum)
Oid get_fn_expr_rettype(FmgrInfo *flinfo)
bool resolve_polymorphic_argtypes(int numargs, Oid *argtypes, char *argmodes, Node *call_expr)
int get_func_arg_info(HeapTuple procTup, Oid **p_argtypes, char ***p_argnames, char **p_argmodes)
bool check_function_bodies
#define HeapTupleIsValid(tuple)
#define HeapTupleHeaderGetRawXmin(tup)
if(TABLE==NULL||TABLE_index==NULL)
bool ItemPointerEquals(ItemPointer pointer1, ItemPointer pointer2)
List * lappend(List *list, void *datum)
List * list_copy(const List *oldlist)
List * list_delete_last(List *list)
bool type_is_rowtype(Oid typid)
Oid get_rel_type_id(Oid relid)
Oid get_base_element_type(Oid typid)
Oid get_array_type(Oid typid)
TypeName * makeTypeName(char *typnam)
TypeName * makeTypeNameFromNameList(List *names)
RangeVar * makeRangeVar(char *schemaname, char *relname, int location)
char * pstrdup(const char *in)
void pfree(void *pointer)
MemoryContext TopMemoryContext
void * palloc0(Size size)
void * MemoryContextAllocZero(MemoryContext context, Size size)
MemoryContext CurrentMemoryContext
void * repalloc(void *pointer, Size size)
void * MemoryContextAlloc(MemoryContext context, Size size)
void MemoryContextSetIdentifier(MemoryContext context, const char *id)
#define AllocSetContextCreate
#define ALLOCSET_DEFAULT_SIZES
RangeVar * makeRangeVarFromNameList(const List *names)
char * NameListToString(const List *names)
Oid RelnameGetRelid(const char *relname)
#define RangeVarGetRelid(relation, lockmode, missing_ok)
#define IsA(nodeptr, _type_)
int parser_errposition(ParseState *pstate, int location)
FormData_pg_attribute * Form_pg_attribute
on_exit_nicely_callback function
static int list_length(const List *l)
#define list_make3(x1, x2, x3)
#define list_make2(x1, x2)
bool function_parse_error_transpose(const char *prosrc)
FormData_pg_proc * Form_pg_proc
FormData_pg_type * Form_pg_type
#define ERRCODE_UNDEFINED_TABLE
PLpgSQL_recfield * plpgsql_build_recfield(PLpgSQL_rec *rec, const char *fldname)
static void add_dummy_return(PLpgSQL_function *function)
static PLpgSQL_row * build_row_from_vars(PLpgSQL_variable **vars, int numvars)
PLpgSQL_type * plpgsql_build_datatype_arrayof(PLpgSQL_type *dtype)
void plpgsql_parser_setup(struct ParseState *pstate, PLpgSQL_expr *expr)
int plpgsql_add_initdatums(int **varnos)
MemoryContext plpgsql_compile_tmp_cxt
PLpgSQL_rec * plpgsql_build_record(const char *refname, int lineno, PLpgSQL_type *dtype, Oid rectypeid, bool add2namespace)
static Node * make_datum_param(PLpgSQL_expr *expr, int dno, int location)
static void plpgsql_HashTableInsert(PLpgSQL_function *function, PLpgSQL_func_hashkey *func_key)
PLpgSQL_type * plpgsql_parse_wordrowtype(char *ident)
int plpgsql_recognize_err_condition(const char *condname, bool allow_sqlstate)
struct plpgsql_hashent plpgsql_HashEnt
static void plpgsql_compile_error_callback(void *arg)
PLpgSQL_type * plpgsql_parse_cwordrowtype(List *idents)
PLpgSQL_variable * plpgsql_build_variable(const char *refname, int lineno, PLpgSQL_type *dtype, bool add2namespace)
static void compute_function_hashkey(FunctionCallInfo fcinfo, Form_pg_proc procStruct, PLpgSQL_func_hashkey *hashkey, bool forValidator)
void plpgsql_HashTableInit(void)
static Node * plpgsql_param_ref(ParseState *pstate, ParamRef *pref)
static void plpgsql_start_datums(void)
char * plpgsql_error_funcname
static PLpgSQL_function * plpgsql_HashTableLookup(PLpgSQL_func_hashkey *func_key)
PLpgSQL_stmt_block * plpgsql_parse_result
bool plpgsql_check_syntax
PLpgSQL_condition * plpgsql_parse_err_condition(char *condname)
static const ExceptionLabelMap exception_label_map[]
PLpgSQL_function * plpgsql_compile(FunctionCallInfo fcinfo, bool forValidator)
static PLpgSQL_function * do_compile(FunctionCallInfo fcinfo, HeapTuple procTup, PLpgSQL_function *function, PLpgSQL_func_hashkey *hashkey, bool forValidator)
static void plpgsql_finish_datums(PLpgSQL_function *function)
PLpgSQL_function * plpgsql_curr_compile
PLpgSQL_type * plpgsql_parse_wordtype(char *ident)
bool plpgsql_parse_dblword(char *word1, char *word2, PLwdatum *wdatum, PLcword *cword)
void plpgsql_adddatum(PLpgSQL_datum *newdatum)
PLpgSQL_datum ** plpgsql_Datums
bool plpgsql_parse_word(char *word1, const char *yytxt, bool lookup, PLwdatum *wdatum, PLword *word)
bool plpgsql_DumpExecTree
static void plpgsql_resolve_polymorphic_argtypes(int numargs, Oid *argtypes, char *argmodes, Node *call_expr, bool forValidator, const char *proname)
static Node * resolve_column_ref(ParseState *pstate, PLpgSQL_expr *expr, ColumnRef *cref, bool error_if_no_field)
static void add_parameter_name(PLpgSQL_nsitem_type itemtype, int itemno, const char *name)
PLpgSQL_function * plpgsql_compile_inline(char *proc_source)
static void plpgsql_HashTableDelete(PLpgSQL_function *function)
bool plpgsql_parse_tripword(char *word1, char *word2, char *word3, PLwdatum *wdatum, PLcword *cword)
static PLpgSQL_type * build_datatype(HeapTuple typeTup, int32 typmod, Oid collation, TypeName *origtypname)
static Node * plpgsql_pre_column_ref(ParseState *pstate, ColumnRef *cref)
static void delete_function(PLpgSQL_function *func)
static Node * plpgsql_post_column_ref(ParseState *pstate, ColumnRef *cref, Node *var)
PLpgSQL_type * plpgsql_parse_cwordtype(List *idents)
static HTAB * plpgsql_HashTable
PLpgSQL_type * plpgsql_build_datatype(Oid typeOid, int32 typmod, Oid collation, TypeName *origtypname)
void plpgsql_exec_get_datum_type_info(PLpgSQL_execstate *estate, PLpgSQL_datum *datum, Oid *typeId, int32 *typMod, Oid *collation)
void plpgsql_ns_init(void)
void plpgsql_dumptree(PLpgSQL_function *func)
void plpgsql_free_function_memory(PLpgSQL_function *func)
void plpgsql_ns_additem(PLpgSQL_nsitem_type itemtype, int itemno, const char *name)
PLpgSQL_nsitem * plpgsql_ns_top(void)
void plpgsql_ns_push(const char *label, PLpgSQL_label_type label_type)
PLpgSQL_nsitem * plpgsql_ns_lookup(PLpgSQL_nsitem *ns_cur, bool localmode, const char *name1, const char *name2, const char *name3, int *names_used)
int plpgsql_variable_conflict
int plpgsql_extra_warnings
bool plpgsql_print_strict_params
void plpgsql_scanner_finish(void)
IdentifierLookup plpgsql_IdentifierLookup
int plpgsql_latest_lineno(void)
void plpgsql_scanner_init(const char *str)
@ PLPGSQL_RESOLVE_VARIABLE
struct PLpgSQL_func_hashkey PLpgSQL_func_hashkey
@ IDENTIFIER_LOOKUP_DECLARE
@ IDENTIFIER_LOOKUP_NORMAL
@ PLPGSQL_PROMISE_TG_RELID
@ PLPGSQL_PROMISE_TG_WHEN
@ PLPGSQL_PROMISE_TG_ARGV
@ PLPGSQL_PROMISE_TG_TABLE_SCHEMA
@ PLPGSQL_PROMISE_TG_EVENT
@ PLPGSQL_PROMISE_TG_TABLE_NAME
@ PLPGSQL_PROMISE_TG_LEVEL
@ PLPGSQL_PROMISE_TG_NARGS
@ PLPGSQL_PROMISE_TG_NAME
int plpgsql_yyparse(void)
static Datum ObjectIdGetDatum(Oid X)
MemoryContextSwitchTo(old_ctx)
static void word(struct vars *v, int dir, struct state *lp, struct state *rp)
char * format_procedure(Oid procedure_oid)
struct ErrorContextCallback * previous
void(* callback)(void *arg)
struct PLpgSQL_nsitem * ns
struct PLpgSQL_function * func
Oid argtypes[FUNC_MAX_ARGS]
struct PLpgSQL_execstate * cur_estate
PLpgSQL_resolve_option resolve_option
PLpgSQL_func_hashkey * fn_hashkey
PLpgSQL_nsitem_type itemtype
ExpandedRecordHeader * erh
ParseParamRefHook p_paramref_hook
PreParseColumnRefHook p_pre_columnref_hook
PostParseColumnRefHook p_post_columnref_hook
uint64 tupDesc_identifier
PLpgSQL_function * function
void ReleaseSysCache(HeapTuple tuple)
HeapTuple SearchSysCache1(int cacheId, Datum key1)
HeapTuple SearchSysCacheAttName(Oid relid, const char *attname)
Datum SysCacheGetAttrNotNull(int cacheId, HeapTuple tup, AttrNumber attributeNumber)
#define CALLED_AS_TRIGGER(fcinfo)
TupleDesc CreateTemplateTupleDesc(int natts)
void TupleDescInitEntryCollation(TupleDesc desc, AttrNumber attributeNumber, Oid collationid)
void TupleDescInitEntry(TupleDesc desc, AttrNumber attributeNumber, const char *attributeName, Oid oidtypeid, int32 typmod, int attdim)
TypeCacheEntry * lookup_type_cache(Oid type_id, int flags)
#define INVALID_TUPLEDESC_IDENTIFIER
#define TYPECACHE_TUPDESC
#define TYPECACHE_DOMAIN_BASE_INFO
String * makeString(char *str)