From a587ded283d8abd1f20258b283911abe759f5f64 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Mon, 14 Dec 2020 18:25:08 +0100 Subject: MDEV-24346 valgrind error in main.precedence in queries like create view v1 as select 2 like 1 escape (3 in (select 0 union select 1)); select 2 union select * from v1; Item_func_like::escape was left uninitialized, because Item_in_optimizer is const_during_execution() but not actually const_item() during execution. It's not, because const subquery evaluation was disabled for derived. Practically it only needs to be disabled for multi-update that runs fix_fields() before all tables are locked. --- sql/item_cmpfunc.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'sql/item_cmpfunc.cc') diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index d0941ef58c2..e0dad886a06 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -5261,6 +5261,7 @@ void Item_func_like::print(String *str, enum_query_type query_type) longlong Item_func_like::val_int() { DBUG_ASSERT(fixed == 1); + DBUG_ASSERT(escape != -1); String* res= args[0]->val_str(&cmp_value1); if (args[0]->null_value) { @@ -5352,10 +5353,13 @@ bool fix_escape_item(THD *thd, Item *escape_item, String *tmp_str, my_error(ER_WRONG_ARGUMENTS,MYF(0),"ESCAPE"); return TRUE; } - + + IF_DBUG(*escape= -1,); + if (escape_item->const_item()) { /* If we are on execution stage */ + /* XXX is it safe to evaluate is_expensive() items here? */ String *escape_str= escape_item->val_str(tmp_str); if (escape_str) { -- cgit v1.2.1