diff options
author | unknown <timour@askmonty.org> | 2012-05-30 19:10:18 +0300 |
---|---|---|
committer | unknown <timour@askmonty.org> | 2012-05-30 19:10:18 +0300 |
commit | 66dfceb11fe2392c98ec0f481a01e8da7b4314b8 (patch) | |
tree | 94cb56bab195e2fa2a1e9786a0134f9b50260726 /sql/item_cmpfunc.cc | |
parent | 662c51bad124b4290bcee52f049729c37e450858 (diff) | |
download | mariadb-git-66dfceb11fe2392c98ec0f481a01e8da7b4314b8.tar.gz |
Fix for bug lp:1006231
Analysis:
When a subquery that needs a temp table is executed during
the prepare or optimize phase of the outer query, at the end
of the subquery execution all the JOIN_TABs of the subquery
are replaced by a new JOIN_TAB that selects from the temp table.
However that temp table has no corresponding TABLE_LIST.
Once EXPLAIN execution reaches its last phase, it tries to print
the names of the subquery tables through its TABLE_LISTs, but in
the case of this bug there is no such TABLE_LIST (it is NULL),
hence a crash.
Solution:
The fix is to block subquery evaluation inside
Item_func_like::fix_fields and Item_func_like::select_optimize()
using the Item::is_expensive() test.
Diffstat (limited to 'sql/item_cmpfunc.cc')
-rw-r--r-- | sql/item_cmpfunc.cc | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index f0ba4917685..0983fb1e81d 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -4656,7 +4656,7 @@ longlong Item_func_like::val_int() Item_func::optimize_type Item_func_like::select_optimize() const { - if (args[1]->const_item()) + if (args[1]->const_item() && !args[1]->is_expensive()) { String* res2= args[1]->val_str((String *)&cmp.value2); const char *ptr2; @@ -4743,7 +4743,8 @@ bool Item_func_like::fix_fields(THD *thd, Item **ref) We could also do boyer-more for non-const items, but as we would have to recompute the tables for each row it's not worth it. */ - if (args[1]->const_item() && !use_strnxfrm(collation.collation)) + if (args[1]->const_item() && !use_strnxfrm(collation.collation) && + !args[1]->is_expensive()) { String* res2 = args[1]->val_str(&cmp.value2); if (!res2) |