diff options
author | Bruce Momjian <bruce@momjian.us> | 2009-06-11 14:49:15 +0000 |
---|---|---|
committer | Bruce Momjian <bruce@momjian.us> | 2009-06-11 14:49:15 +0000 |
commit | d7471402794266078953f1bd113dab4913d631a1 (patch) | |
tree | 618e392a84eaf837e00bf78f8694097b78fec227 /src/backend/executor/functions.c | |
parent | 4e86efb4e51b66ef57b3fe6f28576de23a1bf1c6 (diff) | |
download | postgresql-d7471402794266078953f1bd113dab4913d631a1.tar.gz postgresql-d7471402794266078953f1bd113dab4913d631a1.zip |
8.4 pgindent run, with new combined Linux/FreeBSD/MinGW typedef list
provided by Andrew.
Diffstat (limited to 'src/backend/executor/functions.c')
-rw-r--r-- | src/backend/executor/functions.c | 99 |
1 files changed, 50 insertions, 49 deletions
diff --git a/src/backend/executor/functions.c b/src/backend/executor/functions.c index f71807835f2..b0d8b9008a8 100644 --- a/src/backend/executor/functions.c +++ b/src/backend/executor/functions.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/executor/functions.c,v 1.133 2009/03/27 18:30:21 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/executor/functions.c,v 1.134 2009/06/11 14:48:57 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -101,8 +101,8 @@ typedef SQLFunctionCache *SQLFunctionCachePtr; /* non-export function prototypes */ static execution_state *init_execution_state(List *queryTree_list, - SQLFunctionCachePtr fcache, - bool lazyEvalOK); + SQLFunctionCachePtr fcache, + bool lazyEvalOK); static void init_sql_fcache(FmgrInfo *finfo, bool lazyEvalOK); static void postquel_start(execution_state *es, SQLFunctionCachePtr fcache); static bool postquel_getnext(execution_state *es, SQLFunctionCachePtr fcache); @@ -168,8 +168,8 @@ init_execution_state(List *queryTree_list, newes->next = NULL; newes->status = F_EXEC_START; - newes->setsResult = false; /* might change below */ - newes->lazyEval = false; /* might change below */ + newes->setsResult = false; /* might change below */ + newes->lazyEval = false; /* might change below */ newes->stmt = stmt; newes->qd = NULL; @@ -180,9 +180,9 @@ init_execution_state(List *queryTree_list, } /* - * Mark the last canSetTag query as delivering the function result; - * then, if it is a plain SELECT, mark it for lazy evaluation. - * If it's not a SELECT we must always run it to completion. + * Mark the last canSetTag query as delivering the function result; then, + * if it is a plain SELECT, mark it for lazy evaluation. If it's not a + * SELECT we must always run it to completion. * * Note: at some point we might add additional criteria for whether to use * lazy eval. However, we should prefer to use it whenever the function @@ -191,8 +191,8 @@ init_execution_state(List *queryTree_list, * * Note: don't set setsResult if the function returns VOID, as evidenced * by not having made a junkfilter. This ensures we'll throw away any - * output from a utility statement that check_sql_fn_retval deemed to - * not have output. + * output from a utility statement that check_sql_fn_retval deemed to not + * have output. */ if (lasttages && fcache->junkFilter) { @@ -326,10 +326,10 @@ init_sql_fcache(FmgrInfo *finfo, bool lazyEvalOK) * Note: we set fcache->returnsTuple according to whether we are returning * the whole tuple result or just a single column. In the latter case we * clear returnsTuple because we need not act different from the scalar - * result case, even if it's a rowtype column. (However, we have to - * force lazy eval mode in that case; otherwise we'd need extra code to - * expand the rowtype column into multiple columns, since we have no - * way to notify the caller that it should do that.) + * result case, even if it's a rowtype column. (However, we have to force + * lazy eval mode in that case; otherwise we'd need extra code to expand + * the rowtype column into multiple columns, since we have no way to + * notify the caller that it should do that.) * * check_sql_fn_retval will also construct a JunkFilter we can use to * coerce the returned rowtype to the desired form (unless the result type @@ -459,7 +459,7 @@ postquel_getnext(execution_state *es, SQLFunctionCachePtr fcache) es->qd->utilitystmt), fcache->src, es->qd->params, - false, /* not top level */ + false, /* not top level */ es->qd->dest, NULL); result = true; /* never stops early */ @@ -566,7 +566,7 @@ postquel_get_single_result(TupleTableSlot *slot, /* * Set up to return the function value. For pass-by-reference datatypes, * be sure to allocate the result in resultcontext, not the current memory - * context (which has query lifespan). We can't leave the data in the + * context (which has query lifespan). We can't leave the data in the * TupleTableSlot because we intend to clear the slot before returning. */ oldcontext = MemoryContextSwitchTo(resultcontext); @@ -670,8 +670,8 @@ fmgr_sql(PG_FUNCTION_ARGS) postquel_sub_params(fcache, fcinfo); /* - * Build tuplestore to hold results, if we don't have one already. - * Note it's in the query-lifespan context. + * Build tuplestore to hold results, if we don't have one already. Note + * it's in the query-lifespan context. */ if (!fcache->tstore) fcache->tstore = tuplestore_begin_heap(randomAccess, false, work_mem); @@ -688,7 +688,7 @@ fmgr_sql(PG_FUNCTION_ARGS) */ while (es) { - bool completed; + bool completed; if (es->status == F_EXEC_START) postquel_start(es, fcache); @@ -696,22 +696,22 @@ fmgr_sql(PG_FUNCTION_ARGS) completed = postquel_getnext(es, fcache); /* - * If we ran the command to completion, we can shut it down now. - * Any row(s) we need to return are safely stashed in the tuplestore, - * and we want to be sure that, for example, AFTER triggers get fired + * If we ran the command to completion, we can shut it down now. Any + * row(s) we need to return are safely stashed in the tuplestore, and + * we want to be sure that, for example, AFTER triggers get fired * before we return anything. Also, if the function doesn't return - * set, we can shut it down anyway because it must be a SELECT and - * we don't care about fetching any more result rows. + * set, we can shut it down anyway because it must be a SELECT and we + * don't care about fetching any more result rows. */ if (completed || !fcache->returnsSet) postquel_end(es); /* * Break from loop if we didn't shut down (implying we got a - * lazily-evaluated row). Otherwise we'll press on till the - * whole function is done, relying on the tuplestore to keep hold - * of the data to eventually be returned. This is necessary since - * an INSERT/UPDATE/DELETE RETURNING that sets the result might be + * lazily-evaluated row). Otherwise we'll press on till the whole + * function is done, relying on the tuplestore to keep hold of the + * data to eventually be returned. This is necessary since an + * INSERT/UPDATE/DELETE RETURNING that sets the result might be * followed by additional rule-inserted commands, and we want to * finish doing all those commands before we return anything. */ @@ -730,7 +730,8 @@ fmgr_sql(PG_FUNCTION_ARGS) if (es) { /* - * If we stopped short of being done, we must have a lazy-eval row. + * If we stopped short of being done, we must have a lazy-eval + * row. */ Assert(es->lazyEval); /* Re-use the junkfilter's output slot to fetch back the tuple */ @@ -765,7 +766,7 @@ fmgr_sql(PG_FUNCTION_ARGS) else if (fcache->lazyEval) { /* - * We are done with a lazy evaluation. Clean up. + * We are done with a lazy evaluation. Clean up. */ tuplestore_clear(fcache->tstore); @@ -789,9 +790,9 @@ fmgr_sql(PG_FUNCTION_ARGS) else { /* - * We are done with a non-lazy evaluation. Return whatever is - * in the tuplestore. (It is now caller's responsibility to - * free the tuplestore when done.) + * We are done with a non-lazy evaluation. Return whatever is in + * the tuplestore. (It is now caller's responsibility to free the + * tuplestore when done.) */ rsi->returnMode = SFRM_Materialize; rsi->setResult = fcache->tstore; @@ -844,8 +845,8 @@ fmgr_sql(PG_FUNCTION_ARGS) } /* - * If we've gone through every command in the function, we are done. - * Reset the execution states to start over again on next call. + * If we've gone through every command in the function, we are done. Reset + * the execution states to start over again on next call. */ if (es == NULL) { @@ -997,7 +998,7 @@ ShutdownSQLFunction(Datum arg) * function definition of a polymorphic function.) * * This function returns true if the sql function returns the entire tuple - * result of its final statement, and false otherwise. Note that because we + * result of its final statement, and false otherwise. Note that because we * allow "SELECT rowtype_expression", this may be false even when the declared * function return type is a rowtype. * @@ -1029,14 +1030,14 @@ check_sql_fn_retval(Oid func_id, Oid rettype, List *queryTreeList, *junkFilter = NULL; /* initialize in case of VOID result */ /* - * Find the last canSetTag query in the list. This isn't necessarily - * the last parsetree, because rule rewriting can insert queries after - * what the user wrote. + * Find the last canSetTag query in the list. This isn't necessarily the + * last parsetree, because rule rewriting can insert queries after what + * the user wrote. */ parse = NULL; foreach(lc, queryTreeList) { - Query *q = (Query *) lfirst(lc); + Query *q = (Query *) lfirst(lc); if (q->canSetTag) parse = q; @@ -1044,12 +1045,12 @@ check_sql_fn_retval(Oid func_id, Oid rettype, List *queryTreeList, /* * If it's a plain SELECT, it returns whatever the targetlist says. - * Otherwise, if it's INSERT/UPDATE/DELETE with RETURNING, it returns that. - * Otherwise, the function return type must be VOID. + * Otherwise, if it's INSERT/UPDATE/DELETE with RETURNING, it returns + * that. Otherwise, the function return type must be VOID. * * Note: eventually replace this test with QueryReturnsTuples? We'd need - * a more general method of determining the output type, though. Also, - * it seems too dangerous to consider FETCH or EXECUTE as returning a + * a more general method of determining the output type, though. Also, it + * seems too dangerous to consider FETCH or EXECUTE as returning a * determinable rowtype, since they depend on relatively short-lived * entities. */ @@ -1076,7 +1077,7 @@ check_sql_fn_retval(Oid func_id, Oid rettype, List *queryTreeList, (errcode(ERRCODE_INVALID_FUNCTION_DEFINITION), errmsg("return type mismatch in function declared to return %s", format_type_be(rettype)), - errdetail("Function's final statement must be SELECT or INSERT/UPDATE/DELETE RETURNING."))); + errdetail("Function's final statement must be SELECT or INSERT/UPDATE/DELETE RETURNING."))); return false; } @@ -1112,7 +1113,7 @@ check_sql_fn_retval(Oid func_id, Oid rettype, List *queryTreeList, (errcode(ERRCODE_INVALID_FUNCTION_DEFINITION), errmsg("return type mismatch in function declared to return %s", format_type_be(rettype)), - errdetail("Final statement must return exactly one column."))); + errdetail("Final statement must return exactly one column."))); /* We assume here that non-junk TLEs must come first in tlists */ tle = (TargetEntry *) linitial(tlist); @@ -1148,8 +1149,8 @@ check_sql_fn_retval(Oid func_id, Oid rettype, List *queryTreeList, * If the target list is of length 1, and the type of the varnode in * the target list matches the declared return type, this is okay. * This can happen, for example, where the body of the function is - * 'SELECT func2()', where func2 has the same composite return type - * as the function that's calling it. + * 'SELECT func2()', where func2 has the same composite return type as + * the function that's calling it. */ if (tlistlen == 1) { @@ -1211,7 +1212,7 @@ check_sql_fn_retval(Oid func_id, Oid rettype, List *queryTreeList, (errcode(ERRCODE_INVALID_FUNCTION_DEFINITION), errmsg("return type mismatch in function declared to return %s", format_type_be(rettype)), - errdetail("Final statement returns too many columns."))); + errdetail("Final statement returns too many columns."))); attr = tupdesc->attrs[colindex - 1]; } while (attr->attisdropped); tuplogcols++; |