1
0
mirror of https://github.com/postgres/postgres.git synced 2025-08-12 15:23:02 +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:
Tom Lane
2006-12-26 19:27:26 +00:00
parent 923ec1a19f
commit d3db2bd80c
6 changed files with 20 additions and 6 deletions

View File

@@ -8,7 +8,7 @@
*
*
* 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;
ExecClearTuple(scanstate->csstate.cstate.cs_ResultTupleSlot);
scanstate->csstate.cstate.cs_TupFromTlist = false;
/*
* If we haven't materialized yet, just return.

View File

@@ -8,7 +8,7 @@
*
*
* 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;
numScanKeys = indexstate->iss_NumScanKeys;
node->scan.scanstate->cstate.cs_TupFromTlist = false;
if (econtext)
{
/*
@@ -639,6 +641,8 @@ ExecInitIndexScan(IndexScan *node, EState *estate, Plan *parent)
*/
ExecAssignExprContext(estate, &scanstate->cstate);
scanstate->cstate.cs_TupFromTlist = false;
#define INDEXSCAN_NSLOTS 2
/*

View File

@@ -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.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);
resstate->cstate.cs_TupFromTlist = false;
#define RESULT_NSLOTS 1
/*

View File

@@ -8,7 +8,7 @@
*
*
* 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;
estate = node->plan.state;
scanstate->cstate.cs_TupFromTlist = false;
/* If this is re-scanning of PlanQual ... */
if (estate->es_evTuple != NULL &&
estate->es_evTuple[node->scanrelid - 1] != NULL)

View File

@@ -12,7 +12,7 @@
*
*
* 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);
subquerystate->csstate.css_ScanTupleSlot = NULL;
subquerystate->csstate.cstate.cs_TupFromTlist = false;
}

View File

@@ -8,7 +8,7 @@
*
*
* 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;
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 (exprCtxt != NULL)
node->scan.scanstate->cstate.cs_ExprContext->ecxt_outertuple =
@@ -411,6 +413,8 @@ ExecInitTidScan(TidScan *node, EState *estate, Plan *parent)
*/
ExecAssignExprContext(estate, &scanstate->cstate);
scanstate->cstate.cs_TupFromTlist = false;
#define TIDSCAN_NSLOTS 2
/*