mirror of
https://git.postgresql.org/git/postgresql.git
synced 2025-01-12 18:34:36 +08: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
b85a4cda83
commit
85a373b1f0
@ -21,7 +21,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/executor/nodeBitmapHeapscan.c,v 1.14 2006/10/04 00:29:52 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/executor/nodeBitmapHeapscan.c,v 1.14.2.1 2006/12/26 19:26:56 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -364,6 +364,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.
|
||||
@ -488,6 +490,8 @@ ExecInitBitmapHeapScan(BitmapHeapScan *node, EState *estate, int eflags)
|
||||
*/
|
||||
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.40 2006/06/27 02:51:39 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/executor/nodeFunctionscan.c,v 1.40.2.1 2006/12/26 19:26:56 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -317,6 +317,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.117 2006/10/04 00:29:52 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/executor/nodeIndexscan.c,v 1.117.2.1 2006/12/26 19:26:56 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -168,6 +168,8 @@ ExecIndexReScan(IndexScanState *node, ExprContext *exprCtxt)
|
||||
econtext = node->iss_RuntimeContext; /* context for runtime keys */
|
||||
scanrelid = ((IndexScan *) node->ss.ps.plan)->scan.scanrelid;
|
||||
|
||||
node->ss.ps.ps_TupFromTlist = false;
|
||||
|
||||
if (econtext)
|
||||
{
|
||||
/*
|
||||
@ -476,6 +478,8 @@ ExecInitIndexScan(IndexScan *node, EState *estate, int eflags)
|
||||
*/
|
||||
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.34 2006/03/05 15:58:26 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/executor/nodeResult.c,v 1.34.2.1 2006/12/26 19:26:56 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -200,6 +200,8 @@ ExecInitResult(Result *node, EState *estate, int eflags)
|
||||
*/
|
||||
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.61 2006/10/04 00:29:52 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/executor/nodeSeqscan.c,v 1.61.2.1 2006/12/26 19:26:56 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -295,6 +295,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.32 2006/10/04 00:29:53 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/executor/nodeSubqueryscan.c,v 1.32.2.1 2006/12/26 19:26:56 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -294,4 +294,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.51 2006/10/04 00:29:53 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/executor/nodeTidscan.c,v 1.51.2.1 2006/12/26 19:26:56 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -376,6 +376,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 =
|
||||
@ -482,6 +484,8 @@ ExecInitTidScan(TidScan *node, EState *estate, int eflags)
|
||||
*/
|
||||
ExecAssignExprContext(estate, &tidstate->ss.ps);
|
||||
|
||||
tidstate->ss.ps.ps_TupFromTlist = false;
|
||||
|
||||
/*
|
||||
* initialize child expressions
|
||||
*/
|
||||
|
@ -9,7 +9,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/executor/nodeValuesscan.c,v 1.3 2006/10/04 00:29:53 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/executor/nodeValuesscan.c,v 1.3.2.1 2006/12/26 19:26:56 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -334,6 +334,7 @@ void
|
||||
ExecValuesReScan(ValuesScanState *node, ExprContext *exprCtxt)
|
||||
{
|
||||
ExecClearTuple(node->ss.ps.ps_ResultTupleSlot);
|
||||
node->ss.ps.ps_TupFromTlist = false;
|
||||
|
||||
node->curr_idx = -1;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user