mirror of
https://github.com/postgres/postgres.git
synced 2025-05-02 11:44:50 +03:00
Partial fix for EvalPlanQual bugs reported by Magnus Hagander, 3-Apr.
Ensure that outer tuple link needed for inner indexscan qual evaluation gets set in the EvalPlanQual case. This stops coredump, but we still have resource leaks due to failure to clean up EvalPlanQual properly...
This commit is contained in:
parent
a25a490718
commit
891039c15f
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/executor/nodeIndexscan.c,v 1.47 2000/02/18 09:29:57 inoue Exp $
|
* $Header: /cvsroot/pgsql/src/backend/executor/nodeIndexscan.c,v 1.48 2000/04/07 00:30:41 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -338,6 +338,11 @@ ExecIndexReScan(IndexScan *node, ExprContext *exprCtxt, Plan *parent)
|
|||||||
if (ScanDirectionIsBackward(node->indxorderdir))
|
if (ScanDirectionIsBackward(node->indxorderdir))
|
||||||
indexstate->iss_IndexPtr = numIndices;
|
indexstate->iss_IndexPtr = numIndices;
|
||||||
|
|
||||||
|
/* If we are being passed an outer tuple, save it for runtime key calc */
|
||||||
|
if (exprCtxt != NULL)
|
||||||
|
node->scan.scanstate->cstate.cs_ExprContext->ecxt_outertuple =
|
||||||
|
exprCtxt->ecxt_outertuple;
|
||||||
|
|
||||||
/* If this is re-scanning of PlanQual ... */
|
/* If this is re-scanning of PlanQual ... */
|
||||||
if (estate->es_evTuple != NULL &&
|
if (estate->es_evTuple != NULL &&
|
||||||
estate->es_evTuple[node->scan.scanrelid - 1] != NULL)
|
estate->es_evTuple[node->scan.scanrelid - 1] != NULL)
|
||||||
@ -346,12 +351,6 @@ ExecIndexReScan(IndexScan *node, ExprContext *exprCtxt, Plan *parent)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* it's possible in subselects */
|
|
||||||
if (exprCtxt == NULL)
|
|
||||||
exprCtxt = node->scan.scanstate->cstate.cs_ExprContext;
|
|
||||||
|
|
||||||
node->scan.scanstate->cstate.cs_ExprContext->ecxt_outertuple = exprCtxt->ecxt_outertuple;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* get the index qualifications and recalculate the appropriate values
|
* get the index qualifications and recalculate the appropriate values
|
||||||
*/
|
*/
|
||||||
@ -379,14 +378,16 @@ ExecIndexReScan(IndexScan *node, ExprContext *exprCtxt, Plan *parent)
|
|||||||
{
|
{
|
||||||
clause = nth(j, qual);
|
clause = nth(j, qual);
|
||||||
scanexpr = (run_keys[j] == RIGHT_OP) ?
|
scanexpr = (run_keys[j] == RIGHT_OP) ?
|
||||||
(Node *) get_rightop(clause) : (Node *) get_leftop(clause);
|
(Node *) get_rightop(clause) :
|
||||||
|
(Node *) get_leftop(clause);
|
||||||
/*
|
/*
|
||||||
* pass in isDone but ignore it. We don't iterate in
|
* pass in isDone but ignore it. We don't iterate in
|
||||||
* quals
|
* quals
|
||||||
*/
|
*/
|
||||||
scanvalue = (Datum)
|
scanvalue = (Datum)
|
||||||
ExecEvalExpr(scanexpr, exprCtxt, &isNull, &isDone);
|
ExecEvalExpr(scanexpr,
|
||||||
|
node->scan.scanstate->cstate.cs_ExprContext,
|
||||||
|
&isNull, &isDone);
|
||||||
scan_keys[j].sk_argument = scanvalue;
|
scan_keys[j].sk_argument = scanvalue;
|
||||||
if (isNull)
|
if (isNull)
|
||||||
scan_keys[j].sk_flags |= SK_ISNULL;
|
scan_keys[j].sk_flags |= SK_ISNULL;
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/executor/nodeTidscan.c,v 1.4 2000/01/26 05:56:24 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/executor/nodeTidscan.c,v 1.5 2000/04/07 00:30:41 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -109,8 +109,10 @@ TidNext(TidScan *node)
|
|||||||
if (estate->es_evTupleNull[node->scan.scanrelid - 1])
|
if (estate->es_evTupleNull[node->scan.scanrelid - 1])
|
||||||
return slot; /* return empty slot */
|
return slot; /* return empty slot */
|
||||||
|
|
||||||
|
/* probably ought to use ExecStoreTuple here... */
|
||||||
slot->val = estate->es_evTuple[node->scan.scanrelid - 1];
|
slot->val = estate->es_evTuple[node->scan.scanrelid - 1];
|
||||||
slot->ttc_shouldFree = false;
|
slot->ttc_shouldFree = false;
|
||||||
|
|
||||||
/* Flag for the next call that no more tuples */
|
/* Flag for the next call that no more tuples */
|
||||||
estate->es_evTupleNull[node->scan.scanrelid - 1] = true;
|
estate->es_evTupleNull[node->scan.scanrelid - 1] = true;
|
||||||
return (slot);
|
return (slot);
|
||||||
@ -255,7 +257,6 @@ ExecTidReScan(TidScan *node, ExprContext *exprCtxt, Plan *parent)
|
|||||||
{
|
{
|
||||||
EState *estate;
|
EState *estate;
|
||||||
TidScanState *tidstate;
|
TidScanState *tidstate;
|
||||||
Plan *outerPlan;
|
|
||||||
ItemPointer *tidList;
|
ItemPointer *tidList;
|
||||||
|
|
||||||
tidstate = node->tidstate;
|
tidstate = node->tidstate;
|
||||||
@ -263,15 +264,11 @@ ExecTidReScan(TidScan *node, ExprContext *exprCtxt, Plan *parent)
|
|||||||
tidstate->tss_TidPtr = -1;
|
tidstate->tss_TidPtr = -1;
|
||||||
tidList = tidstate->tss_TidList;
|
tidList = tidstate->tss_TidList;
|
||||||
|
|
||||||
if ((outerPlan = outerPlan((Plan *) node)) != NULL)
|
/* If we are being passed an outer tuple, save it for runtime key calc */
|
||||||
{
|
if (exprCtxt != NULL)
|
||||||
/* we are scanning a subplan */
|
node->scan.scanstate->cstate.cs_ExprContext->ecxt_outertuple =
|
||||||
outerPlan = outerPlan((Plan *) node);
|
exprCtxt->ecxt_outertuple;
|
||||||
ExecReScan(outerPlan, exprCtxt, parent);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
/* otherwise, we are scanning a relation */
|
|
||||||
{
|
|
||||||
/* If this is re-scanning of PlanQual ... */
|
/* If this is re-scanning of PlanQual ... */
|
||||||
if (estate->es_evTuple != NULL &&
|
if (estate->es_evTuple != NULL &&
|
||||||
estate->es_evTuple[node->scan.scanrelid - 1] != NULL)
|
estate->es_evTuple[node->scan.scanrelid - 1] != NULL)
|
||||||
@ -280,13 +277,9 @@ ExecTidReScan(TidScan *node, ExprContext *exprCtxt, Plan *parent)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* it's possible in subselects */
|
tidstate->tss_NumTids = TidListCreate(node->tideval,
|
||||||
if (exprCtxt == NULL)
|
node->scan.scanstate->cstate.cs_ExprContext,
|
||||||
exprCtxt = node->scan.scanstate->cstate.cs_ExprContext;
|
tidList);
|
||||||
|
|
||||||
node->scan.scanstate->cstate.cs_ExprContext->ecxt_outertuple = exprCtxt->ecxt_outertuple;
|
|
||||||
tidstate->tss_NumTids = TidListCreate(node->tideval, exprCtxt, tidList);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* perhaps return something meaningful
|
* perhaps return something meaningful
|
||||||
|
Loading…
x
Reference in New Issue
Block a user