mirror of
https://github.com/postgres/postgres.git
synced 2025-08-14 02:22:38 +03:00
Repair bug #2839: the various ExecReScan functions need to reset
ps_TupFromTlist in plan nodes that make use of it. This was being done correctly in join nodes and Result nodes but not in any relation-scan nodes. Bug would lead to bogus results if a set-returning function appeared in the targetlist of a subquery that could be rescanned after partial execution, for example a subquery within EXISTS(). Bug has been around forever :-( ... surprising it wasn't reported before.
This commit is contained in:
@@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/executor/nodeFunctionscan.c,v 1.12 2002/09/04 20:31:18 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/executor/nodeFunctionscan.c,v 1.12.2.1 2006/12/26 19:27:26 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@@ -361,6 +361,7 @@ ExecFunctionReScan(FunctionScan *node, ExprContext *exprCtxt, Plan *parent)
|
|||||||
scanstate = (FunctionScanState *) node->scan.scanstate;
|
scanstate = (FunctionScanState *) node->scan.scanstate;
|
||||||
|
|
||||||
ExecClearTuple(scanstate->csstate.cstate.cs_ResultTupleSlot);
|
ExecClearTuple(scanstate->csstate.cstate.cs_ResultTupleSlot);
|
||||||
|
scanstate->csstate.cstate.cs_TupFromTlist = false;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If we haven't materialized yet, just return.
|
* If we haven't materialized yet, just return.
|
||||||
|
@@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/executor/nodeIndexscan.c,v 1.71 2002/09/04 20:31:18 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/executor/nodeIndexscan.c,v 1.71.2.1 2006/12/26 19:27:26 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@@ -303,6 +303,8 @@ ExecIndexReScan(IndexScan *node, ExprContext *exprCtxt, Plan *parent)
|
|||||||
runtimeKeyInfo = indexstate->iss_RuntimeKeyInfo;
|
runtimeKeyInfo = indexstate->iss_RuntimeKeyInfo;
|
||||||
numScanKeys = indexstate->iss_NumScanKeys;
|
numScanKeys = indexstate->iss_NumScanKeys;
|
||||||
|
|
||||||
|
node->scan.scanstate->cstate.cs_TupFromTlist = false;
|
||||||
|
|
||||||
if (econtext)
|
if (econtext)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
@@ -639,6 +641,8 @@ ExecInitIndexScan(IndexScan *node, EState *estate, Plan *parent)
|
|||||||
*/
|
*/
|
||||||
ExecAssignExprContext(estate, &scanstate->cstate);
|
ExecAssignExprContext(estate, &scanstate->cstate);
|
||||||
|
|
||||||
|
scanstate->cstate.cs_TupFromTlist = false;
|
||||||
|
|
||||||
#define INDEXSCAN_NSLOTS 2
|
#define INDEXSCAN_NSLOTS 2
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@@ -34,7 +34,7 @@
|
|||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/executor/nodeResult.c,v 1.21 2002/06/20 20:29:28 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/executor/nodeResult.c,v 1.21.2.1 2006/12/26 19:27:26 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@@ -202,6 +202,8 @@ ExecInitResult(Result *node, EState *estate, Plan *parent)
|
|||||||
*/
|
*/
|
||||||
ExecAssignExprContext(estate, &resstate->cstate);
|
ExecAssignExprContext(estate, &resstate->cstate);
|
||||||
|
|
||||||
|
resstate->cstate.cs_TupFromTlist = false;
|
||||||
|
|
||||||
#define RESULT_NSLOTS 1
|
#define RESULT_NSLOTS 1
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/executor/nodeSeqscan.c,v 1.37 2002/09/04 20:31:18 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/executor/nodeSeqscan.c,v 1.37.2.1 2006/12/26 19:27:26 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@@ -318,6 +318,8 @@ ExecSeqReScan(SeqScan *node, ExprContext *exprCtxt, Plan *parent)
|
|||||||
scanstate = node->scanstate;
|
scanstate = node->scanstate;
|
||||||
estate = node->plan.state;
|
estate = node->plan.state;
|
||||||
|
|
||||||
|
scanstate->cstate.cs_TupFromTlist = false;
|
||||||
|
|
||||||
/* 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->scanrelid - 1] != NULL)
|
estate->es_evTuple[node->scanrelid - 1] != NULL)
|
||||||
|
@@ -12,7 +12,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/executor/nodeSubqueryscan.c,v 1.13 2002/06/20 20:29:28 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/executor/nodeSubqueryscan.c,v 1.13.2.1 2006/12/26 19:27:26 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@@ -259,4 +259,5 @@ ExecSubqueryReScan(SubqueryScan *node, ExprContext *exprCtxt, Plan *parent)
|
|||||||
ExecReScan(node->subplan, NULL, (Plan *) node);
|
ExecReScan(node->subplan, NULL, (Plan *) node);
|
||||||
|
|
||||||
subquerystate->csstate.css_ScanTupleSlot = NULL;
|
subquerystate->csstate.css_ScanTupleSlot = NULL;
|
||||||
|
subquerystate->csstate.cstate.cs_TupFromTlist = false;
|
||||||
}
|
}
|
||||||
|
@@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/executor/nodeTidscan.c,v 1.26 2002/09/04 20:31:18 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/executor/nodeTidscan.c,v 1.26.2.1 2006/12/26 19:27:26 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@@ -254,6 +254,8 @@ ExecTidReScan(TidScan *node, ExprContext *exprCtxt, Plan *parent)
|
|||||||
tidstate = node->tidstate;
|
tidstate = node->tidstate;
|
||||||
tidList = tidstate->tss_TidList;
|
tidList = tidstate->tss_TidList;
|
||||||
|
|
||||||
|
node->scan.scanstate->cstate.cs_TupFromTlist = false;
|
||||||
|
|
||||||
/* If we are being passed an outer tuple, save it for runtime key calc */
|
/* If we are being passed an outer tuple, save it for runtime key calc */
|
||||||
if (exprCtxt != NULL)
|
if (exprCtxt != NULL)
|
||||||
node->scan.scanstate->cstate.cs_ExprContext->ecxt_outertuple =
|
node->scan.scanstate->cstate.cs_ExprContext->ecxt_outertuple =
|
||||||
@@ -411,6 +413,8 @@ ExecInitTidScan(TidScan *node, EState *estate, Plan *parent)
|
|||||||
*/
|
*/
|
||||||
ExecAssignExprContext(estate, &scanstate->cstate);
|
ExecAssignExprContext(estate, &scanstate->cstate);
|
||||||
|
|
||||||
|
scanstate->cstate.cs_TupFromTlist = false;
|
||||||
|
|
||||||
#define TIDSCAN_NSLOTS 2
|
#define TIDSCAN_NSLOTS 2
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Reference in New Issue
Block a user