Skip to content

Commit e769138

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 6eb2f0e commit e769138

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/backend/optimizer/util/pathnode.c

+7-1
Original file line numberDiff line numberDiff line change
@@ -3994,9 +3994,15 @@ reparameterize_path(PlannerInfo *root, Path *path,
39943994
case T_Memoize:
39953995
{
39963996
MemoizePath *mpath = (MemoizePath *) path;
3997+
Path *spath = mpath->subpath;
39973998

3999+
spath = reparameterize_path(root, spath,
4000+
required_outer,
4001+
loop_count);
4002+
if (spath == NULL)
4003+
return NULL;
39984004
return (Path *) create_memoize_path(root, rel,
3999-
mpath->subpath,
4005+
spath,
40004006
mpath->param_exprs,
40014007
mpath->hash_operators,
40024008
mpath->singlerow,

0 commit comments

Comments
 (0)