diff --git a/mysql-test/r/func_like.result b/mysql-test/r/func_like.result index 39590eb1c99..8d72b818cf8 100644 --- a/mysql-test/r/func_like.result +++ b/mysql-test/r/func_like.result @@ -188,3 +188,15 @@ DROP TABLE t1, t2; SELECT '' LIKE '1' ESCAPE COUNT(1); ERROR HY000: Incorrect arguments to ESCAPE End of 5.1 tests +# +# Start of 10.0 tests +# +# +# MDEV-5445 Server crashes in Item_func_like::fix_fields on LIKE ExtractValue(..) +# +SELECT 'a' LIKE REPEAT('',0); +'a' LIKE REPEAT('',0) +0 +SELECT 'a' LIKE EXTRACTVALUE('bar','qux'); +'a' LIKE EXTRACTVALUE('bar','qux') +0 diff --git a/mysql-test/t/func_like.test b/mysql-test/t/func_like.test index f1fe52274b2..bc64504c742 100644 --- a/mysql-test/t/func_like.test +++ b/mysql-test/t/func_like.test @@ -133,3 +133,13 @@ DROP TABLE t1, t2; SELECT '' LIKE '1' ESCAPE COUNT(1); --echo End of 5.1 tests + +--echo # +--echo # Start of 10.0 tests +--echo # + +--echo # +--echo # MDEV-5445 Server crashes in Item_func_like::fix_fields on LIKE ExtractValue(..) +--echo # +SELECT 'a' LIKE REPEAT('',0); +SELECT 'a' LIKE EXTRACTVALUE('bar','qux'); diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index b503b32e83c..75bb1608a0e 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -5020,7 +5020,7 @@ bool Item_func_like::fix_fields(THD *thd, Item **ref) turboBM_compute_bad_character_shifts(); DBUG_PRINT("info",("done")); } - use_sampling= ((*first == wild_many || *first == wild_one) && len > 2); + use_sampling= (len > 2 && (*first == wild_many || *first == wild_one)); } } return FALSE;