From f47b2d38f6c4851ef6bd069f5d1ffe033056d582 Mon Sep 17 00:00:00 2001 From: Sergey Petrunya Date: Thu, 28 Jan 2010 16:48:33 +0300 Subject: Subquery optimizations: non-semijoin materialization - Backport into Maria DB 5.3, part 1 --- sql/sql_lex.cc | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) (limited to 'sql/sql_lex.cc') diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index b161da86dbd..2ee73ff962c 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -2076,16 +2076,28 @@ void st_select_lex::print_limit(THD *thd, { SELECT_LEX_UNIT *unit= master_unit(); Item_subselect *item= unit->item; - if (item && unit->global_parameters == this && - (item->substype() == Item_subselect::EXISTS_SUBS || - item->substype() == Item_subselect::IN_SUBS || - item->substype() == Item_subselect::ALL_SUBS)) + + if (item && unit->global_parameters == this) { - DBUG_ASSERT(!item->fixed || - (select_limit->val_int() == LL(1) && offset_limit == 0)); - return; + Item_subselect::subs_type subs_type= item->substype(); + if (subs_type == Item_subselect::EXISTS_SUBS || + subs_type == Item_subselect::IN_SUBS || + subs_type == Item_subselect::ALL_SUBS) + { + DBUG_ASSERT(!item->fixed || + /* + If not using materialization both: + select_limit == 1, and there should be no offset_limit. + */ + (((subs_type == Item_subselect::IN_SUBS) && + ((Item_in_subselect*)item)->exec_method == + Item_in_subselect::MATERIALIZATION) ? + TRUE : + (select_limit->val_int() == 1LL) && + offset_limit == 0)); + return; + } } - if (explicit_limit) { str->append(STRING_WITH_LEN(" limit ")); @@ -2098,6 +2110,7 @@ void st_select_lex::print_limit(THD *thd, } } + /** @brief Restore the LEX and THD in case of a parse error. -- cgit v1.2.1