Commit 4630732f authored by Sergey Petrunya's avatar Sergey Petrunya

MDEV-6799: Crash in field_conv, memcpy_field_possible

- Fix the crash, dont call from->type() at the start of the function
  because it might be unsafe.
- Unfortunately there is no testcase
- And this is also the reason we can't fix it properly (it should be
  safe to call from->type() here).
parent 1f437f3e
......@@ -837,7 +837,10 @@ bool memcpy_field_possible(Field *to,Field *from)
{
const enum_field_types to_real_type= to->real_type();
const enum_field_types from_real_type= from->real_type();
const enum_field_types to_type= from->type();
/*
Warning: Calling from->type() may be unsafe in some (unclear) circumstances
related to SPs. See MDEV-6799.
*/
return (to_real_type == from_real_type &&
!(to->flags & BLOB_FLAG && to->table->copy_blobs) &&
to->pack_length() == from->pack_length() &&
......@@ -850,8 +853,8 @@ bool memcpy_field_possible(Field *to,Field *from)
to->field_length == from->field_length) &&
from->charset() == to->charset() &&
(!sql_mode_for_dates(to->table->in_use) ||
(to_type != MYSQL_TYPE_DATE &&
to_type != MYSQL_TYPE_DATETIME)) &&
(from->type()!= MYSQL_TYPE_DATE &&
from->type()!= MYSQL_TYPE_DATETIME)) &&
(from_real_type != MYSQL_TYPE_VARCHAR ||
((Field_varstring*)from)->length_bytes ==
((Field_varstring*)to)->length_bytes));
......
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