Skip to content

Commit 834d97c

Browse files
committed
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
1 parent bf8fd64 commit 834d97c

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/backend/optimizer/util/pathnode.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3952,9 +3952,15 @@ reparameterize_path(PlannerInfo *root, Path *path,
39523952
case T_Memoize:
39533953
{
39543954
MemoizePath *mpath = (MemoizePath *) path;
3955+
Path *spath = mpath->subpath;
39553956

3957+
spath = reparameterize_path(root, spath,
3958+
required_outer,
3959+
loop_count);
3960+
if (spath == NULL)
3961+
return NULL;
39563962
return (Path *) create_memoize_path(root, rel,
3957-
mpath->subpath,
3963+
spath,
39583964
mpath->param_exprs,
39593965
mpath->hash_operators,
39603966
mpath->singlerow,

0 commit comments

Comments
 (0)