mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
Make first_linear_tab()/next_linear_tab() use named constants instead of TRUE/FALSE flags, for better readability.
This commit is contained in:
@ -218,7 +218,7 @@ void JOIN_CACHE::calc_record_fields()
|
|||||||
The following loop will get inside SJM nests, because data may be unpacked
|
The following loop will get inside SJM nests, because data may be unpacked
|
||||||
to sjm-inner tables.
|
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);
|
tab->calc_used_field_length(FALSE);
|
||||||
flag_fields+= test(tab->used_null_fields || tab->used_uneven_bit_fields);
|
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
|
do
|
||||||
{
|
{
|
||||||
for (tab= cache->start_tab; tab != cache->join_tab;
|
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;
|
uint key_args;
|
||||||
bitmap_clear_all(&tab->table->tmp_set);
|
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 */
|
/* 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;
|
TABLE *table= tab->table;
|
||||||
|
|
||||||
@ -477,7 +478,7 @@ void JOIN_CACHE::create_key_arg_fields()
|
|||||||
{
|
{
|
||||||
cache= cache->prev_cache;
|
cache= cache->prev_cache;
|
||||||
for (tab= cache->start_tab; tab != cache->join_tab;
|
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;
|
CACHE_FIELD *copy_end;
|
||||||
MY_BITMAP *key_read_set= &tab->table->tmp_set;
|
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 */
|
/* Now create local fields that are used to build ref for this key access */
|
||||||
copy= field_descr+flag_fields;
|
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,
|
length+= add_table_data_fields_to_join_cache(tab, &tab->table->tmp_set,
|
||||||
&data_field_count, ©,
|
&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= field_descr+flag_fields+data_field_count;
|
||||||
CACHE_FIELD **copy_ptr= blob_ptr+data_field_ptr_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;
|
MY_BITMAP *rem_field_set;
|
||||||
TABLE *table= tab->table;
|
TABLE *table= tab->table;
|
||||||
@ -741,7 +744,7 @@ ulong JOIN_CACHE::get_min_join_buffer_size()
|
|||||||
{
|
{
|
||||||
size_t len= 0;
|
size_t len= 0;
|
||||||
for (JOIN_TAB *tab= start_tab; tab != join_tab;
|
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();
|
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 min_sz= get_min_join_buffer_size();
|
||||||
size_t len= 0;
|
size_t len= 0;
|
||||||
for (JOIN_TAB *tab= start_tab; tab != join_tab;
|
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();
|
len+= tab->get_used_fieldlength();
|
||||||
}
|
}
|
||||||
@ -875,7 +878,8 @@ int JOIN_CACHE::alloc_buffer()
|
|||||||
min_buff_size= get_min_join_buffer_size();
|
min_buff_size= get_min_join_buffer_size();
|
||||||
buff_size= get_max_join_buffer_size(optimize_buff_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;
|
cache= tab->cache;
|
||||||
if (cache)
|
if (cache)
|
||||||
|
@ -1035,8 +1035,8 @@ JOIN::optimize()
|
|||||||
Perform the optimization on fields evaluation mentioned above
|
Perform the optimization on fields evaluation mentioned above
|
||||||
for all on expressions.
|
for all on expressions.
|
||||||
*/
|
*/
|
||||||
for (JOIN_TAB *tab= first_linear_tab(this, TRUE); tab;
|
for (JOIN_TAB *tab= first_linear_tab(this, WITHOUT_CONST_TABLES); tab;
|
||||||
tab= next_linear_tab(this, tab, TRUE))
|
tab= next_linear_tab(this, tab, WITH_BUSH_ROOTS))
|
||||||
{
|
{
|
||||||
if (*tab->on_expr_ref)
|
if (*tab->on_expr_ref)
|
||||||
{
|
{
|
||||||
@ -1051,8 +1051,8 @@ JOIN::optimize()
|
|||||||
Perform the optimization on fields evaliation mentioned above
|
Perform the optimization on fields evaliation mentioned above
|
||||||
for all used ref items.
|
for all used ref items.
|
||||||
*/
|
*/
|
||||||
for (JOIN_TAB *tab= first_linear_tab(this, TRUE); tab;
|
for (JOIN_TAB *tab= first_linear_tab(this, WITHOUT_CONST_TABLES); tab;
|
||||||
tab= next_linear_tab(this, tab, TRUE))
|
tab= next_linear_tab(this, tab, WITH_BUSH_ROOTS))
|
||||||
{
|
{
|
||||||
uint key_copy_index=0;
|
uint key_copy_index=0;
|
||||||
for (uint i=0; i < tab->ref.key_parts; i++)
|
for (uint i=0; i < tab->ref.key_parts; i++)
|
||||||
@ -1606,9 +1606,8 @@ bool JOIN::setup_subquery_caches()
|
|||||||
if (conds)
|
if (conds)
|
||||||
conds= conds->transform(&Item::expr_cache_insert_transformer,
|
conds= conds->transform(&Item::expr_cache_insert_transformer,
|
||||||
(uchar*) thd);
|
(uchar*) thd);
|
||||||
for (JOIN_TAB *tab= first_linear_tab(this, TRUE);
|
for (JOIN_TAB *tab= first_linear_tab(this, WITHOUT_CONST_TABLES);
|
||||||
tab;
|
tab; tab= next_linear_tab(this, tab, WITH_BUSH_ROOTS))
|
||||||
tab= next_linear_tab(this, tab, TRUE))
|
|
||||||
{
|
{
|
||||||
if (tab->select_cond)
|
if (tab->select_cond)
|
||||||
tab->select_cond=
|
tab->select_cond=
|
||||||
@ -6363,10 +6362,10 @@ prev_record_reads(JOIN *join, uint idx, table_map found_ref)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
JOIN_TAB *first_linear_tab(JOIN *join, bool after_const_tables)
|
JOIN_TAB *first_linear_tab(JOIN *join, enum enum_with_const_tables const_tbls)
|
||||||
{
|
{
|
||||||
JOIN_TAB *first= join->join_tab;
|
JOIN_TAB *first= join->join_tab;
|
||||||
if (after_const_tables)
|
if (const_tbls == WITHOUT_CONST_TABLES)
|
||||||
first+= join->const_tables;
|
first+= join->const_tables;
|
||||||
if (first < join->join_tab + join->top_jtrange_tables)
|
if (first < join->join_tab + join->top_jtrange_tables)
|
||||||
return first;
|
return first;
|
||||||
@ -6402,9 +6401,10 @@ JOIN_TAB *first_linear_tab(JOIN *join, bool after_const_tables)
|
|||||||
(note that sjm1 won't be returned).
|
(note that sjm1 won't be returned).
|
||||||
*/
|
*/
|
||||||
|
|
||||||
JOIN_TAB *next_linear_tab(JOIN* join, JOIN_TAB* tab, bool include_bush_roots)
|
JOIN_TAB *next_linear_tab(JOIN* join, JOIN_TAB* tab,
|
||||||
|
enum enum_with_bush_roots include_bush_roots)
|
||||||
{
|
{
|
||||||
if (include_bush_roots && tab->bush_children)
|
if (include_bush_roots == WITH_BUSH_ROOTS && tab->bush_children)
|
||||||
{
|
{
|
||||||
/* This JOIN_TAB is a SJM nest; Start from first table in nest */
|
/* This JOIN_TAB is a SJM nest; Start from first table in nest */
|
||||||
return tab->bush_children->start;
|
return tab->bush_children->start;
|
||||||
@ -6425,7 +6425,7 @@ JOIN_TAB *next_linear_tab(JOIN* join, JOIN_TAB* tab, bool include_bush_roots)
|
|||||||
if (++tab == join->join_tab + join->top_jtrange_tables)
|
if (++tab == join->join_tab + join->top_jtrange_tables)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (!include_bush_roots && tab->bush_children)
|
if (include_bush_roots == WITHOUT_BUSH_ROOTS && tab->bush_children)
|
||||||
{
|
{
|
||||||
/* This JOIN_TAB is a SJM nest; Start from first table in nest */
|
/* This JOIN_TAB is a SJM nest; Start from first table in nest */
|
||||||
tab= tab->bush_children->start;
|
tab= tab->bush_children->start;
|
||||||
@ -7118,9 +7118,9 @@ static void add_not_null_conds(JOIN *join)
|
|||||||
{
|
{
|
||||||
DBUG_ENTER("add_not_null_conds");
|
DBUG_ENTER("add_not_null_conds");
|
||||||
|
|
||||||
for (JOIN_TAB *tab= first_linear_tab(join, TRUE);
|
for (JOIN_TAB *tab= first_linear_tab(join, WITHOUT_CONST_TABLES);
|
||||||
tab;
|
tab;
|
||||||
tab= next_linear_tab(join, tab, TRUE))
|
tab= next_linear_tab(join, tab, WITH_BUSH_ROOTS))
|
||||||
{
|
{
|
||||||
if (tab->type == JT_REF || tab->type == JT_EQ_REF ||
|
if (tab->type == JT_REF || tab->type == JT_EQ_REF ||
|
||||||
tab->type == JT_REF_OR_NULL)
|
tab->type == JT_REF_OR_NULL)
|
||||||
@ -7250,8 +7250,8 @@ static void
|
|||||||
make_outerjoin_info(JOIN *join)
|
make_outerjoin_info(JOIN *join)
|
||||||
{
|
{
|
||||||
DBUG_ENTER("make_outerjoin_info");
|
DBUG_ENTER("make_outerjoin_info");
|
||||||
for (JOIN_TAB *tab= first_linear_tab(join, TRUE); tab;
|
for (JOIN_TAB *tab= first_linear_tab(join, WITHOUT_CONST_TABLES); tab;
|
||||||
tab= next_linear_tab(join, tab, FALSE))
|
tab= next_linear_tab(join, tab, WITHOUT_BUSH_ROOTS))
|
||||||
{
|
{
|
||||||
TABLE *table=tab->table;
|
TABLE *table=tab->table;
|
||||||
/*
|
/*
|
||||||
@ -7354,9 +7354,9 @@ make_join_select(JOIN *join,SQL_SELECT *select,COND *cond)
|
|||||||
add_cond_and_fix(&const_cond, join->join_tab[i].select_cond);
|
add_cond_and_fix(&const_cond, join->join_tab[i].select_cond);
|
||||||
|
|
||||||
DBUG_EXECUTE("where",print_where(const_cond,"constants", QT_ORDINARY););
|
DBUG_EXECUTE("where",print_where(const_cond,"constants", QT_ORDINARY););
|
||||||
for (JOIN_TAB *tab= first_linear_tab(join, TRUE);
|
for (JOIN_TAB *tab= first_linear_tab(join, WITHOUT_CONST_TABLES);
|
||||||
tab;
|
tab;
|
||||||
tab= next_linear_tab(join, tab, FALSE))
|
tab= next_linear_tab(join, tab, WITHOUT_BUSH_ROOTS))
|
||||||
{
|
{
|
||||||
if (*tab->on_expr_ref)
|
if (*tab->on_expr_ref)
|
||||||
{
|
{
|
||||||
@ -7691,9 +7691,9 @@ make_join_select(JOIN *join,SQL_SELECT *select,COND *cond)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/* First push down constant conditions from on expressions */
|
/* First push down constant conditions from on expressions */
|
||||||
for (JOIN_TAB *join_tab= first_linear_tab(join, TRUE);
|
for (JOIN_TAB *join_tab= first_linear_tab(join, WITHOUT_CONST_TABLES);
|
||||||
join_tab;
|
join_tab;
|
||||||
join_tab= next_linear_tab(join, join_tab, FALSE))
|
join_tab= next_linear_tab(join, join_tab, WITHOUT_BUSH_ROOTS))
|
||||||
{
|
{
|
||||||
if (*join_tab->on_expr_ref)
|
if (*join_tab->on_expr_ref)
|
||||||
{
|
{
|
||||||
@ -7730,9 +7730,9 @@ make_join_select(JOIN *join,SQL_SELECT *select,COND *cond)
|
|||||||
|
|
||||||
table_map used_tables2= (join->const_table_map |
|
table_map used_tables2= (join->const_table_map |
|
||||||
OUTER_REF_TABLE_BIT | RAND_TABLE_BIT);
|
OUTER_REF_TABLE_BIT | RAND_TABLE_BIT);
|
||||||
for (JOIN_TAB *tab= first_linear_tab(join, TRUE);
|
for (JOIN_TAB *tab= first_linear_tab(join, WITHOUT_CONST_TABLES);
|
||||||
tab;
|
tab;
|
||||||
tab= next_linear_tab(join, tab, TRUE))
|
tab= next_linear_tab(join, tab, WITH_BUSH_ROOTS))
|
||||||
{
|
{
|
||||||
if (!tab->table)
|
if (!tab->table)
|
||||||
{
|
{
|
||||||
@ -8408,16 +8408,16 @@ void check_join_cache_usage_for_tables(JOIN *join, ulonglong options,
|
|||||||
{
|
{
|
||||||
JOIN_TAB *tab;
|
JOIN_TAB *tab;
|
||||||
|
|
||||||
for (tab= first_linear_tab(join, TRUE);
|
for (tab= first_linear_tab(join, WITHOUT_CONST_TABLES);
|
||||||
tab;
|
tab;
|
||||||
tab= next_linear_tab(join, tab, TRUE))
|
tab= next_linear_tab(join, tab, WITH_BUSH_ROOTS))
|
||||||
{
|
{
|
||||||
tab->used_join_cache_level= join->max_allowed_join_cache_level;
|
tab->used_join_cache_level= join->max_allowed_join_cache_level;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (tab= first_linear_tab(join, TRUE);
|
for (tab= first_linear_tab(join, WITHOUT_CONST_TABLES);
|
||||||
tab;
|
tab;
|
||||||
tab= next_linear_tab(join, tab, TRUE))
|
tab= next_linear_tab(join, tab, WITH_BUSH_ROOTS))
|
||||||
{
|
{
|
||||||
JOIN_TAB *prev_tab;
|
JOIN_TAB *prev_tab;
|
||||||
restart:
|
restart:
|
||||||
@ -8493,16 +8493,16 @@ make_join_readinfo(JOIN *join, ulonglong options, uint no_jbuf_after)
|
|||||||
setup_semijoin_dups_elimination(join, options, no_jbuf_after))
|
setup_semijoin_dups_elimination(join, options, no_jbuf_after))
|
||||||
DBUG_RETURN(TRUE); /* purecov: inspected */
|
DBUG_RETURN(TRUE); /* purecov: inspected */
|
||||||
|
|
||||||
for (tab= first_linear_tab(join, TRUE);
|
for (tab= first_linear_tab(join, WITHOUT_CONST_TABLES);
|
||||||
tab;
|
tab;
|
||||||
tab= next_linear_tab(join, tab, TRUE))
|
tab= next_linear_tab(join, tab, WITH_BUSH_ROOTS))
|
||||||
{
|
{
|
||||||
tab->partial_join_cardinality= 1;
|
tab->partial_join_cardinality= 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (tab= first_linear_tab(join, TRUE), i= join->const_tables;
|
for (tab= first_linear_tab(join, WITHOUT_CONST_TABLES), i= join->const_tables;
|
||||||
tab;
|
tab;
|
||||||
tab= next_linear_tab(join, tab, TRUE))
|
tab= next_linear_tab(join, tab, WITH_BUSH_ROOTS))
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
The approximation below for partial join cardinality is not good because
|
The approximation below for partial join cardinality is not good because
|
||||||
@ -8523,9 +8523,9 @@ make_join_readinfo(JOIN *join, ulonglong options, uint no_jbuf_after)
|
|||||||
|
|
||||||
check_join_cache_usage_for_tables(join, options, no_jbuf_after);
|
check_join_cache_usage_for_tables(join, options, no_jbuf_after);
|
||||||
|
|
||||||
for (tab= first_linear_tab(join, TRUE), i= join->const_tables;
|
for (tab= first_linear_tab(join, WITHOUT_CONST_TABLES), i= join->const_tables;
|
||||||
tab;
|
tab;
|
||||||
tab= next_linear_tab(join, tab, TRUE), i++)
|
tab= next_linear_tab(join, tab, WITH_BUSH_ROOTS), i++)
|
||||||
{
|
{
|
||||||
if (tab->bush_children)
|
if (tab->bush_children)
|
||||||
{
|
{
|
||||||
@ -9017,8 +9017,8 @@ void JOIN::cleanup(bool full)
|
|||||||
|
|
||||||
if (full)
|
if (full)
|
||||||
{
|
{
|
||||||
for (tab= first_linear_tab(this, FALSE); tab;
|
for (tab= first_linear_tab(this, WITH_CONST_TABLES); tab;
|
||||||
tab= next_linear_tab(this, tab, TRUE))
|
tab= next_linear_tab(this, tab, WITH_BUSH_ROOTS))
|
||||||
{
|
{
|
||||||
tab->cleanup();
|
tab->cleanup();
|
||||||
}
|
}
|
||||||
@ -9026,8 +9026,8 @@ void JOIN::cleanup(bool full)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (tab= first_linear_tab(this, FALSE); tab;
|
for (tab= first_linear_tab(this, WITH_CONST_TABLES); tab;
|
||||||
tab= next_linear_tab(this, tab, TRUE))
|
tab= next_linear_tab(this, tab, WITH_BUSH_ROOTS))
|
||||||
{
|
{
|
||||||
if (tab->table)
|
if (tab->table)
|
||||||
tab->table->file->ha_index_or_rnd_end();
|
tab->table->file->ha_index_or_rnd_end();
|
||||||
|
@ -1048,9 +1048,12 @@ private:
|
|||||||
void cleanup_item_list(List<Item> &items) const;
|
void cleanup_item_list(List<Item> &items) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum enum_with_bush_roots { WITH_BUSH_ROOTS, WITHOUT_BUSH_ROOTS};
|
||||||
|
enum enum_with_const_tables { WITH_CONST_TABLES, WITHOUT_CONST_TABLES};
|
||||||
|
|
||||||
JOIN_TAB *first_linear_tab(JOIN *join, bool after_const_tables);
|
JOIN_TAB *first_linear_tab(JOIN *join, enum enum_with_const_tables const_tbls);
|
||||||
JOIN_TAB *next_linear_tab(JOIN* join, JOIN_TAB* tab, bool include_bush_roots);
|
JOIN_TAB *next_linear_tab(JOIN* join, JOIN_TAB* tab,
|
||||||
|
enum enum_with_bush_roots include_bush_roots);
|
||||||
|
|
||||||
typedef struct st_select_check {
|
typedef struct st_select_check {
|
||||||
uint const_ref,reg_ref;
|
uint const_ref,reg_ref;
|
||||||
|
@ -6606,9 +6606,9 @@ bool get_schema_tables_result(JOIN *join,
|
|||||||
DBUG_ENTER("get_schema_tables_result");
|
DBUG_ENTER("get_schema_tables_result");
|
||||||
|
|
||||||
thd->no_warnings_for_error= 1;
|
thd->no_warnings_for_error= 1;
|
||||||
for (JOIN_TAB *tab= first_linear_tab(join, FALSE);
|
for (JOIN_TAB *tab= first_linear_tab(join, WITH_CONST_TABLES);
|
||||||
tab;
|
tab;
|
||||||
tab= next_linear_tab(join, tab, FALSE))
|
tab= next_linear_tab(join, tab, WITHOUT_BUSH_ROOTS))
|
||||||
{
|
{
|
||||||
if (!tab->table || !tab->table->pos_in_table_list)
|
if (!tab->table || !tab->table->pos_in_table_list)
|
||||||
break;
|
break;
|
||||||
|
Reference in New Issue
Block a user