diff options
author | Sergey Petrunya <psergey@askmonty.org> | 2010-01-28 16:48:33 +0300 |
---|---|---|
committer | Sergey Petrunya <psergey@askmonty.org> | 2010-01-28 16:48:33 +0300 |
commit | f47b2d38f6c4851ef6bd069f5d1ffe033056d582 (patch) | |
tree | 84f3ebd6121f993eb30656da64790920566c5c46 /sql/sql_lex.cc | |
parent | 742afd8eaeccb3531fa350b31445e8397dab7848 (diff) | |
download | mariadb-git-f47b2d38f6c4851ef6bd069f5d1ffe033056d582.tar.gz |
Subquery optimizations: non-semijoin materialization
- Backport into Maria DB 5.3, part 1
Diffstat (limited to 'sql/sql_lex.cc')
-rw-r--r-- | sql/sql_lex.cc | 29 |
1 files changed, 21 insertions, 8 deletions
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. |