diff options
author | Sergei Golubchik <sergii@pisem.net> | 2013-12-16 13:02:21 +0100 |
---|---|---|
committer | Sergei Golubchik <sergii@pisem.net> | 2013-12-16 13:02:21 +0100 |
commit | d28d3ba40dc8ebef87199a2567ec96e9c5d744e2 (patch) | |
tree | c6b9ab1d8193fa2a26c5e376d43e536abd3a47ce /sql/sql_union.cc | |
parent | ff485d2dc4d5adaf5eef0ccd03ce62adf3bd30b3 (diff) | |
parent | 6bf10fac445d73fb796d4863612c87bff5f28b66 (diff) | |
download | mariadb-git-d28d3ba40dc8ebef87199a2567ec96e9c5d744e2.tar.gz |
10.0-base merge
Diffstat (limited to 'sql/sql_union.cc')
-rw-r--r-- | sql/sql_union.cc | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/sql/sql_union.cc b/sql/sql_union.cc index b046b3a4de8..d143930908d 100644 --- a/sql/sql_union.cc +++ b/sql/sql_union.cc @@ -193,13 +193,15 @@ void select_union::cleanup() SYNOPSIS st_select_lex_unit::init_prepare_fake_select_lex() thd - thread handler + first_execution - TRUE at the first execution of the union RETURN options of SELECT */ void -st_select_lex_unit::init_prepare_fake_select_lex(THD *thd_arg) +st_select_lex_unit::init_prepare_fake_select_lex(THD *thd_arg, + bool first_execution) { thd_arg->lex->current_select= fake_select_lex; fake_select_lex->table_list.link_in_list(&result_table_list, @@ -207,7 +209,13 @@ st_select_lex_unit::init_prepare_fake_select_lex(THD *thd_arg) fake_select_lex->context.table_list= fake_select_lex->context.first_name_resolution_table= fake_select_lex->get_table_list(); - if (!fake_select_lex->first_execution) + /* + The flag fake_select_lex->first_execution indicates whether this is + called at the first execution of the statement, while first_execution + shows whether this is called at the first execution of the union that + may form just a subselect. + */ + if (!fake_select_lex->first_execution && first_execution) { for (ORDER *order= global_parameters->order_list.first; order; @@ -481,7 +489,7 @@ bool st_select_lex_unit::prepare(THD *thd_arg, select_result *sel_result, { /* Validate the global parameters of this union */ - init_prepare_fake_select_lex(thd); + init_prepare_fake_select_lex(thd, TRUE); /* Should be done only once (the only item_list per statement) */ DBUG_ASSERT(fake_select_lex->join == 0); if (!(fake_select_lex->join= new JOIN(thd, item_list, thd->variables.option_bits, @@ -622,6 +630,7 @@ bool st_select_lex_unit::exec() SELECT_LEX *select_cursor=first_select(); ulonglong add_rows=0; ha_rows examined_rows= 0; + bool first_execution= !executed; DBUG_ENTER("st_select_lex_unit::exec"); bool was_executed= executed; @@ -644,6 +653,7 @@ bool st_select_lex_unit::exec() { ha_rows records_at_start= 0; thd->lex->current_select= sl; + fake_select_lex->uncacheable|= sl->uncacheable; { set_limit(sl); @@ -750,7 +760,7 @@ bool st_select_lex_unit::exec() if (!thd->is_fatal_error) // Check if EOM { set_limit(global_parameters); - init_prepare_fake_select_lex(thd); + init_prepare_fake_select_lex(thd, first_execution); JOIN *join= fake_select_lex->join; if (!join) { |