Skip to content

Commit bbb1178

Browse files
committed
bugfix: we cannot use an outer path that is parameterized by the inner rel
1 parent 777917d commit bbb1178

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/hooks.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@
2828
#include "utils/lsyscache.h"
2929

3030

31+
/* Borrowed from joinpath.c */
32+
#define PATH_PARAM_BY_REL(path, rel) \
33+
((path)->param_info && bms_overlap(PATH_REQ_OUTER(path), (rel)->relids))
34+
35+
3136
set_join_pathlist_hook_type set_join_pathlist_next = NULL;
3237
set_rel_pathlist_hook_type set_rel_pathlist_hook_next = NULL;
3338
planner_hook_type planner_hook_next = NULL;
@@ -123,6 +128,12 @@ pathman_join_pathlist_hook(PlannerInfo *root,
123128

124129
/* Select cheapest path for outerrel */
125130
outer = outerrel->cheapest_total_path;
131+
132+
/* We cannot use an outer path that is parameterized by the inner rel */
133+
if (PATH_PARAM_BY_REL(outer, innerrel))
134+
continue;
135+
136+
/* Wrap 'outer' in unique path if needed */
126137
if (saved_jointype == JOIN_UNIQUE_OUTER)
127138
{
128139
outer = (Path *) create_unique_path(root, outerrel,

0 commit comments

Comments
 (0)