Preserve AND/OR flatness while extracting restriction OR clauses.
authorTom Lane <tgl@sss.pgh.pa.us>
Tue, 9 Sep 2014 22:35:14 +0000 (18:35 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Tue, 9 Sep 2014 22:35:31 +0000 (18:35 -0400)
commit1b4cc493d2b5216c14ba3ee781cbeff56f96d1b7
treeb3917cb1ce2344bbd8b2fee6a3fb9d81e3a4091e
parent07c8651dd91d5aea38bee268acb582674ca4b5ea
Preserve AND/OR flatness while extracting restriction OR clauses.

The code I added in commit f343a880d5555faf1dad0286c5632047c8f599ad was
careless about preserving AND/OR flatness: it could create a structure with
an OR node directly underneath another one.  That breaks an assumption
that's fairly important for planning efficiency, not to mention triggering
various Asserts (as reported by Benjamin Smith).  Add a trifle more logic
to handle the case properly.
src/backend/optimizer/util/orclauses.c
src/test/regress/expected/join.out
src/test/regress/sql/join.sql