• Anurag Shekhar's avatar
    Bug #47904 Incorrect results w/ table subquery, derived SQs, and LEFT JOIN · 0615cb86
    Anurag Shekhar authored
           on index
    
    'my_decimal' class has two members which can be used to access the 
    value. The member variable buf (inherited from parent class decimal_t) 
    is set to member variable buffer so that both are pointing to same value.
    
    Item_copy_decimal::copy() uses memcpy to clone 'my_decimal'. The member
    buffer is declared as an array and memcpy results in copying the values
    of the array, but the inherited member buf, which should be pointing at
    the begining of the array 'buffer' starts pointing to the begining of 
    buffer in original object (which is being cloned). Further updates on 
    'my_decimal' updates only the inherited member 'buf' but leaves 
    buffer unchanged.
    
    Later when the new object (which now holds a inconsistent value) is cloned
    again using proper cloning function 'my_decimal2decimal' the buf pointer
    is fixed resulting in loss of the current value.
    
    Using my_decimal2decimal instead of memcpy in Item_copy_decimal::copy()
    fixed this problem.
    
    
    mysql-test/r/subselect.result:
      Updated result file after addding test case for bug#47904.
    mysql-test/t/subselect.test:
      Added test case for bug#47904.
    sql/item.cc:
      Memcopy shouldn't be used to clone my_decimal. Use my_decimal2decimal
      instead.
    0615cb86
subselect.result 163 KB