Skip to content

Commit

Permalink
Fix broken MemoizePath support in reparameterize_path().
Browse files Browse the repository at this point in the history
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
  • Loading branch information
tglsfdc committed Dec 4, 2022
1 parent 6eb2f0e commit e769138
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/backend/optimizer/util/pathnode.c
Expand Up @@ -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,
Expand Down

0 comments on commit e769138

Please sign in to comment.