• Gleb Shchepa's avatar
    Bug #40625: Concat fails on DOUBLE values in a Stored · e2a546ae
    Gleb Shchepa authored
                Procedure, while DECIMAL works
    
    Selecting of the CONCAT(...<SP variable>...) result into
    a user variable may return wrong data.
    
    
    Item_func_concat::val_str contains a number of memory
    allocation-saving tricks. One of them concatenates
    strings inplace inserting the value of one string
    at the beginning of the other string. However,
    this trick didn't care about strings those points
    to the same data buffer: this is possible when
    a CONCAT() parameter is a stored procedure variable -
    Item_sp_variable::val_str() uses the intermediate
    Item_sp_variable::str_value field, where it may
    store a reference to an external buffer.
    
    
    The Item_func_concat::val_str function has been
    modified to take into account val_str functions
    (such as Item_sp_variable::val_str) that return
    a pointer to an internal Item member variable
    that may reference to a buffer provided.
    
    
    mysql-test/r/func_concat.result:
      Test case for the bug #40625.
    mysql-test/t/func_concat.test:
      Test case for the bug #40625.
    sql/item_strfunc.cc:
      Bug #40625: Concat fails on DOUBLE values in a Stored
                  Procedure, while DECIMAL works
      
      The Item_func_concat::val_str function has been
      modified to take into account val_str functions
      (such as Item_sp_variable::val_str) that return
      a pointer to an internal Item member variable
      that may reference to a buffer provided.
    e2a546ae
item_strfunc.cc 90.8 KB