1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-29 05:21:33 +03:00

MDEV-12858 + MDEV+12859 + MDEV-12862 - a join patch fixing a few data type problems with CREATE..SELECT

MDEV-12858 Out-of-range error for CREATE..SELECT unsigned_int_column+1
MDEV-12859 Out-of-range error for CREATE..SELECT @a:=EXTRACT(MINUTE_MICROSECOND FROM..)
MDEV-12862 Data type of @a:=1e0 depends on the session character set

1. Moving a part of Item::create_tmp_field() into a new helper method
   Item::create_tmp_field_int() and reusing it in Item::create_tmp_field()
   and Item_func_signed::create_tmp_field().
   Fixing the code in Item::create_tmp_field_int() to call
   Type_handler::make_table_field() instead of doing "new Field_long[long]"
   directly. This change revealed a problem reported in MDEV-12862.

2. Changing the "long vs longlong" cut-off length for
     - Item_func::create_tmp_field()
     - Item_sum::create_tmp_field()
     - Item_func_get_user_var::create_tmp_field()
   from MY_INT32_NUM_DECIMAL_DIGITS to (MY_INT32_NUM_DECIMAL_DIGITS - 2).
   This fixes MDEV-12858.
   After this change, the "convert_int_length" parameter to
   Item::create_tmp_field() is not needed any more, because
   (MY_INT32_NUM_DECIMAL_DIGITS - 2) is always passed.
   So removing the "convert_int_length" parameter.

3. Fixing Item::create_tmp_field() to pass max_char_length() instead
   of max_length to the constructor of Field_double().
   This fixes MDEV-12862.

4. Additionally, fixing
   - Type_handler_{tiny|short|int24|long|longlong}::make_table_field()
   - Type_handler_{float|double}::make_table_field()
   to pass max_char_length() instead of max_length to Field contructors.
   This is needed by the change (1).

5. Adding new tests, and recording new correct results in the old tests in:
   - mysql-test/r/type_ranges.result
   - storage/tokudb/mysql-test/tokudb/r/type_ranges.result
This commit is contained in:
Alexander Barkov
2017-05-22 13:44:26 +04:00
parent feb15f4e45
commit c84bbeda7f
13 changed files with 136 additions and 39 deletions

View File

@ -1946,7 +1946,8 @@ Field *Type_handler_tiny::make_table_field(const LEX_CSTRING *name,
TABLE *table) const
{
return new (table->in_use->mem_root)
Field_tiny(addr.ptr, attr.max_length, addr.null_ptr, addr.null_bit,
Field_tiny(addr.ptr, attr.max_char_length(),
addr.null_ptr, addr.null_bit,
Field::NONE, name, 0/*zerofill*/, attr.unsigned_flag);
}
@ -1958,7 +1959,8 @@ Field *Type_handler_short::make_table_field(const LEX_CSTRING *name,
{
return new (table->in_use->mem_root)
Field_short(addr.ptr, attr.max_length, addr.null_ptr, addr.null_bit,
Field_short(addr.ptr, attr.max_char_length(),
addr.null_ptr, addr.null_bit,
Field::NONE, name, 0/*zerofill*/, attr.unsigned_flag);
}
@ -1969,7 +1971,8 @@ Field *Type_handler_int24::make_table_field(const LEX_CSTRING *name,
TABLE *table) const
{
return new (table->in_use->mem_root)
Field_medium(addr.ptr, attr.max_length, addr.null_ptr, addr.null_bit,
Field_medium(addr.ptr, attr.max_char_length(),
addr.null_ptr, addr.null_bit,
Field::NONE, name,
0/*zerofill*/, attr.unsigned_flag);
}
@ -1981,7 +1984,8 @@ Field *Type_handler_long::make_table_field(const LEX_CSTRING *name,
TABLE *table) const
{
return new (table->in_use->mem_root)
Field_long(addr.ptr, attr.max_length, addr.null_ptr, addr.null_bit,
Field_long(addr.ptr, attr.max_char_length(),
addr.null_ptr, addr.null_bit,
Field::NONE, name, 0/*zerofill*/, attr.unsigned_flag);
}
@ -1992,7 +1996,7 @@ Field *Type_handler_longlong::make_table_field(const LEX_CSTRING *name,
TABLE *table) const
{
return new (table->in_use->mem_root)
Field_longlong(addr.ptr, attr.max_length,
Field_longlong(addr.ptr, attr.max_char_length(),
addr.null_ptr, addr.null_bit,
Field::NONE, name,
0/*zerofill*/, attr.unsigned_flag);
@ -2005,7 +2009,8 @@ Field *Type_handler_float::make_table_field(const LEX_CSTRING *name,
TABLE *table) const
{
return new (table->in_use->mem_root)
Field_float(addr.ptr, attr.max_length, addr.null_ptr, addr.null_bit,
Field_float(addr.ptr, attr.max_char_length(),
addr.null_ptr, addr.null_bit,
Field::NONE, name,
attr.decimals, 0/*zerofill*/, attr.unsigned_flag);
}
@ -2017,7 +2022,7 @@ Field *Type_handler_double::make_table_field(const LEX_CSTRING *name,
TABLE *table) const
{
return new (table->in_use->mem_root)
Field_double(addr.ptr, attr.max_length,
Field_double(addr.ptr, attr.max_char_length(),
addr.null_ptr, addr.null_bit,
Field::NONE, name,
attr.decimals, 0/*zerofill*/, attr.unsigned_flag);