From 02c040dd5c26cbc97ae30776638463c36d96a938 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 30 Jul 2010 07:16:58 +0300 Subject: Fix for luanchpad bug#609043 Removed indirect reference in equalities for cache index lookup. We should use a direct reference because some optimization of the query may optimize out a condition predicate and if the outer reference is the only element of the condition predicate the indirect reference becomes NULL. We can resolve correctly the indirect reference in Expression_cache_tmptable::make_equalities because it is called before optimization of the cached subquery. mysql-test/r/subquery_cache.result: The test suite for the bug added. mysql-test/t/subquery_cache.test: The test suite for the bug added. sql/sql_expression_cache.cc: Removed indirect reference in equalities for cache index lookup. --- sql/sql_expression_cache.cc | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) (limited to 'sql/sql_expression_cache.cc') diff --git a/sql/sql_expression_cache.cc b/sql/sql_expression_cache.cc index 70c36b141b6..924abb24480 100644 --- a/sql/sql_expression_cache.cc +++ b/sql/sql_expression_cache.cc @@ -41,7 +41,6 @@ bool Expression_cache_tmptable::make_equalities() List args; List_iterator_fast li(*list); Item **ref; - Name_resolution_context *cn= NULL; DBUG_ENTER("Expression_cache_tmptable::make_equalities"); for (uint i= 1 /* skip result filed */; (ref= li++); i++) @@ -58,14 +57,7 @@ bool Expression_cache_tmptable::make_equalities() fld->type() == MYSQL_TYPE_NEWDECIMAL || fld->type() == MYSQL_TYPE_DECIMAL) { - if (!cn) - { - // dummy resolution context - cn= new Name_resolution_context(); - cn->init(); - } - args.push_front(new Item_func_eq(new Item_ref(cn, ref, "", "", FALSE), - new Item_field(fld))); + args.push_front(new Item_func_eq(*ref, new Item_field(fld))); } } if (args.elements == 1) -- cgit v1.2.1