diff options
author | unknown <bell@sanja.is.com.ua> | 2003-10-31 23:03:27 +0200 |
---|---|---|
committer | unknown <bell@sanja.is.com.ua> | 2003-10-31 23:03:27 +0200 |
commit | c9fa9615a3a3fe88430f5f867655ff84f7dbb7dc (patch) | |
tree | 319cf19f806cf44cdeb5110b29907a78ab1d83c3 /sql | |
parent | ab9fb4ea752731bb04cfbd844902ae34c63123ab (diff) | |
parent | 8b09f4b074f1b31453fd142b7f3417b33fc0b6f2 (diff) | |
download | mariadb-git-c9fa9615a3a3fe88430f5f867655ff84f7dbb7dc.tar.gz |
merge
sql/sql_select.cc:
Auto merged
sql/sql_select.h:
Auto merged
Diffstat (limited to 'sql')
-rw-r--r-- | sql/sql_select.cc | 30 | ||||
-rw-r--r-- | sql/sql_select.h | 6 |
2 files changed, 31 insertions, 5 deletions
diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 222f5707c69..65515ce7ad9 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -983,8 +983,7 @@ JOIN::optimize() } } - if (select_lex != &thd->lex.select_lex && - select_lex->linkage != DERIVED_TABLE_TYPE) + if (select_lex->master_unit()->dependent) { if (!(tmp_join= (JOIN*)thd->alloc(sizeof(JOIN)))) DBUG_RETURN(-1); @@ -997,10 +996,10 @@ JOIN::optimize() DBUG_RETURN(0); } + /* Restore values in temporary join */ - void JOIN::restore_tmp() { memcpy(tmp_join, this, (size_t) sizeof(JOIN)); @@ -1042,12 +1041,29 @@ JOIN::reinit() if (items0) set_items_ref_array(items0); + if (join_tab_save) + memcpy(join_tab, join_tab_save, sizeof(JOIN_TAB) * tables); + if (tmp_join) restore_tmp(); DBUG_RETURN(0); } + +bool +JOIN::save_join_tab() +{ + if (!join_tab_save && select_lex->master_unit()->dependent) + { + if (!(join_tab_save= (JOIN_TAB*) thd->alloc(sizeof(JOIN_TAB) * tables))) + return 1; + memcpy(join_tab_save, join_tab, sizeof(JOIN_TAB) * tables); + } + return 0; +} + + /* Exec select */ @@ -1249,6 +1265,10 @@ JOIN::exec() if (curr_join->group_list) { thd->proc_info= "Creating sort index"; + if (curr_join->join_tab == join_tab && save_join_tab()) + { + DBUG_VOID_RETURN; + } if (create_sort_index(thd, curr_join, curr_join->group_list, HA_POS_ERROR, HA_POS_ERROR) || make_group_fields(this, curr_join)) @@ -1430,6 +1450,10 @@ JOIN::exec() } } } + if (curr_join->join_tab == join_tab && save_join_tab()) + { + DBUG_VOID_RETURN; + } if (create_sort_index(thd, curr_join, curr_join->group_list ? curr_join->group_list : curr_join->order, diff --git a/sql/sql_select.h b/sql/sql_select.h index 7306f609f66..14450347244 100644 --- a/sql/sql_select.h +++ b/sql/sql_select.h @@ -131,6 +131,7 @@ class JOIN :public Sql_alloc { public: JOIN_TAB *join_tab,**best_ref,**map2table; + JOIN_TAB *join_tab_save; //saved join_tab for subquery reexecution TABLE **table,**all_tables,*sort_by_table; uint tables,const_tables; uint send_group_parts; @@ -202,7 +203,7 @@ class JOIN :public Sql_alloc void init(THD *thd_arg, List<Item> &fields, ulong select_options_arg, select_result *result_arg) { - join_tab= 0; + join_tab= join_tab_save= 0; table= 0; tables= 0; const_tables= 0; @@ -242,7 +243,7 @@ class JOIN :public Sql_alloc zero_result_cause= 0; optimized= 0; - fields_list = fields; + fields_list= fields; bzero((char*) &keyuse,sizeof(keyuse)); tmp_table_param.copy_field=0; tmp_table_param.end_write_records= HA_POS_ERROR; @@ -280,6 +281,7 @@ class JOIN :public Sql_alloc int rollup_send_data(uint idx); bool test_in_subselect(Item **where); void clear(); + bool save_join_tab(); }; |