Commit d2fec340 authored by Alexander Barkov's avatar Alexander Barkov

An after-fix for MDEV-12849 Out-of-range errors when casting hex-hybrid to SIGNED and UNSIGNED

1. Adding the forgotten "SET sql_mode=STRICT_ALL_TABLES" into the test.
2. STRICT_ALL_TABLES revealed that CAST(0xFFFFFFFF AS SIGNED),
   e.g. with a hex number with 8 hex digits, did not work well.
   Fixing Item_func_unsigned::create_tmp_field() and
   Item_func_unsigned::create_field_for_create_select() to handle
   this corner case.
parent ac4ce47b
......@@ -520,6 +520,7 @@ DROP TABLE t1;
--echo # MDEV-12849 Out-of-range errors when casting hex-hybrid to SIGNED and UNSIGNED
--echo #
SET sql_mode=STRICT_ALL_TABLES;
DELIMITER $$;
CREATE PROCEDURE p1(hh TEXT)
BEGIN
......@@ -559,3 +560,4 @@ CALL p1('80FFFFFFFFFFFFFF');
CALL p1('8FFFFFFFFFFFFFFF');
DROP PROCEDURE p1;
SET sql_mode=DEFAULT;
......@@ -834,6 +834,14 @@ class Item_func_signed :public Item_int_func
unsigned_flag= 0;
}
const char *func_name() const { return "cast_as_signed"; }
Field *create_tmp_field(bool group, TABLE *table)
{
return Item::create_tmp_field(false, table,
MY_INT32_NUM_DECIMAL_DIGITS - 2 +
unsigned_flag);
}
Field *create_field_for_create_select(TABLE *table)
{ return Item_func_signed::create_tmp_field(false, table); }
longlong val_int()
{
longlong value= args[0]->val_int_signed_typecast();
......
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