mirror of
https://github.com/postgres/postgres.git
synced 2025-06-13 07:41:39 +03:00
Fix parameter recalculation for Limit nodes: during a ReScan call we must
recompute the limit/offset immediately, so that the updated values are available when the child's ReScan function is invoked. Add a regression test for this, too. Bug is new in HEAD (due to the bounded-sorting patch) so no need for back-patch. I did not do anything about merging this signaling with chgParam processing, but if we were to do that we'd still need to compute the updated values at this point rather than during the first ProcNode call. Per observation and test case from Greg Stark, though I didn't use his patch.
This commit is contained in:
@ -7,7 +7,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/executor/nodeSubplan.c,v 1.88 2007/04/26 23:24:44 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/executor/nodeSubplan.c,v 1.89 2007/05/17 19:35:08 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -242,6 +242,9 @@ ExecScanSubPlan(SubPlanState *node,
|
||||
planstate->chgParam = bms_add_member(planstate->chgParam, paramid);
|
||||
}
|
||||
|
||||
/*
|
||||
* Now that we've set up its parameters, we can reset the subplan.
|
||||
*/
|
||||
ExecReScan(planstate, NULL);
|
||||
|
||||
/*
|
||||
@ -901,6 +904,10 @@ ExecSetParamPlan(SubPlanState *node, ExprContext *econtext)
|
||||
subLinkType == ALL_SUBLINK)
|
||||
elog(ERROR, "ANY/ALL subselect unsupported as initplan");
|
||||
|
||||
/*
|
||||
* By definition, an initplan has no parameters from our query level,
|
||||
* but it could have some from an outer level. Rescan it if needed.
|
||||
*/
|
||||
if (planstate->chgParam != NULL)
|
||||
ExecReScan(planstate, NULL);
|
||||
|
||||
|
Reference in New Issue
Block a user