
From: David Hartwig <daybee@bellatlantic.net>

I put some extra checks to make sure a query was a good candidate for
rewrite into a UNION.    Besides the existing checks:

1.  Make sure the AND/OR tree was rectangular.  ( i.e.    3 X 4  or 10 X
3)
2.  Only one table.
3.  Must have an AND dimension.
4.  At least 9 OP expressions total

Also  cleaned up and commented.

xuegang/gpdb,50wu/gpdb,0x0FFF/gpdb,rubikloud/gpdb,randomtask1155/gpdb,CraigHarris/gpdb,yuanzhao/gpdb,kaknikhil/gpdb,edespino/gpdb,oberstet/postgres-xl,janebeckman/gpdb,zaksoup/gpdb,atris/gpdb,Postgres-XL/Postgres-XL,ashwinstar/gpdb,techdragon/Postgres-XL,Quikling/gpdb,cjcjameson/gpdb,royc1/gpdb,rvs/gpdb,randomtask1155/gpdb,lpetrov-pivotal/gpdb,Quikling/gpdb,zaksoup/gpdb,pavanvd/postgres-xl,edespino/gpdb,0x0FFF/gpdb,foyzur/gpdb,yuanzhao/gpdb,lisakowen/gpdb,Chibin/gpdb,50wu/gpdb,zaksoup/gpdb,tpostgres-projects/tPostgres,adam8157/gpdb,lisakowen/gpdb,arcivanov/postgres-xl,ahachete/gpdb,randomtask1155/gpdb,janebeckman/gpdb,jmcatamney/gpdb,lintzc/gpdb,postmind-net/postgres-xl,adam8157/gpdb,postmind-net/postgres-xl,royc1/gpdb,atris/gpdb,xinzweb/gpdb,yazun/postgres-xl,techdragon/Postgres-XL,Quikling/gpdb,kaknikhil/gpdb,CraigHarris/gpdb,arcivanov/postgres-xl,snaga/postgres-xl,50wu/gpdb,rvs/gpdb,cjcjameson/gpdb,foyzur/gpdb,royc1/gpdb,50wu/gpdb,foyzur/gpdb,Quikling/gpdb,lisakowen/gpdb,rvs/gpdb,edespino/gpdb,zeroae/postgres-xl,lintzc/gpdb,lintzc/gpdb,rvs/gpdb,yuanzhao/gpdb,kmjungersen/PostgresXL,Quikling/gpdb,ahachete/gpdb,jmcatamney/gpdb,zaksoup/gpdb,xinzweb/gpdb,adam8157/gpdb,rubikloud/gpdb,randomtask1155/gpdb,xuegang/gpdb,kaknikhil/gpdb,0x0FFF/gpdb,techdragon/Postgres-XL,kaknikhil/gpdb,atris/gpdb,lintzc/gpdb,greenplum-db/gpdb,janebeckman/gpdb,greenplum-db/gpdb,ashwinstar/gpdb,jmcatamney/gpdb,lpetrov-pivotal/gpdb,snaga/postgres-xl,yazun/postgres-xl,zeroae/postgres-xl,Chibin/gpdb,lisakowen/gpdb,Postgres-XL/Postgres-XL,zaksoup/gpdb,lpetrov-pivotal/gpdb,chrishajas/gpdb,greenplum-db/gpdb,ovr/postgres-xl,xinzweb/gpdb,jmcatamney/gpdb,50wu/gpdb,Chibin/gpdb,Postgres-XL/Postgres-XL,CraigHarris/gpdb,adam8157/gpdb,Chibin/gpdb,janebeckman/gpdb,ashwinstar/gpdb,xinzweb/gpdb,pavanvd/postgres-xl,cjcjameson/gpdb,CraigHarris/gpdb,ahachete/gpdb,CraigHarris/gpdb,ahachete/gpdb,lintzc/gpdb,ashwinstar/gpdb,CraigHarris/gpdb,Chibin/gpdb,Quikling/gpdb,xuegang/gpdb,greenplum-db/gpdb,arcivanov/postgres-xl,Chibin/gpdb,jmcatamney/gpdb,rvs/gpdb,0x0FFF/gpdb,jmcatamney/gpdb,yuanzhao/gpdb,rubikloud/gpdb,tpostgres-projects/tPostgres,yazun/postgres-xl,50wu/gpdb,foyzur/gpdb,oberstet/postgres-xl,greenplum-db/gpdb,pavanvd/postgres-xl,kaknikhil/gpdb,foyzur/gpdb,yuanzhao/gpdb,edespino/gpdb,xuegang/gpdb,tpostgres-projects/tPostgres,royc1/gpdb,janebeckman/gpdb,ashwinstar/gpdb,xuegang/gpdb,CraigHarris/gpdb,janebeckman/gpdb,greenplum-db/gpdb,kmjungersen/PostgresXL,ahachete/gpdb,janebeckman/gpdb,randomtask1155/gpdb,cjcjameson/gpdb,lpetrov-pivotal/gpdb,lpetrov-pivotal/gpdb,50wu/gpdb,xinzweb/gpdb,cjcjameson/gpdb,royc1/gpdb,Postgres-XL/Postgres-XL,ovr/postgres-xl,kaknikhil/gpdb,xinzweb/gpdb,adam8157/gpdb,ovr/postgres-xl,chrishajas/gpdb,janebeckman/gpdb,xuegang/gpdb,Postgres-XL/Postgres-XL,arcivanov/postgres-xl,royc1/gpdb,jmcatamney/gpdb,lintzc/gpdb,foyzur/gpdb,cjcjameson/gpdb,edespino/gpdb,Quikling/gpdb,Quikling/gpdb,randomtask1155/gpdb,cjcjameson/gpdb,tangp3/gpdb,cjcjameson/gpdb,zeroae/postgres-xl,postmind-net/postgres-xl,lintzc/gpdb,randomtask1155/gpdb,lisakowen/gpdb,tangp3/gpdb,ahachete/gpdb,ahachete/gpdb,chrishajas/gpdb,edespino/gpdb,edespino/gpdb,rubikloud/gpdb,rubikloud/gpdb,royc1/gpdb,lpetrov-pivotal/gpdb,janebeckman/gpdb,0x0FFF/gpdb,zeroae/postgres-xl,kaknikhil/gpdb,ashwinstar/gpdb,CraigHarris/gpdb,snaga/postgres-xl,lisakowen/gpdb,yuanzhao/gpdb,atris/gpdb,ahachete/gpdb,techdragon/Postgres-XL,tpostgres-projects/tPostgres,kmjungersen/PostgresXL,ashwinstar/gpdb,arcivanov/postgres-xl,kmjungersen/PostgresXL,lisakowen/gpdb,CraigHarris/gpdb,ovr/postgres-xl,50wu/gpdb,tangp3/gpdb,0x0FFF/gpdb,lintzc/gpdb,yazun/postgres-xl,xinzweb/gpdb,janebeckman/gpdb,cjcjameson/gpdb,greenplum-db/gpdb,xinzweb/gpdb,Quikling/gpdb,yuanzhao/gpdb,techdragon/Postgres-XL,jmcatamney/gpdb,kaknikhil/gpdb,yuanzhao/gpdb,foyzur/gpdb,ashwinstar/gpdb,tpostgres-projects/tPostgres,pavanvd/postgres-xl,postmind-net/postgres-xl,Chibin/gpdb,rvs/gpdb,xuegang/gpdb,lpetrov-pivotal/gpdb,foyzur/gpdb,edespino/gpdb,0x0FFF/gpdb,adam8157/gpdb,snaga/postgres-xl,kmjungersen/PostgresXL,cjcjameson/gpdb,rubikloud/gpdb,rvs/gpdb,rvs/gpdb,ovr/postgres-xl,greenplum-db/gpdb,zaksoup/gpdb,tangp3/gpdb,adam8157/gpdb,zaksoup/gpdb,chrishajas/gpdb,postmind-net/postgres-xl,tangp3/gpdb,edespino/gpdb,xuegang/gpdb,randomtask1155/gpdb,kaknikhil/gpdb,lintzc/gpdb,oberstet/postgres-xl,rubikloud/gpdb,zeroae/postgres-xl,yuanzhao/gpdb,oberstet/postgres-xl,Quikling/gpdb,tangp3/gpdb,zaksoup/gpdb,yazun/postgres-xl,yuanzhao/gpdb,tangp3/gpdb,atris/gpdb,0x0FFF/gpdb,rvs/gpdb,chrishajas/gpdb,atris/gpdb,arcivanov/postgres-xl,rubikloud/gpdb,adam8157/gpdb,lisakowen/gpdb,atris/gpdb,snaga/postgres-xl,xuegang/gpdb,chrishajas/gpdb,edespino/gpdb,pavanvd/postgres-xl,chrishajas/gpdb,Chibin/gpdb,kaknikhil/gpdb,Chibin/gpdb,Chibin/gpdb,rvs/gpdb,royc1/gpdb,tangp3/gpdb,oberstet/postgres-xl,atris/gpdb,lpetrov-pivotal/gpdb,chrishajas/gpdb