mirror of
https://github.com/postgres/postgres.git
synced 2025-05-28 05:21:27 +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:
parent
3dd05aba09
commit
f1d8828e3c
@ -21,7 +21,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/executor/nodeBitmapHeapscan.c,v 1.4.2.1 2005/12/02 01:30:26 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/executor/nodeBitmapHeapscan.c,v 1.4.2.2 2006/12/26 19:27:03 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -306,6 +306,8 @@ ExecBitmapHeapReScan(BitmapHeapScanState *node, ExprContext *exprCtxt)
|
||||
estate = node->ss.ps.state;
|
||||
scanrelid = ((BitmapHeapScan *) node->ss.ps.plan)->scan.scanrelid;
|
||||
|
||||
node->ss.ps.ps_TupFromTlist = false;
|
||||
|
||||
/*
|
||||
* If we are being passed an outer tuple, link it into the "regular"
|
||||
* per-tuple econtext for possible qual eval.
|
||||
@ -429,6 +431,8 @@ ExecInitBitmapHeapScan(BitmapHeapScan *node, EState *estate)
|
||||
*/
|
||||
ExecAssignExprContext(estate, &scanstate->ss.ps);
|
||||
|
||||
scanstate->ss.ps.ps_TupFromTlist = false;
|
||||
|
||||
/*
|
||||
* initialize child expressions
|
||||
*/
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/executor/nodeFunctionscan.c,v 1.35 2005/10/15 02:49:17 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/executor/nodeFunctionscan.c,v 1.35.2.1 2006/12/26 19:27:03 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -320,6 +320,7 @@ void
|
||||
ExecFunctionReScan(FunctionScanState *node, ExprContext *exprCtxt)
|
||||
{
|
||||
ExecClearTuple(node->ss.ps.ps_ResultTupleSlot);
|
||||
node->ss.ps.ps_TupFromTlist = false;
|
||||
|
||||
/*
|
||||
* If we haven't materialized yet, just return.
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/executor/nodeIndexscan.c,v 1.104.2.1 2005/11/22 18:23:09 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/executor/nodeIndexscan.c,v 1.104.2.2 2006/12/26 19:27:03 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -183,6 +183,8 @@ ExecIndexReScan(IndexScanState *node, ExprContext *exprCtxt)
|
||||
numScanKeys = node->iss_NumScanKeys;
|
||||
scanrelid = ((IndexScan *) node->ss.ps.plan)->scan.scanrelid;
|
||||
|
||||
node->ss.ps.ps_TupFromTlist = false;
|
||||
|
||||
if (econtext)
|
||||
{
|
||||
/*
|
||||
@ -384,6 +386,8 @@ ExecInitIndexScan(IndexScan *node, EState *estate)
|
||||
*/
|
||||
ExecAssignExprContext(estate, &indexstate->ss.ps);
|
||||
|
||||
indexstate->ss.ps.ps_TupFromTlist = false;
|
||||
|
||||
/*
|
||||
* initialize child expressions
|
||||
*
|
||||
|
@ -38,7 +38,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/executor/nodeResult.c,v 1.32 2005/10/15 02:49:17 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/executor/nodeResult.c,v 1.32.2.1 2006/12/26 19:27:04 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -196,6 +196,8 @@ ExecInitResult(Result *node, EState *estate)
|
||||
*/
|
||||
ExecAssignExprContext(estate, &resstate->ps);
|
||||
|
||||
resstate->ps.ps_TupFromTlist = false;
|
||||
|
||||
#define RESULT_NSLOTS 1
|
||||
|
||||
/*
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/executor/nodeSeqscan.c,v 1.54 2005/10/15 02:49:17 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/executor/nodeSeqscan.c,v 1.54.2.1 2006/12/26 19:27:04 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -317,6 +317,8 @@ ExecSeqReScan(SeqScanState *node, ExprContext *exprCtxt)
|
||||
estate = node->ps.state;
|
||||
scanrelid = ((SeqScan *) node->ps.plan)->scanrelid;
|
||||
|
||||
node->ps.ps_TupFromTlist = false;
|
||||
|
||||
/* If this is re-scanning of PlanQual ... */
|
||||
if (estate->es_evTuple != NULL &&
|
||||
estate->es_evTuple[scanrelid - 1] != NULL)
|
||||
|
@ -12,7 +12,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/executor/nodeSubqueryscan.c,v 1.27 2005/10/15 02:49:17 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/executor/nodeSubqueryscan.c,v 1.27.2.1 2006/12/26 19:27:04 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -293,4 +293,5 @@ ExecSubqueryReScan(SubqueryScanState *node, ExprContext *exprCtxt)
|
||||
MemoryContextSwitchTo(oldcontext);
|
||||
|
||||
node->ss.ss_ScanTupleSlot = NULL;
|
||||
node->ss.ps.ps_TupFromTlist = false;
|
||||
}
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/executor/nodeTidscan.c,v 1.43 2005/10/15 02:49:17 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/executor/nodeTidscan.c,v 1.43.2.1 2006/12/26 19:27:04 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -275,6 +275,8 @@ ExecTidReScan(TidScanState *node, ExprContext *exprCtxt)
|
||||
estate = node->ss.ps.state;
|
||||
scanrelid = ((TidScan *) node->ss.ps.plan)->scan.scanrelid;
|
||||
|
||||
node->ss.ps.ps_TupFromTlist = false;
|
||||
|
||||
/* If we are being passed an outer tuple, save it for runtime key calc */
|
||||
if (exprCtxt != NULL)
|
||||
node->ss.ps.ps_ExprContext->ecxt_outertuple =
|
||||
@ -389,6 +391,8 @@ ExecInitTidScan(TidScan *node, EState *estate)
|
||||
*/
|
||||
ExecAssignExprContext(estate, &tidstate->ss.ps);
|
||||
|
||||
tidstate->ss.ps.ps_TupFromTlist = false;
|
||||
|
||||
/*
|
||||
* initialize child expressions
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user