From 25517ee14c1a018876b64dce73e8f7fb7e937783 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Mon, 7 Dec 2015 17:41:45 -0500 Subject: Fix another oversight in checking if a join with LATERAL refs is legal. It was possible for the planner to decide to join a LATERAL subquery to the outer side of an outer join before the outer join itself is completed. Normally that's fine because of the associativity rules, but it doesn't work if the subquery contains a lateral reference to the inner side of the outer join. In such a situation the outer join *must* be done first. join_is_legal() missed this consideration and would allow the join to be attempted, but the actual path-building code correctly decided that no valid join path could be made, sometimes leading to planner errors such as "failed to build any N-way joins". Per report from Andreas Seltenreich. Back-patch to 9.3 where LATERAL support was added. --- src/include/optimizer/pathnode.h | 1 + 1 file changed, 1 insertion(+) (limited to 'src/include/optimizer/pathnode.h') diff --git a/src/include/optimizer/pathnode.h b/src/include/optimizer/pathnode.h index 161644c343b..889e1ee87b5 100644 --- a/src/include/optimizer/pathnode.h +++ b/src/include/optimizer/pathnode.h @@ -144,6 +144,7 @@ extern RelOptInfo *build_join_rel(PlannerInfo *root, RelOptInfo *inner_rel, SpecialJoinInfo *sjinfo, List **restrictlist_ptr); +extern Relids min_join_parameterization(PlannerInfo *root, Relids joinrelids); extern RelOptInfo *build_empty_join_rel(PlannerInfo *root); extern AppendRelInfo *find_childrel_appendrelinfo(PlannerInfo *root, RelOptInfo *rel); -- cgit v1.2.3