mirror of
https://github.com/postgres/postgres.git
synced 2025-07-02 09:02:37 +03:00
pgindent run.
This commit is contained in:
@ -6,7 +6,7 @@
|
||||
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $Header: /cvsroot/pgsql/src/backend/executor/execAmi.c,v 1.72 2003/07/21 17:05:00 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/executor/execAmi.c,v 1.73 2003/08/04 00:43:17 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -48,7 +48,7 @@
|
||||
* ----------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
ExecReScan(PlanState *node, ExprContext *exprCtxt)
|
||||
ExecReScan(PlanState * node, ExprContext *exprCtxt)
|
||||
{
|
||||
/* If collecting timing stats, update them */
|
||||
if (node->instrument)
|
||||
@ -61,7 +61,7 @@ ExecReScan(PlanState *node, ExprContext *exprCtxt)
|
||||
|
||||
foreach(lst, node->initPlan)
|
||||
{
|
||||
SubPlanState *sstate = (SubPlanState *) lfirst(lst);
|
||||
SubPlanState *sstate = (SubPlanState *) lfirst(lst);
|
||||
PlanState *splan = sstate->planstate;
|
||||
|
||||
if (splan->plan->extParam != NULL) /* don't care about child
|
||||
@ -72,7 +72,7 @@ ExecReScan(PlanState *node, ExprContext *exprCtxt)
|
||||
}
|
||||
foreach(lst, node->subPlan)
|
||||
{
|
||||
SubPlanState *sstate = (SubPlanState *) lfirst(lst);
|
||||
SubPlanState *sstate = (SubPlanState *) lfirst(lst);
|
||||
PlanState *splan = sstate->planstate;
|
||||
|
||||
if (splan->plan->extParam != NULL)
|
||||
@ -177,7 +177,7 @@ ExecReScan(PlanState *node, ExprContext *exprCtxt)
|
||||
* Marks the current scan position.
|
||||
*/
|
||||
void
|
||||
ExecMarkPos(PlanState *node)
|
||||
ExecMarkPos(PlanState * node)
|
||||
{
|
||||
switch (nodeTag(node))
|
||||
{
|
||||
@ -218,7 +218,7 @@ ExecMarkPos(PlanState *node)
|
||||
* restores the scan position previously saved with ExecMarkPos()
|
||||
*/
|
||||
void
|
||||
ExecRestrPos(PlanState *node)
|
||||
ExecRestrPos(PlanState * node)
|
||||
{
|
||||
switch (nodeTag(node))
|
||||
{
|
||||
@ -302,16 +302,16 @@ ExecSupportsBackwardScan(Plan *node)
|
||||
return false;
|
||||
|
||||
case T_Append:
|
||||
{
|
||||
List *l;
|
||||
|
||||
foreach(l, ((Append *) node)->appendplans)
|
||||
{
|
||||
if (!ExecSupportsBackwardScan((Plan *) lfirst(l)))
|
||||
return false;
|
||||
List *l;
|
||||
|
||||
foreach(l, ((Append *) node)->appendplans)
|
||||
{
|
||||
if (!ExecSupportsBackwardScan((Plan *) lfirst(l)))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
case T_SeqScan:
|
||||
case T_IndexScan:
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/executor/execGrouping.c,v 1.4 2003/07/21 17:05:08 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/executor/execGrouping.c,v 1.5 2003/08/04 00:43:17 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -249,7 +249,7 @@ execTuplesHashPrepare(TupleDesc tupdesc,
|
||||
eq_function = oprfuncid(optup);
|
||||
ReleaseSysCache(optup);
|
||||
hash_function = get_op_hash_function(eq_opr);
|
||||
if (!OidIsValid(hash_function)) /* should not happen */
|
||||
if (!OidIsValid(hash_function)) /* should not happen */
|
||||
elog(ERROR, "could not find hash function for hash operator %u",
|
||||
eq_opr);
|
||||
fmgr_info(eq_function, &(*eqfunctions)[i]);
|
||||
@ -289,8 +289,8 @@ BuildTupleHashTable(int numCols, AttrNumber *keyColIdx,
|
||||
int nbuckets, Size entrysize,
|
||||
MemoryContext tablecxt, MemoryContext tempcxt)
|
||||
{
|
||||
TupleHashTable hashtable;
|
||||
Size tabsize;
|
||||
TupleHashTable hashtable;
|
||||
Size tabsize;
|
||||
|
||||
Assert(nbuckets > 0);
|
||||
Assert(entrysize >= sizeof(TupleHashEntryData));
|
||||
@ -411,9 +411,9 @@ LookupTupleHashEntry(TupleHashTable hashtable, TupleTableSlot *slot,
|
||||
* Iterator state must be initialized with ResetTupleHashIterator() macro.
|
||||
*/
|
||||
TupleHashEntry
|
||||
ScanTupleHashTable(TupleHashTable hashtable, TupleHashIterator *state)
|
||||
ScanTupleHashTable(TupleHashTable hashtable, TupleHashIterator * state)
|
||||
{
|
||||
TupleHashEntry entry;
|
||||
TupleHashEntry entry;
|
||||
|
||||
entry = state->next_entry;
|
||||
while (entry == NULL)
|
||||
|
@ -26,7 +26,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/executor/execMain.c,v 1.212 2003/08/01 00:15:20 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/executor/execMain.c,v 1.213 2003/08/04 00:43:17 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -68,7 +68,7 @@ static void initResultRelInfo(ResultRelInfo *resultRelInfo,
|
||||
Index resultRelationIndex,
|
||||
List *rangeTable,
|
||||
CmdType operation);
|
||||
static TupleTableSlot *ExecutePlan(EState *estate, PlanState *planstate,
|
||||
static TupleTableSlot *ExecutePlan(EState *estate, PlanState * planstate,
|
||||
CmdType operation,
|
||||
long numberTuples,
|
||||
ScanDirection direction,
|
||||
@ -87,7 +87,7 @@ static void EndEvalPlanQual(EState *estate);
|
||||
static void ExecCheckRTEPerms(RangeTblEntry *rte, CmdType operation);
|
||||
static void ExecCheckXactReadOnly(Query *parsetree, CmdType operation);
|
||||
static void EvalPlanQualStart(evalPlanQual *epq, EState *estate,
|
||||
evalPlanQual *priorepq);
|
||||
evalPlanQual *priorepq);
|
||||
static void EvalPlanQualStop(evalPlanQual *epq);
|
||||
|
||||
/* end of local decls */
|
||||
@ -100,7 +100,7 @@ static void EvalPlanQualStop(evalPlanQual *epq);
|
||||
* query plan
|
||||
*
|
||||
* Takes a QueryDesc previously created by CreateQueryDesc (it's not real
|
||||
* clear why we bother to separate the two functions, but...). The tupDesc
|
||||
* clear why we bother to separate the two functions, but...). The tupDesc
|
||||
* field of the QueryDesc is filled in to describe the tuples that will be
|
||||
* returned, and the internal fields (estate and planstate) are set up.
|
||||
*
|
||||
@ -122,8 +122,8 @@ ExecutorStart(QueryDesc *queryDesc, bool explainOnly)
|
||||
Assert(queryDesc->estate == NULL);
|
||||
|
||||
/*
|
||||
* If the transaction is read-only, we need to check if any writes
|
||||
* are planned to non-temporary tables.
|
||||
* If the transaction is read-only, we need to check if any writes are
|
||||
* planned to non-temporary tables.
|
||||
*/
|
||||
if (!explainOnly)
|
||||
ExecCheckXactReadOnly(queryDesc->parsetree, queryDesc->operation);
|
||||
@ -362,8 +362,8 @@ ExecCheckRTEPerms(RangeTblEntry *rte, CmdType operation)
|
||||
|
||||
/*
|
||||
* Otherwise, only plain-relation RTEs need to be checked here.
|
||||
* Function RTEs are checked by init_fcache when the function is prepared
|
||||
* for execution. Join and special RTEs need no checks.
|
||||
* Function RTEs are checked by init_fcache when the function is
|
||||
* prepared for execution. Join and special RTEs need no checks.
|
||||
*/
|
||||
if (rte->rtekind != RTE_RELATION)
|
||||
return;
|
||||
@ -435,7 +435,7 @@ ExecCheckXactReadOnly(Query *parsetree, CmdType operation)
|
||||
if (operation == CMD_DELETE || operation == CMD_INSERT
|
||||
|| operation == CMD_UPDATE)
|
||||
{
|
||||
List *lp;
|
||||
List *lp;
|
||||
|
||||
foreach(lp, parsetree->rtable)
|
||||
{
|
||||
@ -474,9 +474,9 @@ static void
|
||||
InitPlan(QueryDesc *queryDesc, bool explainOnly)
|
||||
{
|
||||
CmdType operation = queryDesc->operation;
|
||||
Query *parseTree = queryDesc->parsetree;
|
||||
Plan *plan = queryDesc->plantree;
|
||||
EState *estate = queryDesc->estate;
|
||||
Query *parseTree = queryDesc->parsetree;
|
||||
Plan *plan = queryDesc->plantree;
|
||||
EState *estate = queryDesc->estate;
|
||||
PlanState *planstate;
|
||||
List *rangeTable;
|
||||
Relation intoRelationDesc;
|
||||
@ -484,8 +484,8 @@ InitPlan(QueryDesc *queryDesc, bool explainOnly)
|
||||
TupleDesc tupType;
|
||||
|
||||
/*
|
||||
* Do permissions checks. It's sufficient to examine the query's
|
||||
* top rangetable here --- subplan RTEs will be checked during
|
||||
* Do permissions checks. It's sufficient to examine the query's top
|
||||
* rangetable here --- subplan RTEs will be checked during
|
||||
* ExecInitSubPlan().
|
||||
*/
|
||||
ExecCheckRTPerms(parseTree->rtable, operation);
|
||||
@ -570,10 +570,11 @@ InitPlan(QueryDesc *queryDesc, bool explainOnly)
|
||||
if (operation == CMD_SELECT && parseTree->into != NULL)
|
||||
{
|
||||
do_select_into = true;
|
||||
|
||||
/*
|
||||
* For now, always create OIDs in SELECT INTO; this is for backwards
|
||||
* compatibility with pre-7.3 behavior. Eventually we might want
|
||||
* to allow the user to choose.
|
||||
* For now, always create OIDs in SELECT INTO; this is for
|
||||
* backwards compatibility with pre-7.3 behavior. Eventually we
|
||||
* might want to allow the user to choose.
|
||||
*/
|
||||
estate->es_force_oids = true;
|
||||
}
|
||||
@ -640,12 +641,12 @@ InitPlan(QueryDesc *queryDesc, bool explainOnly)
|
||||
tupType = ExecGetResultType(planstate);
|
||||
|
||||
/*
|
||||
* Initialize the junk filter if needed. SELECT and INSERT queries need a
|
||||
* filter if there are any junk attrs in the tlist. INSERT and SELECT
|
||||
* INTO also need a filter if the top plan node is a scan node that's not
|
||||
* doing projection (else we'll be scribbling on the scan tuple!) UPDATE
|
||||
* and DELETE always need a filter, since there's always a junk 'ctid'
|
||||
* attribute present --- no need to look first.
|
||||
* Initialize the junk filter if needed. SELECT and INSERT queries
|
||||
* need a filter if there are any junk attrs in the tlist. INSERT and
|
||||
* SELECT INTO also need a filter if the top plan node is a scan node
|
||||
* that's not doing projection (else we'll be scribbling on the scan
|
||||
* tuple!) UPDATE and DELETE always need a filter, since there's
|
||||
* always a junk 'ctid' attribute present --- no need to look first.
|
||||
*/
|
||||
{
|
||||
bool junk_filter_needed = false;
|
||||
@ -752,8 +753,8 @@ InitPlan(QueryDesc *queryDesc, bool explainOnly)
|
||||
|
||||
/*
|
||||
* If doing SELECT INTO, initialize the "into" relation. We must wait
|
||||
* till now so we have the "clean" result tuple type to create the
|
||||
* new table from.
|
||||
* till now so we have the "clean" result tuple type to create the new
|
||||
* table from.
|
||||
*
|
||||
* If EXPLAIN, skip creating the "into" relation.
|
||||
*/
|
||||
@ -795,16 +796,16 @@ InitPlan(QueryDesc *queryDesc, bool explainOnly)
|
||||
FreeTupleDesc(tupdesc);
|
||||
|
||||
/*
|
||||
* Advance command counter so that the newly-created
|
||||
* relation's catalog tuples will be visible to heap_open.
|
||||
* Advance command counter so that the newly-created relation's
|
||||
* catalog tuples will be visible to heap_open.
|
||||
*/
|
||||
CommandCounterIncrement();
|
||||
|
||||
/*
|
||||
* If necessary, create a TOAST table for the into
|
||||
* relation. Note that AlterTableCreateToastTable ends
|
||||
* with CommandCounterIncrement(), so that the TOAST table
|
||||
* will be visible for insertion.
|
||||
* If necessary, create a TOAST table for the into relation. Note
|
||||
* that AlterTableCreateToastTable ends with
|
||||
* CommandCounterIncrement(), so that the TOAST table will be
|
||||
* visible for insertion.
|
||||
*/
|
||||
AlterTableCreateToastTable(intoRelationId, true);
|
||||
|
||||
@ -841,19 +842,19 @@ initResultRelInfo(ResultRelInfo *resultRelInfo,
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
|
||||
errmsg("cannot change sequence relation \"%s\"",
|
||||
RelationGetRelationName(resultRelationDesc))));
|
||||
RelationGetRelationName(resultRelationDesc))));
|
||||
break;
|
||||
case RELKIND_TOASTVALUE:
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
|
||||
errmsg("cannot change toast relation \"%s\"",
|
||||
RelationGetRelationName(resultRelationDesc))));
|
||||
RelationGetRelationName(resultRelationDesc))));
|
||||
break;
|
||||
case RELKIND_VIEW:
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
|
||||
errmsg("cannot change view relation \"%s\"",
|
||||
RelationGetRelationName(resultRelationDesc))));
|
||||
RelationGetRelationName(resultRelationDesc))));
|
||||
break;
|
||||
}
|
||||
|
||||
@ -894,7 +895,7 @@ initResultRelInfo(ResultRelInfo *resultRelInfo,
|
||||
* ----------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
ExecEndPlan(PlanState *planstate, EState *estate)
|
||||
ExecEndPlan(PlanState * planstate, EState *estate)
|
||||
{
|
||||
ResultRelInfo *resultRelInfo;
|
||||
int i;
|
||||
@ -964,18 +965,18 @@ ExecEndPlan(PlanState *planstate, EState *estate)
|
||||
*/
|
||||
static TupleTableSlot *
|
||||
ExecutePlan(EState *estate,
|
||||
PlanState *planstate,
|
||||
PlanState * planstate,
|
||||
CmdType operation,
|
||||
long numberTuples,
|
||||
ScanDirection direction,
|
||||
DestReceiver *dest)
|
||||
{
|
||||
JunkFilter *junkfilter;
|
||||
TupleTableSlot *slot;
|
||||
ItemPointer tupleid = NULL;
|
||||
ItemPointerData tuple_ctid;
|
||||
long current_tuple_count;
|
||||
TupleTableSlot *result;
|
||||
JunkFilter *junkfilter;
|
||||
TupleTableSlot *slot;
|
||||
ItemPointer tupleid = NULL;
|
||||
ItemPointerData tuple_ctid;
|
||||
long current_tuple_count;
|
||||
TupleTableSlot *result;
|
||||
|
||||
/*
|
||||
* initialize local variables
|
||||
@ -1199,7 +1200,7 @@ lnext: ;
|
||||
|
||||
/*
|
||||
* check our tuple count.. if we've processed the proper number
|
||||
* then quit, else loop again and process more tuples. Zero
|
||||
* then quit, else loop again and process more tuples. Zero
|
||||
* numberTuples means no limit.
|
||||
*/
|
||||
current_tuple_count++;
|
||||
@ -1309,7 +1310,7 @@ ExecInsert(TupleTableSlot *slot,
|
||||
|
||||
/* BEFORE ROW INSERT Triggers */
|
||||
if (resultRelInfo->ri_TrigDesc &&
|
||||
resultRelInfo->ri_TrigDesc->n_before_row[TRIGGER_EVENT_INSERT] > 0)
|
||||
resultRelInfo->ri_TrigDesc->n_before_row[TRIGGER_EVENT_INSERT] > 0)
|
||||
{
|
||||
HeapTuple newtuple;
|
||||
|
||||
@ -1686,13 +1687,13 @@ ExecConstraints(ResultRelInfo *resultRelInfo,
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_NOT_NULL_VIOLATION),
|
||||
errmsg("null value for attribute \"%s\" violates NOT NULL constraint",
|
||||
NameStr(rel->rd_att->attrs[attrChk - 1]->attname))));
|
||||
NameStr(rel->rd_att->attrs[attrChk - 1]->attname))));
|
||||
}
|
||||
}
|
||||
|
||||
if (constr->num_check > 0)
|
||||
{
|
||||
const char *failed;
|
||||
const char *failed;
|
||||
|
||||
if ((failed = ExecRelCheck(resultRelInfo, slot, estate)) != NULL)
|
||||
ereport(ERROR,
|
||||
@ -1884,10 +1885,11 @@ EvalPlanQual(EState *estate, Index rti, ItemPointer tid)
|
||||
* integrated with the Param mechanism somehow, so that the upper plan
|
||||
* nodes know that their children's outputs have changed.
|
||||
*
|
||||
* Note that the stack of free evalPlanQual nodes is quite useless at
|
||||
* the moment, since it only saves us from pallocing/releasing the
|
||||
* Note that the stack of free evalPlanQual nodes is quite useless at the
|
||||
* moment, since it only saves us from pallocing/releasing the
|
||||
* evalPlanQual nodes themselves. But it will be useful once we
|
||||
* implement ReScan instead of end/restart for re-using PlanQual nodes.
|
||||
* implement ReScan instead of end/restart for re-using PlanQual
|
||||
* nodes.
|
||||
*/
|
||||
if (endNode)
|
||||
{
|
||||
@ -1898,10 +1900,11 @@ EvalPlanQual(EState *estate, Index rti, ItemPointer tid)
|
||||
/*
|
||||
* Initialize new recheck query.
|
||||
*
|
||||
* Note: if we were re-using PlanQual plans via ExecReScan, we'd need
|
||||
* to instead copy down changeable state from the top plan (including
|
||||
* es_result_relation_info, es_junkFilter) and reset locally changeable
|
||||
* state in the epq (including es_param_exec_vals, es_evTupleNull).
|
||||
* Note: if we were re-using PlanQual plans via ExecReScan, we'd need to
|
||||
* instead copy down changeable state from the top plan (including
|
||||
* es_result_relation_info, es_junkFilter) and reset locally
|
||||
* changeable state in the epq (including es_param_exec_vals,
|
||||
* es_evTupleNull).
|
||||
*/
|
||||
EvalPlanQualStart(epq, estate, epq->next);
|
||||
|
||||
@ -2016,9 +2019,9 @@ EvalPlanQualStart(evalPlanQual *epq, EState *estate, evalPlanQual *priorepq)
|
||||
|
||||
/*
|
||||
* The epqstates share the top query's copy of unchanging state such
|
||||
* as the snapshot, rangetable, result-rel info, and external Param info.
|
||||
* They need their own copies of local state, including a tuple table,
|
||||
* es_param_exec_vals, etc.
|
||||
* as the snapshot, rangetable, result-rel info, and external Param
|
||||
* info. They need their own copies of local state, including a tuple
|
||||
* table, es_param_exec_vals, etc.
|
||||
*/
|
||||
epqstate->es_direction = ForwardScanDirection;
|
||||
epqstate->es_snapshot = estate->es_snapshot;
|
||||
@ -2036,11 +2039,11 @@ EvalPlanQualStart(evalPlanQual *epq, EState *estate, evalPlanQual *priorepq)
|
||||
epqstate->es_instrument = estate->es_instrument;
|
||||
epqstate->es_force_oids = estate->es_force_oids;
|
||||
epqstate->es_topPlan = estate->es_topPlan;
|
||||
|
||||
/*
|
||||
* Each epqstate must have its own es_evTupleNull state, but
|
||||
* all the stack entries share es_evTuple state. This allows
|
||||
* sub-rechecks to inherit the value being examined by an
|
||||
* outer recheck.
|
||||
* Each epqstate must have its own es_evTupleNull state, but all the
|
||||
* stack entries share es_evTuple state. This allows sub-rechecks to
|
||||
* inherit the value being examined by an outer recheck.
|
||||
*/
|
||||
epqstate->es_evTupleNull = (bool *) palloc0(rtsize * sizeof(bool));
|
||||
if (priorepq == NULL)
|
||||
|
@ -12,7 +12,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/executor/execProcnode.c,v 1.37 2003/07/21 17:05:08 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/executor/execProcnode.c,v 1.38 2003/08/04 00:43:17 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -52,7 +52,7 @@
|
||||
* * ExecInitNode() notices that it is looking at a nest loop and
|
||||
* as the code below demonstrates, it calls ExecInitNestLoop().
|
||||
* Eventually this calls ExecInitNode() on the right and left subplans
|
||||
* and so forth until the entire plan is initialized. The result
|
||||
* and so forth until the entire plan is initialized. The result
|
||||
* of ExecInitNode() is a plan state tree built with the same structure
|
||||
* as the underlying plan tree.
|
||||
*
|
||||
@ -226,7 +226,7 @@ ExecInitNode(Plan *node, EState *estate)
|
||||
subps = NIL;
|
||||
foreach(subp, node->initPlan)
|
||||
{
|
||||
SubPlan *subplan = (SubPlan *) lfirst(subp);
|
||||
SubPlan *subplan = (SubPlan *) lfirst(subp);
|
||||
SubPlanState *sstate;
|
||||
|
||||
Assert(IsA(subplan, SubPlan));
|
||||
@ -237,9 +237,9 @@ ExecInitNode(Plan *node, EState *estate)
|
||||
result->initPlan = subps;
|
||||
|
||||
/*
|
||||
* Initialize any subPlans present in this node. These were found
|
||||
* by ExecInitExpr during initialization of the PlanState. Note we
|
||||
* must do this after initializing initPlans, in case their arguments
|
||||
* Initialize any subPlans present in this node. These were found by
|
||||
* ExecInitExpr during initialization of the PlanState. Note we must
|
||||
* do this after initializing initPlans, in case their arguments
|
||||
* contain subPlans (is that actually possible? perhaps not).
|
||||
*/
|
||||
subps = NIL;
|
||||
@ -268,7 +268,7 @@ ExecInitNode(Plan *node, EState *estate)
|
||||
* ----------------------------------------------------------------
|
||||
*/
|
||||
TupleTableSlot *
|
||||
ExecProcNode(PlanState *node)
|
||||
ExecProcNode(PlanState * node)
|
||||
{
|
||||
TupleTableSlot *result;
|
||||
|
||||
@ -280,7 +280,7 @@ ExecProcNode(PlanState *node)
|
||||
if (node == NULL)
|
||||
return NULL;
|
||||
|
||||
if (node->chgParam != NULL) /* something changed */
|
||||
if (node->chgParam != NULL) /* something changed */
|
||||
ExecReScan(node, NULL); /* let ReScan handle this */
|
||||
|
||||
if (node->instrument)
|
||||
@ -484,7 +484,7 @@ ExecCountSlotsNode(Plan *node)
|
||||
* ----------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
ExecEndNode(PlanState *node)
|
||||
ExecEndNode(PlanState * node)
|
||||
{
|
||||
List *subp;
|
||||
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/executor/execQual.c,v 1.138 2003/08/01 00:15:21 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/executor/execQual.c,v 1.139 2003/08/04 00:43:17 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -50,55 +50,55 @@
|
||||
|
||||
|
||||
/* static function decls */
|
||||
static Datum ExecEvalAggref(AggrefExprState *aggref,
|
||||
ExprContext *econtext,
|
||||
bool *isNull);
|
||||
static Datum ExecEvalArrayRef(ArrayRefExprState *astate,
|
||||
ExprContext *econtext,
|
||||
bool *isNull, ExprDoneCond *isDone);
|
||||
static Datum ExecEvalAggref(AggrefExprState * aggref,
|
||||
ExprContext *econtext,
|
||||
bool *isNull);
|
||||
static Datum ExecEvalArrayRef(ArrayRefExprState * astate,
|
||||
ExprContext *econtext,
|
||||
bool *isNull, ExprDoneCond *isDone);
|
||||
static Datum ExecEvalVar(Var *variable, ExprContext *econtext, bool *isNull);
|
||||
static Datum ExecEvalParam(Param *expression, ExprContext *econtext,
|
||||
bool *isNull);
|
||||
static Datum ExecEvalFunc(FuncExprState *fcache, ExprContext *econtext,
|
||||
bool *isNull);
|
||||
static Datum ExecEvalFunc(FuncExprState * fcache, ExprContext *econtext,
|
||||
bool *isNull, ExprDoneCond *isDone);
|
||||
static Datum ExecEvalOper(FuncExprState *fcache, ExprContext *econtext,
|
||||
static Datum ExecEvalOper(FuncExprState * fcache, ExprContext *econtext,
|
||||
bool *isNull, ExprDoneCond *isDone);
|
||||
static Datum ExecEvalDistinct(FuncExprState *fcache, ExprContext *econtext,
|
||||
static Datum ExecEvalDistinct(FuncExprState * fcache, ExprContext *econtext,
|
||||
bool *isNull);
|
||||
static Datum ExecEvalScalarArrayOp(ScalarArrayOpExprState *sstate,
|
||||
ExprContext *econtext, bool *isNull);
|
||||
static Datum ExecEvalScalarArrayOp(ScalarArrayOpExprState * sstate,
|
||||
ExprContext *econtext, bool *isNull);
|
||||
static ExprDoneCond ExecEvalFuncArgs(FunctionCallInfo fcinfo,
|
||||
List *argList, ExprContext *econtext);
|
||||
static Datum ExecEvalNot(BoolExprState *notclause, ExprContext *econtext,
|
||||
bool *isNull);
|
||||
static Datum ExecEvalOr(BoolExprState *orExpr, ExprContext *econtext,
|
||||
bool *isNull);
|
||||
static Datum ExecEvalAnd(BoolExprState *andExpr, ExprContext *econtext,
|
||||
bool *isNull);
|
||||
static Datum ExecEvalCase(CaseExprState *caseExpr, ExprContext *econtext,
|
||||
static Datum ExecEvalNot(BoolExprState * notclause, ExprContext *econtext,
|
||||
bool *isNull);
|
||||
static Datum ExecEvalOr(BoolExprState * orExpr, ExprContext *econtext,
|
||||
bool *isNull);
|
||||
static Datum ExecEvalAnd(BoolExprState * andExpr, ExprContext *econtext,
|
||||
bool *isNull);
|
||||
static Datum ExecEvalCase(CaseExprState * caseExpr, ExprContext *econtext,
|
||||
bool *isNull, ExprDoneCond *isDone);
|
||||
static Datum ExecEvalArray(ArrayExprState *astate,
|
||||
ExprContext *econtext,
|
||||
bool *isNull);
|
||||
static Datum ExecEvalCoalesce(CoalesceExprState *coalesceExpr,
|
||||
ExprContext *econtext,
|
||||
bool *isNull);
|
||||
static Datum ExecEvalNullIf(FuncExprState *nullIfExpr, ExprContext *econtext,
|
||||
bool *isNull);
|
||||
static Datum ExecEvalNullTest(GenericExprState *nstate,
|
||||
ExprContext *econtext,
|
||||
bool *isNull, ExprDoneCond *isDone);
|
||||
static Datum ExecEvalBooleanTest(GenericExprState *bstate,
|
||||
ExprContext *econtext,
|
||||
bool *isNull, ExprDoneCond *isDone);
|
||||
static Datum ExecEvalCoerceToDomain(CoerceToDomainState *cstate,
|
||||
static Datum ExecEvalArray(ArrayExprState * astate,
|
||||
ExprContext *econtext,
|
||||
bool *isNull);
|
||||
static Datum ExecEvalCoalesce(CoalesceExprState * coalesceExpr,
|
||||
ExprContext *econtext,
|
||||
bool *isNull);
|
||||
static Datum ExecEvalNullIf(FuncExprState * nullIfExpr, ExprContext *econtext,
|
||||
bool *isNull);
|
||||
static Datum ExecEvalNullTest(GenericExprState * nstate,
|
||||
ExprContext *econtext,
|
||||
bool *isNull, ExprDoneCond *isDone);
|
||||
static Datum ExecEvalBooleanTest(GenericExprState * bstate,
|
||||
ExprContext *econtext,
|
||||
bool *isNull, ExprDoneCond *isDone);
|
||||
static Datum ExecEvalCoerceToDomain(CoerceToDomainState * cstate,
|
||||
ExprContext *econtext,
|
||||
bool *isNull, ExprDoneCond *isDone);
|
||||
static Datum ExecEvalCoerceToDomainValue(CoerceToDomainValue *conVal,
|
||||
ExprContext *econtext, bool *isNull);
|
||||
static Datum ExecEvalFieldSelect(GenericExprState *fstate,
|
||||
ExprContext *econtext,
|
||||
bool *isNull, ExprDoneCond *isDone);
|
||||
static Datum ExecEvalCoerceToDomainValue(CoerceToDomainValue * conVal,
|
||||
ExprContext *econtext, bool *isNull);
|
||||
static Datum ExecEvalFieldSelect(GenericExprState * fstate,
|
||||
ExprContext *econtext,
|
||||
bool *isNull, ExprDoneCond *isDone);
|
||||
|
||||
|
||||
/*----------
|
||||
@ -127,7 +127,7 @@ static Datum ExecEvalFieldSelect(GenericExprState *fstate,
|
||||
*----------
|
||||
*/
|
||||
static Datum
|
||||
ExecEvalArrayRef(ArrayRefExprState *astate,
|
||||
ExecEvalArrayRef(ArrayRefExprState * astate,
|
||||
ExprContext *econtext,
|
||||
bool *isNull,
|
||||
ExprDoneCond *isDone)
|
||||
@ -301,7 +301,7 @@ ExecEvalArrayRef(ArrayRefExprState *astate,
|
||||
* ----------------------------------------------------------------
|
||||
*/
|
||||
static Datum
|
||||
ExecEvalAggref(AggrefExprState *aggref, ExprContext *econtext, bool *isNull)
|
||||
ExecEvalAggref(AggrefExprState * aggref, ExprContext *econtext, bool *isNull)
|
||||
{
|
||||
if (econtext->ecxt_aggvalues == NULL) /* safety check */
|
||||
elog(ERROR, "no aggregates in this expression context");
|
||||
@ -382,8 +382,8 @@ ExecEvalVar(Var *variable, ExprContext *econtext, bool *isNull)
|
||||
*
|
||||
* XXX this is a horrid crock: since the pointer to the slot might live
|
||||
* longer than the current evaluation context, we are forced to copy
|
||||
* the tuple and slot into a long-lived context --- we use
|
||||
* the econtext's per-query memory which should be safe enough. This
|
||||
* the tuple and slot into a long-lived context --- we use the
|
||||
* econtext's per-query memory which should be safe enough. This
|
||||
* represents a serious memory leak if many such tuples are processed
|
||||
* in one command, however. We ought to redesign the representation
|
||||
* of whole-tuple datums so that this is not necessary.
|
||||
@ -439,7 +439,8 @@ ExecEvalParam(Param *expression, ExprContext *econtext, bool *isNull)
|
||||
{
|
||||
/*
|
||||
* PARAM_EXEC params (internal executor parameters) are stored in
|
||||
* the ecxt_param_exec_vals array, and can be accessed by array index.
|
||||
* the ecxt_param_exec_vals array, and can be accessed by array
|
||||
* index.
|
||||
*/
|
||||
ParamExecData *prm;
|
||||
|
||||
@ -457,9 +458,9 @@ ExecEvalParam(Param *expression, ExprContext *econtext, bool *isNull)
|
||||
else
|
||||
{
|
||||
/*
|
||||
* All other parameter types must be sought in ecxt_param_list_info.
|
||||
* NOTE: The last entry in the param array is always an
|
||||
* entry with kind == PARAM_INVALID.
|
||||
* All other parameter types must be sought in
|
||||
* ecxt_param_list_info. NOTE: The last entry in the param array
|
||||
* is always an entry with kind == PARAM_INVALID.
|
||||
*/
|
||||
ParamListInfo paramList = econtext->ecxt_param_list_info;
|
||||
char *thisParamName = expression->paramname;
|
||||
@ -488,8 +489,8 @@ ExecEvalParam(Param *expression, ExprContext *econtext, bool *isNull)
|
||||
}
|
||||
if (!matchFound)
|
||||
paramList++;
|
||||
} /* while */
|
||||
} /* if */
|
||||
} /* while */
|
||||
} /* if */
|
||||
|
||||
if (!matchFound)
|
||||
{
|
||||
@ -605,7 +606,7 @@ GetAttributeByName(TupleTableSlot *slot, char *attname, bool *isNull)
|
||||
* init_fcache - initialize a FuncExprState node during first use
|
||||
*/
|
||||
void
|
||||
init_fcache(Oid foid, FuncExprState *fcache, MemoryContext fcacheCxt)
|
||||
init_fcache(Oid foid, FuncExprState * fcache, MemoryContext fcacheCxt)
|
||||
{
|
||||
AclResult aclresult;
|
||||
|
||||
@ -678,7 +679,7 @@ ExecEvalFuncArgs(FunctionCallInfo fcinfo,
|
||||
* Evaluate the arguments to a function and then the function itself.
|
||||
*/
|
||||
Datum
|
||||
ExecMakeFunctionResult(FuncExprState *fcache,
|
||||
ExecMakeFunctionResult(FuncExprState * fcache,
|
||||
ExprContext *econtext,
|
||||
bool *isNull,
|
||||
ExprDoneCond *isDone)
|
||||
@ -881,7 +882,7 @@ ExecMakeFunctionResult(FuncExprState *fcache,
|
||||
* object. (If function returns an empty set, we just return NULL instead.)
|
||||
*/
|
||||
Tuplestorestate *
|
||||
ExecMakeTableFunctionResult(ExprState *funcexpr,
|
||||
ExecMakeTableFunctionResult(ExprState * funcexpr,
|
||||
ExprContext *econtext,
|
||||
TupleDesc expectedDesc,
|
||||
TupleDesc *returnDesc)
|
||||
@ -899,14 +900,14 @@ ExecMakeTableFunctionResult(ExprState *funcexpr,
|
||||
bool returnsTuple = false;
|
||||
|
||||
/*
|
||||
* Normally the passed expression tree will be a FuncExprState, since the
|
||||
* grammar only allows a function call at the top level of a table
|
||||
* function reference. However, if the function doesn't return set then
|
||||
* the planner might have replaced the function call via constant-folding
|
||||
* or inlining. So if we see any other kind of expression node, execute
|
||||
* it via the general ExecEvalExpr() code; the only difference is that
|
||||
* we don't get a chance to pass a special ReturnSetInfo to any functions
|
||||
* buried in the expression.
|
||||
* Normally the passed expression tree will be a FuncExprState, since
|
||||
* the grammar only allows a function call at the top level of a table
|
||||
* function reference. However, if the function doesn't return set
|
||||
* then the planner might have replaced the function call via
|
||||
* constant-folding or inlining. So if we see any other kind of
|
||||
* expression node, execute it via the general ExecEvalExpr() code;
|
||||
* the only difference is that we don't get a chance to pass a special
|
||||
* ReturnSetInfo to any functions buried in the expression.
|
||||
*/
|
||||
if (funcexpr && IsA(funcexpr, FuncExprState) &&
|
||||
IsA(funcexpr->expr, FuncExpr))
|
||||
@ -924,7 +925,7 @@ ExecMakeTableFunctionResult(ExprState *funcexpr,
|
||||
*/
|
||||
if (fcache->func.fn_oid == InvalidOid)
|
||||
{
|
||||
FuncExpr *func = (FuncExpr *) fcache->xprstate.expr;
|
||||
FuncExpr *func = (FuncExpr *) fcache->xprstate.expr;
|
||||
|
||||
init_fcache(func->funcid, fcache, econtext->ecxt_per_query_memory);
|
||||
}
|
||||
@ -933,9 +934,9 @@ ExecMakeTableFunctionResult(ExprState *funcexpr,
|
||||
* Evaluate the function's argument list.
|
||||
*
|
||||
* Note: ideally, we'd do this in the per-tuple context, but then the
|
||||
* argument values would disappear when we reset the context in the
|
||||
* inner loop. So do it in caller context. Perhaps we should make a
|
||||
* separate context just to hold the evaluated arguments?
|
||||
* argument values would disappear when we reset the context in
|
||||
* the inner loop. So do it in caller context. Perhaps we should
|
||||
* make a separate context just to hold the evaluated arguments?
|
||||
*/
|
||||
MemSet(&fcinfo, 0, sizeof(fcinfo));
|
||||
fcinfo.flinfo = &(fcache->func);
|
||||
@ -990,7 +991,8 @@ ExecMakeTableFunctionResult(ExprState *funcexpr,
|
||||
rsinfo.setDesc = NULL;
|
||||
|
||||
/*
|
||||
* Switch to short-lived context for calling the function or expression.
|
||||
* Switch to short-lived context for calling the function or
|
||||
* expression.
|
||||
*/
|
||||
callerContext = MemoryContextSwitchTo(econtext->ecxt_per_tuple_memory);
|
||||
|
||||
@ -1004,9 +1006,9 @@ ExecMakeTableFunctionResult(ExprState *funcexpr,
|
||||
HeapTuple tuple;
|
||||
|
||||
/*
|
||||
* reset per-tuple memory context before each call of the
|
||||
* function or expression. This cleans up any local memory the
|
||||
* function may leak when called.
|
||||
* reset per-tuple memory context before each call of the function
|
||||
* or expression. This cleans up any local memory the function may
|
||||
* leak when called.
|
||||
*/
|
||||
ResetExprContext(econtext);
|
||||
|
||||
@ -1157,7 +1159,7 @@ ExecMakeTableFunctionResult(ExprState *funcexpr,
|
||||
* ----------------------------------------------------------------
|
||||
*/
|
||||
static Datum
|
||||
ExecEvalFunc(FuncExprState *fcache,
|
||||
ExecEvalFunc(FuncExprState * fcache,
|
||||
ExprContext *econtext,
|
||||
bool *isNull,
|
||||
ExprDoneCond *isDone)
|
||||
@ -1167,7 +1169,7 @@ ExecEvalFunc(FuncExprState *fcache,
|
||||
*/
|
||||
if (fcache->func.fn_oid == InvalidOid)
|
||||
{
|
||||
FuncExpr *func = (FuncExpr *) fcache->xprstate.expr;
|
||||
FuncExpr *func = (FuncExpr *) fcache->xprstate.expr;
|
||||
|
||||
init_fcache(func->funcid, fcache, econtext->ecxt_per_query_memory);
|
||||
}
|
||||
@ -1180,7 +1182,7 @@ ExecEvalFunc(FuncExprState *fcache,
|
||||
* ----------------------------------------------------------------
|
||||
*/
|
||||
static Datum
|
||||
ExecEvalOper(FuncExprState *fcache,
|
||||
ExecEvalOper(FuncExprState * fcache,
|
||||
ExprContext *econtext,
|
||||
bool *isNull,
|
||||
ExprDoneCond *isDone)
|
||||
@ -1190,7 +1192,7 @@ ExecEvalOper(FuncExprState *fcache,
|
||||
*/
|
||||
if (fcache->func.fn_oid == InvalidOid)
|
||||
{
|
||||
OpExpr *op = (OpExpr *) fcache->xprstate.expr;
|
||||
OpExpr *op = (OpExpr *) fcache->xprstate.expr;
|
||||
|
||||
init_fcache(op->opfuncid, fcache, econtext->ecxt_per_query_memory);
|
||||
}
|
||||
@ -1210,7 +1212,7 @@ ExecEvalOper(FuncExprState *fcache,
|
||||
* ----------------------------------------------------------------
|
||||
*/
|
||||
static Datum
|
||||
ExecEvalDistinct(FuncExprState *fcache,
|
||||
ExecEvalDistinct(FuncExprState * fcache,
|
||||
ExprContext *econtext,
|
||||
bool *isNull)
|
||||
{
|
||||
@ -1242,7 +1244,7 @@ ExecEvalDistinct(FuncExprState *fcache,
|
||||
if (argDone != ExprSingleResult)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_DATATYPE_MISMATCH),
|
||||
errmsg("IS DISTINCT FROM does not support set arguments")));
|
||||
errmsg("IS DISTINCT FROM does not support set arguments")));
|
||||
Assert(fcinfo.nargs == 2);
|
||||
|
||||
if (fcinfo.argnull[0] && fcinfo.argnull[1])
|
||||
@ -1272,11 +1274,11 @@ ExecEvalDistinct(FuncExprState *fcache,
|
||||
*
|
||||
* Evaluate "scalar op ANY/ALL (array)". The operator always yields boolean,
|
||||
* and we combine the results across all array elements using OR and AND
|
||||
* (for ANY and ALL respectively). Of course we short-circuit as soon as
|
||||
* (for ANY and ALL respectively). Of course we short-circuit as soon as
|
||||
* the result is known.
|
||||
*/
|
||||
static Datum
|
||||
ExecEvalScalarArrayOp(ScalarArrayOpExprState *sstate,
|
||||
ExecEvalScalarArrayOp(ScalarArrayOpExprState * sstate,
|
||||
ExprContext *econtext, bool *isNull)
|
||||
{
|
||||
ScalarArrayOpExpr *opexpr = (ScalarArrayOpExpr *) sstate->fxprstate.xprstate.expr;
|
||||
@ -1310,12 +1312,12 @@ ExecEvalScalarArrayOp(ScalarArrayOpExprState *sstate,
|
||||
if (argDone != ExprSingleResult)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_DATATYPE_MISMATCH),
|
||||
errmsg("op ANY/ALL (array) does not support set arguments")));
|
||||
errmsg("op ANY/ALL (array) does not support set arguments")));
|
||||
Assert(fcinfo.nargs == 2);
|
||||
|
||||
/*
|
||||
* If the array is NULL then we return NULL --- it's not very meaningful
|
||||
* to do anything else, even if the operator isn't strict.
|
||||
* If the array is NULL then we return NULL --- it's not very
|
||||
* meaningful to do anything else, even if the operator isn't strict.
|
||||
*/
|
||||
if (fcinfo.argnull[1])
|
||||
{
|
||||
@ -1334,6 +1336,7 @@ ExecEvalScalarArrayOp(ScalarArrayOpExprState *sstate,
|
||||
nitems = ArrayGetNItems(ARR_NDIM(arr), ARR_DIMS(arr));
|
||||
if (nitems <= 0)
|
||||
return BoolGetDatum(!useOr);
|
||||
|
||||
/*
|
||||
* If the scalar is NULL, and the function is strict, return NULL.
|
||||
* This is just to avoid having to test for strictness inside the
|
||||
@ -1347,8 +1350,8 @@ ExecEvalScalarArrayOp(ScalarArrayOpExprState *sstate,
|
||||
}
|
||||
|
||||
/*
|
||||
* We arrange to look up info about the element type only
|
||||
* once per series of calls, assuming the element type doesn't change
|
||||
* We arrange to look up info about the element type only once per
|
||||
* series of calls, assuming the element type doesn't change
|
||||
* underneath us.
|
||||
*/
|
||||
if (sstate->element_type != ARR_ELEMTYPE(arr))
|
||||
@ -1370,8 +1373,8 @@ ExecEvalScalarArrayOp(ScalarArrayOpExprState *sstate,
|
||||
s = (char *) ARR_DATA_PTR(arr);
|
||||
for (i = 0; i < nitems; i++)
|
||||
{
|
||||
Datum elt;
|
||||
Datum thisresult;
|
||||
Datum elt;
|
||||
Datum thisresult;
|
||||
|
||||
/* Get array element */
|
||||
elt = fetch_att(s, typbyval, typlen);
|
||||
@ -1394,7 +1397,7 @@ ExecEvalScalarArrayOp(ScalarArrayOpExprState *sstate,
|
||||
{
|
||||
result = BoolGetDatum(true);
|
||||
resultnull = false;
|
||||
break; /* needn't look at any more elements */
|
||||
break; /* needn't look at any more elements */
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -1403,7 +1406,7 @@ ExecEvalScalarArrayOp(ScalarArrayOpExprState *sstate,
|
||||
{
|
||||
result = BoolGetDatum(false);
|
||||
resultnull = false;
|
||||
break; /* needn't look at any more elements */
|
||||
break; /* needn't look at any more elements */
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1428,7 +1431,7 @@ ExecEvalScalarArrayOp(ScalarArrayOpExprState *sstate,
|
||||
* ----------------------------------------------------------------
|
||||
*/
|
||||
static Datum
|
||||
ExecEvalNot(BoolExprState *notclause, ExprContext *econtext, bool *isNull)
|
||||
ExecEvalNot(BoolExprState * notclause, ExprContext *econtext, bool *isNull)
|
||||
{
|
||||
ExprState *clause;
|
||||
Datum expr_value;
|
||||
@ -1456,7 +1459,7 @@ ExecEvalNot(BoolExprState *notclause, ExprContext *econtext, bool *isNull)
|
||||
* ----------------------------------------------------------------
|
||||
*/
|
||||
static Datum
|
||||
ExecEvalOr(BoolExprState *orExpr, ExprContext *econtext, bool *isNull)
|
||||
ExecEvalOr(BoolExprState * orExpr, ExprContext *econtext, bool *isNull)
|
||||
{
|
||||
List *clauses;
|
||||
List *clause;
|
||||
@ -1504,7 +1507,7 @@ ExecEvalOr(BoolExprState *orExpr, ExprContext *econtext, bool *isNull)
|
||||
* ----------------------------------------------------------------
|
||||
*/
|
||||
static Datum
|
||||
ExecEvalAnd(BoolExprState *andExpr, ExprContext *econtext, bool *isNull)
|
||||
ExecEvalAnd(BoolExprState * andExpr, ExprContext *econtext, bool *isNull)
|
||||
{
|
||||
List *clauses;
|
||||
List *clause;
|
||||
@ -1552,7 +1555,7 @@ ExecEvalAnd(BoolExprState *andExpr, ExprContext *econtext, bool *isNull)
|
||||
* ----------------------------------------------------------------
|
||||
*/
|
||||
static Datum
|
||||
ExecEvalCase(CaseExprState *caseExpr, ExprContext *econtext,
|
||||
ExecEvalCase(CaseExprState * caseExpr, ExprContext *econtext,
|
||||
bool *isNull, ExprDoneCond *isDone)
|
||||
{
|
||||
List *clauses;
|
||||
@ -1610,22 +1613,22 @@ ExecEvalCase(CaseExprState *caseExpr, ExprContext *econtext,
|
||||
* ----------------------------------------------------------------
|
||||
*/
|
||||
static Datum
|
||||
ExecEvalArray(ArrayExprState *astate, ExprContext *econtext,
|
||||
ExecEvalArray(ArrayExprState * astate, ExprContext *econtext,
|
||||
bool *isNull)
|
||||
{
|
||||
ArrayExpr *arrayExpr = (ArrayExpr *) astate->xprstate.expr;
|
||||
ArrayExpr *arrayExpr = (ArrayExpr *) astate->xprstate.expr;
|
||||
ArrayType *result;
|
||||
List *element;
|
||||
Oid element_type = arrayExpr->element_typeid;
|
||||
int ndims = arrayExpr->ndims;
|
||||
int dims[MAXDIM];
|
||||
int lbs[MAXDIM];
|
||||
List *element;
|
||||
Oid element_type = arrayExpr->element_typeid;
|
||||
int ndims = arrayExpr->ndims;
|
||||
int dims[MAXDIM];
|
||||
int lbs[MAXDIM];
|
||||
|
||||
if (ndims == 1)
|
||||
{
|
||||
int nelems;
|
||||
Datum *dvalues;
|
||||
int i = 0;
|
||||
int nelems;
|
||||
Datum *dvalues;
|
||||
int i = 0;
|
||||
|
||||
nelems = length(astate->elements);
|
||||
|
||||
@ -1683,7 +1686,7 @@ ExecEvalArray(ArrayExprState *astate, ExprContext *econtext,
|
||||
/* loop through and get data area from each element */
|
||||
foreach(element, astate->elements)
|
||||
{
|
||||
ExprState *e = (ExprState *) lfirst(element);
|
||||
ExprState *e = (ExprState *) lfirst(element);
|
||||
bool eisnull;
|
||||
Datum arraydatum;
|
||||
ArrayType *array;
|
||||
@ -1718,8 +1721,8 @@ ExecEvalArray(ArrayExprState *astate, ExprContext *econtext,
|
||||
elem_ndims * sizeof(int)) != 0)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR),
|
||||
errmsg("multidimensional arrays must have array "
|
||||
"expressions with matching dimensions")));
|
||||
errmsg("multidimensional arrays must have array "
|
||||
"expressions with matching dimensions")));
|
||||
}
|
||||
|
||||
elem_ndatabytes = ARR_SIZE(array) - ARR_OVERHEAD(elem_ndims);
|
||||
@ -1767,16 +1770,16 @@ ExecEvalArray(ArrayExprState *astate, ExprContext *econtext,
|
||||
* ----------------------------------------------------------------
|
||||
*/
|
||||
static Datum
|
||||
ExecEvalCoalesce(CoalesceExprState *coalesceExpr, ExprContext *econtext,
|
||||
ExecEvalCoalesce(CoalesceExprState * coalesceExpr, ExprContext *econtext,
|
||||
bool *isNull)
|
||||
{
|
||||
List *arg;
|
||||
List *arg;
|
||||
|
||||
/* Simply loop through until something NOT NULL is found */
|
||||
foreach(arg, coalesceExpr->args)
|
||||
{
|
||||
ExprState *e = (ExprState *) lfirst(arg);
|
||||
Datum value;
|
||||
ExprState *e = (ExprState *) lfirst(arg);
|
||||
Datum value;
|
||||
|
||||
value = ExecEvalExpr(e, econtext, isNull, NULL);
|
||||
if (!*isNull)
|
||||
@ -1787,7 +1790,7 @@ ExecEvalCoalesce(CoalesceExprState *coalesceExpr, ExprContext *econtext,
|
||||
*isNull = true;
|
||||
return (Datum) 0;
|
||||
}
|
||||
|
||||
|
||||
/* ----------------------------------------------------------------
|
||||
* ExecEvalNullIf
|
||||
*
|
||||
@ -1797,7 +1800,7 @@ ExecEvalCoalesce(CoalesceExprState *coalesceExpr, ExprContext *econtext,
|
||||
* ----------------------------------------------------------------
|
||||
*/
|
||||
static Datum
|
||||
ExecEvalNullIf(FuncExprState *fcache, ExprContext *econtext,
|
||||
ExecEvalNullIf(FuncExprState * fcache, ExprContext *econtext,
|
||||
bool *isNull)
|
||||
{
|
||||
Datum result;
|
||||
@ -1856,7 +1859,7 @@ ExecEvalNullIf(FuncExprState *fcache, ExprContext *econtext,
|
||||
* ----------------------------------------------------------------
|
||||
*/
|
||||
static Datum
|
||||
ExecEvalNullTest(GenericExprState *nstate,
|
||||
ExecEvalNullTest(GenericExprState * nstate,
|
||||
ExprContext *econtext,
|
||||
bool *isNull,
|
||||
ExprDoneCond *isDone)
|
||||
@ -1901,7 +1904,7 @@ ExecEvalNullTest(GenericExprState *nstate,
|
||||
* ----------------------------------------------------------------
|
||||
*/
|
||||
static Datum
|
||||
ExecEvalBooleanTest(GenericExprState *bstate,
|
||||
ExecEvalBooleanTest(GenericExprState * bstate,
|
||||
ExprContext *econtext,
|
||||
bool *isNull,
|
||||
ExprDoneCond *isDone)
|
||||
@ -1987,7 +1990,7 @@ ExecEvalBooleanTest(GenericExprState *bstate,
|
||||
* datum) otherwise throw an error.
|
||||
*/
|
||||
static Datum
|
||||
ExecEvalCoerceToDomain(CoerceToDomainState *cstate, ExprContext *econtext,
|
||||
ExecEvalCoerceToDomain(CoerceToDomainState * cstate, ExprContext *econtext,
|
||||
bool *isNull, ExprDoneCond *isDone)
|
||||
{
|
||||
CoerceToDomain *ctest = (CoerceToDomain *) cstate->xprstate.expr;
|
||||
@ -2009,43 +2012,44 @@ ExecEvalCoerceToDomain(CoerceToDomainState *cstate, ExprContext *econtext,
|
||||
if (*isNull)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_NOT_NULL_VIOLATION),
|
||||
errmsg("domain %s does not allow NULL values",
|
||||
format_type_be(ctest->resulttype))));
|
||||
errmsg("domain %s does not allow NULL values",
|
||||
format_type_be(ctest->resulttype))));
|
||||
break;
|
||||
case DOM_CONSTRAINT_CHECK:
|
||||
{
|
||||
Datum conResult;
|
||||
bool conIsNull;
|
||||
Datum save_datum;
|
||||
bool save_isNull;
|
||||
{
|
||||
Datum conResult;
|
||||
bool conIsNull;
|
||||
Datum save_datum;
|
||||
bool save_isNull;
|
||||
|
||||
/*
|
||||
* Set up value to be returned by CoerceToDomainValue nodes.
|
||||
* We must save and restore prior setting of econtext's
|
||||
* domainValue fields, in case this node is itself within
|
||||
* a check expression for another domain.
|
||||
*/
|
||||
save_datum = econtext->domainValue_datum;
|
||||
save_isNull = econtext->domainValue_isNull;
|
||||
/*
|
||||
* Set up value to be returned by CoerceToDomainValue
|
||||
* nodes. We must save and restore prior setting of
|
||||
* econtext's domainValue fields, in case this node is
|
||||
* itself within a check expression for another
|
||||
* domain.
|
||||
*/
|
||||
save_datum = econtext->domainValue_datum;
|
||||
save_isNull = econtext->domainValue_isNull;
|
||||
|
||||
econtext->domainValue_datum = result;
|
||||
econtext->domainValue_isNull = *isNull;
|
||||
econtext->domainValue_datum = result;
|
||||
econtext->domainValue_isNull = *isNull;
|
||||
|
||||
conResult = ExecEvalExpr(con->check_expr,
|
||||
econtext, &conIsNull, NULL);
|
||||
conResult = ExecEvalExpr(con->check_expr,
|
||||
econtext, &conIsNull, NULL);
|
||||
|
||||
if (!conIsNull &&
|
||||
!DatumGetBool(conResult))
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_CHECK_VIOLATION),
|
||||
errmsg("value for domain %s violates CHECK constraint \"%s\"",
|
||||
format_type_be(ctest->resulttype),
|
||||
con->name)));
|
||||
econtext->domainValue_datum = save_datum;
|
||||
econtext->domainValue_isNull = save_isNull;
|
||||
if (!conIsNull &&
|
||||
!DatumGetBool(conResult))
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_CHECK_VIOLATION),
|
||||
errmsg("value for domain %s violates CHECK constraint \"%s\"",
|
||||
format_type_be(ctest->resulttype),
|
||||
con->name)));
|
||||
econtext->domainValue_datum = save_datum;
|
||||
econtext->domainValue_isNull = save_isNull;
|
||||
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
elog(ERROR, "unrecognized constraint type: %d",
|
||||
(int) con->constrainttype);
|
||||
@ -2063,7 +2067,7 @@ ExecEvalCoerceToDomain(CoerceToDomainState *cstate, ExprContext *econtext,
|
||||
* Return the value stored by CoerceToDomain.
|
||||
*/
|
||||
static Datum
|
||||
ExecEvalCoerceToDomainValue(CoerceToDomainValue *conVal,
|
||||
ExecEvalCoerceToDomainValue(CoerceToDomainValue * conVal,
|
||||
ExprContext *econtext, bool *isNull)
|
||||
{
|
||||
*isNull = econtext->domainValue_isNull;
|
||||
@ -2077,7 +2081,7 @@ ExecEvalCoerceToDomainValue(CoerceToDomainValue *conVal,
|
||||
* ----------------------------------------------------------------
|
||||
*/
|
||||
static Datum
|
||||
ExecEvalFieldSelect(GenericExprState *fstate,
|
||||
ExecEvalFieldSelect(GenericExprState * fstate,
|
||||
ExprContext *econtext,
|
||||
bool *isNull,
|
||||
ExprDoneCond *isDone)
|
||||
@ -2141,7 +2145,7 @@ ExecEvalFieldSelect(GenericExprState *fstate,
|
||||
* ----------------------------------------------------------------
|
||||
*/
|
||||
Datum
|
||||
ExecEvalExpr(ExprState *expression,
|
||||
ExecEvalExpr(ExprState * expression,
|
||||
ExprContext *econtext,
|
||||
bool *isNull,
|
||||
ExprDoneCond *isDone)
|
||||
@ -2308,7 +2312,7 @@ ExecEvalExpr(ExprState *expression,
|
||||
* Same as above, but get into the right allocation context explicitly.
|
||||
*/
|
||||
Datum
|
||||
ExecEvalExprSwitchContext(ExprState *expression,
|
||||
ExecEvalExprSwitchContext(ExprState * expression,
|
||||
ExprContext *econtext,
|
||||
bool *isNull,
|
||||
ExprDoneCond *isDone)
|
||||
@ -2327,7 +2331,7 @@ ExecEvalExprSwitchContext(ExprState *expression,
|
||||
* ExecInitExpr: prepare an expression tree for execution
|
||||
*
|
||||
* This function builds and returns an ExprState tree paralleling the given
|
||||
* Expr node tree. The ExprState tree can then be handed to ExecEvalExpr
|
||||
* Expr node tree. The ExprState tree can then be handed to ExecEvalExpr
|
||||
* for execution. Because the Expr tree itself is read-only as far as
|
||||
* ExecInitExpr and ExecEvalExpr are concerned, several different executions
|
||||
* of the same plan tree can occur concurrently.
|
||||
@ -2337,7 +2341,7 @@ ExecEvalExprSwitchContext(ExprState *expression,
|
||||
* the same as the per-query context of the associated ExprContext.
|
||||
*
|
||||
* Any Aggref and SubPlan nodes found in the tree are added to the lists
|
||||
* of such nodes held by the parent PlanState. Otherwise, we do very little
|
||||
* of such nodes held by the parent PlanState. Otherwise, we do very little
|
||||
* initialization here other than building the state-node tree. Any nontrivial
|
||||
* work associated with initializing runtime info for a node should happen
|
||||
* during the first actual evaluation of that node. (This policy lets us
|
||||
@ -2356,7 +2360,7 @@ ExecEvalExprSwitchContext(ExprState *expression,
|
||||
* This case should usually come through ExecPrepareExpr, not directly here.
|
||||
*/
|
||||
ExprState *
|
||||
ExecInitExpr(Expr *node, PlanState *parent)
|
||||
ExecInitExpr(Expr *node, PlanState * parent)
|
||||
{
|
||||
ExprState *state;
|
||||
|
||||
@ -2373,7 +2377,7 @@ ExecInitExpr(Expr *node, PlanState *parent)
|
||||
break;
|
||||
case T_Aggref:
|
||||
{
|
||||
Aggref *aggref = (Aggref *) node;
|
||||
Aggref *aggref = (Aggref *) node;
|
||||
AggrefExprState *astate = makeNode(AggrefExprState);
|
||||
|
||||
if (parent && IsA(parent, AggState))
|
||||
@ -2389,8 +2393,8 @@ ExecInitExpr(Expr *node, PlanState *parent)
|
||||
/*
|
||||
* Complain if the aggregate's argument contains any
|
||||
* aggregates; nested agg functions are semantically
|
||||
* nonsensical. (This should have been caught earlier,
|
||||
* but we defend against it here anyway.)
|
||||
* nonsensical. (This should have been caught
|
||||
* earlier, but we defend against it here anyway.)
|
||||
*/
|
||||
if (naggs != aggstate->numaggs)
|
||||
ereport(ERROR,
|
||||
@ -2433,41 +2437,41 @@ ExecInitExpr(Expr *node, PlanState *parent)
|
||||
|
||||
fstate->args = (List *)
|
||||
ExecInitExpr((Expr *) funcexpr->args, parent);
|
||||
fstate->func.fn_oid = InvalidOid; /* not initialized */
|
||||
fstate->func.fn_oid = InvalidOid; /* not initialized */
|
||||
state = (ExprState *) fstate;
|
||||
}
|
||||
break;
|
||||
case T_OpExpr:
|
||||
{
|
||||
OpExpr *opexpr = (OpExpr *) node;
|
||||
OpExpr *opexpr = (OpExpr *) node;
|
||||
FuncExprState *fstate = makeNode(FuncExprState);
|
||||
|
||||
fstate->args = (List *)
|
||||
ExecInitExpr((Expr *) opexpr->args, parent);
|
||||
fstate->func.fn_oid = InvalidOid; /* not initialized */
|
||||
fstate->func.fn_oid = InvalidOid; /* not initialized */
|
||||
state = (ExprState *) fstate;
|
||||
}
|
||||
break;
|
||||
case T_DistinctExpr:
|
||||
{
|
||||
DistinctExpr *distinctexpr = (DistinctExpr *) node;
|
||||
DistinctExpr *distinctexpr = (DistinctExpr *) node;
|
||||
FuncExprState *fstate = makeNode(FuncExprState);
|
||||
|
||||
fstate->args = (List *)
|
||||
ExecInitExpr((Expr *) distinctexpr->args, parent);
|
||||
fstate->func.fn_oid = InvalidOid; /* not initialized */
|
||||
fstate->func.fn_oid = InvalidOid; /* not initialized */
|
||||
state = (ExprState *) fstate;
|
||||
}
|
||||
break;
|
||||
case T_ScalarArrayOpExpr:
|
||||
{
|
||||
ScalarArrayOpExpr *opexpr = (ScalarArrayOpExpr *) node;
|
||||
ScalarArrayOpExpr *opexpr = (ScalarArrayOpExpr *) node;
|
||||
ScalarArrayOpExprState *sstate = makeNode(ScalarArrayOpExprState);
|
||||
|
||||
sstate->fxprstate.args = (List *)
|
||||
ExecInitExpr((Expr *) opexpr->args, parent);
|
||||
sstate->fxprstate.func.fn_oid = InvalidOid; /* not initialized */
|
||||
sstate->element_type = InvalidOid; /* ditto */
|
||||
sstate->fxprstate.func.fn_oid = InvalidOid; /* not initialized */
|
||||
sstate->element_type = InvalidOid; /* ditto */
|
||||
state = (ExprState *) sstate;
|
||||
}
|
||||
break;
|
||||
@ -2484,7 +2488,7 @@ ExecInitExpr(Expr *node, PlanState *parent)
|
||||
case T_SubPlan:
|
||||
{
|
||||
/* Keep this in sync with ExecInitExprInitPlan, below */
|
||||
SubPlan *subplan = (SubPlan *) node;
|
||||
SubPlan *subplan = (SubPlan *) node;
|
||||
SubPlanState *sstate = makeNode(SubPlanState);
|
||||
|
||||
if (!parent)
|
||||
@ -2492,7 +2496,8 @@ ExecInitExpr(Expr *node, PlanState *parent)
|
||||
|
||||
/*
|
||||
* Here we just add the SubPlanState nodes to
|
||||
* parent->subPlan. The subplans will be initialized later.
|
||||
* parent->subPlan. The subplans will be initialized
|
||||
* later.
|
||||
*/
|
||||
parent->subPlan = lcons(sstate, parent->subPlan);
|
||||
sstate->sub_estate = NULL;
|
||||
@ -2508,7 +2513,7 @@ ExecInitExpr(Expr *node, PlanState *parent)
|
||||
break;
|
||||
case T_FieldSelect:
|
||||
{
|
||||
FieldSelect *fselect = (FieldSelect *) node;
|
||||
FieldSelect *fselect = (FieldSelect *) node;
|
||||
GenericExprState *gstate = makeNode(GenericExprState);
|
||||
|
||||
gstate->arg = ExecInitExpr(fselect->arg, parent);
|
||||
@ -2517,7 +2522,7 @@ ExecInitExpr(Expr *node, PlanState *parent)
|
||||
break;
|
||||
case T_RelabelType:
|
||||
{
|
||||
RelabelType *relabel = (RelabelType *) node;
|
||||
RelabelType *relabel = (RelabelType *) node;
|
||||
GenericExprState *gstate = makeNode(GenericExprState);
|
||||
|
||||
gstate->arg = ExecInitExpr(relabel->arg, parent);
|
||||
@ -2552,10 +2557,10 @@ ExecInitExpr(Expr *node, PlanState *parent)
|
||||
break;
|
||||
case T_ArrayExpr:
|
||||
{
|
||||
ArrayExpr *arrayexpr = (ArrayExpr *) node;
|
||||
ArrayExpr *arrayexpr = (ArrayExpr *) node;
|
||||
ArrayExprState *astate = makeNode(ArrayExprState);
|
||||
FastList outlist;
|
||||
List *inlist;
|
||||
FastList outlist;
|
||||
List *inlist;
|
||||
|
||||
FastListInit(&outlist);
|
||||
foreach(inlist, arrayexpr->elements)
|
||||
@ -2585,8 +2590,8 @@ ExecInitExpr(Expr *node, PlanState *parent)
|
||||
FastListInit(&outlist);
|
||||
foreach(inlist, coalesceexpr->args)
|
||||
{
|
||||
Expr *e = (Expr *) lfirst(inlist);
|
||||
ExprState *estate;
|
||||
Expr *e = (Expr *) lfirst(inlist);
|
||||
ExprState *estate;
|
||||
|
||||
estate = ExecInitExpr(e, parent);
|
||||
FastAppend(&outlist, estate);
|
||||
@ -2602,7 +2607,7 @@ ExecInitExpr(Expr *node, PlanState *parent)
|
||||
|
||||
fstate->args = (List *)
|
||||
ExecInitExpr((Expr *) nullifexpr->args, parent);
|
||||
fstate->func.fn_oid = InvalidOid; /* not initialized */
|
||||
fstate->func.fn_oid = InvalidOid; /* not initialized */
|
||||
state = (ExprState *) fstate;
|
||||
}
|
||||
break;
|
||||
@ -2617,7 +2622,7 @@ ExecInitExpr(Expr *node, PlanState *parent)
|
||||
break;
|
||||
case T_BooleanTest:
|
||||
{
|
||||
BooleanTest *btest = (BooleanTest *) node;
|
||||
BooleanTest *btest = (BooleanTest *) node;
|
||||
GenericExprState *gstate = makeNode(GenericExprState);
|
||||
|
||||
gstate->arg = ExecInitExpr(btest->arg, parent);
|
||||
@ -2626,7 +2631,7 @@ ExecInitExpr(Expr *node, PlanState *parent)
|
||||
break;
|
||||
case T_CoerceToDomain:
|
||||
{
|
||||
CoerceToDomain *ctest = (CoerceToDomain *) node;
|
||||
CoerceToDomain *ctest = (CoerceToDomain *) node;
|
||||
CoerceToDomainState *cstate = makeNode(CoerceToDomainState);
|
||||
|
||||
cstate->arg = ExecInitExpr(ctest->arg, parent);
|
||||
@ -2636,7 +2641,7 @@ ExecInitExpr(Expr *node, PlanState *parent)
|
||||
break;
|
||||
case T_TargetEntry:
|
||||
{
|
||||
TargetEntry *tle = (TargetEntry *) node;
|
||||
TargetEntry *tle = (TargetEntry *) node;
|
||||
GenericExprState *gstate = makeNode(GenericExprState);
|
||||
|
||||
gstate->arg = ExecInitExpr(tle->expr, parent);
|
||||
@ -2673,12 +2678,12 @@ ExecInitExpr(Expr *node, PlanState *parent)
|
||||
|
||||
/*
|
||||
* ExecInitExprInitPlan --- initialize a subplan expr that's being handled
|
||||
* as an InitPlan. This is identical to ExecInitExpr's handling of a regular
|
||||
* as an InitPlan. This is identical to ExecInitExpr's handling of a regular
|
||||
* subplan expr, except we do NOT want to add the node to the parent's
|
||||
* subplan list.
|
||||
*/
|
||||
SubPlanState *
|
||||
ExecInitExprInitPlan(SubPlan *node, PlanState *parent)
|
||||
ExecInitExprInitPlan(SubPlan *node, PlanState * parent)
|
||||
{
|
||||
SubPlanState *sstate = makeNode(SubPlanState);
|
||||
|
||||
@ -2704,7 +2709,7 @@ ExecInitExprInitPlan(SubPlan *node, PlanState *parent)
|
||||
* This differs from ExecInitExpr in that we don't assume the caller is
|
||||
* already running in the EState's per-query context. Also, we apply
|
||||
* fix_opfuncids() to the passed expression tree to be sure it is ready
|
||||
* to run. (In ordinary Plan trees the planner will have fixed opfuncids,
|
||||
* to run. (In ordinary Plan trees the planner will have fixed opfuncids,
|
||||
* but callers outside the executor will not have done this.)
|
||||
*/
|
||||
ExprState *
|
||||
@ -2988,8 +2993,8 @@ ExecTargetList(List *targetlist,
|
||||
if (itemIsDone[resind] == ExprEndResult)
|
||||
{
|
||||
/*
|
||||
* Oh dear, this item is returning an empty
|
||||
* set. Guess we can't make a tuple after all.
|
||||
* Oh dear, this item is returning an empty set.
|
||||
* Guess we can't make a tuple after all.
|
||||
*/
|
||||
*isDone = ExprEndResult;
|
||||
break;
|
||||
|
@ -12,7 +12,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/executor/execScan.c,v 1.23 2003/02/03 15:07:07 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/executor/execScan.c,v 1.24 2003/08/04 00:43:17 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -45,7 +45,7 @@ static bool tlist_matches_tupdesc(List *tlist, Index varno, TupleDesc tupdesc);
|
||||
* ----------------------------------------------------------------
|
||||
*/
|
||||
TupleTableSlot *
|
||||
ExecScan(ScanState *node,
|
||||
ExecScan(ScanState * node,
|
||||
ExecScanAccessMtd accessMtd) /* function returning a tuple */
|
||||
{
|
||||
EState *estate;
|
||||
@ -134,9 +134,10 @@ ExecScan(ScanState *node,
|
||||
if (projInfo)
|
||||
{
|
||||
/*
|
||||
* Form a projection tuple, store it in the result tuple slot
|
||||
* and return it --- unless we find we can project no tuples
|
||||
* from this scan tuple, in which case continue scan.
|
||||
* Form a projection tuple, store it in the result tuple
|
||||
* slot and return it --- unless we find we can project no
|
||||
* tuples from this scan tuple, in which case continue
|
||||
* scan.
|
||||
*/
|
||||
resultSlot = ExecProject(projInfo, &isDone);
|
||||
if (isDone != ExprEndResult)
|
||||
@ -175,13 +176,13 @@ ExecScan(ScanState *node,
|
||||
* ExecAssignScanType must have been called already.
|
||||
*/
|
||||
void
|
||||
ExecAssignScanProjectionInfo(ScanState *node)
|
||||
ExecAssignScanProjectionInfo(ScanState * node)
|
||||
{
|
||||
Scan *scan = (Scan *) node->ps.plan;
|
||||
Scan *scan = (Scan *) node->ps.plan;
|
||||
|
||||
if (tlist_matches_tupdesc(scan->plan.targetlist,
|
||||
scan->scanrelid,
|
||||
node->ss_ScanTupleSlot->ttc_tupleDescriptor))
|
||||
node->ss_ScanTupleSlot->ttc_tupleDescriptor))
|
||||
node->ps.ps_ProjInfo = NULL;
|
||||
else
|
||||
ExecAssignProjectionInfo(&node->ps);
|
||||
@ -190,13 +191,13 @@ ExecAssignScanProjectionInfo(ScanState *node)
|
||||
static bool
|
||||
tlist_matches_tupdesc(List *tlist, Index varno, TupleDesc tupdesc)
|
||||
{
|
||||
int numattrs = tupdesc->natts;
|
||||
int attrno;
|
||||
int numattrs = tupdesc->natts;
|
||||
int attrno;
|
||||
|
||||
for (attrno = 1; attrno <= numattrs; attrno++)
|
||||
{
|
||||
Form_pg_attribute att_tup = tupdesc->attrs[attrno - 1];
|
||||
Var *var;
|
||||
Var *var;
|
||||
|
||||
if (tlist == NIL)
|
||||
return false; /* tlist too short */
|
||||
|
@ -15,7 +15,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/executor/execTuples.c,v 1.67 2003/07/21 17:05:09 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/executor/execTuples.c,v 1.68 2003/08/04 00:43:17 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -482,7 +482,7 @@ ExecSetSlotDescriptorIsNew(TupleTableSlot *slot, /* slot to change */
|
||||
* ----------------
|
||||
*/
|
||||
void
|
||||
ExecInitResultTupleSlot(EState *estate, PlanState *planstate)
|
||||
ExecInitResultTupleSlot(EState *estate, PlanState * planstate)
|
||||
{
|
||||
INIT_SLOT_DEFS;
|
||||
INIT_SLOT_ALLOC;
|
||||
@ -494,7 +494,7 @@ ExecInitResultTupleSlot(EState *estate, PlanState *planstate)
|
||||
* ----------------
|
||||
*/
|
||||
void
|
||||
ExecInitScanTupleSlot(EState *estate, ScanState *scanstate)
|
||||
ExecInitScanTupleSlot(EState *estate, ScanState * scanstate)
|
||||
{
|
||||
INIT_SLOT_DEFS;
|
||||
INIT_SLOT_ALLOC;
|
||||
@ -807,7 +807,7 @@ do_text_output_multiline(TupOutputState *tstate, char *text)
|
||||
if (eol)
|
||||
*eol++ = '\0';
|
||||
else
|
||||
eol = text + strlen(text);
|
||||
eol = text +strlen(text);
|
||||
|
||||
do_tup_output(tstate, &text);
|
||||
text = eol;
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/executor/execUtils.c,v 1.100 2003/05/28 16:03:56 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/executor/execUtils.c,v 1.101 2003/08/04 00:43:17 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -166,8 +166,8 @@ CreateExecutorState(void)
|
||||
ALLOCSET_DEFAULT_MAXSIZE);
|
||||
|
||||
/*
|
||||
* Make the EState node within the per-query context. This way,
|
||||
* we don't need a separate pfree() operation for it at shutdown.
|
||||
* Make the EState node within the per-query context. This way, we
|
||||
* don't need a separate pfree() operation for it at shutdown.
|
||||
*/
|
||||
oldcontext = MemoryContextSwitchTo(qcontext);
|
||||
|
||||
@ -248,6 +248,7 @@ FreeExecutorState(EState *estate)
|
||||
FreeExprContext((ExprContext *) lfirst(estate->es_exprcontexts));
|
||||
/* FreeExprContext removed the list link for us */
|
||||
}
|
||||
|
||||
/*
|
||||
* Free the per-query memory context, thereby releasing all working
|
||||
* memory, including the EState node itself.
|
||||
@ -310,10 +311,10 @@ CreateExprContext(EState *estate)
|
||||
econtext->ecxt_callbacks = NULL;
|
||||
|
||||
/*
|
||||
* Link the ExprContext into the EState to ensure it is shut down
|
||||
* when the EState is freed. Because we use lcons(), shutdowns will
|
||||
* occur in reverse order of creation, which may not be essential
|
||||
* but can't hurt.
|
||||
* Link the ExprContext into the EState to ensure it is shut down when
|
||||
* the EState is freed. Because we use lcons(), shutdowns will occur
|
||||
* in reverse order of creation, which may not be essential but can't
|
||||
* hurt.
|
||||
*/
|
||||
estate->es_exprcontexts = lcons(econtext, estate->es_exprcontexts);
|
||||
|
||||
@ -377,14 +378,14 @@ MakePerTupleExprContext(EState *estate)
|
||||
/* ----------------
|
||||
* ExecAssignExprContext
|
||||
*
|
||||
* This initializes the ps_ExprContext field. It is only necessary
|
||||
* This initializes the ps_ExprContext field. It is only necessary
|
||||
* to do this for nodes which use ExecQual or ExecProject
|
||||
* because those routines require an econtext. Other nodes that
|
||||
* because those routines require an econtext. Other nodes that
|
||||
* don't have to evaluate expressions don't need to do this.
|
||||
* ----------------
|
||||
*/
|
||||
void
|
||||
ExecAssignExprContext(EState *estate, PlanState *planstate)
|
||||
ExecAssignExprContext(EState *estate, PlanState * planstate)
|
||||
{
|
||||
planstate->ps_ExprContext = CreateExprContext(estate);
|
||||
}
|
||||
@ -394,7 +395,7 @@ ExecAssignExprContext(EState *estate, PlanState *planstate)
|
||||
* ----------------
|
||||
*/
|
||||
void
|
||||
ExecAssignResultType(PlanState *planstate,
|
||||
ExecAssignResultType(PlanState * planstate,
|
||||
TupleDesc tupDesc, bool shouldFree)
|
||||
{
|
||||
TupleTableSlot *slot = planstate->ps_ResultTupleSlot;
|
||||
@ -407,7 +408,7 @@ ExecAssignResultType(PlanState *planstate,
|
||||
* ----------------
|
||||
*/
|
||||
void
|
||||
ExecAssignResultTypeFromOuterPlan(PlanState *planstate)
|
||||
ExecAssignResultTypeFromOuterPlan(PlanState * planstate)
|
||||
{
|
||||
PlanState *outerPlan;
|
||||
TupleDesc tupDesc;
|
||||
@ -423,7 +424,7 @@ ExecAssignResultTypeFromOuterPlan(PlanState *planstate)
|
||||
* ----------------
|
||||
*/
|
||||
void
|
||||
ExecAssignResultTypeFromTL(PlanState *planstate)
|
||||
ExecAssignResultTypeFromTL(PlanState * planstate)
|
||||
{
|
||||
bool hasoid = false;
|
||||
TupleDesc tupDesc;
|
||||
@ -445,9 +446,9 @@ ExecAssignResultTypeFromTL(PlanState *planstate)
|
||||
* each of the child plans of the topmost Append plan. So, this is
|
||||
* ugly but it works, for now ...
|
||||
*
|
||||
* SELECT INTO is also pretty grotty, because we don't yet have the
|
||||
* INTO relation's descriptor at this point; we have to look aside
|
||||
* at a flag set by InitPlan().
|
||||
* SELECT INTO is also pretty grotty, because we don't yet have the INTO
|
||||
* relation's descriptor at this point; we have to look aside at a
|
||||
* flag set by InitPlan().
|
||||
*/
|
||||
if (planstate->state->es_force_oids)
|
||||
hasoid = true;
|
||||
@ -465,9 +466,9 @@ ExecAssignResultTypeFromTL(PlanState *planstate)
|
||||
}
|
||||
|
||||
/*
|
||||
* ExecTypeFromTL needs the parse-time representation of the tlist, not
|
||||
* a list of ExprStates. This is good because some plan nodes don't
|
||||
* bother to set up planstate->targetlist ...
|
||||
* ExecTypeFromTL needs the parse-time representation of the tlist,
|
||||
* not a list of ExprStates. This is good because some plan nodes
|
||||
* don't bother to set up planstate->targetlist ...
|
||||
*/
|
||||
tupDesc = ExecTypeFromTL(planstate->plan->targetlist, hasoid);
|
||||
ExecAssignResultType(planstate, tupDesc, true);
|
||||
@ -478,7 +479,7 @@ ExecAssignResultTypeFromTL(PlanState *planstate)
|
||||
* ----------------
|
||||
*/
|
||||
TupleDesc
|
||||
ExecGetResultType(PlanState *planstate)
|
||||
ExecGetResultType(PlanState * planstate)
|
||||
{
|
||||
TupleTableSlot *slot = planstate->ps_ResultTupleSlot;
|
||||
|
||||
@ -524,7 +525,7 @@ ExecBuildProjectionInfo(List *targetList,
|
||||
* ----------------
|
||||
*/
|
||||
void
|
||||
ExecAssignProjectionInfo(PlanState *planstate)
|
||||
ExecAssignProjectionInfo(PlanState * planstate)
|
||||
{
|
||||
planstate->ps_ProjInfo =
|
||||
ExecBuildProjectionInfo(planstate->targetlist,
|
||||
@ -543,7 +544,7 @@ ExecAssignProjectionInfo(PlanState *planstate)
|
||||
* ----------------
|
||||
*/
|
||||
void
|
||||
ExecFreeExprContext(PlanState *planstate)
|
||||
ExecFreeExprContext(PlanState * planstate)
|
||||
{
|
||||
ExprContext *econtext;
|
||||
|
||||
@ -575,7 +576,7 @@ ExecFreeExprContext(PlanState *planstate)
|
||||
* ----------------
|
||||
*/
|
||||
TupleDesc
|
||||
ExecGetScanType(ScanState *scanstate)
|
||||
ExecGetScanType(ScanState * scanstate)
|
||||
{
|
||||
TupleTableSlot *slot = scanstate->ss_ScanTupleSlot;
|
||||
|
||||
@ -587,7 +588,7 @@ ExecGetScanType(ScanState *scanstate)
|
||||
* ----------------
|
||||
*/
|
||||
void
|
||||
ExecAssignScanType(ScanState *scanstate,
|
||||
ExecAssignScanType(ScanState * scanstate,
|
||||
TupleDesc tupDesc, bool shouldFree)
|
||||
{
|
||||
TupleTableSlot *slot = scanstate->ss_ScanTupleSlot;
|
||||
@ -600,7 +601,7 @@ ExecAssignScanType(ScanState *scanstate,
|
||||
* ----------------
|
||||
*/
|
||||
void
|
||||
ExecAssignScanTypeFromOuterPlan(ScanState *scanstate)
|
||||
ExecAssignScanTypeFromOuterPlan(ScanState * scanstate)
|
||||
{
|
||||
PlanState *outerPlan;
|
||||
TupleDesc tupDesc;
|
||||
@ -795,8 +796,8 @@ ExecInsertIndexTuples(TupleTableSlot *slot,
|
||||
|
||||
/*
|
||||
* We will use the EState's per-tuple context for evaluating
|
||||
* predicates and index expressions (creating it if it's not
|
||||
* already there).
|
||||
* predicates and index expressions (creating it if it's not already
|
||||
* there).
|
||||
*/
|
||||
econtext = GetPerTupleExprContext(estate);
|
||||
|
||||
@ -841,8 +842,8 @@ ExecInsertIndexTuples(TupleTableSlot *slot,
|
||||
|
||||
/*
|
||||
* FormIndexDatum fills in its datum and null parameters with
|
||||
* attribute information taken from the given heap tuple.
|
||||
* It also computes any expressions needed.
|
||||
* attribute information taken from the given heap tuple. It also
|
||||
* computes any expressions needed.
|
||||
*/
|
||||
FormIndexDatum(indexInfo,
|
||||
heapTuple,
|
||||
@ -878,7 +879,7 @@ ExecInsertIndexTuples(TupleTableSlot *slot,
|
||||
* Add changed parameters to a plan node's chgParam set
|
||||
*/
|
||||
void
|
||||
UpdateChangedParamSet(PlanState *node, Bitmapset *newchg)
|
||||
UpdateChangedParamSet(PlanState * node, Bitmapset * newchg)
|
||||
{
|
||||
Bitmapset *parmset;
|
||||
|
||||
@ -887,6 +888,7 @@ UpdateChangedParamSet(PlanState *node, Bitmapset *newchg)
|
||||
* Don't include anything else into its chgParam set.
|
||||
*/
|
||||
parmset = bms_intersect(node->plan->allParam, newchg);
|
||||
|
||||
/*
|
||||
* Keep node->chgParam == NULL if there's not actually any members;
|
||||
* this allows the simplest possible tests in executor node files.
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/executor/functions.c,v 1.69 2003/07/28 18:33:18 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/executor/functions.c,v 1.70 2003/08/04 00:43:17 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -29,8 +29,8 @@
|
||||
|
||||
|
||||
/*
|
||||
* We have an execution_state record for each query in a function. Each
|
||||
* record contains a querytree and plantree for its query. If the query
|
||||
* We have an execution_state record for each query in a function. Each
|
||||
* record contains a querytree and plantree for its query. If the query
|
||||
* is currently in F_EXEC_RUN state then there's a QueryDesc too.
|
||||
*/
|
||||
typedef enum
|
||||
@ -83,7 +83,7 @@ static void postquel_start(execution_state *es, SQLFunctionCachePtr fcache);
|
||||
static TupleTableSlot *postquel_getnext(execution_state *es);
|
||||
static void postquel_end(execution_state *es);
|
||||
static void postquel_sub_params(SQLFunctionCachePtr fcache,
|
||||
FunctionCallInfo fcinfo);
|
||||
FunctionCallInfo fcinfo);
|
||||
static Datum postquel_execute(execution_state *es,
|
||||
FunctionCallInfo fcinfo,
|
||||
SQLFunctionCachePtr fcache);
|
||||
@ -177,11 +177,11 @@ init_sql_fcache(FmgrInfo *finfo)
|
||||
if (rettype == ANYARRAYOID || rettype == ANYELEMENTOID)
|
||||
{
|
||||
rettype = get_fn_expr_rettype(finfo);
|
||||
if (rettype == InvalidOid) /* this probably should not happen */
|
||||
if (rettype == InvalidOid) /* this probably should not happen */
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_DATATYPE_MISMATCH),
|
||||
errmsg("could not determine actual result type for function declared %s",
|
||||
format_type_be(procedureStruct->prorettype))));
|
||||
format_type_be(procedureStruct->prorettype))));
|
||||
}
|
||||
|
||||
/* Now look up the actual result type */
|
||||
@ -226,7 +226,7 @@ init_sql_fcache(FmgrInfo *finfo)
|
||||
fcache->funcSlot = NULL;
|
||||
|
||||
/*
|
||||
* Parse and plan the queries. We need the argument type info to pass
|
||||
* Parse and plan the queries. We need the argument type info to pass
|
||||
* to the parser.
|
||||
*/
|
||||
nargs = procedureStruct->pronargs;
|
||||
@ -234,7 +234,7 @@ init_sql_fcache(FmgrInfo *finfo)
|
||||
|
||||
if (nargs > 0)
|
||||
{
|
||||
int argnum;
|
||||
int argnum;
|
||||
|
||||
argOidVect = (Oid *) palloc(nargs * sizeof(Oid));
|
||||
memcpy(argOidVect,
|
||||
@ -243,7 +243,7 @@ init_sql_fcache(FmgrInfo *finfo)
|
||||
/* Resolve any polymorphic argument types */
|
||||
for (argnum = 0; argnum < nargs; argnum++)
|
||||
{
|
||||
Oid argtype = argOidVect[argnum];
|
||||
Oid argtype = argOidVect[argnum];
|
||||
|
||||
if (argtype == ANYARRAYOID || argtype == ANYELEMENTOID)
|
||||
{
|
||||
@ -309,7 +309,7 @@ postquel_getnext(execution_state *es)
|
||||
|
||||
/*
|
||||
* If it's the function's last command, and it's a SELECT, fetch one
|
||||
* row at a time so we can return the results. Otherwise just run it
|
||||
* row at a time so we can return the results. Otherwise just run it
|
||||
* to completion.
|
||||
*/
|
||||
if (LAST_POSTQUEL_COMMAND(es) && es->qd->operation == CMD_SELECT)
|
||||
@ -655,14 +655,14 @@ sql_exec_error_callback(void *arg)
|
||||
/*
|
||||
* Try to determine where in the function we failed. If there is a
|
||||
* query with non-null QueryDesc, finger it. (We check this rather
|
||||
* than looking for F_EXEC_RUN state, so that errors during ExecutorStart
|
||||
* or ExecutorEnd are blamed on the appropriate query; see postquel_start
|
||||
* and postquel_end.)
|
||||
* than looking for F_EXEC_RUN state, so that errors during
|
||||
* ExecutorStart or ExecutorEnd are blamed on the appropriate query;
|
||||
* see postquel_start and postquel_end.)
|
||||
*/
|
||||
if (fcache)
|
||||
{
|
||||
execution_state *es;
|
||||
int query_num;
|
||||
int query_num;
|
||||
|
||||
es = fcache->func_state;
|
||||
query_num = 1;
|
||||
|
@ -45,7 +45,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/executor/nodeAgg.c,v 1.112 2003/08/01 00:15:21 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/executor/nodeAgg.c,v 1.113 2003/08/04 00:43:17 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -173,12 +173,12 @@ typedef struct AggStatePerGroupData
|
||||
* later input value. Only the first non-NULL input will be
|
||||
* auto-substituted.
|
||||
*/
|
||||
} AggStatePerGroupData;
|
||||
} AggStatePerGroupData;
|
||||
|
||||
/*
|
||||
* To implement hashed aggregation, we need a hashtable that stores a
|
||||
* representative tuple and an array of AggStatePerGroup structs for each
|
||||
* distinct set of GROUP BY column values. We compute the hash key from
|
||||
* distinct set of GROUP BY column values. We compute the hash key from
|
||||
* the GROUP BY columns.
|
||||
*/
|
||||
typedef struct AggHashEntryData *AggHashEntry;
|
||||
@ -188,27 +188,27 @@ typedef struct AggHashEntryData
|
||||
TupleHashEntryData shared; /* common header for hash table entries */
|
||||
/* per-aggregate transition status array - must be last! */
|
||||
AggStatePerGroupData pergroup[1]; /* VARIABLE LENGTH ARRAY */
|
||||
} AggHashEntryData; /* VARIABLE LENGTH STRUCT */
|
||||
} AggHashEntryData; /* VARIABLE LENGTH STRUCT */
|
||||
|
||||
|
||||
static void initialize_aggregates(AggState *aggstate,
|
||||
AggStatePerAgg peragg,
|
||||
AggStatePerGroup pergroup);
|
||||
AggStatePerAgg peragg,
|
||||
AggStatePerGroup pergroup);
|
||||
static void advance_transition_function(AggState *aggstate,
|
||||
AggStatePerAgg peraggstate,
|
||||
AggStatePerGroup pergroupstate,
|
||||
Datum newVal, bool isNull);
|
||||
AggStatePerAgg peraggstate,
|
||||
AggStatePerGroup pergroupstate,
|
||||
Datum newVal, bool isNull);
|
||||
static void advance_aggregates(AggState *aggstate, AggStatePerGroup pergroup);
|
||||
static void process_sorted_aggregate(AggState *aggstate,
|
||||
AggStatePerAgg peraggstate,
|
||||
AggStatePerGroup pergroupstate);
|
||||
AggStatePerAgg peraggstate,
|
||||
AggStatePerGroup pergroupstate);
|
||||
static void finalize_aggregate(AggState *aggstate,
|
||||
AggStatePerAgg peraggstate,
|
||||
AggStatePerGroup pergroupstate,
|
||||
Datum *resultVal, bool *resultIsNull);
|
||||
AggStatePerAgg peraggstate,
|
||||
AggStatePerGroup pergroupstate,
|
||||
Datum *resultVal, bool *resultIsNull);
|
||||
static void build_hash_table(AggState *aggstate);
|
||||
static AggHashEntry lookup_hash_entry(AggState *aggstate,
|
||||
TupleTableSlot *slot);
|
||||
TupleTableSlot *slot);
|
||||
static TupleTableSlot *agg_retrieve_direct(AggState *aggstate);
|
||||
static void agg_fill_hash_table(AggState *aggstate);
|
||||
static TupleTableSlot *agg_retrieve_hash_table(AggState *aggstate);
|
||||
@ -231,7 +231,7 @@ initialize_aggregates(AggState *aggstate,
|
||||
{
|
||||
AggStatePerAgg peraggstate = &peragg[aggno];
|
||||
AggStatePerGroup pergroupstate = &pergroup[aggno];
|
||||
Aggref *aggref = peraggstate->aggref;
|
||||
Aggref *aggref = peraggstate->aggref;
|
||||
|
||||
/*
|
||||
* Start a fresh sort operation for each DISTINCT aggregate.
|
||||
@ -265,18 +265,18 @@ initialize_aggregates(AggState *aggstate,
|
||||
|
||||
oldContext = MemoryContextSwitchTo(aggstate->aggcontext);
|
||||
pergroupstate->transValue = datumCopy(peraggstate->initValue,
|
||||
peraggstate->transtypeByVal,
|
||||
peraggstate->transtypeLen);
|
||||
peraggstate->transtypeByVal,
|
||||
peraggstate->transtypeLen);
|
||||
MemoryContextSwitchTo(oldContext);
|
||||
}
|
||||
pergroupstate->transValueIsNull = peraggstate->initValueIsNull;
|
||||
|
||||
/*
|
||||
* If the initial value for the transition state doesn't exist in the
|
||||
* pg_aggregate table then we will let the first non-NULL value
|
||||
* returned from the outer procNode become the initial value. (This is
|
||||
* useful for aggregates like max() and min().) The noTransValue flag
|
||||
* signals that we still need to do this.
|
||||
* If the initial value for the transition state doesn't exist in
|
||||
* the pg_aggregate table then we will let the first non-NULL
|
||||
* value returned from the outer procNode become the initial
|
||||
* value. (This is useful for aggregates like max() and min().)
|
||||
* The noTransValue flag signals that we still need to do this.
|
||||
*/
|
||||
pergroupstate->noTransValue = peraggstate->initValueIsNull;
|
||||
}
|
||||
@ -299,8 +299,8 @@ advance_transition_function(AggState *aggstate,
|
||||
if (peraggstate->transfn.fn_strict)
|
||||
{
|
||||
/*
|
||||
* For a strict transfn, nothing happens at a NULL input
|
||||
* tuple; we just keep the prior transValue.
|
||||
* For a strict transfn, nothing happens at a NULL input tuple; we
|
||||
* just keep the prior transValue.
|
||||
*/
|
||||
if (isNull)
|
||||
return;
|
||||
@ -314,12 +314,13 @@ advance_transition_function(AggState *aggstate,
|
||||
* here is OK.)
|
||||
*
|
||||
* We must copy the datum into aggcontext if it is pass-by-ref.
|
||||
* We do not need to pfree the old transValue, since it's NULL.
|
||||
* We do not need to pfree the old transValue, since it's
|
||||
* NULL.
|
||||
*/
|
||||
oldContext = MemoryContextSwitchTo(aggstate->aggcontext);
|
||||
pergroupstate->transValue = datumCopy(newVal,
|
||||
peraggstate->transtypeByVal,
|
||||
peraggstate->transtypeLen);
|
||||
peraggstate->transtypeByVal,
|
||||
peraggstate->transtypeLen);
|
||||
pergroupstate->transValueIsNull = false;
|
||||
pergroupstate->noTransValue = false;
|
||||
MemoryContextSwitchTo(oldContext);
|
||||
@ -363,12 +364,12 @@ advance_transition_function(AggState *aggstate,
|
||||
newVal = FunctionCallInvoke(&fcinfo);
|
||||
|
||||
/*
|
||||
* If pass-by-ref datatype, must copy the new value into aggcontext and
|
||||
* pfree the prior transValue. But if transfn returned a pointer to its
|
||||
* first input, we don't need to do anything.
|
||||
* If pass-by-ref datatype, must copy the new value into aggcontext
|
||||
* and pfree the prior transValue. But if transfn returned a pointer
|
||||
* to its first input, we don't need to do anything.
|
||||
*/
|
||||
if (!peraggstate->transtypeByVal &&
|
||||
DatumGetPointer(newVal) != DatumGetPointer(pergroupstate->transValue))
|
||||
DatumGetPointer(newVal) != DatumGetPointer(pergroupstate->transValue))
|
||||
{
|
||||
if (!fcinfo.isnull)
|
||||
{
|
||||
@ -388,7 +389,7 @@ advance_transition_function(AggState *aggstate,
|
||||
}
|
||||
|
||||
/*
|
||||
* Advance all the aggregates for one input tuple. The input tuple
|
||||
* Advance all the aggregates for one input tuple. The input tuple
|
||||
* has been stored in tmpcontext->ecxt_scantuple, so that it is accessible
|
||||
* to ExecEvalExpr. pergroup is the array of per-group structs to use
|
||||
* (this might be in a hashtable entry).
|
||||
@ -467,8 +468,8 @@ process_sorted_aggregate(AggState *aggstate,
|
||||
continue;
|
||||
|
||||
/*
|
||||
* Clear and select the working context for evaluation of
|
||||
* the equality function and transition function.
|
||||
* Clear and select the working context for evaluation of the
|
||||
* equality function and transition function.
|
||||
*/
|
||||
MemoryContextReset(workcontext);
|
||||
oldContext = MemoryContextSwitchTo(workcontext);
|
||||
@ -570,9 +571,9 @@ finalize_aggregate(AggState *aggstate,
|
||||
static void
|
||||
build_hash_table(AggState *aggstate)
|
||||
{
|
||||
Agg *node = (Agg *) aggstate->ss.ps.plan;
|
||||
MemoryContext tmpmem = aggstate->tmpcontext->ecxt_per_tuple_memory;
|
||||
Size entrysize;
|
||||
Agg *node = (Agg *) aggstate->ss.ps.plan;
|
||||
MemoryContext tmpmem = aggstate->tmpcontext->ecxt_per_tuple_memory;
|
||||
Size entrysize;
|
||||
|
||||
Assert(node->aggstrategy == AGG_HASHED);
|
||||
Assert(node->numGroups > 0);
|
||||
@ -622,9 +623,9 @@ lookup_hash_entry(AggState *aggstate, TupleTableSlot *slot)
|
||||
* the appropriate attribute for each aggregate function use (Aggref
|
||||
* node) appearing in the targetlist or qual of the node. The number
|
||||
* of tuples to aggregate over depends on whether grouped or plain
|
||||
* aggregation is selected. In grouped aggregation, we produce a result
|
||||
* aggregation is selected. In grouped aggregation, we produce a result
|
||||
* row for each group; in plain aggregation there's a single result row
|
||||
* for the whole query. In either case, the value of each aggregate is
|
||||
* for the whole query. In either case, the value of each aggregate is
|
||||
* stored in the expression context to be used when ExecProject evaluates
|
||||
* the result tuple.
|
||||
*/
|
||||
@ -641,9 +642,7 @@ ExecAgg(AggState *node)
|
||||
return agg_retrieve_hash_table(node);
|
||||
}
|
||||
else
|
||||
{
|
||||
return agg_retrieve_direct(node);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@ -736,7 +735,7 @@ agg_retrieve_direct(AggState *aggstate)
|
||||
firstSlot,
|
||||
InvalidBuffer,
|
||||
true);
|
||||
aggstate->grp_firstTuple = NULL; /* don't keep two pointers */
|
||||
aggstate->grp_firstTuple = NULL; /* don't keep two pointers */
|
||||
|
||||
/* set up for first advance_aggregates call */
|
||||
tmpcontext->ecxt_scantuple = firstSlot;
|
||||
@ -773,7 +772,7 @@ agg_retrieve_direct(AggState *aggstate)
|
||||
firstSlot->ttc_tupleDescriptor,
|
||||
node->numCols, node->grpColIdx,
|
||||
aggstate->eqfunctions,
|
||||
tmpcontext->ecxt_per_tuple_memory))
|
||||
tmpcontext->ecxt_per_tuple_memory))
|
||||
{
|
||||
/*
|
||||
* Save the first input tuple of the next group.
|
||||
@ -806,15 +805,15 @@ agg_retrieve_direct(AggState *aggstate)
|
||||
* anything), create a dummy all-nulls input tuple for use by
|
||||
* ExecProject. 99.44% of the time this is a waste of cycles,
|
||||
* because ordinarily the projected output tuple's targetlist
|
||||
* cannot contain any direct (non-aggregated) references to
|
||||
* input columns, so the dummy tuple will not be referenced.
|
||||
* However there are special cases where this isn't so --- in
|
||||
* particular an UPDATE involving an aggregate will have a
|
||||
* targetlist reference to ctid. We need to return a null for
|
||||
* ctid in that situation, not coredump.
|
||||
* cannot contain any direct (non-aggregated) references to input
|
||||
* columns, so the dummy tuple will not be referenced. However
|
||||
* there are special cases where this isn't so --- in particular
|
||||
* an UPDATE involving an aggregate will have a targetlist
|
||||
* reference to ctid. We need to return a null for ctid in that
|
||||
* situation, not coredump.
|
||||
*
|
||||
* The values returned for the aggregates will be the initial
|
||||
* values of the transition functions.
|
||||
* The values returned for the aggregates will be the initial values
|
||||
* of the transition functions.
|
||||
*/
|
||||
if (TupIsNull(firstSlot))
|
||||
{
|
||||
@ -872,7 +871,7 @@ agg_fill_hash_table(AggState *aggstate)
|
||||
{
|
||||
PlanState *outerPlan;
|
||||
ExprContext *tmpcontext;
|
||||
AggHashEntry entry;
|
||||
AggHashEntry entry;
|
||||
TupleTableSlot *outerslot;
|
||||
|
||||
/*
|
||||
@ -883,8 +882,8 @@ agg_fill_hash_table(AggState *aggstate)
|
||||
tmpcontext = aggstate->tmpcontext;
|
||||
|
||||
/*
|
||||
* Process each outer-plan tuple, and then fetch the next one,
|
||||
* until we exhaust the outer plan.
|
||||
* Process each outer-plan tuple, and then fetch the next one, until
|
||||
* we exhaust the outer plan.
|
||||
*/
|
||||
for (;;)
|
||||
{
|
||||
@ -921,8 +920,8 @@ agg_retrieve_hash_table(AggState *aggstate)
|
||||
bool *aggnulls;
|
||||
AggStatePerAgg peragg;
|
||||
AggStatePerGroup pergroup;
|
||||
TupleHashTable hashtable;
|
||||
AggHashEntry entry;
|
||||
TupleHashTable hashtable;
|
||||
AggHashEntry entry;
|
||||
TupleTableSlot *firstSlot;
|
||||
TupleTableSlot *resultSlot;
|
||||
int aggno;
|
||||
@ -1045,20 +1044,20 @@ ExecInitAgg(Agg *node, EState *estate)
|
||||
aggstate->hashtable = NULL;
|
||||
|
||||
/*
|
||||
* Create expression contexts. We need two, one for per-input-tuple
|
||||
* processing and one for per-output-tuple processing. We cheat a little
|
||||
* by using ExecAssignExprContext() to build both.
|
||||
* Create expression contexts. We need two, one for per-input-tuple
|
||||
* processing and one for per-output-tuple processing. We cheat a
|
||||
* little by using ExecAssignExprContext() to build both.
|
||||
*/
|
||||
ExecAssignExprContext(estate, &aggstate->ss.ps);
|
||||
aggstate->tmpcontext = aggstate->ss.ps.ps_ExprContext;
|
||||
ExecAssignExprContext(estate, &aggstate->ss.ps);
|
||||
|
||||
/*
|
||||
* We also need a long-lived memory context for holding hashtable
|
||||
* data structures and transition values. NOTE: the details of what
|
||||
* is stored in aggcontext and what is stored in the regular per-query
|
||||
* memory context are driven by a simple decision: we want to reset the
|
||||
* aggcontext in ExecReScanAgg to recover no-longer-wanted space.
|
||||
* We also need a long-lived memory context for holding hashtable data
|
||||
* structures and transition values. NOTE: the details of what is
|
||||
* stored in aggcontext and what is stored in the regular per-query
|
||||
* memory context are driven by a simple decision: we want to reset
|
||||
* the aggcontext in ExecReScanAgg to recover no-longer-wanted space.
|
||||
*/
|
||||
aggstate->aggcontext =
|
||||
AllocSetContextCreate(CurrentMemoryContext,
|
||||
@ -1079,10 +1078,10 @@ ExecInitAgg(Agg *node, EState *estate)
|
||||
* initialize child expressions
|
||||
*
|
||||
* Note: ExecInitExpr finds Aggrefs for us, and also checks that no aggs
|
||||
* contain other agg calls in their arguments. This would make no sense
|
||||
* under SQL semantics anyway (and it's forbidden by the spec). Because
|
||||
* that is true, we don't need to worry about evaluating the aggs in any
|
||||
* particular order.
|
||||
* contain other agg calls in their arguments. This would make no
|
||||
* sense under SQL semantics anyway (and it's forbidden by the spec).
|
||||
* Because that is true, we don't need to worry about evaluating the
|
||||
* aggs in any particular order.
|
||||
*/
|
||||
aggstate->ss.ps.targetlist = (List *)
|
||||
ExecInitExpr((Expr *) node->plan.targetlist,
|
||||
@ -1116,19 +1115,20 @@ ExecInitAgg(Agg *node, EState *estate)
|
||||
if (numaggs <= 0)
|
||||
{
|
||||
/*
|
||||
* This is not an error condition: we might be using the Agg node just
|
||||
* to do hash-based grouping. Even in the regular case,
|
||||
* constant-expression simplification could optimize away all of the
|
||||
* Aggrefs in the targetlist and qual. So keep going, but force local
|
||||
* copy of numaggs positive so that palloc()s below don't choke.
|
||||
* This is not an error condition: we might be using the Agg node
|
||||
* just to do hash-based grouping. Even in the regular case,
|
||||
* constant-expression simplification could optimize away all of
|
||||
* the Aggrefs in the targetlist and qual. So keep going, but
|
||||
* force local copy of numaggs positive so that palloc()s below
|
||||
* don't choke.
|
||||
*/
|
||||
numaggs = 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* If we are grouping, precompute fmgr lookup data for inner loop.
|
||||
* We need both equality and hashing functions to do it by hashing,
|
||||
* but only equality if not hashing.
|
||||
* If we are grouping, precompute fmgr lookup data for inner loop. We
|
||||
* need both equality and hashing functions to do it by hashing, but
|
||||
* only equality if not hashing.
|
||||
*/
|
||||
if (node->numCols > 0)
|
||||
{
|
||||
@ -1146,8 +1146,8 @@ ExecInitAgg(Agg *node, EState *estate)
|
||||
}
|
||||
|
||||
/*
|
||||
* Set up aggregate-result storage in the output expr context, and also
|
||||
* allocate my private per-agg working storage
|
||||
* Set up aggregate-result storage in the output expr context, and
|
||||
* also allocate my private per-agg working storage
|
||||
*/
|
||||
econtext = aggstate->ss.ps.ps_ExprContext;
|
||||
econtext->ecxt_aggvalues = (Datum *) palloc0(sizeof(Datum) * numaggs);
|
||||
@ -1174,8 +1174,8 @@ ExecInitAgg(Agg *node, EState *estate)
|
||||
* unchanging fields of the per-agg data. We also detect duplicate
|
||||
* aggregates (for example, "SELECT sum(x) ... HAVING sum(x) > 0").
|
||||
* When duplicates are detected, we only make an AggStatePerAgg struct
|
||||
* for the first one. The clones are simply pointed at the same result
|
||||
* entry by giving them duplicate aggno values.
|
||||
* for the first one. The clones are simply pointed at the same
|
||||
* result entry by giving them duplicate aggno values.
|
||||
*/
|
||||
aggno = -1;
|
||||
foreach(alist, aggstate->aggs)
|
||||
@ -1425,9 +1425,9 @@ ExecReScanAgg(AggState *node, ExprContext *exprCtxt)
|
||||
if (((Agg *) node->ss.ps.plan)->aggstrategy == AGG_HASHED)
|
||||
{
|
||||
/*
|
||||
* In the hashed case, if we haven't yet built the hash table
|
||||
* then we can just return; nothing done yet, so nothing to undo.
|
||||
* If subnode's chgParam is not NULL then it will be re-scanned by
|
||||
* In the hashed case, if we haven't yet built the hash table then
|
||||
* we can just return; nothing done yet, so nothing to undo. If
|
||||
* subnode's chgParam is not NULL then it will be re-scanned by
|
||||
* ExecProcNode, else no reason to re-scan it at all.
|
||||
*/
|
||||
if (!node->table_filled)
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/executor/nodeAppend.c,v 1.52 2003/02/09 00:30:39 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/executor/nodeAppend.c,v 1.53 2003/08/04 00:43:17 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -355,7 +355,7 @@ ExecReScanAppend(AppendState *node, ExprContext *exprCtxt)
|
||||
|
||||
for (i = node->as_firstplan; i <= node->as_lastplan; i++)
|
||||
{
|
||||
PlanState *subnode = node->appendplans[i];
|
||||
PlanState *subnode = node->appendplans[i];
|
||||
|
||||
/*
|
||||
* ExecReScan doesn't know about my subplans, so I have to do
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/executor/nodeHash.c,v 1.77 2003/07/21 17:05:09 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/executor/nodeHash.c,v 1.78 2003/08/04 00:43:17 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -244,7 +244,7 @@ ExecHashTableCreate(Hash *node, List *hashOperators)
|
||||
i = 0;
|
||||
foreach(ho, hashOperators)
|
||||
{
|
||||
Oid hashfn;
|
||||
Oid hashfn;
|
||||
|
||||
hashfn = get_op_hash_function(lfirsto(ho));
|
||||
if (!OidIsValid(hashfn))
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/executor/nodeHashjoin.c,v 1.53 2003/07/21 17:05:09 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/executor/nodeHashjoin.c,v 1.54 2003/08/04 00:43:17 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -22,8 +22,8 @@
|
||||
#include "utils/memutils.h"
|
||||
|
||||
|
||||
static TupleTableSlot *ExecHashJoinOuterGetTuple(PlanState *node,
|
||||
HashJoinState *hjstate);
|
||||
static TupleTableSlot *ExecHashJoinOuterGetTuple(PlanState * node,
|
||||
HashJoinState *hjstate);
|
||||
static TupleTableSlot *ExecHashJoinGetSavedTuple(HashJoinState *hjstate,
|
||||
BufFile *file,
|
||||
TupleTableSlot *tupleSlot);
|
||||
@ -94,10 +94,10 @@ ExecHashJoin(HashJoinState *node)
|
||||
|
||||
/*
|
||||
* If we're doing an IN join, we want to return at most one row per
|
||||
* outer tuple; so we can stop scanning the inner scan if we matched on
|
||||
* the previous try.
|
||||
* outer tuple; so we can stop scanning the inner scan if we matched
|
||||
* on the previous try.
|
||||
*/
|
||||
if (node->js.jointype == JOIN_IN &&
|
||||
if (node->js.jointype == JOIN_IN &&
|
||||
node->hj_MatchedOuter)
|
||||
node->hj_NeedNewOuter = true;
|
||||
|
||||
@ -244,7 +244,10 @@ ExecHashJoin(HashJoinState *node)
|
||||
}
|
||||
}
|
||||
|
||||
/* If we didn't return a tuple, may need to set NeedNewOuter */
|
||||
/*
|
||||
* If we didn't return a tuple, may need to set
|
||||
* NeedNewOuter
|
||||
*/
|
||||
if (node->js.jointype == JOIN_IN)
|
||||
{
|
||||
node->hj_NeedNewOuter = true;
|
||||
@ -365,7 +368,7 @@ ExecInitHashJoin(HashJoin *node, EState *estate)
|
||||
case JOIN_LEFT:
|
||||
hjstate->hj_NullInnerTupleSlot =
|
||||
ExecInitNullTupleSlot(estate,
|
||||
ExecGetResultType(innerPlanState(hjstate)));
|
||||
ExecGetResultType(innerPlanState(hjstate)));
|
||||
break;
|
||||
default:
|
||||
elog(ERROR, "unrecognized join type: %d",
|
||||
@ -407,10 +410,10 @@ ExecInitHashJoin(HashJoin *node, EState *estate)
|
||||
hjstate->hj_CurTuple = (HashJoinTuple) NULL;
|
||||
|
||||
/*
|
||||
* The planner already made a list of the inner hashkeys for us,
|
||||
* but we also need a list of the outer hashkeys, as well as a list
|
||||
* of the hash operator OIDs. Both lists of exprs must then be prepared
|
||||
* for execution.
|
||||
* The planner already made a list of the inner hashkeys for us, but
|
||||
* we also need a list of the outer hashkeys, as well as a list of the
|
||||
* hash operator OIDs. Both lists of exprs must then be prepared for
|
||||
* execution.
|
||||
*/
|
||||
hjstate->hj_InnerHashKeys = (List *)
|
||||
ExecInitExpr((Expr *) hashNode->hashkeys,
|
||||
@ -496,7 +499,7 @@ ExecEndHashJoin(HashJoinState *node)
|
||||
*/
|
||||
|
||||
static TupleTableSlot *
|
||||
ExecHashJoinOuterGetTuple(PlanState *node, HashJoinState *hjstate)
|
||||
ExecHashJoinOuterGetTuple(PlanState * node, HashJoinState *hjstate)
|
||||
{
|
||||
HashJoinTable hashtable = hjstate->hj_HashTable;
|
||||
int curbatch = hashtable->curbatch;
|
||||
@ -701,11 +704,11 @@ ExecReScanHashJoin(HashJoinState *node, ExprContext *exprCtxt)
|
||||
Assert(node->hj_HashTable != NULL);
|
||||
|
||||
/*
|
||||
* In a multi-batch join, we currently have to do rescans the hard way,
|
||||
* primarily because batch temp files may have already been released.
|
||||
* But if it's a single-batch join, and there is no parameter change
|
||||
* for the inner subnode, then we can just re-use the existing hash
|
||||
* table without rebuilding it.
|
||||
* In a multi-batch join, we currently have to do rescans the hard
|
||||
* way, primarily because batch temp files may have already been
|
||||
* released. But if it's a single-batch join, and there is no
|
||||
* parameter change for the inner subnode, then we can just re-use the
|
||||
* existing hash table without rebuilding it.
|
||||
*/
|
||||
if (node->hj_HashTable->nbatch == 0 &&
|
||||
((PlanState *) node)->righttree->chgParam == NULL)
|
||||
@ -718,6 +721,7 @@ ExecReScanHashJoin(HashJoinState *node, ExprContext *exprCtxt)
|
||||
node->hj_hashdone = false;
|
||||
ExecHashTableDestroy(node->hj_HashTable);
|
||||
node->hj_HashTable = NULL;
|
||||
|
||||
/*
|
||||
* if chgParam of subnode is not null then plan will be re-scanned
|
||||
* by first ExecProcNode.
|
||||
@ -736,8 +740,8 @@ ExecReScanHashJoin(HashJoinState *node, ExprContext *exprCtxt)
|
||||
node->hj_MatchedOuter = false;
|
||||
|
||||
/*
|
||||
* if chgParam of subnode is not null then plan will be re-scanned
|
||||
* by first ExecProcNode.
|
||||
* if chgParam of subnode is not null then plan will be re-scanned by
|
||||
* first ExecProcNode.
|
||||
*/
|
||||
if (((PlanState *) node)->lefttree->chgParam == NULL)
|
||||
ExecReScan(((PlanState *) node)->lefttree, exprCtxt);
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/executor/nodeIndexscan.c,v 1.80 2003/07/21 17:05:09 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/executor/nodeIndexscan.c,v 1.81 2003/08/04 00:43:18 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -290,7 +290,8 @@ ExecIndexReScan(IndexScanState *node, ExprContext *exprCtxt)
|
||||
int j;
|
||||
|
||||
estate = node->ss.ps.state;
|
||||
econtext = node->iss_RuntimeContext; /* context for runtime keys */
|
||||
econtext = node->iss_RuntimeContext; /* context for runtime
|
||||
* keys */
|
||||
numIndices = node->iss_NumIndices;
|
||||
scanDescs = node->iss_ScanDescs;
|
||||
scanKeys = node->iss_ScanKeys;
|
||||
@ -882,7 +883,7 @@ ExecInitIndexScan(IndexScan *node, EState *estate)
|
||||
reloid)));
|
||||
|
||||
indexstate->ss.ss_currentRelation = currentRelation;
|
||||
indexstate->ss.ss_currentScanDesc = NULL; /* no heap scan here */
|
||||
indexstate->ss.ss_currentScanDesc = NULL; /* no heap scan here */
|
||||
|
||||
/*
|
||||
* get the scan type from the relation descriptor.
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/executor/nodeLimit.c,v 1.15 2003/07/21 17:05:09 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/executor/nodeLimit.c,v 1.16 2003/08/04 00:43:18 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -55,17 +55,21 @@ ExecLimit(LimitState *node)
|
||||
switch (node->lstate)
|
||||
{
|
||||
case LIMIT_INITIAL:
|
||||
|
||||
/*
|
||||
* If backwards scan, just return NULL without changing state.
|
||||
*/
|
||||
if (!ScanDirectionIsForward(direction))
|
||||
return NULL;
|
||||
|
||||
/*
|
||||
* First call for this scan, so compute limit/offset. (We can't do
|
||||
* this any earlier, because parameters from upper nodes may not
|
||||
* be set until now.) This also sets position = 0.
|
||||
* First call for this scan, so compute limit/offset. (We
|
||||
* can't do this any earlier, because parameters from upper
|
||||
* nodes may not be set until now.) This also sets position =
|
||||
* 0.
|
||||
*/
|
||||
recompute_limits(node);
|
||||
|
||||
/*
|
||||
* Check for empty window; if so, treat like empty subplan.
|
||||
*/
|
||||
@ -74,6 +78,7 @@ ExecLimit(LimitState *node)
|
||||
node->lstate = LIMIT_EMPTY;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Fetch rows from subplan until we reach position > offset.
|
||||
*/
|
||||
@ -83,8 +88,8 @@ ExecLimit(LimitState *node)
|
||||
if (TupIsNull(slot))
|
||||
{
|
||||
/*
|
||||
* The subplan returns too few tuples for us to produce
|
||||
* any output at all.
|
||||
* The subplan returns too few tuples for us to
|
||||
* produce any output at all.
|
||||
*/
|
||||
node->lstate = LIMIT_EMPTY;
|
||||
return NULL;
|
||||
@ -93,6 +98,7 @@ ExecLimit(LimitState *node)
|
||||
if (++node->position > node->offset)
|
||||
break;
|
||||
}
|
||||
|
||||
/*
|
||||
* Okay, we have the first tuple of the window.
|
||||
*/
|
||||
@ -100,9 +106,10 @@ ExecLimit(LimitState *node)
|
||||
break;
|
||||
|
||||
case LIMIT_EMPTY:
|
||||
|
||||
/*
|
||||
* The subplan is known to return no tuples (or not more than
|
||||
* OFFSET tuples, in general). So we return no tuples.
|
||||
* OFFSET tuples, in general). So we return no tuples.
|
||||
*/
|
||||
return NULL;
|
||||
|
||||
@ -113,7 +120,8 @@ ExecLimit(LimitState *node)
|
||||
* Forwards scan, so check for stepping off end of window.
|
||||
* If we are at the end of the window, return NULL without
|
||||
* advancing the subplan or the position variable; but
|
||||
* change the state machine state to record having done so.
|
||||
* change the state machine state to record having done
|
||||
* so.
|
||||
*/
|
||||
if (!node->noCount &&
|
||||
node->position >= node->offset + node->count)
|
||||
@ -121,6 +129,7 @@ ExecLimit(LimitState *node)
|
||||
node->lstate = LIMIT_WINDOWEND;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Get next tuple from subplan, if any.
|
||||
*/
|
||||
@ -136,14 +145,16 @@ ExecLimit(LimitState *node)
|
||||
else
|
||||
{
|
||||
/*
|
||||
* Backwards scan, so check for stepping off start of window.
|
||||
* As above, change only state-machine status if so.
|
||||
* Backwards scan, so check for stepping off start of
|
||||
* window. As above, change only state-machine status if
|
||||
* so.
|
||||
*/
|
||||
if (node->position <= node->offset + 1)
|
||||
{
|
||||
node->lstate = LIMIT_WINDOWSTART;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Get previous tuple from subplan; there should be one!
|
||||
*/
|
||||
@ -158,9 +169,11 @@ ExecLimit(LimitState *node)
|
||||
case LIMIT_SUBPLANEOF:
|
||||
if (ScanDirectionIsForward(direction))
|
||||
return NULL;
|
||||
|
||||
/*
|
||||
* Backing up from subplan EOF, so re-fetch previous tuple;
|
||||
* there should be one! Note previous tuple must be in window.
|
||||
* there should be one! Note previous tuple must be in
|
||||
* window.
|
||||
*/
|
||||
slot = ExecProcNode(outerPlan);
|
||||
if (TupIsNull(slot))
|
||||
@ -173,9 +186,10 @@ ExecLimit(LimitState *node)
|
||||
case LIMIT_WINDOWEND:
|
||||
if (ScanDirectionIsForward(direction))
|
||||
return NULL;
|
||||
|
||||
/*
|
||||
* Backing up from window end: simply re-return the last
|
||||
* tuple fetched from the subplan.
|
||||
* Backing up from window end: simply re-return the last tuple
|
||||
* fetched from the subplan.
|
||||
*/
|
||||
slot = node->subSlot;
|
||||
node->lstate = LIMIT_INWINDOW;
|
||||
@ -185,6 +199,7 @@ ExecLimit(LimitState *node)
|
||||
case LIMIT_WINDOWSTART:
|
||||
if (!ScanDirectionIsForward(direction))
|
||||
return NULL;
|
||||
|
||||
/*
|
||||
* Advancing after having backed off window start: simply
|
||||
* re-return the last tuple fetched from the subplan.
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/executor/nodeMaterial.c,v 1.42 2003/03/27 16:51:27 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/executor/nodeMaterial.c,v 1.43 2003/08/04 00:43:18 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -79,15 +79,15 @@ ExecMaterial(MaterialState *node)
|
||||
{
|
||||
/*
|
||||
* When reversing direction at tuplestore EOF, the first
|
||||
* getheaptuple call will fetch the last-added tuple; but
|
||||
* we want to return the one before that, if possible.
|
||||
* So do an extra fetch.
|
||||
* getheaptuple call will fetch the last-added tuple; but we
|
||||
* want to return the one before that, if possible. So do an
|
||||
* extra fetch.
|
||||
*/
|
||||
heapTuple = tuplestore_getheaptuple(tuplestorestate,
|
||||
forward,
|
||||
&should_free);
|
||||
if (heapTuple == NULL)
|
||||
return NULL; /* the tuplestore must be empty */
|
||||
return NULL; /* the tuplestore must be empty */
|
||||
if (should_free)
|
||||
heap_freetuple(heapTuple);
|
||||
}
|
||||
@ -129,10 +129,11 @@ ExecMaterial(MaterialState *node)
|
||||
}
|
||||
heapTuple = outerslot->val;
|
||||
should_free = false;
|
||||
|
||||
/*
|
||||
* Append returned tuple to tuplestore, too. NOTE: because the
|
||||
* tuplestore is certainly in EOF state, its read position will move
|
||||
* forward over the added tuple. This is what we want.
|
||||
* tuplestore is certainly in EOF state, its read position will
|
||||
* move forward over the added tuple. This is what we want.
|
||||
*/
|
||||
tuplestore_puttuple(tuplestorestate, (void *) heapTuple);
|
||||
}
|
||||
@ -293,8 +294,8 @@ ExecMaterialReScan(MaterialState *node, ExprContext *exprCtxt)
|
||||
* If subnode is to be rescanned then we forget previous stored
|
||||
* results; we have to re-read the subplan and re-store.
|
||||
*
|
||||
* Otherwise we can just rewind and rescan the stored output.
|
||||
* The state of the subnode does not change.
|
||||
* Otherwise we can just rewind and rescan the stored output. The state
|
||||
* of the subnode does not change.
|
||||
*/
|
||||
if (((PlanState *) node)->lefttree->chgParam != NULL)
|
||||
{
|
||||
@ -303,7 +304,5 @@ ExecMaterialReScan(MaterialState *node, ExprContext *exprCtxt)
|
||||
node->eof_underlying = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
tuplestore_rescan((Tuplestorestate *) node->tuplestorestate);
|
||||
}
|
||||
}
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/executor/nodeMergejoin.c,v 1.58 2003/07/21 17:05:10 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/executor/nodeMergejoin.c,v 1.59 2003/08/04 00:43:18 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -102,7 +102,7 @@ static bool MergeCompare(List *eqQual, List *compareQual, ExprContext *econtext)
|
||||
*/
|
||||
static void
|
||||
MJFormSkipQuals(List *qualList, List **ltQuals, List **gtQuals,
|
||||
PlanState *parent)
|
||||
PlanState * parent)
|
||||
{
|
||||
List *ltexprs,
|
||||
*gtexprs,
|
||||
@ -358,9 +358,9 @@ ExecMergeJoin(MergeJoinState *node)
|
||||
List *otherqual;
|
||||
bool qualResult;
|
||||
bool compareResult;
|
||||
PlanState *innerPlan;
|
||||
PlanState *innerPlan;
|
||||
TupleTableSlot *innerTupleSlot;
|
||||
PlanState *outerPlan;
|
||||
PlanState *outerPlan;
|
||||
TupleTableSlot *outerTupleSlot;
|
||||
ExprContext *econtext;
|
||||
bool doFillOuter;
|
||||
@ -644,7 +644,7 @@ ExecMergeJoin(MergeJoinState *node)
|
||||
* tuple, and return it if it passes the non-join
|
||||
* quals.
|
||||
*/
|
||||
node->mj_MatchedInner = true; /* do it only once */
|
||||
node->mj_MatchedInner = true; /* do it only once */
|
||||
|
||||
ResetExprContext(econtext);
|
||||
|
||||
@ -720,7 +720,7 @@ ExecMergeJoin(MergeJoinState *node)
|
||||
* tuple, and return it if it passes the non-join
|
||||
* quals.
|
||||
*/
|
||||
node->mj_MatchedOuter = true; /* do it only once */
|
||||
node->mj_MatchedOuter = true; /* do it only once */
|
||||
|
||||
ResetExprContext(econtext);
|
||||
|
||||
@ -1004,7 +1004,7 @@ ExecMergeJoin(MergeJoinState *node)
|
||||
* tuple, and return it if it passes the non-join
|
||||
* quals.
|
||||
*/
|
||||
node->mj_MatchedOuter = true; /* do it only once */
|
||||
node->mj_MatchedOuter = true; /* do it only once */
|
||||
|
||||
ResetExprContext(econtext);
|
||||
|
||||
@ -1181,7 +1181,7 @@ ExecMergeJoin(MergeJoinState *node)
|
||||
* tuple, and return it if it passes the non-join
|
||||
* quals.
|
||||
*/
|
||||
node->mj_MatchedInner = true; /* do it only once */
|
||||
node->mj_MatchedInner = true; /* do it only once */
|
||||
|
||||
ResetExprContext(econtext);
|
||||
|
||||
@ -1266,7 +1266,7 @@ ExecMergeJoin(MergeJoinState *node)
|
||||
* tuple, and return it if it passes the non-join
|
||||
* quals.
|
||||
*/
|
||||
node->mj_MatchedInner = true; /* do it only once */
|
||||
node->mj_MatchedInner = true; /* do it only once */
|
||||
|
||||
ResetExprContext(econtext);
|
||||
|
||||
@ -1333,7 +1333,7 @@ ExecMergeJoin(MergeJoinState *node)
|
||||
* tuple, and return it if it passes the non-join
|
||||
* quals.
|
||||
*/
|
||||
node->mj_MatchedOuter = true; /* do it only once */
|
||||
node->mj_MatchedOuter = true; /* do it only once */
|
||||
|
||||
ResetExprContext(econtext);
|
||||
|
||||
@ -1462,12 +1462,12 @@ ExecInitMergeJoin(MergeJoin *node, EState *estate)
|
||||
case JOIN_LEFT:
|
||||
mergestate->mj_NullInnerTupleSlot =
|
||||
ExecInitNullTupleSlot(estate,
|
||||
ExecGetResultType(innerPlanState(mergestate)));
|
||||
ExecGetResultType(innerPlanState(mergestate)));
|
||||
break;
|
||||
case JOIN_RIGHT:
|
||||
mergestate->mj_NullOuterTupleSlot =
|
||||
ExecInitNullTupleSlot(estate,
|
||||
ExecGetResultType(outerPlanState(mergestate)));
|
||||
ExecGetResultType(outerPlanState(mergestate)));
|
||||
|
||||
/*
|
||||
* Can't handle right or full join with non-nil extra
|
||||
@ -1481,10 +1481,10 @@ ExecInitMergeJoin(MergeJoin *node, EState *estate)
|
||||
case JOIN_FULL:
|
||||
mergestate->mj_NullOuterTupleSlot =
|
||||
ExecInitNullTupleSlot(estate,
|
||||
ExecGetResultType(outerPlanState(mergestate)));
|
||||
ExecGetResultType(outerPlanState(mergestate)));
|
||||
mergestate->mj_NullInnerTupleSlot =
|
||||
ExecInitNullTupleSlot(estate,
|
||||
ExecGetResultType(innerPlanState(mergestate)));
|
||||
ExecGetResultType(innerPlanState(mergestate)));
|
||||
|
||||
/*
|
||||
* Can't handle right or full join with non-nil extra
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/executor/nodeNestloop.c,v 1.33 2003/07/21 17:05:10 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/executor/nodeNestloop.c,v 1.34 2003/08/04 00:43:18 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -103,8 +103,8 @@ ExecNestLoop(NestLoopState *node)
|
||||
|
||||
/*
|
||||
* If we're doing an IN join, we want to return at most one row per
|
||||
* outer tuple; so we can stop scanning the inner scan if we matched on
|
||||
* the previous try.
|
||||
* outer tuple; so we can stop scanning the inner scan if we matched
|
||||
* on the previous try.
|
||||
*/
|
||||
if (node->js.jointype == JOIN_IN &&
|
||||
node->nl_MatchedOuter)
|
||||
@ -330,7 +330,7 @@ ExecInitNestLoop(NestLoop *node, EState *estate)
|
||||
case JOIN_LEFT:
|
||||
nlstate->nl_NullInnerTupleSlot =
|
||||
ExecInitNullTupleSlot(estate,
|
||||
ExecGetResultType(innerPlanState(nlstate)));
|
||||
ExecGetResultType(innerPlanState(nlstate)));
|
||||
break;
|
||||
default:
|
||||
elog(ERROR, "unrecognized join type: %d",
|
||||
@ -404,7 +404,7 @@ ExecEndNestLoop(NestLoopState *node)
|
||||
void
|
||||
ExecReScanNestLoop(NestLoopState *node, ExprContext *exprCtxt)
|
||||
{
|
||||
PlanState *outerPlan = outerPlanState(node);
|
||||
PlanState *outerPlan = outerPlanState(node);
|
||||
|
||||
/*
|
||||
* If outerPlan->chgParam is not null then plan will be automatically
|
||||
|
@ -34,7 +34,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/executor/nodeResult.c,v 1.24 2002/12/15 16:17:46 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/executor/nodeResult.c,v 1.25 2003/08/04 00:43:18 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -64,7 +64,7 @@ ExecResult(ResultState *node)
|
||||
{
|
||||
TupleTableSlot *outerTupleSlot;
|
||||
TupleTableSlot *resultSlot;
|
||||
PlanState *outerPlan;
|
||||
PlanState *outerPlan;
|
||||
ExprContext *econtext;
|
||||
ExprDoneCond isDone;
|
||||
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/executor/nodeSeqscan.c,v 1.43 2003/02/03 15:07:07 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/executor/nodeSeqscan.c,v 1.44 2003/08/04 00:43:18 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -29,8 +29,8 @@
|
||||
#include "executor/nodeSeqscan.h"
|
||||
#include "parser/parsetree.h"
|
||||
|
||||
static void InitScanRelation(SeqScanState *node, EState *estate);
|
||||
static TupleTableSlot *SeqNext(SeqScanState *node);
|
||||
static void InitScanRelation(SeqScanState * node, EState *estate);
|
||||
static TupleTableSlot *SeqNext(SeqScanState * node);
|
||||
|
||||
/* ----------------------------------------------------------------
|
||||
* Scan Support
|
||||
@ -43,7 +43,7 @@ static TupleTableSlot *SeqNext(SeqScanState *node);
|
||||
* ----------------------------------------------------------------
|
||||
*/
|
||||
static TupleTableSlot *
|
||||
SeqNext(SeqScanState *node)
|
||||
SeqNext(SeqScanState * node)
|
||||
{
|
||||
HeapTuple tuple;
|
||||
HeapScanDesc scandesc;
|
||||
@ -123,7 +123,7 @@ SeqNext(SeqScanState *node)
|
||||
*/
|
||||
|
||||
TupleTableSlot *
|
||||
ExecSeqScan(SeqScanState *node)
|
||||
ExecSeqScan(SeqScanState * node)
|
||||
{
|
||||
/*
|
||||
* use SeqNext as access method
|
||||
@ -139,7 +139,7 @@ ExecSeqScan(SeqScanState *node)
|
||||
* ----------------------------------------------------------------
|
||||
*/
|
||||
static void
|
||||
InitScanRelation(SeqScanState *node, EState *estate)
|
||||
InitScanRelation(SeqScanState * node, EState *estate)
|
||||
{
|
||||
Index relid;
|
||||
List *rangeTable;
|
||||
@ -252,7 +252,7 @@ ExecCountSlotsSeqScan(SeqScan *node)
|
||||
* ----------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
ExecEndSeqScan(SeqScanState *node)
|
||||
ExecEndSeqScan(SeqScanState * node)
|
||||
{
|
||||
Relation relation;
|
||||
HeapScanDesc scanDesc;
|
||||
@ -302,7 +302,7 @@ ExecEndSeqScan(SeqScanState *node)
|
||||
* ----------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
ExecSeqReScan(SeqScanState *node, ExprContext *exprCtxt)
|
||||
ExecSeqReScan(SeqScanState * node, ExprContext *exprCtxt)
|
||||
{
|
||||
EState *estate;
|
||||
Index scanrelid;
|
||||
@ -332,7 +332,7 @@ ExecSeqReScan(SeqScanState *node, ExprContext *exprCtxt)
|
||||
* ----------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
ExecSeqMarkPos(SeqScanState *node)
|
||||
ExecSeqMarkPos(SeqScanState * node)
|
||||
{
|
||||
HeapScanDesc scan;
|
||||
|
||||
@ -347,7 +347,7 @@ ExecSeqMarkPos(SeqScanState *node)
|
||||
* ----------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
ExecSeqRestrPos(SeqScanState *node)
|
||||
ExecSeqRestrPos(SeqScanState * node)
|
||||
{
|
||||
HeapScanDesc scan;
|
||||
|
||||
|
@ -7,7 +7,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/executor/nodeSubplan.c,v 1.51 2003/07/21 17:05:10 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/executor/nodeSubplan.c,v 1.52 2003/08/04 00:43:18 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -29,13 +29,13 @@
|
||||
#include "utils/lsyscache.h"
|
||||
|
||||
|
||||
static Datum ExecHashSubPlan(SubPlanState *node,
|
||||
ExprContext *econtext,
|
||||
bool *isNull);
|
||||
static Datum ExecScanSubPlan(SubPlanState *node,
|
||||
ExprContext *econtext,
|
||||
bool *isNull);
|
||||
static void buildSubPlanHash(SubPlanState *node);
|
||||
static Datum ExecHashSubPlan(SubPlanState * node,
|
||||
ExprContext *econtext,
|
||||
bool *isNull);
|
||||
static Datum ExecScanSubPlan(SubPlanState * node,
|
||||
ExprContext *econtext,
|
||||
bool *isNull);
|
||||
static void buildSubPlanHash(SubPlanState * node);
|
||||
static bool findPartialMatch(TupleHashTable hashtable, TupleTableSlot *slot);
|
||||
static bool tupleAllNulls(HeapTuple tuple);
|
||||
|
||||
@ -45,11 +45,11 @@ static bool tupleAllNulls(HeapTuple tuple);
|
||||
* ----------------------------------------------------------------
|
||||
*/
|
||||
Datum
|
||||
ExecSubPlan(SubPlanState *node,
|
||||
ExecSubPlan(SubPlanState * node,
|
||||
ExprContext *econtext,
|
||||
bool *isNull)
|
||||
{
|
||||
SubPlan *subplan = (SubPlan *) node->xprstate.expr;
|
||||
SubPlan *subplan = (SubPlan *) node->xprstate.expr;
|
||||
|
||||
if (subplan->setParam != NIL)
|
||||
elog(ERROR, "cannot set parent params from subquery");
|
||||
@ -64,11 +64,11 @@ ExecSubPlan(SubPlanState *node,
|
||||
* ExecHashSubPlan: store subselect result in an in-memory hash table
|
||||
*/
|
||||
static Datum
|
||||
ExecHashSubPlan(SubPlanState *node,
|
||||
ExecHashSubPlan(SubPlanState * node,
|
||||
ExprContext *econtext,
|
||||
bool *isNull)
|
||||
{
|
||||
SubPlan *subplan = (SubPlan *) node->xprstate.expr;
|
||||
SubPlan *subplan = (SubPlan *) node->xprstate.expr;
|
||||
PlanState *planstate = node->planstate;
|
||||
ExprContext *innerecontext = node->innerecontext;
|
||||
TupleTableSlot *slot;
|
||||
@ -79,8 +79,8 @@ ExecHashSubPlan(SubPlanState *node,
|
||||
elog(ERROR, "hashed subplan with direct correlation not supported");
|
||||
|
||||
/*
|
||||
* If first time through or we need to rescan the subplan, build
|
||||
* the hash table.
|
||||
* If first time through or we need to rescan the subplan, build the
|
||||
* hash table.
|
||||
*/
|
||||
if (node->hashtable == NULL || planstate->chgParam != NULL)
|
||||
buildSubPlanHash(node);
|
||||
@ -94,19 +94,19 @@ ExecHashSubPlan(SubPlanState *node,
|
||||
return BoolGetDatum(false);
|
||||
|
||||
/*
|
||||
* Evaluate lefthand expressions and form a projection tuple.
|
||||
* First we have to set the econtext to use (hack alert!).
|
||||
* Evaluate lefthand expressions and form a projection tuple. First we
|
||||
* have to set the econtext to use (hack alert!).
|
||||
*/
|
||||
node->projLeft->pi_exprContext = econtext;
|
||||
slot = ExecProject(node->projLeft, NULL);
|
||||
tup = slot->val;
|
||||
|
||||
/*
|
||||
* Note: because we are typically called in a per-tuple context,
|
||||
* we have to explicitly clear the projected tuple before returning.
|
||||
* Otherwise, we'll have a double-free situation: the per-tuple context
|
||||
* will probably be reset before we're called again, and then the tuple
|
||||
* slot will think it still needs to free the tuple.
|
||||
* Note: because we are typically called in a per-tuple context, we
|
||||
* have to explicitly clear the projected tuple before returning.
|
||||
* Otherwise, we'll have a double-free situation: the per-tuple
|
||||
* context will probably be reset before we're called again, and then
|
||||
* the tuple slot will think it still needs to free the tuple.
|
||||
*/
|
||||
|
||||
/*
|
||||
@ -116,20 +116,20 @@ ExecHashSubPlan(SubPlanState *node,
|
||||
ResetExprContext(innerecontext);
|
||||
|
||||
/*
|
||||
* If the LHS is all non-null, probe for an exact match in the
|
||||
* main hash table. If we find one, the result is TRUE.
|
||||
* Otherwise, scan the partly-null table to see if there are any
|
||||
* rows that aren't provably unequal to the LHS; if so, the result
|
||||
* is UNKNOWN. (We skip that part if we don't care about UNKNOWN.)
|
||||
* Otherwise, the result is FALSE.
|
||||
* If the LHS is all non-null, probe for an exact match in the main
|
||||
* hash table. If we find one, the result is TRUE. Otherwise, scan
|
||||
* the partly-null table to see if there are any rows that aren't
|
||||
* provably unequal to the LHS; if so, the result is UNKNOWN. (We
|
||||
* skip that part if we don't care about UNKNOWN.) Otherwise, the
|
||||
* result is FALSE.
|
||||
*
|
||||
* Note: the reason we can avoid a full scan of the main hash table
|
||||
* is that the combining operators are assumed never to yield NULL
|
||||
* when both inputs are non-null. If they were to do so, we might
|
||||
* need to produce UNKNOWN instead of FALSE because of an UNKNOWN
|
||||
* result in comparing the LHS to some main-table entry --- which
|
||||
* is a comparison we will not even make, unless there's a chance
|
||||
* match of hash keys.
|
||||
* Note: the reason we can avoid a full scan of the main hash table is
|
||||
* that the combining operators are assumed never to yield NULL when
|
||||
* both inputs are non-null. If they were to do so, we might need to
|
||||
* produce UNKNOWN instead of FALSE because of an UNKNOWN result in
|
||||
* comparing the LHS to some main-table entry --- which is a
|
||||
* comparison we will not even make, unless there's a chance match of
|
||||
* hash keys.
|
||||
*/
|
||||
if (HeapTupleNoNulls(tup))
|
||||
{
|
||||
@ -151,14 +151,14 @@ ExecHashSubPlan(SubPlanState *node,
|
||||
}
|
||||
|
||||
/*
|
||||
* When the LHS is partly or wholly NULL, we can never return TRUE.
|
||||
* If we don't care about UNKNOWN, just return FALSE. Otherwise,
|
||||
* if the LHS is wholly NULL, immediately return UNKNOWN. (Since the
|
||||
* combining operators are strict, the result could only be FALSE if the
|
||||
* sub-select were empty, but we already handled that case.) Otherwise,
|
||||
* we must scan both the main and partly-null tables to see if there are
|
||||
* any rows that aren't provably unequal to the LHS; if so, the result is
|
||||
* UNKNOWN. Otherwise, the result is FALSE.
|
||||
* When the LHS is partly or wholly NULL, we can never return TRUE. If
|
||||
* we don't care about UNKNOWN, just return FALSE. Otherwise, if the
|
||||
* LHS is wholly NULL, immediately return UNKNOWN. (Since the
|
||||
* combining operators are strict, the result could only be FALSE if
|
||||
* the sub-select were empty, but we already handled that case.)
|
||||
* Otherwise, we must scan both the main and partly-null tables to see
|
||||
* if there are any rows that aren't provably unequal to the LHS; if
|
||||
* so, the result is UNKNOWN. Otherwise, the result is FALSE.
|
||||
*/
|
||||
if (node->hashnulls == NULL)
|
||||
{
|
||||
@ -194,11 +194,11 @@ ExecHashSubPlan(SubPlanState *node,
|
||||
* ExecScanSubPlan: default case where we have to rescan subplan each time
|
||||
*/
|
||||
static Datum
|
||||
ExecScanSubPlan(SubPlanState *node,
|
||||
ExecScanSubPlan(SubPlanState * node,
|
||||
ExprContext *econtext,
|
||||
bool *isNull)
|
||||
{
|
||||
SubPlan *subplan = (SubPlan *) node->xprstate.expr;
|
||||
SubPlan *subplan = (SubPlan *) node->xprstate.expr;
|
||||
PlanState *planstate = node->planstate;
|
||||
SubLinkType subLinkType = subplan->subLinkType;
|
||||
bool useOr = subplan->useOr;
|
||||
@ -218,14 +218,14 @@ ExecScanSubPlan(SubPlanState *node,
|
||||
oldcontext = MemoryContextSwitchTo(node->sub_estate->es_query_cxt);
|
||||
|
||||
/*
|
||||
* Set Params of this plan from parent plan correlation values.
|
||||
* (Any calculation we have to do is done in the parent econtext,
|
||||
* since the Param values don't need to have per-query lifetime.)
|
||||
* Set Params of this plan from parent plan correlation values. (Any
|
||||
* calculation we have to do is done in the parent econtext, since the
|
||||
* Param values don't need to have per-query lifetime.)
|
||||
*/
|
||||
pvar = node->args;
|
||||
foreach(lst, subplan->parParam)
|
||||
{
|
||||
int paramid = lfirsti(lst);
|
||||
int paramid = lfirsti(lst);
|
||||
ParamExecData *prm = &(econtext->ecxt_param_exec_vals[paramid]);
|
||||
|
||||
Assert(pvar != NIL);
|
||||
@ -241,23 +241,24 @@ ExecScanSubPlan(SubPlanState *node,
|
||||
ExecReScan(planstate, NULL);
|
||||
|
||||
/*
|
||||
* For all sublink types except EXPR_SUBLINK and ARRAY_SUBLINK, the result
|
||||
* is boolean as are the results of the combining operators. We combine
|
||||
* results within a tuple (if there are multiple columns) using OR
|
||||
* semantics if "useOr" is true, AND semantics if not. We then combine
|
||||
* results across tuples (if the subplan produces more than one) using OR
|
||||
* semantics for ANY_SUBLINK or AND semantics for ALL_SUBLINK.
|
||||
* (MULTIEXPR_SUBLINK doesn't allow multiple tuples from the subplan.)
|
||||
* NULL results from the combining operators are handled according to
|
||||
* the usual SQL semantics for OR and AND. The result for no input
|
||||
* tuples is FALSE for ANY_SUBLINK, TRUE for ALL_SUBLINK, NULL for
|
||||
* MULTIEXPR_SUBLINK.
|
||||
* For all sublink types except EXPR_SUBLINK and ARRAY_SUBLINK, the
|
||||
* result is boolean as are the results of the combining operators. We
|
||||
* combine results within a tuple (if there are multiple columns)
|
||||
* using OR semantics if "useOr" is true, AND semantics if not. We
|
||||
* then combine results across tuples (if the subplan produces more
|
||||
* than one) using OR semantics for ANY_SUBLINK or AND semantics for
|
||||
* ALL_SUBLINK. (MULTIEXPR_SUBLINK doesn't allow multiple tuples from
|
||||
* the subplan.) NULL results from the combining operators are handled
|
||||
* according to the usual SQL semantics for OR and AND. The result
|
||||
* for no input tuples is FALSE for ANY_SUBLINK, TRUE for ALL_SUBLINK,
|
||||
* NULL for MULTIEXPR_SUBLINK.
|
||||
*
|
||||
* For EXPR_SUBLINK we require the subplan to produce no more than one
|
||||
* tuple, else an error is raised. For ARRAY_SUBLINK we allow the subplan
|
||||
* to produce more than one tuple. In either case, if zero tuples are
|
||||
* produced, we return NULL. Assuming we get a tuple, we just use its
|
||||
* first column (there can be only one non-junk column in this case).
|
||||
* tuple, else an error is raised. For ARRAY_SUBLINK we allow the
|
||||
* subplan to produce more than one tuple. In either case, if zero
|
||||
* tuples are produced, we return NULL. Assuming we get a tuple, we
|
||||
* just use its first column (there can be only one non-junk column in
|
||||
* this case).
|
||||
*/
|
||||
result = BoolGetDatum(subLinkType == ALL_SUBLINK);
|
||||
*isNull = false;
|
||||
@ -311,8 +312,8 @@ ExecScanSubPlan(SubPlanState *node,
|
||||
|
||||
if (subLinkType == ARRAY_SUBLINK)
|
||||
{
|
||||
Datum dvalue;
|
||||
bool disnull;
|
||||
Datum dvalue;
|
||||
bool disnull;
|
||||
|
||||
found = true;
|
||||
/* stash away current value */
|
||||
@ -346,7 +347,8 @@ ExecScanSubPlan(SubPlanState *node,
|
||||
bool expnull;
|
||||
|
||||
/*
|
||||
* Load up the Param representing this column of the sub-select.
|
||||
* Load up the Param representing this column of the
|
||||
* sub-select.
|
||||
*/
|
||||
prmdata = &(econtext->ecxt_param_exec_vals[paramid]);
|
||||
Assert(prmdata->execPlan == NULL);
|
||||
@ -432,8 +434,8 @@ ExecScanSubPlan(SubPlanState *node,
|
||||
{
|
||||
/*
|
||||
* deal with empty subplan result. result/isNull were previously
|
||||
* initialized correctly for all sublink types except EXPR, ARRAY, and
|
||||
* MULTIEXPR; for those, return NULL.
|
||||
* initialized correctly for all sublink types except EXPR, ARRAY,
|
||||
* and MULTIEXPR; for those, return NULL.
|
||||
*/
|
||||
if (subLinkType == EXPR_SUBLINK ||
|
||||
subLinkType == ARRAY_SUBLINK ||
|
||||
@ -459,9 +461,9 @@ ExecScanSubPlan(SubPlanState *node,
|
||||
* buildSubPlanHash: load hash table by scanning subplan output.
|
||||
*/
|
||||
static void
|
||||
buildSubPlanHash(SubPlanState *node)
|
||||
buildSubPlanHash(SubPlanState * node)
|
||||
{
|
||||
SubPlan *subplan = (SubPlan *) node->xprstate.expr;
|
||||
SubPlan *subplan = (SubPlan *) node->xprstate.expr;
|
||||
PlanState *planstate = node->planstate;
|
||||
int ncols = length(node->exprs);
|
||||
ExprContext *innerecontext = node->innerecontext;
|
||||
@ -474,19 +476,19 @@ buildSubPlanHash(SubPlanState *node)
|
||||
Assert(!subplan->useOr);
|
||||
|
||||
/*
|
||||
* If we already had any hash tables, destroy 'em; then create
|
||||
* empty hash table(s).
|
||||
* If we already had any hash tables, destroy 'em; then create empty
|
||||
* hash table(s).
|
||||
*
|
||||
* If we need to distinguish accurately between FALSE and UNKNOWN
|
||||
* (i.e., NULL) results of the IN operation, then we have to store
|
||||
* subplan output rows that are partly or wholly NULL. We store such
|
||||
* rows in a separate hash table that we expect will be much smaller
|
||||
* than the main table. (We can use hashing to eliminate partly-null
|
||||
* rows that are not distinct. We keep them separate to minimize the
|
||||
* cost of the inevitable full-table searches; see findPartialMatch.)
|
||||
* If we need to distinguish accurately between FALSE and UNKNOWN (i.e.,
|
||||
* NULL) results of the IN operation, then we have to store subplan
|
||||
* output rows that are partly or wholly NULL. We store such rows in
|
||||
* a separate hash table that we expect will be much smaller than the
|
||||
* main table. (We can use hashing to eliminate partly-null rows that
|
||||
* are not distinct. We keep them separate to minimize the cost of
|
||||
* the inevitable full-table searches; see findPartialMatch.)
|
||||
*
|
||||
* If it's not necessary to distinguish FALSE and UNKNOWN, then we
|
||||
* don't need to store subplan output rows that contain NULL.
|
||||
* If it's not necessary to distinguish FALSE and UNKNOWN, then we don't
|
||||
* need to store subplan output rows that contain NULL.
|
||||
*/
|
||||
MemoryContextReset(node->tablecxt);
|
||||
node->hashtable = NULL;
|
||||
@ -529,7 +531,8 @@ buildSubPlanHash(SubPlanState *node)
|
||||
|
||||
/*
|
||||
* We are probably in a short-lived expression-evaluation context.
|
||||
* Switch to the child plan's per-query context for calling ExecProcNode.
|
||||
* Switch to the child plan's per-query context for calling
|
||||
* ExecProcNode.
|
||||
*/
|
||||
oldcontext = MemoryContextSwitchTo(node->sub_estate->es_query_cxt);
|
||||
|
||||
@ -539,8 +542,9 @@ buildSubPlanHash(SubPlanState *node)
|
||||
ExecReScan(planstate, NULL);
|
||||
|
||||
/*
|
||||
* Scan the subplan and load the hash table(s). Note that when there are
|
||||
* duplicate rows coming out of the sub-select, only one copy is stored.
|
||||
* Scan the subplan and load the hash table(s). Note that when there
|
||||
* are duplicate rows coming out of the sub-select, only one copy is
|
||||
* stored.
|
||||
*/
|
||||
for (slot = ExecProcNode(planstate);
|
||||
!TupIsNull(slot);
|
||||
@ -572,9 +576,9 @@ buildSubPlanHash(SubPlanState *node)
|
||||
|
||||
/*
|
||||
* If result contains any nulls, store separately or not at all.
|
||||
* (Since we know the projection tuple has no junk columns, we
|
||||
* can just look at the overall hasnull info bit, instead of
|
||||
* groveling through the columns.)
|
||||
* (Since we know the projection tuple has no junk columns, we can
|
||||
* just look at the overall hasnull info bit, instead of groveling
|
||||
* through the columns.)
|
||||
*/
|
||||
if (HeapTupleNoNulls(tup))
|
||||
{
|
||||
@ -621,7 +625,7 @@ findPartialMatch(TupleHashTable hashtable, TupleTableSlot *slot)
|
||||
HeapTuple tuple = slot->val;
|
||||
TupleDesc tupdesc = slot->ttc_tupleDescriptor;
|
||||
TupleHashIterator hashiter;
|
||||
TupleHashEntry entry;
|
||||
TupleHashEntry entry;
|
||||
|
||||
ResetTupleHashIterator(&hashiter);
|
||||
while ((entry = ScanTupleHashTable(hashtable, &hashiter)) != NULL)
|
||||
@ -643,8 +647,8 @@ findPartialMatch(TupleHashTable hashtable, TupleTableSlot *slot)
|
||||
static bool
|
||||
tupleAllNulls(HeapTuple tuple)
|
||||
{
|
||||
int ncols = tuple->t_data->t_natts;
|
||||
int i;
|
||||
int ncols = tuple->t_data->t_natts;
|
||||
int i;
|
||||
|
||||
for (i = 1; i <= ncols; i++)
|
||||
{
|
||||
@ -659,15 +663,15 @@ tupleAllNulls(HeapTuple tuple)
|
||||
* ----------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
ExecInitSubPlan(SubPlanState *node, EState *estate)
|
||||
ExecInitSubPlan(SubPlanState * node, EState *estate)
|
||||
{
|
||||
SubPlan *subplan = (SubPlan *) node->xprstate.expr;
|
||||
SubPlan *subplan = (SubPlan *) node->xprstate.expr;
|
||||
EState *sp_estate;
|
||||
MemoryContext oldcontext;
|
||||
|
||||
/*
|
||||
* Do access checking on the rangetable entries in the subquery.
|
||||
* Here, we assume the subquery is a SELECT.
|
||||
* Do access checking on the rangetable entries in the subquery. Here,
|
||||
* we assume the subquery is a SELECT.
|
||||
*/
|
||||
ExecCheckRTPerms(subplan->rtable, CMD_SELECT);
|
||||
|
||||
@ -690,9 +694,9 @@ ExecInitSubPlan(SubPlanState *node, EState *estate)
|
||||
* create an EState for the subplan
|
||||
*
|
||||
* The subquery needs its own EState because it has its own rangetable.
|
||||
* It shares our Param ID space, however. XXX if rangetable access were
|
||||
* done differently, the subquery could share our EState, which would
|
||||
* eliminate some thrashing about in this module...
|
||||
* It shares our Param ID space, however. XXX if rangetable access
|
||||
* were done differently, the subquery could share our EState, which
|
||||
* would eliminate some thrashing about in this module...
|
||||
*/
|
||||
sp_estate = CreateExecutorState();
|
||||
node->sub_estate = sp_estate;
|
||||
@ -721,9 +725,9 @@ ExecInitSubPlan(SubPlanState *node, EState *estate)
|
||||
* to set params for parent plan then mark parameters as needing
|
||||
* evaluation.
|
||||
*
|
||||
* Note that in the case of un-correlated subqueries we don't care
|
||||
* about setting parent->chgParam here: indices take care about
|
||||
* it, for others - it doesn't matter...
|
||||
* Note that in the case of un-correlated subqueries we don't care about
|
||||
* setting parent->chgParam here: indices take care about it, for
|
||||
* others - it doesn't matter...
|
||||
*/
|
||||
if (subplan->setParam != NIL)
|
||||
{
|
||||
@ -731,7 +735,7 @@ ExecInitSubPlan(SubPlanState *node, EState *estate)
|
||||
|
||||
foreach(lst, subplan->setParam)
|
||||
{
|
||||
int paramid = lfirsti(lst);
|
||||
int paramid = lfirsti(lst);
|
||||
ParamExecData *prm = &(estate->es_param_exec_vals[paramid]);
|
||||
|
||||
prm->execPlan = node;
|
||||
@ -744,8 +748,8 @@ ExecInitSubPlan(SubPlanState *node, EState *estate)
|
||||
*/
|
||||
if (subplan->useHashTable)
|
||||
{
|
||||
int ncols,
|
||||
i;
|
||||
int ncols,
|
||||
i;
|
||||
TupleDesc tupDesc;
|
||||
TupleTable tupTable;
|
||||
TupleTableSlot *slot;
|
||||
@ -768,15 +772,16 @@ ExecInitSubPlan(SubPlanState *node, EState *estate)
|
||||
ncols = length(node->exprs);
|
||||
node->keyColIdx = (AttrNumber *) palloc(ncols * sizeof(AttrNumber));
|
||||
for (i = 0; i < ncols; i++)
|
||||
node->keyColIdx[i] = i+1;
|
||||
node->keyColIdx[i] = i + 1;
|
||||
|
||||
/*
|
||||
* We use ExecProject to evaluate the lefthand and righthand
|
||||
* expression lists and form tuples. (You might think that we
|
||||
* could use the sub-select's output tuples directly, but that is
|
||||
* not the case if we had to insert any run-time coercions of the
|
||||
* sub-select's output datatypes; anyway this avoids storing any
|
||||
* resjunk columns that might be in the sub-select's output.)
|
||||
* Run through the combining expressions to build tlists for the
|
||||
* resjunk columns that might be in the sub-select's output.) Run
|
||||
* through the combining expressions to build tlists for the
|
||||
* lefthand and righthand sides. We need both the ExprState list
|
||||
* (for ExecProject) and the underlying parse Exprs (for
|
||||
* ExecTypeFromTL).
|
||||
@ -791,7 +796,7 @@ ExecInitSubPlan(SubPlanState *node, EState *estate)
|
||||
i = 1;
|
||||
foreach(lexpr, node->exprs)
|
||||
{
|
||||
FuncExprState *fstate = (FuncExprState *) lfirst(lexpr);
|
||||
FuncExprState *fstate = (FuncExprState *) lfirst(lexpr);
|
||||
OpExpr *opexpr = (OpExpr *) fstate->xprstate.expr;
|
||||
ExprState *exstate;
|
||||
Expr *expr;
|
||||
@ -834,34 +839,34 @@ ExecInitSubPlan(SubPlanState *node, EState *estate)
|
||||
rightptlist = lappend(rightptlist, tle);
|
||||
|
||||
/* Lookup the combining function */
|
||||
fmgr_info(opexpr->opfuncid, &node->eqfunctions[i-1]);
|
||||
node->eqfunctions[i-1].fn_expr = (Node *) opexpr;
|
||||
fmgr_info(opexpr->opfuncid, &node->eqfunctions[i - 1]);
|
||||
node->eqfunctions[i - 1].fn_expr = (Node *) opexpr;
|
||||
|
||||
/* Lookup the associated hash function */
|
||||
hashfn = get_op_hash_function(opexpr->opno);
|
||||
if (!OidIsValid(hashfn))
|
||||
elog(ERROR, "could not find hash function for hash operator %u",
|
||||
opexpr->opno);
|
||||
fmgr_info(hashfn, &node->hashfunctions[i-1]);
|
||||
fmgr_info(hashfn, &node->hashfunctions[i - 1]);
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
/*
|
||||
* Create a tupletable to hold these tuples. (Note: we never bother
|
||||
* to free the tupletable explicitly; that's okay because it will
|
||||
* never store raw disk tuples that might have associated buffer
|
||||
* pins. The only resource involved is memory, which will be
|
||||
* cleaned up by freeing the query context.)
|
||||
* Create a tupletable to hold these tuples. (Note: we never
|
||||
* bother to free the tupletable explicitly; that's okay because
|
||||
* it will never store raw disk tuples that might have associated
|
||||
* buffer pins. The only resource involved is memory, which will
|
||||
* be cleaned up by freeing the query context.)
|
||||
*/
|
||||
tupTable = ExecCreateTupleTable(2);
|
||||
|
||||
/*
|
||||
* Construct tupdescs, slots and projection nodes for left and
|
||||
* right sides. The lefthand expressions will be evaluated in
|
||||
* the parent plan node's exprcontext, which we don't have access
|
||||
* to here. Fortunately we can just pass NULL for now and fill it
|
||||
* in later (hack alert!). The righthand expressions will be
|
||||
* right sides. The lefthand expressions will be evaluated in the
|
||||
* parent plan node's exprcontext, which we don't have access to
|
||||
* here. Fortunately we can just pass NULL for now and fill it in
|
||||
* later (hack alert!). The righthand expressions will be
|
||||
* evaluated in our own innerecontext.
|
||||
*/
|
||||
tupDesc = ExecTypeFromTL(leftptlist, false);
|
||||
@ -894,11 +899,11 @@ ExecInitSubPlan(SubPlanState *node, EState *estate)
|
||||
* ----------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
ExecSetParamPlan(SubPlanState *node, ExprContext *econtext)
|
||||
ExecSetParamPlan(SubPlanState * node, ExprContext *econtext)
|
||||
{
|
||||
SubPlan *subplan = (SubPlan *) node->xprstate.expr;
|
||||
SubPlan *subplan = (SubPlan *) node->xprstate.expr;
|
||||
PlanState *planstate = node->planstate;
|
||||
SubLinkType subLinkType = subplan->subLinkType;
|
||||
SubLinkType subLinkType = subplan->subLinkType;
|
||||
MemoryContext oldcontext;
|
||||
TupleTableSlot *slot;
|
||||
List *lst;
|
||||
@ -928,7 +933,7 @@ ExecSetParamPlan(SubPlanState *node, ExprContext *econtext)
|
||||
if (subLinkType == EXISTS_SUBLINK)
|
||||
{
|
||||
/* There can be only one param... */
|
||||
int paramid = lfirsti(subplan->setParam);
|
||||
int paramid = lfirsti(subplan->setParam);
|
||||
ParamExecData *prm = &(econtext->ecxt_param_exec_vals[paramid]);
|
||||
|
||||
prm->execPlan = NULL;
|
||||
@ -940,8 +945,8 @@ ExecSetParamPlan(SubPlanState *node, ExprContext *econtext)
|
||||
|
||||
if (subLinkType == ARRAY_SUBLINK)
|
||||
{
|
||||
Datum dvalue;
|
||||
bool disnull;
|
||||
Datum dvalue;
|
||||
bool disnull;
|
||||
|
||||
found = true;
|
||||
/* stash away current value */
|
||||
@ -963,8 +968,8 @@ ExecSetParamPlan(SubPlanState *node, ExprContext *econtext)
|
||||
found = true;
|
||||
|
||||
/*
|
||||
* We need to copy the subplan's tuple into our own context,
|
||||
* in case any of the params are pass-by-ref type --- the pointers
|
||||
* We need to copy the subplan's tuple into our own context, in
|
||||
* case any of the params are pass-by-ref type --- the pointers
|
||||
* stored in the param structs will point at this copied tuple!
|
||||
* node->curTuple keeps track of the copied tuple for eventual
|
||||
* freeing.
|
||||
@ -981,7 +986,7 @@ ExecSetParamPlan(SubPlanState *node, ExprContext *econtext)
|
||||
*/
|
||||
foreach(lst, subplan->setParam)
|
||||
{
|
||||
int paramid = lfirsti(lst);
|
||||
int paramid = lfirsti(lst);
|
||||
ParamExecData *prm = &(econtext->ecxt_param_exec_vals[paramid]);
|
||||
|
||||
prm->execPlan = NULL;
|
||||
@ -995,7 +1000,7 @@ ExecSetParamPlan(SubPlanState *node, ExprContext *econtext)
|
||||
if (subLinkType == EXISTS_SUBLINK)
|
||||
{
|
||||
/* There can be only one param... */
|
||||
int paramid = lfirsti(subplan->setParam);
|
||||
int paramid = lfirsti(subplan->setParam);
|
||||
ParamExecData *prm = &(econtext->ecxt_param_exec_vals[paramid]);
|
||||
|
||||
prm->execPlan = NULL;
|
||||
@ -1006,7 +1011,7 @@ ExecSetParamPlan(SubPlanState *node, ExprContext *econtext)
|
||||
{
|
||||
foreach(lst, subplan->setParam)
|
||||
{
|
||||
int paramid = lfirsti(lst);
|
||||
int paramid = lfirsti(lst);
|
||||
ParamExecData *prm = &(econtext->ecxt_param_exec_vals[paramid]);
|
||||
|
||||
prm->execPlan = NULL;
|
||||
@ -1018,7 +1023,7 @@ ExecSetParamPlan(SubPlanState *node, ExprContext *econtext)
|
||||
else if (subLinkType == ARRAY_SUBLINK)
|
||||
{
|
||||
/* There can be only one param... */
|
||||
int paramid = lfirsti(subplan->setParam);
|
||||
int paramid = lfirsti(subplan->setParam);
|
||||
ParamExecData *prm = &(econtext->ecxt_param_exec_vals[paramid]);
|
||||
|
||||
Assert(astate != NULL);
|
||||
@ -1036,7 +1041,7 @@ ExecSetParamPlan(SubPlanState *node, ExprContext *econtext)
|
||||
* ----------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
ExecEndSubPlan(SubPlanState *node)
|
||||
ExecEndSubPlan(SubPlanState * node)
|
||||
{
|
||||
if (node->needShutdown)
|
||||
{
|
||||
@ -1056,10 +1061,10 @@ ExecEndSubPlan(SubPlanState *node)
|
||||
* Mark an initplan as needing recalculation
|
||||
*/
|
||||
void
|
||||
ExecReScanSetParamPlan(SubPlanState *node, PlanState *parent)
|
||||
ExecReScanSetParamPlan(SubPlanState * node, PlanState * parent)
|
||||
{
|
||||
PlanState *planstate = node->planstate;
|
||||
SubPlan *subplan = (SubPlan *) node->xprstate.expr;
|
||||
SubPlan *subplan = (SubPlan *) node->xprstate.expr;
|
||||
EState *estate = parent->state;
|
||||
List *lst;
|
||||
|
||||
@ -1080,7 +1085,7 @@ ExecReScanSetParamPlan(SubPlanState *node, PlanState *parent)
|
||||
*/
|
||||
foreach(lst, subplan->setParam)
|
||||
{
|
||||
int paramid = lfirsti(lst);
|
||||
int paramid = lfirsti(lst);
|
||||
ParamExecData *prm = &(estate->es_param_exec_vals[paramid]);
|
||||
|
||||
prm->execPlan = node;
|
||||
|
@ -12,7 +12,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/executor/nodeSubqueryscan.c,v 1.18 2003/02/09 00:30:39 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/executor/nodeSubqueryscan.c,v 1.19 2003/08/04 00:43:18 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -160,10 +160,11 @@ ExecInitSubqueryScan(SubqueryScan *node, EState *estate)
|
||||
Assert(rte->rtekind == RTE_SUBQUERY);
|
||||
|
||||
/*
|
||||
* The subquery needs its own EState because it has its own rangetable.
|
||||
* It shares our Param ID space, however. XXX if rangetable access were
|
||||
* done differently, the subquery could share our EState, which would
|
||||
* eliminate some thrashing about in this module...
|
||||
* The subquery needs its own EState because it has its own
|
||||
* rangetable. It shares our Param ID space, however. XXX if
|
||||
* rangetable access were done differently, the subquery could share
|
||||
* our EState, which would eliminate some thrashing about in this
|
||||
* module...
|
||||
*/
|
||||
sp_estate = CreateExecutorState();
|
||||
subquerystate->sss_SubEState = sp_estate;
|
||||
@ -259,9 +260,9 @@ ExecSubqueryReScan(SubqueryScanState *node, ExprContext *exprCtxt)
|
||||
|
||||
/*
|
||||
* ExecReScan doesn't know about my subplan, so I have to do
|
||||
* changed-parameter signaling myself. This is just as well,
|
||||
* because the subplan has its own memory context in which its
|
||||
* chgParam state lives.
|
||||
* changed-parameter signaling myself. This is just as well, because
|
||||
* the subplan has its own memory context in which its chgParam state
|
||||
* lives.
|
||||
*/
|
||||
if (node->ss.ps.chgParam != NULL)
|
||||
UpdateChangedParamSet(node->subplan, node->ss.ps.chgParam);
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/executor/nodeUnique.c,v 1.38 2003/02/02 19:08:57 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/executor/nodeUnique.c,v 1.39 2003/08/04 00:43:18 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -57,9 +57,9 @@ ExecUnique(UniqueState *node)
|
||||
* now loop, returning only non-duplicate tuples. We assume that the
|
||||
* tuples arrive in sorted order so we can detect duplicates easily.
|
||||
*
|
||||
* We return the first tuple from each group of duplicates (or the
|
||||
* last tuple of each group, when moving backwards). At either end
|
||||
* of the subplan, clear priorTuple so that we correctly return the
|
||||
* We return the first tuple from each group of duplicates (or the last
|
||||
* tuple of each group, when moving backwards). At either end of the
|
||||
* subplan, clear priorTuple so that we correctly return the
|
||||
* first/last tuple when reversing direction.
|
||||
*/
|
||||
for (;;)
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/executor/spi.c,v 1.99 2003/07/21 17:05:10 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/executor/spi.c,v 1.100 2003/08/04 00:43:18 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -95,8 +95,8 @@ SPI_connect(void)
|
||||
/*
|
||||
* Create memory contexts for this procedure
|
||||
*
|
||||
* XXX it would be better to use PortalContext as the parent context,
|
||||
* but we may not be inside a portal (consider deferred-trigger
|
||||
* XXX it would be better to use PortalContext as the parent context, but
|
||||
* we may not be inside a portal (consider deferred-trigger
|
||||
* execution).
|
||||
*/
|
||||
_SPI_current->procCxt = AllocSetContextCreate(TopTransactionContext,
|
||||
@ -799,7 +799,7 @@ SPI_cursor_open(const char *name, void *plan, Datum *Values, const char *Nulls)
|
||||
*/
|
||||
PortalDefineQuery(portal,
|
||||
NULL, /* unfortunately don't have sourceText */
|
||||
"SELECT", /* cursor's query is always a SELECT */
|
||||
"SELECT", /* cursor's query is always a SELECT */
|
||||
makeList1(queryTree),
|
||||
makeList1(planTree),
|
||||
PortalGetHeapMemory(portal));
|
||||
@ -1007,9 +1007,9 @@ _SPI_execute(const char *src, int tcount, _SPI_plan *plan)
|
||||
/*
|
||||
* Do parse analysis and rule rewrite for each raw parsetree.
|
||||
*
|
||||
* We save the querytrees from each raw parsetree as a separate
|
||||
* sublist. This allows _SPI_execute_plan() to know where the
|
||||
* boundaries between original queries fall.
|
||||
* We save the querytrees from each raw parsetree as a separate sublist.
|
||||
* This allows _SPI_execute_plan() to know where the boundaries
|
||||
* between original queries fall.
|
||||
*/
|
||||
query_list_list = NIL;
|
||||
plan_list = NIL;
|
||||
@ -1136,8 +1136,8 @@ _SPI_execute_plan(_SPI_plan *plan, Datum *Values, const char *Nulls,
|
||||
|
||||
foreach(query_list_list_item, query_list_list)
|
||||
{
|
||||
List *query_list = lfirst(query_list_list_item);
|
||||
List *query_list_item;
|
||||
List *query_list = lfirst(query_list_list_item);
|
||||
List *query_list_item;
|
||||
|
||||
/* Reset state for each original parsetree */
|
||||
/* (at most one of its querytrees will be marked canSetTag) */
|
||||
@ -1148,7 +1148,7 @@ _SPI_execute_plan(_SPI_plan *plan, Datum *Values, const char *Nulls,
|
||||
|
||||
foreach(query_list_item, query_list)
|
||||
{
|
||||
Query *queryTree = (Query *) lfirst(query_list_item);
|
||||
Query *queryTree = (Query *) lfirst(query_list_item);
|
||||
Plan *planTree;
|
||||
QueryDesc *qdesc;
|
||||
DestReceiver *dest;
|
||||
@ -1190,10 +1190,10 @@ _SPI_pquery(QueryDesc *queryDesc, bool runit, int tcount)
|
||||
{
|
||||
case CMD_SELECT:
|
||||
res = SPI_OK_SELECT;
|
||||
if (queryDesc->parsetree->into != NULL) /* select into table */
|
||||
if (queryDesc->parsetree->into != NULL) /* select into table */
|
||||
{
|
||||
res = SPI_OK_SELINTO;
|
||||
queryDesc->dest = None_Receiver; /* don't output results */
|
||||
queryDesc->dest = None_Receiver; /* don't output results */
|
||||
}
|
||||
break;
|
||||
case CMD_INSERT:
|
||||
@ -1351,7 +1351,7 @@ _SPI_checktuples(void)
|
||||
SPITupleTable *tuptable = _SPI_current->tuptable;
|
||||
bool failed = false;
|
||||
|
||||
if (tuptable == NULL) /* spi_dest_startup was not called */
|
||||
if (tuptable == NULL) /* spi_dest_startup was not called */
|
||||
failed = true;
|
||||
else if (processed != (tuptable->alloced - tuptable->free))
|
||||
failed = true;
|
||||
@ -1372,7 +1372,8 @@ _SPI_copy_plan(_SPI_plan *plan, int location)
|
||||
parentcxt = _SPI_current->procCxt;
|
||||
else if (location == _SPI_CPLAN_TOPCXT)
|
||||
parentcxt = TopMemoryContext;
|
||||
else /* (this case not currently used) */
|
||||
else
|
||||
/* (this case not currently used) */
|
||||
parentcxt = CurrentMemoryContext;
|
||||
|
||||
/*
|
||||
|
@ -9,7 +9,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/executor/tstoreReceiver.c,v 1.6 2003/05/08 18:16:36 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/executor/tstoreReceiver.c,v 1.7 2003/08/04 00:43:18 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -21,10 +21,10 @@
|
||||
|
||||
typedef struct
|
||||
{
|
||||
DestReceiver pub;
|
||||
Tuplestorestate *tstore;
|
||||
MemoryContext cxt;
|
||||
} TStoreState;
|
||||
DestReceiver pub;
|
||||
Tuplestorestate *tstore;
|
||||
MemoryContext cxt;
|
||||
} TStoreState;
|
||||
|
||||
|
||||
/*
|
||||
|
Reference in New Issue
Block a user