diff options
author | unknown <sanja@askmonty.org> | 2014-06-04 13:03:55 +0300 |
---|---|---|
committer | unknown <sanja@askmonty.org> | 2014-06-04 13:03:55 +0300 |
commit | 113333d44725fe35a5eb52c7df58140e1cce45f8 (patch) | |
tree | 39712e607c3b3cd247950886e6e74c3df565053e /sql/item_cmpfunc.cc | |
parent | 67bf16a48b7e12090e0c02aeafdac0e08c95ea78 (diff) | |
download | mariadb-git-113333d44725fe35a5eb52c7df58140e1cce45f8.tar.gz |
MDEV-6046: MySQL Bug#11766684 59851: UNINITIALISED VALUE IN ITEM_FUNC_LIKE::SELECT_OPTIMIZE WITH SUBQUERY AND
Diffstat (limited to 'sql/item_cmpfunc.cc')
-rw-r--r-- | sql/item_cmpfunc.cc | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index f142c51db4d..2c4218279d7 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -4896,21 +4896,20 @@ longlong Item_func_like::val_int() Item_func::optimize_type Item_func_like::select_optimize() const { - if (args[1]->const_item() && !args[1]->is_expensive()) - { - String* res2= args[1]->val_str((String *)&cmp.value2); - const char *ptr2; + if (!args[1]->const_item() || args[1]->is_expensive()) + return OPTIMIZE_NONE; - if (!res2 || !(ptr2= res2->ptr())) - return OPTIMIZE_NONE; + String* res2= args[1]->val_str((String *)&cmp.value2); + if (!res2) + return OPTIMIZE_NONE; - if (*ptr2 != wild_many) - { - if (args[0]->result_type() != STRING_RESULT || *ptr2 != wild_one) - return OPTIMIZE_OP; - } - } - return OPTIMIZE_NONE; + if (!res2->length()) // Can optimize empty wildcard: column LIKE '' + return OPTIMIZE_OP; + + DBUG_ASSERT(res2->ptr()); + char first= res2->ptr()[0]; + return (first == wild_many || first == wild_one) ? + OPTIMIZE_NONE : OPTIMIZE_OP; } |