Commit eaae1305 authored by Sergei Golubchik's avatar Sergei Golubchik

MDEV-25808 PREPARE/EXECUTE makes signed integer out of unsigned

Closes #1844
parent 9fde2bba
......@@ -50,3 +50,17 @@ t1_first
deallocate prepare stmt1;
deallocate prepare stmt2;
drop table t1;
#
# MDEV-25808 PREPARE/EXECUTE makes signed integer out of unsigned
#
prepare p1 from 'select concat(?)';
execute p1 using 17864960750176564435;
concat(?)
17864960750176564435
prepare p1 from 'select SQRT(?) is not null';
execute p1 using 17864960750176564435;
SQRT(?) is not null
1
#
# End of 10.3 tests
#
......@@ -40,3 +40,15 @@ execute stmt2;
deallocate prepare stmt1;
deallocate prepare stmt2;
drop table t1;
--echo #
--echo # MDEV-25808 PREPARE/EXECUTE makes signed integer out of unsigned
--echo #
prepare p1 from 'select concat(?)';
execute p1 using 17864960750176564435;
prepare p1 from 'select SQRT(?) is not null';
execute p1 using 17864960750176564435;
--echo #
--echo # End of 10.3 tests
--echo #
......@@ -4592,13 +4592,15 @@ bool Item_param::get_date(MYSQL_TIME *res, ulonglong fuzzydate)
}
double Item_param::PValue::val_real() const
double Item_param::PValue::val_real(const Type_std_attributes *attr) const
{
switch (type_handler()->cmp_type()) {
case REAL_RESULT:
return real;
case INT_RESULT:
return (double) integer;
return attr->unsigned_flag
? (double) (ulonglong) integer
: (double) integer;
case DECIMAL_RESULT:
{
double result;
......@@ -4680,7 +4682,7 @@ String *Item_param::PValue::val_str(String *str,
str->set_real(real, NOT_FIXED_DEC, &my_charset_bin);
return str;
case INT_RESULT:
str->set(integer, &my_charset_bin);
str->set_int(integer, attr->unsigned_flag, &my_charset_bin);
return str;
case DECIMAL_RESULT:
if (my_decimal2string(E_DEC_FATAL_ERROR, &m_decimal, 0, 0, 0, str) <= 1)
......
......@@ -3565,7 +3565,7 @@ class Item_param :public Item_basic_value,
m_string.swap(other.m_string);
m_string_ptr.swap(other.m_string_ptr);
}
double val_real() const;
double val_real(const Type_std_attributes *attr) const;
longlong val_int(const Type_std_attributes *attr) const;
my_decimal *val_decimal(my_decimal *dec, const Type_std_attributes *attr);
String *val_str(String *str, const Type_std_attributes *attr);
......@@ -3619,7 +3619,7 @@ class Item_param :public Item_basic_value,
double val_real()
{
return can_return_value() ? value.val_real() : 0e0;
return can_return_value() ? value.val_real(this) : 0e0;
}
longlong val_int()
{
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment