diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2007-05-17 19:35:08 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2007-05-17 19:35:08 +0000 |
commit | b11123b675d9317f771d2bc44f72594de329098d (patch) | |
tree | bf3e5080edbe144393337623b932f0b5c1540459 /src/backend/executor/nodeSubplan.c | |
parent | 64058429c54afb49a679c58e5ff699640bd42502 (diff) | |
download | postgresql-b11123b675d9317f771d2bc44f72594de329098d.tar.gz postgresql-b11123b675d9317f771d2bc44f72594de329098d.zip |
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.
Diffstat (limited to 'src/backend/executor/nodeSubplan.c')
-rw-r--r-- | src/backend/executor/nodeSubplan.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/backend/executor/nodeSubplan.c b/src/backend/executor/nodeSubplan.c index a66f51c26a6..ac91ed1be64 100644 --- a/src/backend/executor/nodeSubplan.c +++ b/src/backend/executor/nodeSubplan.c @@ -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); |