Fix LP BUG#702345
Fix LP BUG#702345

Analysis:
Close to its end JOIN::optimize() assigns having to tmp_having, and
sets the having clause to NULL:

  tmp_having= having;
  if (select_options & SELECT_DESCRIBE)
  {
    error= 0;
    DBUG_RETURN(0);
  }
  having= 0;

At the same time, this query detects an empty result set, and calls
return_zero_rows(), which checks the HAVING clause as follows:

    if (having && having->val_int() == 0)
      send_row=0;

However having has been already set to NULL, so return_zero_rows
doesn't check the having clause, hence the wrong result.

Solution:
Check join->tmp_having in addition to join->having.

There is no additional test case, because the failure was in
the current regression test.


davidl-zend/zenddbi,ollie314/server,ollie314/server,ollie314/server,ollie314/server,davidl-zend/zenddbi,ollie314/server,natsys/mariadb_10.2,natsys/mariadb_10.2,natsys/mariadb_10.2,natsys/mariadb_10.2,slanterns/server,ollie314/server,flynn1973/mariadb-aix,natsys/mariadb_10.2,davidl-zend/zenddbi,natsys/mariadb_10.2,davidl-zend/zenddbi,flynn1973/mariadb-aix,davidl-zend/zenddbi,ollie314/server,flynn1973/mariadb-aix,flynn1973/mariadb-aix,flynn1973/mariadb-aix,natsys/mariadb_10.2,natsys/mariadb_10.2,davidl-zend/zenddbi,ollie314/server,natsys/mariadb_10.2,natsys/mariadb_10.2,ollie314/server,flynn1973/mariadb-aix,davidl-zend/zenddbi,flynn1973/mariadb-aix,davidl-zend/zenddbi,flynn1973/mariadb-aix,flynn1973/mariadb-aix,natsys/mariadb_10.2,flynn1973/mariadb-aix,ollie314/server,ollie314/server,flynn1973/mariadb-aix,davidl-zend/zenddbi,davidl-zend/zenddbi,davidl-zend/zenddbi