mirror of
https://github.com/postgres/postgres.git
synced 2025-05-17 06:41:24 +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
8eb0f23a96
commit
0fbfdf55f8
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/executor/nodeFunctionscan.c,v 1.22 2003/09/25 23:02:12 tgl Exp $
|
* $Header: /cvsroot/pgsql/src/backend/executor/nodeFunctionscan.c,v 1.22.2.1 2006/12/26 19:27:20 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -341,6 +341,7 @@ void
|
|||||||
ExecFunctionReScan(FunctionScanState *node, ExprContext *exprCtxt)
|
ExecFunctionReScan(FunctionScanState *node, ExprContext *exprCtxt)
|
||||||
{
|
{
|
||||||
ExecClearTuple(node->ss.ps.ps_ResultTupleSlot);
|
ExecClearTuple(node->ss.ps.ps_ResultTupleSlot);
|
||||||
|
node->ss.ps.ps_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.84.2.2 2006/05/19 16:31:05 tgl Exp $
|
* $Header: /cvsroot/pgsql/src/backend/executor/nodeIndexscan.c,v 1.84.2.3 2006/12/26 19:27:20 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -375,6 +375,8 @@ ExecIndexReScan(IndexScanState *node, ExprContext *exprCtxt)
|
|||||||
numScanKeys = node->iss_NumScanKeys;
|
numScanKeys = node->iss_NumScanKeys;
|
||||||
scanrelid = ((IndexScan *) node->ss.ps.plan)->scan.scanrelid;
|
scanrelid = ((IndexScan *) node->ss.ps.plan)->scan.scanrelid;
|
||||||
|
|
||||||
|
node->ss.ps.ps_TupFromTlist = false;
|
||||||
|
|
||||||
if (econtext)
|
if (econtext)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
@ -647,6 +649,8 @@ ExecInitIndexScan(IndexScan *node, EState *estate)
|
|||||||
*/
|
*/
|
||||||
ExecAssignExprContext(estate, &indexstate->ss.ps);
|
ExecAssignExprContext(estate, &indexstate->ss.ps);
|
||||||
|
|
||||||
|
indexstate->ss.ps.ps_TupFromTlist = false;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* initialize child expressions
|
* initialize child expressions
|
||||||
*/
|
*/
|
||||||
|
@ -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.26 2003/08/04 02:39:59 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/executor/nodeResult.c,v 1.26.4.1 2006/12/26 19:27:20 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -194,6 +194,8 @@ ExecInitResult(Result *node, EState *estate)
|
|||||||
*/
|
*/
|
||||||
ExecAssignExprContext(estate, &resstate->ps);
|
ExecAssignExprContext(estate, &resstate->ps);
|
||||||
|
|
||||||
|
resstate->ps.ps_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.46 2003/08/08 21:41:42 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/executor/nodeSeqscan.c,v 1.46.4.1 2006/12/26 19:27:20 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -311,6 +311,8 @@ ExecSeqReScan(SeqScanState *node, ExprContext *exprCtxt)
|
|||||||
estate = node->ps.state;
|
estate = node->ps.state;
|
||||||
scanrelid = ((SeqScan *) node->ps.plan)->scanrelid;
|
scanrelid = ((SeqScan *) node->ps.plan)->scanrelid;
|
||||||
|
|
||||||
|
node->ps.ps_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[scanrelid - 1] != NULL)
|
estate->es_evTuple[scanrelid - 1] != NULL)
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/executor/nodeSubqueryscan.c,v 1.22 2003/10/01 21:30:52 tgl Exp $
|
* $Header: /cvsroot/pgsql/src/backend/executor/nodeSubqueryscan.c,v 1.22.2.1 2006/12/26 19:27:20 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -278,4 +278,5 @@ ExecSubqueryReScan(SubqueryScanState *node, ExprContext *exprCtxt)
|
|||||||
MemoryContextSwitchTo(oldcontext);
|
MemoryContextSwitchTo(oldcontext);
|
||||||
|
|
||||||
node->ss.ss_ScanTupleSlot = NULL;
|
node->ss.ss_ScanTupleSlot = NULL;
|
||||||
|
node->ss.ps.ps_TupFromTlist = false;
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/executor/nodeTidscan.c,v 1.35 2003/09/26 01:17:01 tgl Exp $
|
* $Header: /cvsroot/pgsql/src/backend/executor/nodeTidscan.c,v 1.35.2.1 2006/12/26 19:27:20 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -270,6 +270,8 @@ ExecTidReScan(TidScanState *node, ExprContext *exprCtxt)
|
|||||||
estate = node->ss.ps.state;
|
estate = node->ss.ps.state;
|
||||||
scanrelid = ((TidScan *) node->ss.ps.plan)->scan.scanrelid;
|
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 we are being passed an outer tuple, save it for runtime key calc */
|
||||||
if (exprCtxt != NULL)
|
if (exprCtxt != NULL)
|
||||||
node->ss.ps.ps_ExprContext->ecxt_outertuple =
|
node->ss.ps.ps_ExprContext->ecxt_outertuple =
|
||||||
@ -385,6 +387,8 @@ ExecInitTidScan(TidScan *node, EState *estate)
|
|||||||
*/
|
*/
|
||||||
ExecAssignExprContext(estate, &tidstate->ss.ps);
|
ExecAssignExprContext(estate, &tidstate->ss.ps);
|
||||||
|
|
||||||
|
tidstate->ss.ps.ps_TupFromTlist = false;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* initialize child expressions
|
* initialize child expressions
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user