Skip to content

Commit ce093aa

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 ec3daee commit ce093aa

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
@@ -3937,9 +3937,15 @@ reparameterize_path(PlannerInfo *root, Path *path,
39373937
case T_Memoize:
39383938
{
39393939
MemoizePath *mpath = (MemoizePath *) path;
3940+
Path *spath = mpath->subpath;
39403941

3942+
spath = reparameterize_path(root, spath,
3943+
required_outer,
3944+
loop_count);
3945+
if (spath == NULL)
3946+
return NULL;
39413947
return (Path *) create_memoize_path(root, rel,
3942-
mpath->subpath,
3948+
spath,
39433949
mpath->param_exprs,
39443950
mpath->hash_operators,
39453951
mpath->singlerow,

0 commit comments

Comments
 (0)