diff options
Diffstat (limited to 'sql/item_cmpfunc.cc')
-rw-r--r-- | sql/item_cmpfunc.cc | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index 3a76982d80e..19bd6176bd1 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -513,19 +513,31 @@ bool Item_func::setup_args_and_comparator(THD *thd, Arg_comparator *cmp) { DBUG_ASSERT(arg_count >= 2); // Item_func_nullif has arg_count == 3 + Query_arena *arena, backup; + arena= thd->activate_stmt_arena_if_needed(&backup); + if (args[0]->cmp_type() == STRING_RESULT && args[1]->cmp_type() == STRING_RESULT) { DTCollation tmp; if (agg_arg_charsets_for_comparison(tmp, args, 2)) + { + if (arena) + thd->restore_active_arena(arena, &backup); + return true; + } cmp->m_compare_collation= tmp.collation; } // Convert constants when compared to int/year field DBUG_ASSERT(functype() != LIKE_FUNC); convert_const_compared_to_int_field(thd); - return cmp->set_cmp_func(this, &args[0], &args[1], true); + bool ret= cmp->set_cmp_func(this, &args[0], &args[1], true); + if (arena) + thd->restore_active_arena(arena, &backup); + + return ret; } |