From 2775f80f7d287cb0ed478543bf135b9399f56d66 Mon Sep 17 00:00:00 2001 From: Sergey Petrunya Date: Tue, 6 Apr 2010 00:16:45 +0400 Subject: MWL#90: Subqueries: Inside-out execution for non-semijoin materialized subqueries that are AND-parts of the WHERE - First code (needs cleanup). --- sql/sql_join_cache.cc | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'sql/sql_join_cache.cc') diff --git a/sql/sql_join_cache.cc b/sql/sql_join_cache.cc index d88cc7a9f7f..ee863f5ca74 100644 --- a/sql/sql_join_cache.cc +++ b/sql/sql_join_cache.cc @@ -33,6 +33,7 @@ #define NO_MORE_RECORDS_IN_BUFFER (uint)(-1) +int do_jtbm_materialization_if_needed(JOIN_TAB *tab); /***************************************************************************** * Join cache module @@ -1778,6 +1779,10 @@ enum_nested_loop_state JOIN_CACHE_BNL::join_matching_records(bool skip_last) } /* Start retrieving all records of the joined table */ + + //jtbm-todo: error handling! + do_jtbm_materialization_if_needed(join_tab); + if ((error= join_init_read_record(join_tab))) { rc= error < 0 ? NESTED_LOOP_NO_MORE_ROWS: NESTED_LOOP_ERROR; -- cgit v1.2.1 From b9688830ecb3ab528770aaa00a4b57c29859dc65 Mon Sep 17 00:00:00 2001 From: Sergey Petrunya Date: Mon, 10 May 2010 19:28:19 +0400 Subject: Subquery optimizations: - Better comments - Use more appropriate return types for functions - Provide handling where it was missing. --- sql/sql_join_cache.cc | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'sql/sql_join_cache.cc') diff --git a/sql/sql_join_cache.cc b/sql/sql_join_cache.cc index ee863f5ca74..33e688fae54 100644 --- a/sql/sql_join_cache.cc +++ b/sql/sql_join_cache.cc @@ -33,8 +33,6 @@ #define NO_MORE_RECORDS_IN_BUFFER (uint)(-1) -int do_jtbm_materialization_if_needed(JOIN_TAB *tab); - /***************************************************************************** * Join cache module ******************************************************************************/ @@ -1780,8 +1778,11 @@ enum_nested_loop_state JOIN_CACHE_BNL::join_matching_records(bool skip_last) /* Start retrieving all records of the joined table */ - //jtbm-todo: error handling! - do_jtbm_materialization_if_needed(join_tab); + if (do_jtbm_materialization_if_needed(join_tab)) + { + rc= NESTED_LOOP_ERROR; + goto finish; + } if ((error= join_init_read_record(join_tab))) { -- cgit v1.2.1 From dad93f2c822f174f4674c4a04c2382c18a262e36 Mon Sep 17 00:00:00 2001 From: Sergey Petrunya Date: Fri, 4 Jun 2010 17:40:57 +0400 Subject: MWL#90, code movearound to unify merged and non-merged semi-join materialization processing - First code, needs cleanup. --- sql/sql_join_cache.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sql/sql_join_cache.cc') diff --git a/sql/sql_join_cache.cc b/sql/sql_join_cache.cc index 33e688fae54..13c5e5c8ee3 100644 --- a/sql/sql_join_cache.cc +++ b/sql/sql_join_cache.cc @@ -1778,7 +1778,7 @@ enum_nested_loop_state JOIN_CACHE_BNL::join_matching_records(bool skip_last) /* Start retrieving all records of the joined table */ - if (do_jtbm_materialization_if_needed(join_tab)) + if (join_tab_execution_startup(join_tab)) { rc= NESTED_LOOP_ERROR; goto finish; -- cgit v1.2.1 From 49568aefe7a9d95e303ccfe40614fd3d1ee5b12f Mon Sep 17 00:00:00 2001 From: Sergey Petrunya Date: Sat, 5 Jun 2010 12:37:16 +0400 Subject: MWL#90: Code cleanup: Unification of merged and non-merged SJM nests processing - Make join buffering code to take into account that JOIN_TABs are not a linear array anymore. --- sql/sql_join_cache.cc | 76 +++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 68 insertions(+), 8 deletions(-) (limited to 'sql/sql_join_cache.cc') diff --git a/sql/sql_join_cache.cc b/sql/sql_join_cache.cc index 13c5e5c8ee3..bf77239ce74 100644 --- a/sql/sql_join_cache.cc +++ b/sql/sql_join_cache.cc @@ -137,6 +137,7 @@ uint add_table_data_fields_to_join_cache(JOIN_TAB *tab, return len; } +JOIN_TAB *next_linear_tab(JOIN* join, JOIN_TAB* tab, bool include_bush_roots); /* Determine different counters of fields associated with a record in the cache @@ -157,10 +158,61 @@ uint add_table_data_fields_to_join_cache(JOIN_TAB *tab, void JOIN_CACHE::calc_record_fields() { - JOIN_TAB *tab = prev_cache ? prev_cache->join_tab : + //psergey4-todo: prev_cache, or + // - first non-const table if on top level + // - first table inside SJM nest if within sjm nest + // this->join_tab is 'our' join_tab + + // No. the right idea: start from ... and walk to the current join_tab + /// with an iterator, skipping + // join nests (can do so for now) + + /* + The above sucks, too. + The right idea: + - for SJM-inner tables, walk only within the nest + - for SJM-outer tables, use all preceding tables, including inner ones. + eof + */ + +/* JOIN_TAB *tab = prev_cache ? prev_cache->join_tab : join->join_tab+join->const_tables; - tables= join_tab-tab; +*/ +/* JOIN_TAB *tab; + if (prev_cache) + tab= prev_cache->join_tab; + else + { + if (tab->bush_root_tab) + { + ; + } + else + { + / * top-level * / + tab= join->join_tab+join->const_tables; + } + }*/ + JOIN_TAB *tab; + if (prev_cache) + tab= prev_cache->join_tab; + else + { + if (join_tab->bush_root_tab) + { + // inside SJM-Mat nest: pick first one + tab= join_tab->bush_root_tab->bush_children->start; + } + else + { + // outside SJM-Mat nest: start from first non-const table + tab= join->join_tab + join->const_tables; + } + } + start_tab= tab; + //tables= join_tab-tab; + //tables= 0; fields= 0; blobs= 0; flag_fields= 0; @@ -168,7 +220,7 @@ void JOIN_CACHE::calc_record_fields() data_field_ptr_count= 0; referenced_fields= 0; - for ( ; tab < join_tab ; tab++) + for ( ; tab != join_tab ; tab= next_linear_tab(join, tab, TRUE)) { calc_used_field_length(join->thd, tab); flag_fields+= test(tab->used_null_fields || tab->used_uneven_bit_fields); @@ -177,6 +229,7 @@ void JOIN_CACHE::calc_record_fields() blobs+= tab->used_blobs; fields+= tab->check_rowid_field(); + //tables++; } if ((with_match_flag= join_tab->use_match_flag())) flag_fields++; @@ -271,7 +324,8 @@ void JOIN_CACHE::create_flag_fields() ©); /* Create fields for all null bitmaps and null row flags that are needed */ - for (tab= join_tab-tables; tab < join_tab; tab++) + //for (tab= join_tab-tables; tab < join_tab; tab++) + for (tab= start_tab; tab != join_tab; tab= next_linear_tab(join, tab, TRUE)) { TABLE *table= tab->table; @@ -336,7 +390,8 @@ void JOIN_CACHE:: create_remaining_fields(bool all_read_fields) CACHE_FIELD *copy= field_descr+flag_fields+data_field_count; CACHE_FIELD **copy_ptr= blob_ptr+data_field_ptr_count; - for (tab= join_tab-tables; tab < join_tab; tab++) + for (tab= start_tab; tab != join_tab; tab= next_linear_tab(join, tab, TRUE)) + //for (tab= join_tab-tables; tab < join_tab; tab++) { MY_BITMAP *rem_field_set; TABLE *table= tab->table; @@ -557,7 +612,9 @@ int JOIN_CACHE_BKA::init() of the counting 'in local_key_arg_fields' and 'external_key_arg_fields' respectively. */ - for (tab= cache->join_tab-cache->tables; tab < cache->join_tab ; tab++) + // for (tab= cache->join_tab-cache->tables; tab < cache->join_tab ; tab++) + for (tab= cache->start_tab; tab != cache->join_tab; tab= + next_linear_tab(cache->join, tab, TRUE)) { uint key_args; bitmap_clear_all(&tab->table->tmp_set); @@ -597,7 +654,9 @@ int JOIN_CACHE_BKA::init() while (ext_key_arg_cnt) { cache= cache->prev_cache; - for (tab= cache->join_tab-cache->tables; tab < cache->join_tab ; tab++) + for (tab= cache->start_tab; tab != cache->join_tab; tab= + next_linear_tab(cache->join, tab, TRUE)) + //for (tab= cache->join_tab-cache->tables; tab < cache->join_tab ; tab++) { CACHE_FIELD *copy_end; MY_BITMAP *key_read_set= &tab->table->tmp_set; @@ -640,7 +699,8 @@ int JOIN_CACHE_BKA::init() /* Now create local fields that are used to build ref for this key access */ copy= field_descr+flag_fields; - for (tab= join_tab-tables; tab < join_tab ; tab++) + //for (tab= join_tab-tables; tab < join_tab ; tab++) + for (tab= start_tab; tab != join_tab; tab= next_linear_tab(join, tab, TRUE)) { length+= add_table_data_fields_to_join_cache(tab, &tab->table->tmp_set, &data_field_count, ©, -- cgit v1.2.1 From ef27f6c33979d669291ac77d0be777bf16a82e7e Mon Sep 17 00:00:00 2001 From: Sergey Petrunya Date: Sat, 5 Jun 2010 22:43:27 +0400 Subject: Buildbot fixes: - Make join buffering take into account that join_tabs are not a single linear array anymore - Remove outer join + SJ-Materialization crash (OJ+SJ the processing is most likely still incorrect) --- sql/sql_join_cache.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'sql/sql_join_cache.cc') diff --git a/sql/sql_join_cache.cc b/sql/sql_join_cache.cc index bf77239ce74..a4db80b29a1 100644 --- a/sql/sql_join_cache.cc +++ b/sql/sql_join_cache.cc @@ -1830,7 +1830,8 @@ enum_nested_loop_state JOIN_CACHE_BNL::join_matching_records(bool skip_last) join_tab->select->quick= 0; } - for (tab= join->join_tab; tab != join_tab ; tab++) + //for (tab= join->join_tab; tab != join_tab ; tab++) + for (tab= start_tab ; tab != join_tab ; tab= next_linear_tab(join, tab, TRUE)) { tab->status= tab->table->status; tab->table->status= 0; @@ -1894,7 +1895,8 @@ enum_nested_loop_state JOIN_CACHE_BNL::join_matching_records(bool skip_last) if (error > 0) // Fatal error rc= NESTED_LOOP_ERROR; finish: - for (tab= join->join_tab; tab != join_tab ; tab++) + //for (tab= join->join_tab; tab != join_tab ; tab++) + for (tab= start_tab ; tab != join_tab ; tab= next_linear_tab(join, tab, TRUE)) tab->table->status= tab->status; return rc; } -- cgit v1.2.1 From 26c3dc455ba934db40d7ad409358c3605fa196d0 Mon Sep 17 00:00:00 2001 From: Sergey Petrunya Date: Tue, 8 Jun 2010 18:22:31 +0400 Subject: MWL#90: Subqueries: Inside-out execution for non-semijoin materialized subqueries that are AND-parts of the WHERE - Address feedback - Code cleanup (not finished) --- sql/sql_join_cache.cc | 46 ++++++++-------------------------------------- 1 file changed, 8 insertions(+), 38 deletions(-) (limited to 'sql/sql_join_cache.cc') diff --git a/sql/sql_join_cache.cc b/sql/sql_join_cache.cc index a4db80b29a1..5db5928fba1 100644 --- a/sql/sql_join_cache.cc +++ b/sql/sql_join_cache.cc @@ -158,42 +158,6 @@ JOIN_TAB *next_linear_tab(JOIN* join, JOIN_TAB* tab, bool include_bush_roots); void JOIN_CACHE::calc_record_fields() { - //psergey4-todo: prev_cache, or - // - first non-const table if on top level - // - first table inside SJM nest if within sjm nest - // this->join_tab is 'our' join_tab - - // No. the right idea: start from ... and walk to the current join_tab - /// with an iterator, skipping - // join nests (can do so for now) - - /* - The above sucks, too. - The right idea: - - for SJM-inner tables, walk only within the nest - - for SJM-outer tables, use all preceding tables, including inner ones. - eof - */ - -/* JOIN_TAB *tab = prev_cache ? prev_cache->join_tab : - join->join_tab+join->const_tables; -*/ - -/* JOIN_TAB *tab; - if (prev_cache) - tab= prev_cache->join_tab; - else - { - if (tab->bush_root_tab) - { - ; - } - else - { - / * top-level * / - tab= join->join_tab+join->const_tables; - } - }*/ JOIN_TAB *tab; if (prev_cache) tab= prev_cache->join_tab; @@ -201,12 +165,18 @@ void JOIN_CACHE::calc_record_fields() { if (join_tab->bush_root_tab) { - // inside SJM-Mat nest: pick first one + /* + If the tab we're attached to is inside an SJM-nest, start from the + first tab in that SJM nest + */ tab= join_tab->bush_root_tab->bush_children->start; } else { - // outside SJM-Mat nest: start from first non-const table + /* + The tab we're attached to is not inside an SJM-nest. Start from the + first non-const table. + */ tab= join->join_tab + join->const_tables; } } -- cgit v1.2.1 From 946aef4a58337c6e5adf5a08d04dd397630f0c46 Mon Sep 17 00:00:00 2001 From: psergey Date: Sat, 10 Jul 2010 20:51:12 +0300 Subject: MWL#90: code cleanup - Remove deadcode - Improve comments - Do small several small TODOs --- sql/sql_join_cache.cc | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'sql/sql_join_cache.cc') diff --git a/sql/sql_join_cache.cc b/sql/sql_join_cache.cc index 5db5928fba1..1d5c04711e1 100644 --- a/sql/sql_join_cache.cc +++ b/sql/sql_join_cache.cc @@ -1809,11 +1809,8 @@ enum_nested_loop_state JOIN_CACHE_BNL::join_matching_records(bool skip_last) /* Start retrieving all records of the joined table */ - if (join_tab_execution_startup(join_tab)) - { - rc= NESTED_LOOP_ERROR; + if ((rc= join_tab_execution_startup(join_tab)) < 0) goto finish; - } if ((error= join_init_read_record(join_tab))) { -- cgit v1.2.1 From 089d2e2ea39c13de7e84c40c4c087775379b8442 Mon Sep 17 00:00:00 2001 From: Sergey Petrunya Date: Wed, 16 Feb 2011 00:59:02 +0300 Subject: Post-merge fixes part 2 --- sql/sql_join_cache.cc | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'sql/sql_join_cache.cc') diff --git a/sql/sql_join_cache.cc b/sql/sql_join_cache.cc index 5f3aa7e16e8..58cbb3fd1ca 100644 --- a/sql/sql_join_cache.cc +++ b/sql/sql_join_cache.cc @@ -235,6 +235,10 @@ psergey-merge: was: } } start_tab= tab; + while (start_tab->bush_children && start_tab != join_tab) + start_tab++; + tab= start_tab; + //tables= join_tab-tab; //tables= 0; fields= 0; -- cgit v1.2.1 From db7461783e3947270fca31b8f3baa6e95cb95528 Mon Sep 17 00:00:00 2001 From: Sergey Petrunya Date: Wed, 16 Feb 2011 01:13:48 +0300 Subject: Post-merge fixes part 3 --- sql/sql_join_cache.cc | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'sql/sql_join_cache.cc') diff --git a/sql/sql_join_cache.cc b/sql/sql_join_cache.cc index 58cbb3fd1ca..55b84077c26 100644 --- a/sql/sql_join_cache.cc +++ b/sql/sql_join_cache.cc @@ -253,7 +253,7 @@ psergey-merge: was: The following loop will get inside SJM nests, because data may be unpacked to sjm-inner tables. */ - for ( ; tab != join_tab ; tab= next_linear_tab(join, tab, TRUE)) + for ( ; tab != join_tab ; tab= next_linear_tab(join, tab, FALSE)) { tab->calc_used_field_length(FALSE); flag_fields+= test(tab->used_null_fields || tab->used_uneven_bit_fields); @@ -313,7 +313,7 @@ void JOIN_CACHE::collect_info_on_key_args() tab"=start_tab" is not a correct substitute for "cache->join_tab - cache->tables". */ - for (tab= cache->start_tab; tab != cache->join_tab; tab= next_linear_tab(join, tab, TRUE)) + for (tab= cache->start_tab; tab != cache->join_tab; tab= next_linear_tab(join, tab, FALSE)) //for (tab= cache->join_tab-cache->tables; tab ; // tab= cache->get_next_table(tab)) { @@ -433,7 +433,7 @@ void JOIN_CACHE::create_flag_fields() /* Create fields for all null bitmaps and null row flags that are needed */ // // psergey-merge: for (tab= join_tab-tables; tab; tab= get_next_table(tab)) //for (tab= join_tab-tables; tab < join_tab; tab++) - for (tab= start_tab; tab != join_tab; tab= next_linear_tab(join, tab, TRUE)) + for (tab= start_tab; tab != join_tab; tab= next_linear_tab(join, tab, FALSE)) { TABLE *table= tab->table; @@ -524,7 +524,7 @@ void JOIN_CACHE::create_key_arg_fields() // tab= cache->get_next_table(tab)) //psergey-merge: ^ for (tab= cache->start_tab; tab != cache->join_tab; - tab= next_linear_tab(join, tab, TRUE)) + tab= next_linear_tab(join, tab, FALSE)) { CACHE_FIELD *copy_end; MY_BITMAP *key_read_set= &tab->table->tmp_set; @@ -574,7 +574,7 @@ void JOIN_CACHE::create_key_arg_fields() /* Now create local fields that are used to build ref for this key access */ copy= field_descr+flag_fields; - for (tab= start_tab; tab != join_tab; tab= next_linear_tab(join, tab, TRUE)) + for (tab= start_tab; tab != join_tab; tab= next_linear_tab(join, tab, FALSE)) //for (tab= join_tab-tables; tab; tab= get_next_table(tab)) { length+= add_table_data_fields_to_join_cache(tab, &tab->table->tmp_set, @@ -631,7 +631,7 @@ void JOIN_CACHE::create_remaining_fields() CACHE_FIELD *copy= field_descr+flag_fields+data_field_count; CACHE_FIELD **copy_ptr= blob_ptr+data_field_ptr_count; - for (tab= start_tab; tab != join_tab; tab= next_linear_tab(join, tab, TRUE)) + for (tab= start_tab; tab != join_tab; tab= next_linear_tab(join, tab, FALSE)) //psergey-merge: for (tab= join_tab-tables; tab; tab= get_next_table(tab)) //for (tab= join_tab-tables; tab < join_tab; tab++) { @@ -791,7 +791,7 @@ ulong JOIN_CACHE::get_min_join_buffer_size() { ulong len= 0; //for (JOIN_TAB *tab= join_tab-tables; tab < join_tab; tab++) - for (JOIN_TAB *tab= start_tab; tab != join_tab; tab= next_linear_tab(join, tab, TRUE)) + for (JOIN_TAB *tab= start_tab; tab != join_tab; tab= next_linear_tab(join, tab, FALSE)) len+= tab->get_max_used_fieldlength(); len+= get_record_max_affix_length() + get_max_key_addon_space_per_record(); ulong min_sz= len*min_records; @@ -845,7 +845,7 @@ ulong JOIN_CACHE::get_max_join_buffer_size(bool optimize_buff_size) ulong min_sz= get_min_join_buffer_size(); ulong len= 0; //for (JOIN_TAB *tab= join_tab-tables; tab < join_tab; tab++) - for (JOIN_TAB *tab= start_tab; tab != join_tab; tab= next_linear_tab(join, tab, TRUE)) + for (JOIN_TAB *tab= start_tab; tab != join_tab; tab= next_linear_tab(join, tab, FALSE)) len+= tab->get_used_fieldlength(); len+= get_record_max_affix_length(); avg_record_length= len; @@ -924,7 +924,7 @@ int JOIN_CACHE::alloc_buffer() // for (tab= cache->join_tab-cache->tables; tab < cache->join_tab ; tab++) // (fixed) for (tab= join->join_tab + join->const_tables; tab!= join_tab; - tab= next_linear_tab(join, tab, TRUE)) + tab= next_linear_tab(join, tab, FALSE)) { cache= tab->cache; if (cache) -- cgit v1.2.1 From 716091e2a058644b81755ec3f3b1f736b0c84782 Mon Sep 17 00:00:00 2001 From: Sergey Petrunya Date: Wed, 16 Feb 2011 13:26:27 +0300 Subject: Post-merge fixes part 4 --- sql/sql_join_cache.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sql/sql_join_cache.cc') diff --git a/sql/sql_join_cache.cc b/sql/sql_join_cache.cc index 55b84077c26..fbbcf395980 100644 --- a/sql/sql_join_cache.cc +++ b/sql/sql_join_cache.cc @@ -923,7 +923,7 @@ int JOIN_CACHE::alloc_buffer() //psergey-merge: for (tab= join->join_tab+join->const_tables; tab <= join_tab; tab++) // for (tab= cache->join_tab-cache->tables; tab < cache->join_tab ; tab++) // (fixed) - for (tab= join->join_tab + join->const_tables; tab!= join_tab; + for (tab= /*join->join_tab + join->const_tables*/ start_tab; tab!= join_tab; tab= next_linear_tab(join, tab, FALSE)) { cache= tab->cache; -- cgit v1.2.1 From e69c642920224680528c0c8548ff52c674bee3d9 Mon Sep 17 00:00:00 2001 From: Sergey Petrunya Date: Wed, 16 Feb 2011 13:59:14 +0300 Subject: Post-merge fixes part 5 --- sql/sql_join_cache.cc | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'sql/sql_join_cache.cc') diff --git a/sql/sql_join_cache.cc b/sql/sql_join_cache.cc index fbbcf395980..68cb0c86adb 100644 --- a/sql/sql_join_cache.cc +++ b/sql/sql_join_cache.cc @@ -235,8 +235,13 @@ psergey-merge: was: } } start_tab= tab; + /* while (start_tab->bush_children && start_tab != join_tab) start_tab++; + */ + if (start_tab->bush_children) + start_tab= start_tab->bush_children->start; + tab= start_tab; //tables= join_tab-tab; -- cgit v1.2.1 From f93b0bbebb4a533bfdd1983017c4d0c4a25110e4 Mon Sep 17 00:00:00 2001 From: Sergey Petrunya Date: Fri, 18 Feb 2011 14:17:28 +0300 Subject: MWL#90: subquery optimizations - Remove redundant changes againist 5.3-main --- sql/sql_join_cache.cc | 33 +-------------------------------- 1 file changed, 1 insertion(+), 32 deletions(-) (limited to 'sql/sql_join_cache.cc') diff --git a/sql/sql_join_cache.cc b/sql/sql_join_cache.cc index 68cb0c86adb..134af78d43b 100644 --- a/sql/sql_join_cache.cc +++ b/sql/sql_join_cache.cc @@ -1061,7 +1061,6 @@ int JOIN_CACHE::realloc_buffer() */ int JOIN_CACHE::init() -//psergey-merge:wtf is this here: for (tab= start_tab; tab != join_tab; tab= next_linear_tab(join, tab, TRUE)) { DBUG_ENTER("JOIN_CACHE::init"); @@ -3260,23 +3259,7 @@ uint JOIN_CACHE_HASHED::get_next_key(uchar ** key) int JOIN_TAB_SCAN::open() { - //psergey-merge: todo: check the below: - //JOIN_TAB *bound= join_tab-cache->tables; - -#if 0 - JOIN_TAB *bound= cache->start_tab; - - // psergey-todo-merge: can we really iterate backwards? - // Q: is there really a need to iterate backwards? - - for (JOIN_TAB *tab= join_tab-1; tab != bound && !tab->cache; tab--) - { - tab->status= tab->table->status; - tab->table->status= 0; - } -#endif save_or_restore_used_tabs(join_tab, FALSE); - is_first_record= TRUE; return join_init_read_record(join_tab); } @@ -3381,12 +3364,7 @@ void save_or_restore_used_tabs(JOIN_TAB *join_tab, bool save) void JOIN_TAB_SCAN::close() { -#if 0 - JOIN_TAB *bound= join_tab - cache->tables; - for (JOIN_TAB *tab= join_tab-1; tab != bound && !tab->cache; tab--) - tab->table->status= tab->status; -#endif - save_or_restore_used_tabs(join_tab, TRUE); + save_or_restore_used_tabs(join_tab, TRUE); } @@ -3786,15 +3764,6 @@ int JOIN_TAB_SCAN_MRR::open() /* Dynamic range access is never used with BKA */ DBUG_ASSERT(join_tab->use_quick != 2); -/* -psergey-merge: done? - JOIN_TAB *bound= join_tab - cache->tables; - for (JOIN_TAB *tab= join_tab-1; tab != bound && !tab->cache; tab--) - { - tab->status= tab->table->status; - tab->table->status= 0; - } -*/ save_or_restore_used_tabs(join_tab, FALSE); init_mrr_buff(); -- cgit v1.2.1 From e7aa18fb9c527eda66fb20e5a796f7c658b5e06b Mon Sep 17 00:00:00 2001 From: Sergey Petrunya Date: Sat, 19 Feb 2011 00:22:38 +0300 Subject: Code cleanup (1) --- sql/sql_join_cache.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sql/sql_join_cache.cc') diff --git a/sql/sql_join_cache.cc b/sql/sql_join_cache.cc index 134af78d43b..b7062747073 100644 --- a/sql/sql_join_cache.cc +++ b/sql/sql_join_cache.cc @@ -2219,7 +2219,7 @@ enum_nested_loop_state JOIN_CACHE::join_matching_records(bool skip_last) } /* Prepare to retrieve all records of the joined table */ - if ((error= join_tab_scan->open())) //psergey-merge: TODO: look what it does inside? status-reset should use next_linear_tab + if ((error= join_tab_scan->open())) goto finish; /* psergey-note: if this returns error, we will assert in net_send_statement() */ if ((rc= join_tab_execution_startup(join_tab)) < 0) -- cgit v1.2.1 From 862135a18a626648c66b4f4c450d819d4f382818 Mon Sep 17 00:00:00 2001 From: Sergey Petrunya Date: Tue, 22 Feb 2011 17:19:03 +0300 Subject: Code cleanup (remove garbage comments and #if 0-s) --- sql/sql_join_cache.cc | 89 +++------------------------------------------------ 1 file changed, 5 insertions(+), 84 deletions(-) (limited to 'sql/sql_join_cache.cc') diff --git a/sql/sql_join_cache.cc b/sql/sql_join_cache.cc index b7062747073..921144d9ec1 100644 --- a/sql/sql_join_cache.cc +++ b/sql/sql_join_cache.cc @@ -34,6 +34,8 @@ #define NO_MORE_RECORDS_IN_BUFFER (uint)(-1) void save_or_restore_used_tabs(JOIN_TAB *join_tab, bool save); +JOIN_TAB *next_linear_tab(JOIN* join, JOIN_TAB* tab, bool include_bush_roots); + /***************************************************************************** * Join cache module ******************************************************************************/ @@ -138,54 +140,6 @@ uint add_table_data_fields_to_join_cache(JOIN_TAB *tab, return len; } -JOIN_TAB *next_linear_tab(JOIN* join, JOIN_TAB* tab, bool include_bush_roots); - -// /* -// Get the next table whose records are stored in the join buffer of this cache -// -// SYNOPSIS -// get_next_table() -// tab the table for which the next table is to be returned -// -// DESCRIPTION -// For a given table whose records are stored in this cache the function -// returns the next such table if there is any. -// The function takes into account that the tables whose records are -// are stored in the same cache now can interleave with tables from -// materialized semijoin subqueries. -// -// TODO -// This function should be modified/simplified after the new code for -// materialized semijoins is merged. -// -// RETURN -// The next join table whose records are stored in the buffer of this cache -// if such table exists, 0 - otherwise -// */ -// -// JOIN_TAB *JOIN_CACHE::get_next_table(JOIN_TAB *tab) -// { -// -// if (++tab == join_tab) -// return NULL; -// if (join_tab->first_sjm_sibling) -// return tab; -// uint i= tab-join->join_tab; -// /* -// Temporary measure before MWL#90 refactorings are there: if 'tab' is at upper -// level (i.e. it's not inside an SJM nest), still include into the join buffer -// the tables from within SJM nest. We might need the subquery's select list -// columns, because SJ-Materialization-Scan upacks data to those. -// -// while (sj_is_materialize_strategy(join->best_positions[i].sj_strategy) && -// i < join->tables) -// i+= join->best_positions[i].n_sj_tables; -// -// */ -// return join->join_tab+i < join_tab ? join->join_tab+i : NULL; -// } - - /* Determine different counters of fields associated with a record in the cache @@ -206,13 +160,7 @@ JOIN_TAB *next_linear_tab(JOIN* join, JOIN_TAB* tab, bool include_bush_roots); void JOIN_CACHE::calc_record_fields() { JOIN_TAB *tab; -/** -psergey-merge: was: - JOIN_TAB *tab = prev_cache ? prev_cache->join_tab : - (join_tab->first_sjm_sibling ? - join_tab->first_sjm_sibling : - join->join_tab+join->const_tables); -**/ + if (prev_cache) tab= prev_cache->join_tab; else @@ -235,17 +183,11 @@ psergey-merge: was: } } start_tab= tab; - /* - while (start_tab->bush_children && start_tab != join_tab) - start_tab++; - */ if (start_tab->bush_children) start_tab= start_tab->bush_children->start; tab= start_tab; - //tables= join_tab-tab; - //tables= 0; fields= 0; blobs= 0; flag_fields= 0; @@ -253,7 +195,6 @@ psergey-merge: was: data_field_ptr_count= 0; referenced_fields= 0; - //psergey-merge: for ( ; tab ; tab= get_next_table(tab)) /* The following loop will get inside SJM nests, because data may be unpacked to sjm-inner tables. @@ -267,7 +208,6 @@ psergey-merge: was: blobs+= tab->used_blobs; fields+= tab->check_rowid_field(); - //tables++; } if ((with_match_flag= join_tab->use_match_flag())) flag_fields++; @@ -313,14 +253,7 @@ void JOIN_CACHE::collect_info_on_key_args() cache= this; do { - /* - psergey-merge: - tab"=start_tab" is not a correct substitute for - "cache->join_tab - cache->tables". - */ for (tab= cache->start_tab; tab != cache->join_tab; tab= next_linear_tab(join, tab, FALSE)) - //for (tab= cache->join_tab-cache->tables; tab ; - // tab= cache->get_next_table(tab)) { uint key_args; bitmap_clear_all(&tab->table->tmp_set); @@ -436,8 +369,6 @@ void JOIN_CACHE::create_flag_fields() ©); /* Create fields for all null bitmaps and null row flags that are needed */ -// // psergey-merge: for (tab= join_tab-tables; tab; tab= get_next_table(tab)) - //for (tab= join_tab-tables; tab < join_tab; tab++) for (tab= start_tab; tab != join_tab; tab= next_linear_tab(join, tab, FALSE)) { TABLE *table= tab->table; @@ -525,9 +456,6 @@ void JOIN_CACHE::create_key_arg_fields() while (ext_key_arg_cnt) { cache= cache->prev_cache; - //for (tab= cache->join_tab-cache->tables; tab; - // tab= cache->get_next_table(tab)) - //psergey-merge: ^ for (tab= cache->start_tab; tab != cache->join_tab; tab= next_linear_tab(join, tab, FALSE)) { @@ -637,8 +565,6 @@ void JOIN_CACHE::create_remaining_fields() CACHE_FIELD **copy_ptr= blob_ptr+data_field_ptr_count; for (tab= start_tab; tab != join_tab; tab= next_linear_tab(join, tab, FALSE)) -//psergey-merge: for (tab= join_tab-tables; tab; tab= get_next_table(tab)) - //for (tab= join_tab-tables; tab < join_tab; tab++) { MY_BITMAP *rem_field_set; TABLE *table= tab->table; @@ -795,7 +721,6 @@ ulong JOIN_CACHE::get_min_join_buffer_size() if (!min_buff_size) { ulong len= 0; - //for (JOIN_TAB *tab= join_tab-tables; tab < join_tab; tab++) for (JOIN_TAB *tab= start_tab; tab != join_tab; tab= next_linear_tab(join, tab, FALSE)) len+= tab->get_max_used_fieldlength(); len+= get_record_max_affix_length() + get_max_key_addon_space_per_record(); @@ -849,7 +774,6 @@ ulong JOIN_CACHE::get_max_join_buffer_size(bool optimize_buff_size) ulong max_sz; ulong min_sz= get_min_join_buffer_size(); ulong len= 0; - //for (JOIN_TAB *tab= join_tab-tables; tab < join_tab; tab++) for (JOIN_TAB *tab= start_tab; tab != join_tab; tab= next_linear_tab(join, tab, FALSE)) len+= tab->get_used_fieldlength(); len+= get_record_max_affix_length(); @@ -925,11 +849,8 @@ int JOIN_CACHE::alloc_buffer() set_if_bigger(max_records, 10); min_buff_size= get_min_join_buffer_size(); buff_size= get_max_join_buffer_size(optimize_buff_size); -//psergey-merge: for (tab= join->join_tab+join->const_tables; tab <= join_tab; tab++) -// for (tab= cache->join_tab-cache->tables; tab < cache->join_tab ; tab++) -// (fixed) - for (tab= /*join->join_tab + join->const_tables*/ start_tab; tab!= join_tab; - tab= next_linear_tab(join, tab, FALSE)) + + for (tab= start_tab; tab!= join_tab; tab= next_linear_tab(join, tab, FALSE)) { cache= tab->cache; if (cache) -- cgit v1.2.1 From b8f00542e2ed66803d747cc5151279b9edf1392a Mon Sep 17 00:00:00 2001 From: Sergey Petrunya Date: Tue, 1 Mar 2011 12:01:10 +0300 Subject: BUG#724228: Wrong result with materialization=on and three aggregates in maria-5.3-mwl90 - In join buffering code, call join_tab_execution_startup() (#1) before we call join_tab_scan->open() (#2). This is important with SJ-Materialization because #1 fills the materialized table, while #2 will actually try to read the first row. Attempt to read the first row before we have populated the materialized table would cause zero rows to be returned when actually there were matches. --- sql/sql_join_cache.cc | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'sql/sql_join_cache.cc') diff --git a/sql/sql_join_cache.cc b/sql/sql_join_cache.cc index 921144d9ec1..ec8fd9997f6 100644 --- a/sql/sql_join_cache.cc +++ b/sql/sql_join_cache.cc @@ -2139,14 +2139,13 @@ enum_nested_loop_state JOIN_CACHE::join_matching_records(bool skip_last) join_tab->select->quick= 0; } + if ((rc= join_tab_execution_startup(join_tab)) < 0) + goto finish; + /* Prepare to retrieve all records of the joined table */ if ((error= join_tab_scan->open())) goto finish; /* psergey-note: if this returns error, we will assert in net_send_statement() */ - if ((rc= join_tab_execution_startup(join_tab)) < 0) - goto finish; - - while (!(error= join_tab_scan->next())) { if (join->thd->killed) -- cgit v1.2.1 From 125bfa2ce722f909e7133c4e381b549bcdb3192c Mon Sep 17 00:00:00 2001 From: Sergey Petrunya Date: Tue, 1 Mar 2011 13:33:23 +0300 Subject: Fix error code handling in fix for BUG#724228 --- sql/sql_join_cache.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'sql/sql_join_cache.cc') diff --git a/sql/sql_join_cache.cc b/sql/sql_join_cache.cc index 7b26842eb9f..bdc944d8d6c 100644 --- a/sql/sql_join_cache.cc +++ b/sql/sql_join_cache.cc @@ -2140,7 +2140,7 @@ enum_nested_loop_state JOIN_CACHE::join_matching_records(bool skip_last) } if ((rc= join_tab_execution_startup(join_tab)) < 0) - goto finish; + goto finish2; /* Prepare to retrieve all records of the joined table */ if ((error= join_tab_scan->open())) @@ -2187,6 +2187,7 @@ enum_nested_loop_state JOIN_CACHE::join_matching_records(bool skip_last) finish: if (error) rc= error < 0 ? NESTED_LOOP_NO_MORE_ROWS: NESTED_LOOP_ERROR; +finish2: join_tab_scan->close(); return rc; } -- cgit v1.2.1 From d56e74eb9ba27ae98884b9ddb37c3d7a575b50fe Mon Sep 17 00:00:00 2001 From: Sergey Petrunya Date: Mon, 21 Mar 2011 23:06:16 +0300 Subject: MWL#90: Address review feedback part #2 --- sql/sql_join_cache.cc | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'sql/sql_join_cache.cc') diff --git a/sql/sql_join_cache.cc b/sql/sql_join_cache.cc index bdc944d8d6c..face1f9196e 100644 --- a/sql/sql_join_cache.cc +++ b/sql/sql_join_cache.cc @@ -3235,6 +3235,13 @@ int JOIN_TAB_SCAN::next() } +/* + Walk back in join order from join_tab until we encounter a join tab with + tab->cache!=NULL, and save/restore tab->table->status along the way. + + @param save TRUE save + FALSE restore +*/ void save_or_restore_used_tabs(JOIN_TAB *join_tab, bool save) { JOIN_TAB *first= join_tab->bush_root_tab? @@ -3251,6 +3258,7 @@ void save_or_restore_used_tabs(JOIN_TAB *join_tab, bool save) { if (save) child->table->status= child->status; + else { tab->status= tab->table->status; tab->table->status= 0; -- cgit v1.2.1 From b77e3dc9f403cea4d8ccebf87267096f5194d31c Mon Sep 17 00:00:00 2001 From: Sergey Petrunya Date: Tue, 22 Mar 2011 13:09:55 +0300 Subject: MWL#90: Address review feedback part #5 --- sql/sql_join_cache.cc | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'sql/sql_join_cache.cc') diff --git a/sql/sql_join_cache.cc b/sql/sql_join_cache.cc index face1f9196e..af0c3c6709e 100644 --- a/sql/sql_join_cache.cc +++ b/sql/sql_join_cache.cc @@ -185,6 +185,7 @@ void JOIN_CACHE::calc_record_fields() start_tab= tab; if (start_tab->bush_children) start_tab= start_tab->bush_children->start; + DBUG_ASSERT(!start_tab->bush_children); tab= start_tab; @@ -508,7 +509,6 @@ void JOIN_CACHE::create_key_arg_fields() /* Now create local fields that are used to build ref for this key access */ copy= field_descr+flag_fields; for (tab= start_tab; tab != join_tab; tab= next_linear_tab(join, tab, FALSE)) - //for (tab= join_tab-tables; tab; tab= get_next_table(tab)) { length+= add_table_data_fields_to_join_cache(tab, &tab->table->tmp_set, &data_field_count, ©, @@ -721,8 +721,11 @@ ulong JOIN_CACHE::get_min_join_buffer_size() if (!min_buff_size) { size_t len= 0; - for (JOIN_TAB *tab= start_tab; tab != join_tab; tab= next_linear_tab(join, tab, FALSE)) + for (JOIN_TAB *tab= start_tab; tab != join_tab; + tab= next_linear_tab(join, tab, FALSE)) + { len+= tab->get_max_used_fieldlength(); + } len+= get_record_max_affix_length() + get_max_key_addon_space_per_record(); size_t min_sz= len*min_records; size_t add_sz= 0; @@ -774,8 +777,11 @@ ulong JOIN_CACHE::get_max_join_buffer_size(bool optimize_buff_size) size_t max_sz; size_t min_sz= get_min_join_buffer_size(); size_t len= 0; - for (JOIN_TAB *tab= start_tab; tab != join_tab; tab= next_linear_tab(join, tab, FALSE)) + for (JOIN_TAB *tab= start_tab; tab != join_tab; + tab= next_linear_tab(join, tab, FALSE)) + { len+= tab->get_used_fieldlength(); + } len+= get_record_max_affix_length(); avg_record_length= len; len+= get_max_key_addon_space_per_record() + avg_aux_buffer_incr; -- cgit v1.2.1 From 39fe368d689e6562867cc15e211fc9480129f3a7 Mon Sep 17 00:00:00 2001 From: Sergey Petrunya Date: Tue, 22 Mar 2011 16:46:39 +0300 Subject: MWL#90: Address review feedback part #7 --- sql/sql_join_cache.cc | 46 +++++++++++++++++++++++++++++++++------------- 1 file changed, 33 insertions(+), 13 deletions(-) (limited to 'sql/sql_join_cache.cc') diff --git a/sql/sql_join_cache.cc b/sql/sql_join_cache.cc index af0c3c6709e..8db38e0b4e0 100644 --- a/sql/sql_join_cache.cc +++ b/sql/sql_join_cache.cc @@ -33,8 +33,7 @@ #define NO_MORE_RECORDS_IN_BUFFER (uint)(-1) -void save_or_restore_used_tabs(JOIN_TAB *join_tab, bool save); -JOIN_TAB *next_linear_tab(JOIN* join, JOIN_TAB* tab, bool include_bush_roots); +static void save_or_restore_used_tabs(JOIN_TAB *join_tab, bool save); /***************************************************************************** * Join cache module @@ -168,27 +167,46 @@ void JOIN_CACHE::calc_record_fields() if (join_tab->bush_root_tab) { /* - If the tab we're attached to is inside an SJM-nest, start from the - first tab in that SJM nest + --ot1--SJM1--------------ot2--... + | + | + +-it1--...--itN + ^____________ this->join_tab is somewhere here, + inside an sjm nest. + + The join buffer should store the values of it1.*, it2.*, .. + It should not store values of ot1.*. */ tab= join_tab->bush_root_tab->bush_children->start; } else { /* - The tab we're attached to is not inside an SJM-nest. Start from the - first non-const table. + -ot1--ot2--SJM1--SJM2--------------ot3--...--otN + | | ^ + | +-it21--...--it2N | + | \-- we're somewhere here, + +-it11--...--it1N at the top level + + The join buffer should store the values of + + ot1.*, ot2.*, it1{i}, it2{j}.*, ot3.*, ... + + that is, we should start from the first non-const top-level table. + + We will need to store columns of SJ-inner tables (it_X_Y.*), but we're + not interested in storing the columns of materialization tables + themselves. Beause of that, if the first non-const top-level table is a + materialized table, we move to its bush_children: */ tab= join->join_tab + join->const_tables; + if (tab->bush_children) + tab= tab->bush_children->start; } } - start_tab= tab; - if (start_tab->bush_children) - start_tab= start_tab->bush_children->start; DBUG_ASSERT(!start_tab->bush_children); - tab= start_tab; - + start_tab= tab; fields= 0; blobs= 0; flag_fields= 0; @@ -254,7 +272,8 @@ void JOIN_CACHE::collect_info_on_key_args() cache= this; do { - for (tab= cache->start_tab; tab != cache->join_tab; tab= next_linear_tab(join, tab, FALSE)) + for (tab= cache->start_tab; tab != cache->join_tab; + tab= next_linear_tab(join, tab, FALSE)) { uint key_args; bitmap_clear_all(&tab->table->tmp_set); @@ -3248,7 +3267,8 @@ int JOIN_TAB_SCAN::next() @param save TRUE save FALSE restore */ -void save_or_restore_used_tabs(JOIN_TAB *join_tab, bool save) + +static void save_or_restore_used_tabs(JOIN_TAB *join_tab, bool save) { JOIN_TAB *first= join_tab->bush_root_tab? join_tab->bush_root_tab->bush_children->start : -- cgit v1.2.1 From 739e6c99a27fbc957546941e5303653585706133 Mon Sep 17 00:00:00 2001 From: Sergey Petrunya Date: Tue, 22 Mar 2011 19:23:12 +0300 Subject: MWL#90: Address review feedback part #8 --- sql/sql_join_cache.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sql/sql_join_cache.cc') diff --git a/sql/sql_join_cache.cc b/sql/sql_join_cache.cc index 8db38e0b4e0..2250e38fc72 100644 --- a/sql/sql_join_cache.cc +++ b/sql/sql_join_cache.cc @@ -204,7 +204,7 @@ void JOIN_CACHE::calc_record_fields() tab= tab->bush_children->start; } } - DBUG_ASSERT(!start_tab->bush_children); + DBUG_ASSERT(!tab->bush_children); start_tab= tab; fields= 0; -- cgit v1.2.1 From f064087ed0eba378ef83270562ec3f9438d88859 Mon Sep 17 00:00:00 2001 From: Sergey Petrunya Date: Tue, 22 Mar 2011 19:42:36 +0300 Subject: MWL#90: Address review feedback part #9: - among everything else, switch to using first/next_linear_tab() in make_outerjoin_info(). --- sql/sql_join_cache.cc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'sql/sql_join_cache.cc') diff --git a/sql/sql_join_cache.cc b/sql/sql_join_cache.cc index 2250e38fc72..87c1fb9f2ec 100644 --- a/sql/sql_join_cache.cc +++ b/sql/sql_join_cache.cc @@ -2169,7 +2169,13 @@ enum_nested_loop_state JOIN_CACHE::join_matching_records(bool skip_last) /* Prepare to retrieve all records of the joined table */ if ((error= join_tab_scan->open())) - goto finish; /* psergey-note: if this returns error, we will assert in net_send_statement() */ + { + /* + TODO: if we get here, we will assert in net_send_statement(). Add test + coverage and fix. + */ + goto finish; + } while (!(error= join_tab_scan->next())) { -- cgit v1.2.1 From 253087815ad407599552d68900ac8b1cbac02bb5 Mon Sep 17 00:00:00 2001 From: Sergey Petrunya Date: Fri, 25 Mar 2011 12:58:27 +0300 Subject: Make first_linear_tab()/next_linear_tab() use named constants instead of TRUE/FALSE flags, for better readability. --- sql/sql_join_cache.cc | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'sql/sql_join_cache.cc') diff --git a/sql/sql_join_cache.cc b/sql/sql_join_cache.cc index 87c1fb9f2ec..0fcb8bd1bca 100644 --- a/sql/sql_join_cache.cc +++ b/sql/sql_join_cache.cc @@ -218,7 +218,7 @@ void JOIN_CACHE::calc_record_fields() The following loop will get inside SJM nests, because data may be unpacked to sjm-inner tables. */ - for ( ; tab != join_tab ; tab= next_linear_tab(join, tab, FALSE)) + for (; tab != join_tab ; tab= next_linear_tab(join, tab, WITHOUT_BUSH_ROOTS)) { tab->calc_used_field_length(FALSE); flag_fields+= test(tab->used_null_fields || tab->used_uneven_bit_fields); @@ -273,7 +273,7 @@ void JOIN_CACHE::collect_info_on_key_args() do { for (tab= cache->start_tab; tab != cache->join_tab; - tab= next_linear_tab(join, tab, FALSE)) + tab= next_linear_tab(join, tab, WITHOUT_BUSH_ROOTS)) { uint key_args; bitmap_clear_all(&tab->table->tmp_set); @@ -389,7 +389,8 @@ void JOIN_CACHE::create_flag_fields() ©); /* Create fields for all null bitmaps and null row flags that are needed */ - for (tab= start_tab; tab != join_tab; tab= next_linear_tab(join, tab, FALSE)) + for (tab= start_tab; tab != join_tab; + tab= next_linear_tab(join, tab, WITHOUT_BUSH_ROOTS)) { TABLE *table= tab->table; @@ -477,7 +478,7 @@ void JOIN_CACHE::create_key_arg_fields() { cache= cache->prev_cache; for (tab= cache->start_tab; tab != cache->join_tab; - tab= next_linear_tab(join, tab, FALSE)) + tab= next_linear_tab(join, tab, WITHOUT_BUSH_ROOTS)) { CACHE_FIELD *copy_end; MY_BITMAP *key_read_set= &tab->table->tmp_set; @@ -527,7 +528,8 @@ void JOIN_CACHE::create_key_arg_fields() /* Now create local fields that are used to build ref for this key access */ copy= field_descr+flag_fields; - for (tab= start_tab; tab != join_tab; tab= next_linear_tab(join, tab, FALSE)) + for (tab= start_tab; tab != join_tab; + tab= next_linear_tab(join, tab, WITHOUT_BUSH_ROOTS)) { length+= add_table_data_fields_to_join_cache(tab, &tab->table->tmp_set, &data_field_count, ©, @@ -583,7 +585,8 @@ void JOIN_CACHE::create_remaining_fields() CACHE_FIELD *copy= field_descr+flag_fields+data_field_count; CACHE_FIELD **copy_ptr= blob_ptr+data_field_ptr_count; - for (tab= start_tab; tab != join_tab; tab= next_linear_tab(join, tab, FALSE)) + for (tab= start_tab; tab != join_tab; + tab= next_linear_tab(join, tab, WITHOUT_BUSH_ROOTS)) { MY_BITMAP *rem_field_set; TABLE *table= tab->table; @@ -741,7 +744,7 @@ ulong JOIN_CACHE::get_min_join_buffer_size() { size_t len= 0; for (JOIN_TAB *tab= start_tab; tab != join_tab; - tab= next_linear_tab(join, tab, FALSE)) + tab= next_linear_tab(join, tab, WITHOUT_BUSH_ROOTS)) { len+= tab->get_max_used_fieldlength(); } @@ -797,7 +800,7 @@ ulong JOIN_CACHE::get_max_join_buffer_size(bool optimize_buff_size) size_t min_sz= get_min_join_buffer_size(); size_t len= 0; for (JOIN_TAB *tab= start_tab; tab != join_tab; - tab= next_linear_tab(join, tab, FALSE)) + tab= next_linear_tab(join, tab, WITHOUT_BUSH_ROOTS)) { len+= tab->get_used_fieldlength(); } @@ -875,7 +878,8 @@ int JOIN_CACHE::alloc_buffer() min_buff_size= get_min_join_buffer_size(); buff_size= get_max_join_buffer_size(optimize_buff_size); - for (tab= start_tab; tab!= join_tab; tab= next_linear_tab(join, tab, FALSE)) + for (tab= start_tab; tab!= join_tab; + tab= next_linear_tab(join, tab, WITHOUT_BUSH_ROOTS)) { cache= tab->cache; if (cache) -- cgit v1.2.1