• unknown's avatar
    Fixed LP bug #609121 · f41f9e36
    unknown authored
    The bug was a result of missing logic to handle the case
    when there are 'expensive' predicates that are not evaluated
    during constant table optimization. Such is the case for
    the IN predicate, which is considered expensive if it is
    computed via materialization. In general this bug can be
    triggered with any expensive predicate instead of IN.
    
    When FALSE constant predicates are not evaluated during constant
    optimization, the execution path changes so that instead of
    setting JOIN::zero_result_cause after make_join_select, and
    exiting JOIN::exec via the call to return_zero_rows(), execution
    ends in JOIN::exec in the branch:
    if (join->tables == join->const_tables)
    {
      ...
      else if (join->send_row_on_empty_set())
         ...
         rc= join->result->send_data(*columns_list);
    }
    Unlike return_zero_rows(), this branch didn't evaluate the
    having clause of the query.
    
    The patch adds a call to evaluate the HAVING clause of a query even
    when all tables are constant, because even for an empty result set
    some aggregate functions may produce a NULL value.
    f41f9e36
sql_select.h 68 KB