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/execScan.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/execScan.c')
-rw-r--r-- | src/backend/executor/execScan.c | 208 |
1 files changed, 107 insertions, 101 deletions
diff --git a/src/backend/executor/execScan.c b/src/backend/executor/execScan.c index 8e69f491731..6ea50bb2a93 100644 --- a/src/backend/executor/execScan.c +++ b/src/backend/executor/execScan.c @@ -1,17 +1,17 @@ /*------------------------------------------------------------------------- * * execScan.c-- - * This code provides support for generalized relation scans. ExecScan - * is passed a node and a pointer to a function to "do the right thing" - * and return a tuple from the relation. ExecScan then does the tedious - * stuff - checking the qualification and projecting the tuple - * appropriately. + * This code provides support for generalized relation scans. ExecScan + * is passed a node and a pointer to a function to "do the right thing" + * and return a tuple from the relation. ExecScan then does the tedious + * stuff - checking the qualification and projecting the tuple + * appropriately. * * Copyright (c) 1994, Regents of the University of California * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/executor/execScan.c,v 1.3 1997/07/28 00:53:51 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/execScan.c,v 1.4 1997/09/07 04:41:23 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -23,117 +23,123 @@ #include "executor/executor.h" /* ---------------------------------------------------------------- - * ExecScan - * - * Scans the relation using the 'access method' indicated and - * returns the next qualifying tuple in the direction specified - * in the global variable ExecDirection. - * The access method returns the next tuple and execScan() is - * responisble for checking the tuple returned against the qual-clause. - * - * Conditions: - * -- the "cursor" maintained by the AMI is positioned at the tuple - * returned previously. - * - * Initial States: - * -- the relation indicated is opened for scanning so that the - * "cursor" is positioned before the first qualifying tuple. + * ExecScan * - * May need to put startmmgr and endmmgr in here. + * Scans the relation using the 'access method' indicated and + * returns the next qualifying tuple in the direction specified + * in the global variable ExecDirection. + * The access method returns the next tuple and execScan() is + * responisble for checking the tuple returned against the qual-clause. + * + * Conditions: + * -- the "cursor" maintained by the AMI is positioned at the tuple + * returned previously. + * + * Initial States: + * -- the relation indicated is opened for scanning so that the + * "cursor" is positioned before the first qualifying tuple. + * + * May need to put startmmgr and endmmgr in here. * ---------------------------------------------------------------- */ TupleTableSlot * -ExecScan(Scan *node, - TupleTableSlot* (*accessMtd)()) /* function returning a tuple */ +ExecScan(Scan * node, + TupleTableSlot * (*accessMtd) ()) /* function returning a + * tuple */ { - CommonScanState *scanstate; - EState *estate; - List *qual; - bool isDone; - - TupleTableSlot *slot; - TupleTableSlot *resultSlot; - HeapTuple newTuple; - - ExprContext *econtext; - ProjectionInfo *projInfo; - - - /* ---------------- - * initialize misc variables - * ---------------- - */ - newTuple = NULL; - slot = NULL; - - estate = node->plan.state; - scanstate = node->scanstate; - - /* ---------------- - * get the expression context - * ---------------- - */ - econtext = scanstate->cstate.cs_ExprContext; - - /* ---------------- - * initialize fields in ExprContext which don't change - * in the course of the scan.. - * ---------------- - */ - qual = node->plan.qual; - econtext->ecxt_relation = scanstate->css_currentRelation; - econtext->ecxt_relid = node->scanrelid; - - if (scanstate->cstate.cs_TupFromTlist) { - projInfo = scanstate->cstate.cs_ProjInfo; - resultSlot = ExecProject(projInfo, &isDone); - if (!isDone) - return resultSlot; - } - /* - * get a tuple from the access method - * loop until we obtain a tuple which passes the qualification. - */ - for(;;) { - slot = (TupleTableSlot *) (*accessMtd)(node); + CommonScanState *scanstate; + EState *estate; + List *qual; + bool isDone; + + TupleTableSlot *slot; + TupleTableSlot *resultSlot; + HeapTuple newTuple; + + ExprContext *econtext; + ProjectionInfo *projInfo; + /* ---------------- - * if the slot returned by the accessMtd contains - * NULL, then it means there is nothing more to scan - * so we just return the empty slot. + * initialize misc variables * ---------------- */ - if (TupIsNull(slot)) return slot; - + newTuple = NULL; + slot = NULL; + + estate = node->plan.state; + scanstate = node->scanstate; + /* ---------------- - * place the current tuple into the expr context + * get the expression context * ---------------- */ - econtext->ecxt_scantuple = slot; - + econtext = scanstate->cstate.cs_ExprContext; + /* ---------------- - * check that the current tuple satisfies the qual-clause - * if our qualification succeeds then we - * leave the loop. + * initialize fields in ExprContext which don't change + * in the course of the scan.. * ---------------- */ + qual = node->plan.qual; + econtext->ecxt_relation = scanstate->css_currentRelation; + econtext->ecxt_relid = node->scanrelid; + + if (scanstate->cstate.cs_TupFromTlist) + { + projInfo = scanstate->cstate.cs_ProjInfo; + resultSlot = ExecProject(projInfo, &isDone); + if (!isDone) + return resultSlot; + } + + /* + * get a tuple from the access method loop until we obtain a tuple + * which passes the qualification. + */ + for (;;) + { + slot = (TupleTableSlot *) (*accessMtd) (node); + + /* ---------------- + * if the slot returned by the accessMtd contains + * NULL, then it means there is nothing more to scan + * so we just return the empty slot. + * ---------------- + */ + if (TupIsNull(slot)) + return slot; + + /* ---------------- + * place the current tuple into the expr context + * ---------------- + */ + econtext->ecxt_scantuple = slot; + + /* ---------------- + * check that the current tuple satisfies the qual-clause + * if our qualification succeeds then we + * leave the loop. + * ---------------- + */ + + /* + * add a check for non-nil qual here to avoid a function call to + * ExecQual() when the qual is nil + */ + if (!qual || ExecQual(qual, econtext) == true) + break; + } - /* add a check for non-nil qual here to avoid a - function call to ExecQual() when the qual is nil */ - if (!qual || ExecQual(qual, econtext) == true) - break; - } - - /* ---------------- - * form a projection tuple, store it in the result tuple - * slot and return it. - * ---------------- - */ - projInfo = scanstate->cstate.cs_ProjInfo; + /* ---------------- + * form a projection tuple, store it in the result tuple + * slot and return it. + * ---------------- + */ + projInfo = scanstate->cstate.cs_ProjInfo; - resultSlot = ExecProject(projInfo, &isDone); - scanstate->cstate.cs_TupFromTlist = !isDone; + resultSlot = ExecProject(projInfo, &isDone); + scanstate->cstate.cs_TupFromTlist = !isDone; - return resultSlot; + return resultSlot; } - |