Make real sure we don't reassociate joins into or out of SEMI/ANTI joins.
Make real sure we don't reassociate joins into or out of SEMI/ANTI joins.

Per the discussion in optimizer/README, it's unsafe to reassociate anything
into or out of the RHS of a SEMI or ANTI join.  An example from Piotr
Stefaniak showed that join_is_legal() wasn't sufficiently enforcing this
rule, so lock it down a little harder.

I couldn't find a reasonably simple example of the optimizer trying to
do this, so no new regression test.  (Piotr's example involved the random
search in GEQO accidentally trying an invalid case and triggering a sanity
check way downstream in clause selectivity estimation, which did not seem
like a sequence of events that would be useful to memorialize in a
regression test as-is.)

Back-patch to all active branches.

ashwinstar/gpdb,50wu/gpdb,jmcatamney/gpdb,jmcatamney/gpdb,greenplum-db/gpdb,lisakowen/gpdb,50wu/gpdb,lisakowen/gpdb,adam8157/gpdb,ashwinstar/gpdb,xinzweb/gpdb,adam8157/gpdb,ashwinstar/gpdb,ashwinstar/gpdb,jmcatamney/gpdb,xinzweb/gpdb,ashwinstar/gpdb,jmcatamney/gpdb,50wu/gpdb,lisakowen/gpdb,50wu/gpdb,adam8157/gpdb,jmcatamney/gpdb,50wu/gpdb,greenplum-db/gpdb,adam8157/gpdb,ashwinstar/gpdb,adam8157/gpdb,greenplum-db/gpdb,jmcatamney/gpdb,adam8157/gpdb,ashwinstar/gpdb,adam8157/gpdb,lisakowen/gpdb,xinzweb/gpdb,lisakowen/gpdb,lisakowen/gpdb,xinzweb/gpdb,50wu/gpdb,xinzweb/gpdb,xinzweb/gpdb,jmcatamney/gpdb,greenplum-db/gpdb,greenplum-db/gpdb,lisakowen/gpdb,jmcatamney/gpdb,greenplum-db/gpdb,greenplum-db/gpdb,greenplum-db/gpdb,50wu/gpdb,xinzweb/gpdb,adam8157/gpdb,ashwinstar/gpdb,lisakowen/gpdb,50wu/gpdb,xinzweb/gpdb