List:Commits« Previous MessageNext Message »
From:Sergei Golubchik Date:December 20 2007 7:39pm
Subject:Re: bk commit into 5.0 tree (mhansson:1.2546) BUG#33143
View as plain text  
Hi!

On Dec 19, mhansson@stripped wrote:
> ChangeSet@stripped, 2007-12-19 12:23:33+01:00, mhansson@stripped +5 -0
>   Bug#33143: Incorrect ORDER BY for ROUND()/TRUNCATE() result
>   
>   The ROUND(X, D) function changes the scale of a result field X to D
>   digits.
>   When D is not constant, the binary encoding of a DECIMAL value, used
>   in filesort cannot guarantee proper ordering.
>   Fixed by using the scale of X (as opposed to that of any expression
>   containong ROUND) in the temporary table, and changing number of
>   digits only when retreiving sorted values from the temporary table.

I don't think it's conceptually correct.
That is, you found the problem corectly, but I believe an Item is not
allowed to change the metadata after fix_fields. Item_func_round is just
wrong, breaking the api. Adding a workaround to the hierarchy root Item
is not a proper fix then, the fix should be to fix Item_func_round.

Item_func_round only messes with metadata to have ::val_str() to
generate the correct number of digits. There could be other ways to
achieve the same. E.g.:

  Item_func_round::val_str(String *s)
  {
    uint8 old_dec=decimals;
    String *res=Item_func_num1::val_str(s);
    decimals=old_dec;
    return res;
  }

or introducing runtime_decimals, or whatever. Keeping implementation
problems of the Item_func_round in the Item_func_round.

Regards / Mit vielen Grüssen,
Sergei

-- 
   __  ___     ___ ____  __
  /  |/  /_ __/ __/ __ \/ /   Sergei Golubchik <serg@stripped>
 / /|_/ / // /\ \/ /_/ / /__  Principal Software Developer
/_/  /_/\_, /___/\___\_\___/  MySQL GmbH, Dachauer Str. 37, D-80335 München
       <___/                  Geschäftsführer: Kaj Arnö - HRB
München 162140
Thread
bk commit into 5.0 tree (mhansson:1.2546) BUG#33143mhansson19 Dec
  • Re: bk commit into 5.0 tree (mhansson:1.2546) BUG#33143Sergei Golubchik20 Dec