diff options
Diffstat (limited to 'src/backend/utils/fmgr')
| -rw-r--r-- | src/backend/utils/fmgr/dfmgr.c | 16 | ||||
| -rw-r--r-- | src/backend/utils/fmgr/fmgr.c | 99 | ||||
| -rw-r--r-- | src/backend/utils/fmgr/funcapi.c | 83 |
3 files changed, 98 insertions, 100 deletions
diff --git a/src/backend/utils/fmgr/dfmgr.c b/src/backend/utils/fmgr/dfmgr.c index 3c33fbfa6f..2212f49fc4 100644 --- a/src/backend/utils/fmgr/dfmgr.c +++ b/src/backend/utils/fmgr/dfmgr.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/fmgr/dfmgr.c,v 1.80 2005/05/11 01:26:02 neilc Exp $ + * $PostgreSQL: pgsql/src/backend/utils/fmgr/dfmgr.c,v 1.81 2005/10/15 02:49:32 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -30,8 +30,8 @@ typedef struct df_files { struct df_files *next; /* List link */ dev_t device; /* Device file is on */ -#ifndef WIN32 /* ensures we never again depend on this - * under win32 */ +#ifndef WIN32 /* ensures we never again depend on this under + * win32 */ ino_t inode; /* Inode number of file */ #endif void *handle; /* a handle for pg_dl* functions */ @@ -200,8 +200,8 @@ load_file(char *filename) /* * We need to do stat() in order to determine whether this is the same - * file as a previously loaded file; it's also handy so as to give a - * good error message if bogus file name given. + * file as a previously loaded file; it's also handy so as to give a good + * error message if bogus file name given. */ if (stat(fullname, &stat_buf) == -1) ereport(ERROR, @@ -209,8 +209,8 @@ load_file(char *filename) errmsg("could not access file \"%s\": %m", fullname))); /* - * We have to zap all entries in the list that match on either - * filename or inode, else load_external_function() won't do anything. + * We have to zap all entries in the list that match on either filename or + * inode, else load_external_function() won't do anything. */ prv = NULL; for (file_scanner = file_list; file_scanner != NULL; file_scanner = nxt) @@ -351,7 +351,7 @@ substitute_libpath_macro(const char *name) strncmp(name, "$libdir", strlen("$libdir")) != 0) ereport(ERROR, (errcode(ERRCODE_INVALID_NAME), - errmsg("invalid macro name in dynamic library path: %s", name))); + errmsg("invalid macro name in dynamic library path: %s", name))); ret = palloc(strlen(pkglib_path) + strlen(sep_ptr) + 1); diff --git a/src/backend/utils/fmgr/fmgr.c b/src/backend/utils/fmgr/fmgr.c index dd6134ccfd..4e5dcc3002 100644 --- a/src/backend/utils/fmgr/fmgr.c +++ b/src/backend/utils/fmgr/fmgr.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/fmgr/fmgr.c,v 1.96 2005/06/28 05:09:01 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/fmgr/fmgr.c,v 1.97 2005/10/15 02:49:32 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -41,9 +41,9 @@ * some warnings about int->pointer conversions... */ #if (defined(__mc68000__) || (defined(__m68k__))) && defined(__ELF__) -typedef int32 (*func_ptr) (); +typedef int32 (*func_ptr) (); #else -typedef char * (*func_ptr) (); +typedef char *(*func_ptr) (); #endif /* @@ -52,8 +52,8 @@ typedef char * (*func_ptr) (); typedef struct { func_ptr func; /* Address of the oldstyle function */ - bool arg_toastable[FUNC_MAX_ARGS]; /* is n'th arg of a - * toastable datatype? */ + bool arg_toastable[FUNC_MAX_ARGS]; /* is n'th arg of a toastable + * datatype? */ } Oldstyle_fnextra; /* @@ -95,8 +95,8 @@ fmgr_isbuiltin(Oid id) int high = fmgr_nbuiltins - 1; /* - * Loop invariant: low is the first index that could contain target - * entry, and high is the last index that could contain it. + * Loop invariant: low is the first index that could contain target entry, + * and high is the last index that could contain it. */ while (low <= high) { @@ -177,9 +177,9 @@ fmgr_info_cxt_security(Oid functionId, FmgrInfo *finfo, MemoryContext mcxt, char *prosrc; /* - * fn_oid *must* be filled in last. Some code assumes that if fn_oid - * is valid, the whole struct is valid. Some FmgrInfo struct's do - * survive elogs. + * fn_oid *must* be filled in last. Some code assumes that if fn_oid is + * valid, the whole struct is valid. Some FmgrInfo struct's do survive + * elogs. */ finfo->fn_oid = InvalidOid; finfo->fn_extra = NULL; @@ -189,8 +189,7 @@ fmgr_info_cxt_security(Oid functionId, FmgrInfo *finfo, MemoryContext mcxt, if ((fbp = fmgr_isbuiltin(functionId)) != NULL) { /* - * Fast path for builtin functions: don't bother consulting - * pg_proc + * Fast path for builtin functions: don't bother consulting pg_proc */ finfo->fn_nargs = fbp->nargs; finfo->fn_strict = fbp->strict; @@ -227,11 +226,11 @@ fmgr_info_cxt_security(Oid functionId, FmgrInfo *finfo, MemoryContext mcxt, /* * For an ordinary builtin function, we should never get here * because the isbuiltin() search above will have succeeded. - * However, if the user has done a CREATE FUNCTION to create - * an alias for a builtin function, we can end up here. In - * that case we have to look up the function by name. The - * name of the internal function is stored in prosrc (it - * doesn't have to be the same as the name of the alias!) + * However, if the user has done a CREATE FUNCTION to create an + * alias for a builtin function, we can end up here. In that case + * we have to look up the function by name. The name of the + * internal function is stored in prosrc (it doesn't have to be + * the same as the name of the alias!) */ prosrcdatum = SysCacheGetAttr(PROCOID, procedureTuple, Anum_pg_proc_prosrc, &isnull); @@ -300,8 +299,7 @@ fmgr_info_C_lang(Oid functionId, FmgrInfo *finfo, HeapTuple procedureTuple) void *libraryhandle; /* - * Get prosrc and probin strings (link symbol and library - * filename) + * Get prosrc and probin strings (link symbol and library filename) */ prosrcattr = SysCacheGetAttr(PROCOID, procedureTuple, Anum_pg_proc_prosrc, &isnull); @@ -605,14 +603,13 @@ fmgr_oldstyle(PG_FUNCTION_ARGS) fnextra = (Oldstyle_fnextra *) fcinfo->flinfo->fn_extra; /* - * Result is NULL if any argument is NULL, but we still call the - * function (peculiar, but that's the way it worked before, and after - * all this is a backwards-compatibility wrapper). Note, however, - * that we'll never get here with NULL arguments if the function is - * marked strict. + * Result is NULL if any argument is NULL, but we still call the function + * (peculiar, but that's the way it worked before, and after all this is a + * backwards-compatibility wrapper). Note, however, that we'll never get + * here with NULL arguments if the function is marked strict. * - * We also need to detoast any TOAST-ed inputs, since it's unlikely that - * an old-style function knows about TOASTing. + * We also need to detoast any TOAST-ed inputs, since it's unlikely that an + * old-style function knows about TOASTing. */ isnull = false; for (i = 0; i < n_arguments; i++) @@ -634,9 +631,9 @@ fmgr_oldstyle(PG_FUNCTION_ARGS) case 1: /* - * nullvalue() used to use isNull to check if arg is NULL; - * perhaps there are other functions still out there that also - * rely on this undocumented hack? + * nullvalue() used to use isNull to check if arg is NULL; perhaps + * there are other functions still out there that also rely on + * this undocumented hack? */ returnValue = (*user_fn) (fcinfo->arg[0], &fcinfo->isnull); break; @@ -744,16 +741,16 @@ fmgr_oldstyle(PG_FUNCTION_ARGS) default: /* - * Increasing FUNC_MAX_ARGS doesn't automatically add cases to - * the above code, so mention the actual value in this error - * not FUNC_MAX_ARGS. You could add cases to the above if you - * needed to support old-style functions with many arguments, - * but making 'em be new-style is probably a better idea. + * Increasing FUNC_MAX_ARGS doesn't automatically add cases to the + * above code, so mention the actual value in this error not + * FUNC_MAX_ARGS. You could add cases to the above if you needed + * to support old-style functions with many arguments, but making + * 'em be new-style is probably a better idea. */ ereport(ERROR, (errcode(ERRCODE_TOO_MANY_ARGUMENTS), - errmsg("function %u has too many arguments (%d, maximum is %d)", - fcinfo->flinfo->fn_oid, n_arguments, 16))); + errmsg("function %u has too many arguments (%d, maximum is %d)", + fcinfo->flinfo->fn_oid, n_arguments, 16))); returnValue = NULL; /* keep compiler quiet */ break; } @@ -769,7 +766,7 @@ fmgr_oldstyle(PG_FUNCTION_ARGS) struct fmgr_security_definer_cache { FmgrInfo flinfo; - Oid userid; + Oid userid; }; /* @@ -785,8 +782,8 @@ fmgr_security_definer(PG_FUNCTION_ARGS) { Datum result; FmgrInfo *save_flinfo; - struct fmgr_security_definer_cache * volatile fcache; - Oid save_userid; + struct fmgr_security_definer_cache *volatile fcache; + Oid save_userid; HeapTuple tuple; if (!fcinfo->flinfo->fn_extra) @@ -1719,8 +1716,8 @@ fmgr(Oid procedureId,...) if (n_arguments > FUNC_MAX_ARGS) ereport(ERROR, (errcode(ERRCODE_TOO_MANY_ARGUMENTS), - errmsg("function %u has too many arguments (%d, maximum is %d)", - flinfo.fn_oid, n_arguments, FUNC_MAX_ARGS))); + errmsg("function %u has too many arguments (%d, maximum is %d)", + flinfo.fn_oid, n_arguments, FUNC_MAX_ARGS))); va_start(pvar, procedureId); for (i = 0; i < n_arguments; i++) fcinfo.arg[i] = (Datum) va_arg(pvar, char *); @@ -1760,10 +1757,10 @@ Int64GetDatum(int64 X) #else /* INT64_IS_BUSTED */ /* - * On a machine with no 64-bit-int C datatype, sizeof(int64) will not - * be 8, but we want Int64GetDatum to return an 8-byte object anyway, - * with zeroes in the unused bits. This is needed so that, for - * example, hash join of int8 will behave properly. + * On a machine with no 64-bit-int C datatype, sizeof(int64) will not be + * 8, but we want Int64GetDatum to return an 8-byte object anyway, with + * zeroes in the unused bits. This is needed so that, for example, hash + * join of int8 will behave properly. */ int64 *retval = (int64 *) palloc0(Max(sizeof(int64), 8)); @@ -1846,8 +1843,8 @@ get_fn_expr_rettype(FmgrInfo *flinfo) Node *expr; /* - * can't return anything useful if we have no FmgrInfo or if its - * fn_expr node has not been initialized + * can't return anything useful if we have no FmgrInfo or if its fn_expr + * node has not been initialized */ if (!flinfo || !flinfo->fn_expr) return InvalidOid; @@ -1866,8 +1863,8 @@ Oid get_fn_expr_argtype(FmgrInfo *flinfo, int argnum) { /* - * can't return anything useful if we have no FmgrInfo or if its - * fn_expr node has not been initialized + * can't return anything useful if we have no FmgrInfo or if its fn_expr + * node has not been initialized */ if (!flinfo || !flinfo->fn_expr) return InvalidOid; @@ -1909,8 +1906,8 @@ get_call_expr_argtype(Node *expr, int argnum) argtype = exprType((Node *) list_nth(args, argnum)); /* - * special hack for ScalarArrayOpExpr: what the underlying function - * will actually get passed is the element type of the array. + * special hack for ScalarArrayOpExpr: what the underlying function will + * actually get passed is the element type of the array. */ if (IsA(expr, ScalarArrayOpExpr) && argnum == 1) diff --git a/src/backend/utils/fmgr/funcapi.c b/src/backend/utils/fmgr/funcapi.c index 598168a70a..0a51f7ae0f 100644 --- a/src/backend/utils/fmgr/funcapi.c +++ b/src/backend/utils/fmgr/funcapi.c @@ -7,7 +7,7 @@ * Copyright (c) 2002-2005, PostgreSQL Global Development Group * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/fmgr/funcapi.c,v 1.25 2005/10/06 19:51:15 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/fmgr/funcapi.c,v 1.26 2005/10/15 02:49:32 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -29,13 +29,13 @@ static void shutdown_MultiFuncCall(Datum arg); static TypeFuncClass internal_get_result_type(Oid funcid, - Node *call_expr, - ReturnSetInfo *rsinfo, - Oid *resultTypeId, - TupleDesc *resultTupleDesc); + Node *call_expr, + ReturnSetInfo *rsinfo, + Oid *resultTypeId, + TupleDesc *resultTupleDesc); static bool resolve_polymorphic_tupdesc(TupleDesc tupdesc, - oidvector *declared_args, - Node *call_expr); + oidvector *declared_args, + Node *call_expr); static TypeFuncClass get_type_func_class(Oid typid); @@ -89,8 +89,8 @@ init_MultiFuncCall(PG_FUNCTION_ARGS) fcinfo->flinfo->fn_extra = retval; /* - * Ensure we will get shut down cleanly if the exprcontext is not - * run to completion. + * Ensure we will get shut down cleanly if the exprcontext is not run + * to completion. */ RegisterExprContextCallback(rsi->econtext, shutdown_MultiFuncCall, @@ -119,16 +119,16 @@ per_MultiFuncCall(PG_FUNCTION_ARGS) FuncCallContext *retval = (FuncCallContext *) fcinfo->flinfo->fn_extra; /* - * Clear the TupleTableSlot, if present. This is for safety's sake: - * the Slot will be in a long-lived context (it better be, if the + * Clear the TupleTableSlot, if present. This is for safety's sake: the + * Slot will be in a long-lived context (it better be, if the * FuncCallContext is pointing to it), but in most usage patterns the - * tuples stored in it will be in the function's per-tuple context. So - * at the beginning of each call, the Slot will hold a dangling - * pointer to an already-recycled tuple. We clear it out here. + * tuples stored in it will be in the function's per-tuple context. So at + * the beginning of each call, the Slot will hold a dangling pointer to an + * already-recycled tuple. We clear it out here. * * Note: use of retval->slot is obsolete as of 8.0, and we expect that it - * will always be NULL. This is just here for backwards compatibility - * in case someone creates a slot anyway. + * will always be NULL. This is just here for backwards compatibility in + * case someone creates a slot anyway. */ if (retval->slot != NULL) ExecClearTuple(retval->slot); @@ -168,8 +168,8 @@ shutdown_MultiFuncCall(Datum arg) flinfo->fn_extra = NULL; /* - * Caller is responsible to free up memory for individual struct - * elements other than att_in_funcinfo and elements. + * Caller is responsible to free up memory for individual struct elements + * other than att_in_funcinfo and elements. */ if (funcctx->attinmeta != NULL) pfree(funcctx->attinmeta); @@ -183,14 +183,14 @@ shutdown_MultiFuncCall(Datum arg) * Given a function's call info record, determine the kind of datatype * it is supposed to return. If resultTypeId isn't NULL, *resultTypeId * receives the actual datatype OID (this is mainly useful for scalar - * result types). If resultTupleDesc isn't NULL, *resultTupleDesc + * result types). If resultTupleDesc isn't NULL, *resultTupleDesc * receives a pointer to a TupleDesc when the result is of a composite * type, or NULL when it's a scalar result. NB: the tupledesc should * be copied if it is to be accessed over a long period. * * One hard case that this handles is resolution of actual rowtypes for * functions returning RECORD (from either the function's OUT parameter - * list, or a ReturnSetInfo context node). TYPEFUNC_RECORD is returned + * list, or a ReturnSetInfo context node). TYPEFUNC_RECORD is returned * only when we couldn't resolve the actual rowtype for lack of information. * * The other hard case that this handles is resolution of polymorphism. @@ -238,7 +238,7 @@ get_expr_result_type(Node *expr, else { /* handle as a generic expression; no chance to resolve RECORD */ - Oid typid = exprType(expr); + Oid typid = exprType(expr); if (resultTypeId) *resultTypeId = typid; @@ -273,7 +273,7 @@ get_func_result_type(Oid functionId, /* * internal_get_result_type -- workhorse code implementing all the above * - * funcid must always be supplied. call_expr and rsinfo can be NULL if not + * funcid must always be supplied. call_expr and rsinfo can be NULL if not * available. We will return TYPEFUNC_RECORD, and store NULL into * *resultTupleDesc, if we cannot deduce the complete result rowtype from * the available information. @@ -306,9 +306,9 @@ internal_get_result_type(Oid funcid, if (tupdesc) { /* - * It has OUT parameters, so it's basically like a regular - * composite type, except we have to be able to resolve any - * polymorphic OUT parameters. + * It has OUT parameters, so it's basically like a regular composite + * type, except we have to be able to resolve any polymorphic OUT + * parameters. */ if (resultTypeId) *resultTypeId = rettype; @@ -341,7 +341,7 @@ internal_get_result_type(Oid funcid, */ if (rettype == ANYARRAYOID || rettype == ANYELEMENTOID) { - Oid newrettype = exprType(call_expr); + Oid newrettype = exprType(call_expr); if (newrettype == InvalidOid) /* this probably should not happen */ ereport(ERROR, @@ -355,7 +355,7 @@ internal_get_result_type(Oid funcid, if (resultTypeId) *resultTypeId = rettype; if (resultTupleDesc) - *resultTupleDesc = NULL; /* default result */ + *resultTupleDesc = NULL; /* default result */ /* Classify the result type */ result = get_type_func_class(rettype); @@ -391,7 +391,7 @@ internal_get_result_type(Oid funcid, /* * Given the result tuple descriptor for a function with OUT parameters, * replace any polymorphic columns (ANYELEMENT/ANYARRAY) with correct data - * types deduced from the input arguments. Returns TRUE if able to deduce + * types deduced from the input arguments. Returns TRUE if able to deduce * all types, FALSE if not. */ static bool @@ -425,7 +425,7 @@ resolve_polymorphic_tupdesc(TupleDesc tupdesc, oidvector *declared_args, return true; /* - * Otherwise, extract actual datatype(s) from input arguments. (We assume + * Otherwise, extract actual datatype(s) from input arguments. (We assume * the parser already validated consistency of the arguments.) */ if (!call_expr) @@ -468,14 +468,14 @@ resolve_polymorphic_tupdesc(TupleDesc tupdesc, oidvector *declared_args, switch (tupdesc->attrs[i]->atttypid) { case ANYELEMENTOID: - TupleDescInitEntry(tupdesc, i+1, + TupleDescInitEntry(tupdesc, i + 1, NameStr(tupdesc->attrs[i]->attname), anyelement_type, -1, 0); break; case ANYARRAYOID: - TupleDescInitEntry(tupdesc, i+1, + TupleDescInitEntry(tupdesc, i + 1, NameStr(tupdesc->attrs[i]->attname), anyarray_type, -1, @@ -492,7 +492,7 @@ resolve_polymorphic_tupdesc(TupleDesc tupdesc, oidvector *declared_args, /* * Given the declared argument types and modes for a function, * replace any polymorphic types (ANYELEMENT/ANYARRAY) with correct data - * types deduced from the input arguments. Returns TRUE if able to deduce + * types deduced from the input arguments. Returns TRUE if able to deduce * all types, FALSE if not. This is the same logic as * resolve_polymorphic_tupdesc, but with a different argument representation. * @@ -513,7 +513,7 @@ resolve_polymorphic_argtypes(int numargs, Oid *argtypes, char *argmodes, inargno = 0; for (i = 0; i < numargs; i++) { - char argmode = argmodes ? argmodes[i] : PROARGMODE_IN; + char argmode = argmodes ? argmodes[i] : PROARGMODE_IN; switch (argtypes[i]) { @@ -612,10 +612,11 @@ get_type_func_class(Oid typid) case 'p': if (typid == RECORDOID) return TYPEFUNC_RECORD; + /* * We treat VOID and CSTRING as legitimate scalar datatypes, - * mostly for the convenience of the JDBC driver (which wants - * to be able to do "SELECT * FROM foo()" for all legitimately + * mostly for the convenience of the JDBC driver (which wants to + * be able to do "SELECT * FROM foo()" for all legitimately * user-callable functions). */ if (typid == VOIDOID || typid == CSTRINGOID) @@ -681,14 +682,14 @@ get_func_result_name(Oid functionId) * since the array data is just going to look like a C array of * values. */ - arr = DatumGetArrayTypeP(proargmodes); /* ensure not toasted */ + arr = DatumGetArrayTypeP(proargmodes); /* ensure not toasted */ numargs = ARR_DIMS(arr)[0]; if (ARR_NDIM(arr) != 1 || numargs < 0 || ARR_ELEMTYPE(arr) != CHAROID) elog(ERROR, "proargmodes is not a 1-D char array"); argmodes = (char *) ARR_DATA_PTR(arr); - arr = DatumGetArrayTypeP(proargnames); /* ensure not toasted */ + arr = DatumGetArrayTypeP(proargnames); /* ensure not toasted */ if (ARR_NDIM(arr) != 1 || ARR_DIMS(arr)[0] != numargs || ARR_ELEMTYPE(arr) != TEXTOID) @@ -769,7 +770,7 @@ build_function_result_tupdesc_t(HeapTuple procTuple) Anum_pg_proc_proargnames, &isnull); if (isnull) - proargnames = PointerGetDatum(NULL); /* just to be sure */ + proargnames = PointerGetDatum(NULL); /* just to be sure */ return build_function_result_tupdesc_d(proallargtypes, proargmodes, @@ -848,7 +849,7 @@ build_function_result_tupdesc_d(Datum proallargtypes, numoutargs = 0; for (i = 0; i < numargs; i++) { - char *pname; + char *pname; if (argmodes[i] == PROARGMODE_IN) continue; @@ -879,7 +880,7 @@ build_function_result_tupdesc_d(Datum proallargtypes, desc = CreateTemplateTupleDesc(numoutargs, false); for (i = 0; i < numoutargs; i++) { - TupleDescInitEntry(desc, i+1, + TupleDescInitEntry(desc, i + 1, outargnames[i], outargtypes[i], -1, @@ -986,7 +987,7 @@ TypeGetTupleDesc(Oid typeoid, List *colaliases) if (list_length(colaliases) != 1) ereport(ERROR, (errcode(ERRCODE_DATATYPE_MISMATCH), - errmsg("number of aliases does not match number of columns"))); + errmsg("number of aliases does not match number of columns"))); /* OK, get the column alias */ attname = strVal(linitial(colaliases)); |
