Comment 7 for bug 1738488

Revision history for this message
Mike Rylander (mrylander) wrote :

IMO, while I'll always be in favor of more testing, especially by more individuals, I hope others agree that this should be an uncontroversial code change. In essence it takes this:

SELECT foo.bar
  FROM t1 x
        left join t2 y on (x.a = y.a)
        left join t3 foo on (y.b = foo.b)
        left join t2 a on (x.a = a.a) --duplicated JOIN branch
        left join t3 b on (b.b = b.b)
  WHERE foo.baz = '123'
  ORDER BY b.bar;

to

SELECT foo.bar
  FROM t1 x
        left join t2 y on (x.a = y.a)
        left join t3 foo on (y.b = foo.b)
  WHERE foo.baz = '123'
  ORDER BY foo.bar;

They'll produce the same results, but only because the query generator isn't trying to do anything sophisticated. If we teach json_query how to do LATERAL joins (say, by being able to include a function call in the FROM clause) then we'd very likely get what we'd consider an incorrect result. Probably in the form of duplicated rows, or unintended side effects.

Thanks, Dan!