Improve eqjoinsel's ndistinct clamping to work for multiple levels of join.
Improve eqjoinsel's ndistinct clamping to work for multiple levels of join.

This patch fixes an oversight in my commit
7f3eba30c9d622d1981b1368f2d79ba0999cdff2 of 2008-10-23.  That patch
accounted for baserel restriction clauses that reduced the number of rows
coming out of a table (and hence the number of possibly-distinct values of
a join variable), but not for join restriction clauses that might have been
applied at a lower level of join.  To account for the latter, look up the
sizes of the min_lefthand and min_righthand inputs of the current join,
and clamp with those in the same way as for the base relations.

Noted while investigating a complaint from Ben Chobot, although this in
itself doesn't seem to explain his report.

Back-patch to 8.4; previous versions used different estimation methods
for which this heuristic isn't relevant.

xinzweb/gpdb,kmjungersen/PostgresXL,snaga/postgres-xl,ovr/postgres-xl,50wu/gpdb,ashwinstar/gpdb,ovr/postgres-xl,ashwinstar/gpdb,kmjungersen/PostgresXL,oberstet/postgres-xl,lisakowen/gpdb,zeroae/postgres-xl,ovr/postgres-xl,adam8157/gpdb,greenplum-db/gpdb,yazun/postgres-xl,jmcatamney/gpdb,jmcatamney/gpdb,postmind-net/postgres-xl,adam8157/gpdb,greenplum-db/gpdb,snaga/postgres-xl,adam8157/gpdb,ashwinstar/gpdb,techdragon/Postgres-XL,50wu/gpdb,postmind-net/postgres-xl,lisakowen/gpdb,50wu/gpdb,greenplum-db/gpdb,jmcatamney/gpdb,ashwinstar/gpdb,snaga/postgres-xl,greenplum-db/gpdb,tpostgres-projects/tPostgres,xinzweb/gpdb,Postgres-XL/Postgres-XL,arcivanov/postgres-xl,arcivanov/postgres-xl,oberstet/postgres-xl,arcivanov/postgres-xl,snaga/postgres-xl,xinzweb/gpdb,jmcatamney/gpdb,50wu/gpdb,tpostgres-projects/tPostgres,lisakowen/gpdb,oberstet/postgres-xl,oberstet/postgres-xl,techdragon/Postgres-XL,greenplum-db/gpdb,postmind-net/postgres-xl,techdragon/Postgres-XL,kmjungersen/PostgresXL,greenplum-db/gpdb,postmind-net/postgres-xl,adam8157/gpdb,ashwinstar/gpdb,yazun/postgres-xl,50wu/gpdb,pavanvd/postgres-xl,Postgres-XL/Postgres-XL,adam8157/gpdb,xinzweb/gpdb,kmjungersen/PostgresXL,lisakowen/gpdb,Postgres-XL/Postgres-XL,pavanvd/postgres-xl,zeroae/postgres-xl,lisakowen/gpdb,xinzweb/gpdb,kmjungersen/PostgresXL,ovr/postgres-xl,Postgres-XL/Postgres-XL,jmcatamney/gpdb,techdragon/Postgres-XL,ashwinstar/gpdb,arcivanov/postgres-xl,tpostgres-projects/tPostgres,ovr/postgres-xl,xinzweb/gpdb,oberstet/postgres-xl,pavanvd/postgres-xl,lisakowen/gpdb,Postgres-XL/Postgres-XL,yazun/postgres-xl,tpostgres-projects/tPostgres,techdragon/Postgres-XL,pavanvd/postgres-xl,50wu/gpdb,greenplum-db/gpdb,greenplum-db/gpdb,zeroae/postgres-xl,yazun/postgres-xl,zeroae/postgres-xl,arcivanov/postgres-xl,zeroae/postgres-xl,50wu/gpdb,yazun/postgres-xl,tpostgres-projects/tPostgres,lisakowen/gpdb,postmind-net/postgres-xl,snaga/postgres-xl,xinzweb/gpdb,xinzweb/gpdb,jmcatamney/gpdb,50wu/gpdb,ashwinstar/gpdb,jmcatamney/gpdb,pavanvd/postgres-xl,lisakowen/gpdb,adam8157/gpdb,adam8157/gpdb,arcivanov/postgres-xl,jmcatamney/gpdb,ashwinstar/gpdb,adam8157/gpdb