• Tom Lane's avatar
    Fix another oversight in checking if a join with LATERAL refs is legal. · 7e19db0c
    Tom Lane authored
    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.
    7e19db0c
pathnode.h 6.08 KB