diff options
author | Bruce Momjian <bruce@momjian.us> | 1997-09-07 05:04:48 +0000 |
---|---|---|
committer | Bruce Momjian <bruce@momjian.us> | 1997-09-07 05:04:48 +0000 |
commit | 1ccd423235a48739d6f7a4d7889705b5f9ecc69b (patch) | |
tree | 8001c4e839dfad8f29ceda7f8c5f5dbb8759b564 /src/backend/executor/execFlatten.c | |
parent | 8fecd4febf8357f3cc20383ed29ced484877d5ac (diff) | |
download | postgresql-1ccd423235a48739d6f7a4d7889705b5f9ecc69b.tar.gz postgresql-1ccd423235a48739d6f7a4d7889705b5f9ecc69b.zip |
Massive commit to run PGINDENT on all *.c and *.h files.
Diffstat (limited to 'src/backend/executor/execFlatten.c')
-rw-r--r-- | src/backend/executor/execFlatten.c | 372 |
1 files changed, 190 insertions, 182 deletions
diff --git a/src/backend/executor/execFlatten.c b/src/backend/executor/execFlatten.c index c9bde2ff663..43d616712fa 100644 --- a/src/backend/executor/execFlatten.c +++ b/src/backend/executor/execFlatten.c @@ -1,29 +1,29 @@ /*------------------------------------------------------------------------- * * execFlatten.c-- - * This file handles the nodes associated with flattening sets in the - * target list of queries containing functions returning sets. + * This file handles the nodes associated with flattening sets in the + * target list of queries containing functions returning sets. * * Copyright (c) 1994, Regents of the University of California * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/executor/Attic/execFlatten.c,v 1.2 1997/08/19 21:30:56 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/Attic/execFlatten.c,v 1.3 1997/09/07 04:41:12 momjian Exp $ * *------------------------------------------------------------------------- */ /* * ExecEvalIter() - - * Iterate through the all return tuples/base types from a function one - * at time (i.e. one per ExecEvalIter call). Not really needed for - * postquel functions, but for reasons of orthogonality, these nodes - * exist above pq functions as well as c functions. + * Iterate through the all return tuples/base types from a function one + * at time (i.e. one per ExecEvalIter call). Not really needed for + * postquel functions, but for reasons of orthogonality, these nodes + * exist above pq functions as well as c functions. * * ExecEvalFjoin() - - * Given N Iter nodes return a vector of all combinations of results - * one at a time (i.e. one result vector per ExecEvalFjoin call). This - * node does the actual flattening work. + * Given N Iter nodes return a vector of all combinations of results + * one at a time (i.e. one result vector per ExecEvalFjoin call). This + * node does the actual flattening work. */ #include "postgres.h" #include "nodes/primnodes.h" @@ -33,208 +33,216 @@ #include "executor/execFlatten.h" #ifdef SETS_FIXED -static bool FjoinBumpOuterNodes(TargetEntry *tlist, ExprContext *econtext, - DatumPtr results, char *nulls); +static bool +FjoinBumpOuterNodes(TargetEntry * tlist, ExprContext * econtext, + DatumPtr results, char *nulls); + #endif Datum -ExecEvalIter(Iter *iterNode, - ExprContext *econtext, - bool *resultIsNull, - bool *iterIsDone) +ExecEvalIter(Iter * iterNode, + ExprContext * econtext, + bool * resultIsNull, + bool * iterIsDone) { - Node *expression; - - expression = iterNode->iterexpr; - - /* - * Really Iter nodes are only needed for C functions, postquel function - * by their nature return 1 result at a time. For now we are only worrying - * about postquel functions, c functions will come later. - */ - return ExecEvalExpr(expression, econtext, resultIsNull, iterIsDone); + Node *expression; + + expression = iterNode->iterexpr; + + /* + * Really Iter nodes are only needed for C functions, postquel + * function by their nature return 1 result at a time. For now we are + * only worrying about postquel functions, c functions will come + * later. + */ + return ExecEvalExpr(expression, econtext, resultIsNull, iterIsDone); } void -ExecEvalFjoin(TargetEntry *tlist, - ExprContext *econtext, - bool *isNullVect, - bool *fj_isDone) +ExecEvalFjoin(TargetEntry * tlist, + ExprContext * econtext, + bool * isNullVect, + bool * fj_isDone) { #ifdef SETS_FIXED - bool isDone; - int curNode; - List *tlistP; - - Fjoin *fjNode = tlist->fjoin; - DatumPtr resVect = fjNode->fj_results; - BoolPtr alwaysDone = fjNode->fj_alwaysDone; - - if (fj_isDone) *fj_isDone = false; - /* - * For the next tuple produced by the plan, we need to re-initialize - * the Fjoin node. - */ - if (!fjNode->fj_initialized) + bool isDone; + int curNode; + List *tlistP; + + Fjoin *fjNode = tlist->fjoin; + DatumPtr resVect = fjNode->fj_results; + BoolPtr alwaysDone = fjNode->fj_alwaysDone; + + if (fj_isDone) + *fj_isDone = false; + + /* + * For the next tuple produced by the plan, we need to re-initialize + * the Fjoin node. + */ + if (!fjNode->fj_initialized) { - /* - * Initialize all of the Outer nodes - */ - curNode = 1; - foreach(tlistP, lnext(tlist)) + + /* + * Initialize all of the Outer nodes + */ + curNode = 1; + foreach(tlistP, lnext(tlist)) { - TargetEntry *tle = lfirst(tlistP); - - resVect[curNode] = ExecEvalIter((Iter*)tle->expr, - econtext, - &isNullVect[curNode], - &isDone); - if (isDone) - isNullVect[curNode] = alwaysDone[curNode] = true; - else - alwaysDone[curNode] = false; - - curNode++; + TargetEntry *tle = lfirst(tlistP); + + resVect[curNode] = ExecEvalIter((Iter *) tle->expr, + econtext, + &isNullVect[curNode], + &isDone); + if (isDone) + isNullVect[curNode] = alwaysDone[curNode] = true; + else + alwaysDone[curNode] = false; + + curNode++; } - - /* - * Initialize the inner node - */ - resVect[0] = ExecEvalIter((Iter*)fjNode->fj_innerNode->expr, - econtext, - &isNullVect[0], - &isDone); - if (isDone) - isNullVect[0] = alwaysDone[0] = true; - else - alwaysDone[0] = false; - - /* - * Mark the Fjoin as initialized now. - */ - fjNode->fj_initialized = TRUE; - - /* - * If the inner node is always done, then we are done for now - */ - if (isDone) - return; + + /* + * Initialize the inner node + */ + resVect[0] = ExecEvalIter((Iter *) fjNode->fj_innerNode->expr, + econtext, + &isNullVect[0], + &isDone); + if (isDone) + isNullVect[0] = alwaysDone[0] = true; + else + alwaysDone[0] = false; + + /* + * Mark the Fjoin as initialized now. + */ + fjNode->fj_initialized = TRUE; + + /* + * If the inner node is always done, then we are done for now + */ + if (isDone) + return; } - else + else { - /* - * If we're already initialized, all we need to do is get the - * next inner result and pair it up with the existing outer node - * result vector. Watch out for the degenerate case, where the - * inner node never returns results. - */ - - /* - * Fill in nulls for every function that is always done. - */ - for (curNode=fjNode->fj_nNodes-1; curNode >= 0; curNode--) - isNullVect[curNode] = alwaysDone[curNode]; - - if (alwaysDone[0] == true) + + /* + * If we're already initialized, all we need to do is get the next + * inner result and pair it up with the existing outer node result + * vector. Watch out for the degenerate case, where the inner + * node never returns results. + */ + + /* + * Fill in nulls for every function that is always done. + */ + for (curNode = fjNode->fj_nNodes - 1; curNode >= 0; curNode--) + isNullVect[curNode] = alwaysDone[curNode]; + + if (alwaysDone[0] == true) { - *fj_isDone = FjoinBumpOuterNodes(tlist, - econtext, - resVect, - isNullVect); - return; + *fj_isDone = FjoinBumpOuterNodes(tlist, + econtext, + resVect, + isNullVect); + return; } - else - resVect[0] = ExecEvalIter((Iter*)fjNode->fj_innerNode->expr, - econtext, - &isNullVect[0], - &isDone); + else + resVect[0] = ExecEvalIter((Iter *) fjNode->fj_innerNode->expr, + econtext, + &isNullVect[0], + &isDone); } - - /* - * if the inner node is done - */ - if (isDone) + + /* + * if the inner node is done + */ + if (isDone) { - *fj_isDone = FjoinBumpOuterNodes(tlist, - econtext, - resVect, - isNullVect); - if (*fj_isDone) - return; - - resVect[0] = ExecEvalIter((Iter*)fjNode->fj_innerNode->expr, - econtext, - &isNullVect[0], - &isDone); - + *fj_isDone = FjoinBumpOuterNodes(tlist, + econtext, + resVect, + isNullVect); + if (*fj_isDone) + return; + + resVect[0] = ExecEvalIter((Iter *) fjNode->fj_innerNode->expr, + econtext, + &isNullVect[0], + &isDone); + } #endif - return; + return; } #ifdef SETS_FIXED -static bool -FjoinBumpOuterNodes(TargetEntry *tlist, - ExprContext *econtext, - DatumPtr results, - char *nulls) +static bool +FjoinBumpOuterNodes(TargetEntry * tlist, + ExprContext * econtext, + DatumPtr results, + char *nulls) { - bool funcIsDone = true; - Fjoin *fjNode = tlist->fjoin; - char *alwaysDone = fjNode->fj_alwaysDone; - List *outerList = lnext(tlist); - List *trailers = lnext(tlist); - int trailNode = 1; - int curNode = 1; - - /* - * Run through list of functions until we get to one that isn't yet - * done returning values. Watch out for funcs that are always done. - */ - while ((funcIsDone == true) && (outerList != NIL)) + bool funcIsDone = true; + Fjoin *fjNode = tlist->fjoin; + char *alwaysDone = fjNode->fj_alwaysDone; + List *outerList = lnext(tlist); + List *trailers = lnext(tlist); + int trailNode = 1; + int curNode = 1; + + /* + * Run through list of functions until we get to one that isn't yet + * done returning values. Watch out for funcs that are always done. + */ + while ((funcIsDone == true) && (outerList != NIL)) { - TargetEntry *tle = lfirst(outerList); - - if (alwaysDone[curNode] == true) - nulls[curNode] = 'n'; - else - results[curNode] = ExecEvalIter((Iter)tle->expr, - econtext, - &nulls[curNode], - &funcIsDone); - curNode++; - outerList = lnext(outerList); + TargetEntry *tle = lfirst(outerList); + + if (alwaysDone[curNode] == true) + nulls[curNode] = 'n'; + else + results[curNode] = ExecEvalIter((Iter) tle->expr, + econtext, + &nulls[curNode], + &funcIsDone); + curNode++; + outerList = lnext(outerList); } - - /* - * If every function is done, then we are done flattening. - * Mark the Fjoin node unitialized, it is time to get the - * next tuple from the plan and redo all of the flattening. - */ - if (funcIsDone) + + /* + * If every function is done, then we are done flattening. Mark the + * Fjoin node unitialized, it is time to get the next tuple from the + * plan and redo all of the flattening. + */ + if (funcIsDone) { - set_fj_initialized(fjNode, false); - return (true); + set_fj_initialized(fjNode, false); + return (true); } - - /* - * We found a function that wasn't done. Now re-run every function - * before it. As usual watch out for functions that are always done. - */ - trailNode = 1; - while (trailNode != curNode-1) + + /* + * We found a function that wasn't done. Now re-run every function + * before it. As usual watch out for functions that are always done. + */ + trailNode = 1; + while (trailNode != curNode - 1) { - TargetEntry *tle = lfirst(trailers); - - if (alwaysDone[trailNode] != true) - results[trailNode] = ExecEvalIter((Iter)tle->expr, - econtext, - &nulls[trailNode], - &funcIsDone); - trailNode++; - trailers = lnext(trailers); + TargetEntry *tle = lfirst(trailers); + + if (alwaysDone[trailNode] != true) + results[trailNode] = ExecEvalIter((Iter) tle->expr, + econtext, + &nulls[trailNode], + &funcIsDone); + trailNode++; + trailers = lnext(trailers); } - return false; + return false; } + #endif |