• Sergey Glukhov's avatar
    Bug#54416 MAX from JOIN with HAVING returning NULL with 5.1 and Empty set · 652456f6
    Sergey Glukhov authored
    The problem there is that HAVING condition evaluates const
    parts of condition despite the condition has references
    on aggregate functions. Table t1 became const tables
    after make_join_statistics and table1.pk = 1, HAVING is
    transformed into MAX(1) < 7 and taken away from HAVING.
    The fix is to skip evaluation of HAVING conts parts if
    HAVING condition has references on aggregate functions.
    
    
    mysql-test/r/having.result:
      test case
    mysql-test/t/having.test:
      test case
    sql/sql_select.cc:
      skip evaluation of HAVING conts parts if
      HAVING condition has references on aggregate functions.
    652456f6
having.test 16.7 KB