SELECT  tab1.i
FROM    tab1
        -- The ph_may_need optimization should be effective for the
	-- top-level LEFT JOIN. The PHV in sub1 is only referenced below it.
        LEFT JOIN
	(  tab2
           LEFT JOIN
           ( tab3
             LEFT JOIN
             ( SELECT
                   -- This expression should be wrapped in the PHV
                   -- That PHV should have eval_at = {tab4, tab5}.
                   -- 
                   -- Join clause of j1 is the highest reference to the PHV.
                   -- Thus ph_may_need should be {tab2, tab3, tab4, tab5}. Therefore
                   -- the ph_may_need optimization should avoid addition of eval_at
                   -- to min_righthand of the top-level join's SpecialJoinInfo.
		   COALESCE(tab4.l, tab5.m, 1) AS x
                 FROM  tab4
                       LEFT JOIN
                       tab5
                       ON l = m
             ) AS sub1(x)
             ON tab3.k = sub1.x
           ) AS j2(k, x) 
	   ON tab2.j = j2.x
         ) AS j1(j, k)
         -- This clause references j.k (RHS of the lower join) to keep min_righthand
         -- of the top-level join bigger (ph_may_need needs to be its subset).
	 ON tab1.i = j1.k;
