diff options
author | Sergey Petrunya <psergey@askmonty.org> | 2011-08-27 09:47:21 +0400 |
---|---|---|
committer | Sergey Petrunya <psergey@askmonty.org> | 2011-08-27 09:47:21 +0400 |
commit | d9045bce1ddf1f017f0e127606c809271c953ef0 (patch) | |
tree | 72fb6e272c5301e6d7f5f3bbafd934db5fad1560 /sql/sql_lex.cc | |
parent | f4dd6831f5863ea5f239ca24c5b3c03bd2575c4a (diff) | |
download | mariadb-git-d9045bce1ddf1f017f0e127606c809271c953ef0.tar.gz |
-Make show_explain.test stable
- Fix st_select_lex::set_explain_type() to allow producing exactly the
same EXPLAINs as it did before. SHOW EXPLAIN output may produce
select_type=SIMPLE instead or select_type=PRIMARY or vice versa (which
is ok because values of select_type weren't self-consistent in this
regard to begin with)
Diffstat (limited to 'sql/sql_lex.cc')
-rw-r--r-- | sql/sql_lex.cc | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index 82b171789bc..a9f07c337fa 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -1640,7 +1640,8 @@ void st_select_lex::init_query() link_next= 0; lock_option= TL_READ_DEFAULT; is_prep_leaf_list_saved= FALSE; - + + have_merged_subqueries= FALSE; bzero((char*) expr_cache_may_be_used, sizeof(expr_cache_may_be_used)); } @@ -3119,7 +3120,7 @@ bool st_select_lex::optimize_unflattened_subqueries() if (options & SELECT_DESCRIBE) { /* Optimize the subquery in the context of EXPLAIN. */ - sl->set_explain_type(); + sl->set_explain_type(FALSE); sl->options|= SELECT_DESCRIBE; inner_join->select_options|= SELECT_DESCRIBE; } @@ -3482,7 +3483,7 @@ void SELECT_LEX::update_used_tables() Set the EXPLAIN type for this subquery. */ -void st_select_lex::set_explain_type() +void st_select_lex::set_explain_type(bool on_the_fly) { bool is_primary= FALSE; if (next_select()) @@ -3504,6 +3505,9 @@ void st_select_lex::set_explain_type() } } + if (on_the_fly && !is_primary && have_merged_subqueries) + is_primary= TRUE; + SELECT_LEX *first= master_unit()->first_select(); /* drop UNCACHEABLE_EXPLAIN, because it is for internal usage only */ uint8 is_uncacheable= (uncacheable & ~UNCACHEABLE_EXPLAIN); @@ -3521,6 +3525,10 @@ void st_select_lex::set_explain_type() "DEPENDENT UNION": is_uncacheable ? "UNCACHEABLE UNION": (this == master_unit()->fake_select_lex)? "UNION RESULT" : "UNION"))); + + if (this == master_unit()->fake_select_lex) + type= "UNION RESULT"; + options|= SELECT_DESCRIBE; } |