summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorAlexander Barkov <bar@mariadb.com>2019-08-16 20:58:14 +0400
committerAlexander Barkov <bar@mariadb.com>2019-08-16 20:58:14 +0400
commitf987de7122b8bd72b758cb8e172bec1ff5f7124b (patch)
tree916212ad16a941791c4a8bd4bbe59ada34207ad2 /sql
parentecdacf7264eecb520657ef9ed42021bcc0bcad06 (diff)
parentec1f195ecf797fc5f37b0cfdbe4ee76d71a96729 (diff)
downloadmariadb-git-f987de7122b8bd72b758cb8e172bec1ff5f7124b.tar.gz
Merge remote-tracking branch 'origin/5.5' into 10.1
Diffstat (limited to 'sql')
-rw-r--r--sql/sql_select.cc27
1 files changed, 25 insertions, 2 deletions
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 29fc3f80ed0..5b96c15bff5 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -16158,8 +16158,31 @@ static Field *create_tmp_field_from_item(THD *thd, Item *item, TABLE *table,
{
Field *UNINIT_VAR(new_field);
DBUG_ASSERT(thd == table->in_use);
- new_field= item->Item::create_tmp_field(false, table);
-
+ if (item->type() == Item::FUNC_ITEM &&
+ static_cast<Item_func*>(item)->functype() == Item_func::SUSERVAR_FUNC)
+ {
+ /*
+ A temporary solution for versions 5.5 .. 10.3.
+ This change should be null-merged to 10.4.
+
+ Item_func_set_user_var is special. It overrides make_field().
+ by adding a special branch `if (result_field)...`.
+ So it's important to preserve the exact data type here,
+ to avoid type mismatch in Protocol_text::store_longlong()
+ See MDEV-15955.
+
+ Other Item_func descendants are not affected by MDEV-15955.
+ They don't override make_field() so they don't use result_field
+ when initializing Send_field.
+
+ This is properly fixed in 10.4 in the method
+ Item_func_user_var::create_tmp_field_ex().
+ */
+ new_field= item->tmp_table_field_from_field_type(table, false, true);
+ }
+ else
+ new_field= item->Item::create_tmp_field(false, table);
+
if (copy_func &&
(item->is_result_field() ||
(item->real_item()->is_result_field())))