summaryrefslogtreecommitdiff
path: root/sql/item_cmpfunc.cc
diff options
context:
space:
mode:
authorunknown <timour@askmonty.org>2012-05-24 14:08:28 +0300
committerunknown <timour@askmonty.org>2012-05-24 14:08:28 +0300
commit4fa89b5fe05280fefa2b30df927d0db6c6888f98 (patch)
tree9a416766024c28cf9879e907f465ab6035f98b77 /sql/item_cmpfunc.cc
parente5bca74bfb47a1c45c995573fd58b1a751ccd884 (diff)
downloadmariadb-git-4fa89b5fe05280fefa2b30df927d0db6c6888f98.tar.gz
Test case for bug lp:1001117, MySQL BUG#12330344
Analysis: The problem in the original MySQL bug is that the range optimizer performs its analysis in a separate MEM_ROOT object that is freed after the range optimzier is done. During range analysis get_mm_tree calls Item_func_like::select_optimize, which in turn evaluates its right argument. In the test case the right argument is a subquery. In MySQL, subqueries are optimized lazyly, thus the call to val_str triggers optimization for the subquery. All objects needed by the subquery plan end up in the temporary MEM_ROOT used by the range optimizer. When execution ends, the JOIN::cleanup process tries to cleanup objects of the subquery plan, but all these objects are gone with the temporary MEM_ROOT. The solution for MySQL is to switch the mem_root. In MariaDB with the patch for bug lp:944706, all constant subqueries that may be used by the optimization process are preoptimized. Therefore Item_func_like::select_optimize only triggers subquery execution, and the above problem is not present. The patch however adds a test whether the evaluated right argument of the LIKE predicate is expensive. This is consistent with our approach not to evaluate expensive expressions during optimization.
Diffstat (limited to 'sql/item_cmpfunc.cc')
-rw-r--r--sql/item_cmpfunc.cc2
1 files changed, 1 insertions, 1 deletions
diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc
index b45b138ced2..560373b69e6 100644
--- a/sql/item_cmpfunc.cc
+++ b/sql/item_cmpfunc.cc
@@ -4736,7 +4736,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;