• unknown's avatar
    Bug #15881: cast problems · 78b88379
    unknown authored
      The optimizer removes expressions from GROUP BY/DISTINCT
      if they happen to participate in a <expression> = <const>
      predicates of the WHERE clause (the idea being that if
      it's always equal to a constant it can't have multiple 
      values).
      However for predicates where the expression and the 
      constant item are of different result type this is not
      valid (e.g. a string column compared to 0).
      Fixed by additional check of the result types of the 
      expression and the constant and if they differ the 
      expression don't get removed from the group by list.
    
    
    mysql-test/r/distinct.result:
      Bug #15881: cast problems
        - test case
    mysql-test/t/distinct.test:
      Bug #15881: cast problems
        - test case
    sql/sql_select.cc:
      Bug #15881: cast problems
        - can't use <expr>=<const> to remove GROUP BY/DISTINCT cols
          if they're not of the same type.
    78b88379
sql_select.cc 473 KB