• unknown's avatar
    Fixed bug#13575: SP funcs in select with distinct/group and order by can · 50c8c206
    unknown authored
    produce wrong data
    
    By default Item_sp_func::val_str() returns string from it's result_field 
    internal buffer. When grouping is present Item_copy_string is used to 
    store SP function result, but it doesn't additionally buffer the result.
    When the next record is read, internal buffer is overwritten, due to
    this Item_copy_string::val_str() will have wrong data. Thus producing
    weird query result.
    
    The Item_func_sp::val_str() now makes a copy of returned value to prevent
    occasional corruption.
    
    
    mysql-test/t/sp.test:
      Added test case for bug#13575: SP funcs in select with distinct/group and order by can
      produce wrong data
    mysql-test/r/sp.result:
      Added test case for bug#13575: SP funcs in select with distinct/group and
          order by can produce wrong data
    sql/item_func.h:
      Fixed bug#13575: SP funcs in select with distinct/group and order by can
          produce wrong data
          The Item_func_sp::val_str() now makes a copy of returned value to prevent
          occasinal corruption.
    50c8c206
sp.result 106 KB