summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Lane2022-12-04 18:48:12 +0000
committerTom Lane2022-12-04 18:48:12 +0000
commite76913802c5347831aadc1513b59196bde6ec116 (patch)
tree5fc3de182ec4390ca762890fec6b2773ead4fe8a
parent6eb2f0ed4cd5c8668c3127024a8a58b10fa2e8dc (diff)
Fix broken MemoizePath support in reparameterize_path().
It neglected to recurse to the subpath, meaning you'd get back a path identical to the input. This could produce wrong query results if the omission meant that the subpath fails to enforce some join clause it should be enforcing. We don't have a test case for this at the moment, but the code is obviously broken and the fix is equally obvious. Back-patch to v14 where Memoize was introduced. Richard Guo Discussion: https://postgr.es/m/CAMbWs4_R=ORpz=Lkn2q3ebPC5EuWyfZF+tmfCPVLBVK5W39mHA@mail.gmail.com
-rw-r--r--src/backend/optimizer/util/pathnode.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/backend/optimizer/util/pathnode.c b/src/backend/optimizer/util/pathnode.c
index ea2e158f6d..5379c087a1 100644
--- a/src/backend/optimizer/util/pathnode.c
+++ b/src/backend/optimizer/util/pathnode.c
@@ -3994,9 +3994,15 @@ reparameterize_path(PlannerInfo *root, Path *path,
case T_Memoize:
{
MemoizePath *mpath = (MemoizePath *) path;
+ Path *spath = mpath->subpath;
+ spath = reparameterize_path(root, spath,
+ required_outer,
+ loop_count);
+ if (spath == NULL)
+ return NULL;
return (Path *) create_memoize_path(root, rel,
- mpath->subpath,
+ spath,
mpath->param_exprs,
mpath->hash_operators,
mpath->singlerow,