Konstantin Osipov wrote:
> * Davi Arnaut <davi@stripped> [08/02/08 14:00]:
>
>> ChangeSet@stripped, 2008-02-08 08:55:55-02:00, davi@stripped +5 -0
>> Bug#33798 prepared statements improperly handle large unsigned ints
>>
>> The unsignedness of large integer user variables was not being
>> properly preserved when feeded to prepared statements. This was
>> happening because the unsigned flags wasn't being updated when
>> converting the user variable is converted to a parameter.
>>
>> The solution is to copy the unsigned flag when converting the
>> user variable to a parameter and take the unsigned flag into
>> account when converting the integer to a string.
>
> The patch is OK to push, see one item below.
>
>> --- a/sql/item.cc 2008-01-11 15:57:33 -02:00
>> +++ b/sql/item.cc 2008-02-08 08:55:54 -02:00
>> @@ -2580,6 +2580,7 @@ bool Item_param::set_from_user_var(THD *
>> if (entry && entry->value)
>> {
>> item_result_type= entry->type;
>> + unsigned_flag= entry->unsigned_flag;
>
> That assignment should be enough -- set() does not truncate
> anything anyway.
>> if (strict_type && required_result_type != item_result_type)
>> DBUG_RETURN(1);
>> switch (item_result_type) {
>> @@ -2875,7 +2876,10 @@ const String *Item_param::query_val_str(
>> {
>> switch (state) {
>> case INT_VALUE:
>> - str->set(value.integer, &my_charset_bin);
>> + if (unsigned_flag)
>> + str->set((ulonglong) value.integer, &my_charset_bin);
>> + else
>> + str->set(value.integer, &my_charset_bin);
>
> In other words, this change does not seem to be necessary.
>
Yes, it's necessary, otherwise we end-up with a wrong binlog. The
integer to string conversion is different for unsigned and signed, take
a look at String::set.
Regards,
--
Davi Arnaut, Software Engineer
MySQL Inc, www.mysql.com
Are you MySQL certified? www.mysql.com/certification