1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-08 11:22:35 +03:00

cleanup: style fixes, sql_join_cache.cc

This commit is contained in:
Sergei Golubchik
2017-02-01 16:41:17 +01:00
parent 8246b0ac50
commit 5d7607f340
4 changed files with 291 additions and 296 deletions

View File

@@ -5609,7 +5609,7 @@ set join_cache_level = default;
set optimizer_switch=@tmp_optimizer_switch; set optimizer_switch=@tmp_optimizer_switch;
DROP TABLE t1,t2,t3; DROP TABLE t1,t2,t3;
# #
# Bug #925985: LEFT JOIN with optimize_join_buffer_size=off + # lp:925985 LEFT JOIN with optimize_join_buffer_size=off +
# join_buffer_size > join_buffer_space_limit # join_buffer_size > join_buffer_space_limit
# #
CREATE TABLE t1 (a int); CREATE TABLE t1 (a int);

View File

@@ -3587,7 +3587,7 @@ set optimizer_switch=@tmp_optimizer_switch;
DROP TABLE t1,t2,t3; DROP TABLE t1,t2,t3;
--echo # --echo #
--echo # Bug #925985: LEFT JOIN with optimize_join_buffer_size=off + --echo # lp:925985 LEFT JOIN with optimize_join_buffer_size=off +
--echo # join_buffer_size > join_buffer_space_limit --echo # join_buffer_size > join_buffer_space_limit
--echo # --echo #

View File

@@ -1376,7 +1376,8 @@ uint JOIN_CACHE::write_record_data(uchar * link, bool *is_full)
if (copy->referenced_field_no) if (copy->referenced_field_no)
copy->offset= cp-curr_rec_pos; copy->offset= cp-curr_rec_pos;
if (copy->type == CACHE_BLOB) switch (copy->type) {
case CACHE_BLOB:
{ {
Field_blob *blob_field= (Field_blob *) copy->field; Field_blob *blob_field= (Field_blob *) copy->field;
if (last_record) if (last_record)
@@ -1397,10 +1398,8 @@ uint JOIN_CACHE::write_record_data(uchar * link, bool *is_full)
memcpy(cp+copy->length, copy->str, copy->blob_length); memcpy(cp+copy->length, copy->str, copy->blob_length);
cp+= copy->length+copy->blob_length; cp+= copy->length+copy->blob_length;
} }
break;
} }
else
{
switch (copy->type) {
case CACHE_VARSTR1: case CACHE_VARSTR1:
/* Copy the significant part of the short varstring field */ /* Copy the significant part of the short varstring field */
len= (uint) copy->str[0] + 1; len= (uint) copy->str[0] + 1;
@@ -1461,7 +1460,6 @@ uint JOIN_CACHE::write_record_data(uchar * link, bool *is_full)
cp+= copy->length; cp+= copy->length;
} }
} }
}
/* Add the offsets of the fields that are referenced from other caches */ /* Add the offsets of the fields that are referenced from other caches */
if (referenced_fields) if (referenced_fields)
@@ -1717,7 +1715,7 @@ uint JOIN_CACHE::aux_buffer_incr(ulong recno)
The function reads all flag and data fields of a record from the join The function reads all flag and data fields of a record from the join
buffer into the corresponding record buffers. buffer into the corresponding record buffers.
The fields are read starting from the position 'pos' which is The fields are read starting from the position 'pos' which is
supposed to point to the beginning og the first record field. supposed to point to the beginning of the first record field.
The function increments the value of 'pos' by the length of the The function increments the value of 'pos' by the length of the
read data. read data.
@@ -1811,7 +1809,8 @@ uint JOIN_CACHE::read_record_field(CACHE_FIELD *copy, bool blob_in_rec_buff)
/* Do not copy the field if its value is null */ /* Do not copy the field if its value is null */
if (copy->field && copy->field->maybe_null() && copy->field->is_null()) if (copy->field && copy->field->maybe_null() && copy->field->is_null())
return 0; return 0;
if (copy->type == CACHE_BLOB) switch (copy->type) {
case CACHE_BLOB:
{ {
Field_blob *blob_field= (Field_blob *) copy->field; Field_blob *blob_field= (Field_blob *) copy->field;
/* /*
@@ -1830,9 +1829,7 @@ uint JOIN_CACHE::read_record_field(CACHE_FIELD *copy, bool blob_in_rec_buff)
len= copy->length + blob_field->get_length(); len= copy->length + blob_field->get_length();
} }
} }
else break;
{
switch (copy->type) {
case CACHE_VARSTR1: case CACHE_VARSTR1:
/* Copy the significant part of the short varstring field */ /* Copy the significant part of the short varstring field */
len= (uint) pos[0] + 1; len= (uint) pos[0] + 1;
@@ -1862,7 +1859,6 @@ uint JOIN_CACHE::read_record_field(CACHE_FIELD *copy, bool blob_in_rec_buff)
len= copy->length; len= copy->length;
memcpy(copy->str, pos, len); memcpy(copy->str, pos, len);
} }
}
pos+= len; pos+= len;
return len; return len;
} }
@@ -2718,7 +2714,7 @@ int JOIN_CACHE_HASHED::init(bool for_explain)
data_fields_offset+= copy->length; data_fields_offset+= copy->length;
} }
DBUG_RETURN(rc); DBUG_RETURN(0);
} }
@@ -4222,8 +4218,7 @@ bool check_only_first_match= join_tab->check_only_first_match();
RANGE_SEQ_IF rs_funcs= { bka_range_seq_key_info, RANGE_SEQ_IF rs_funcs= { bka_range_seq_key_info,
bka_range_seq_init, bka_range_seq_init,
bka_range_seq_next, bka_range_seq_next,
check_only_first_match ? check_only_first_match ? bka_range_seq_skip_record : 0,
bka_range_seq_skip_record : 0,
bka_skip_index_tuple }; bka_skip_index_tuple };
DBUG_ENTER("JOIN_CACHE_BKA::init"); DBUG_ENTER("JOIN_CACHE_BKA::init");
@@ -4513,8 +4508,7 @@ RETURN VALUE
*/ */
static static
bool bkah_range_seq_skip_record(range_seq_t rseq, range_id_t range_info, bool bkah_range_seq_skip_record(range_seq_t rseq, range_id_t range_info, uchar *rowid)
uchar *rowid)
{ {
DBUG_ENTER("bkah_range_seq_skip_record"); DBUG_ENTER("bkah_range_seq_skip_record");
JOIN_CACHE_BKAH *cache= (JOIN_CACHE_BKAH *) rseq; JOIN_CACHE_BKAH *cache= (JOIN_CACHE_BKAH *) rseq;

View File

@@ -10752,6 +10752,7 @@ uint check_join_cache_usage(JOIN_TAB *tab,
uint bufsz= 4096; uint bufsz= 4096;
JOIN_CACHE *prev_cache=0; JOIN_CACHE *prev_cache=0;
JOIN *join= tab->join; JOIN *join= tab->join;
MEM_ROOT *root= join->thd->mem_root;
uint cache_level= tab->used_join_cache_level; uint cache_level= tab->used_join_cache_level;
bool force_unlinked_cache= bool force_unlinked_cache=
!(join->allowed_join_cache_types & JOIN_CACHE_INCREMENTAL_BIT); !(join->allowed_join_cache_types & JOIN_CACHE_INCREMENTAL_BIT);
@@ -10871,7 +10872,7 @@ uint check_join_cache_usage(JOIN_TAB *tab,
case JT_ALL: case JT_ALL:
if (cache_level == 1) if (cache_level == 1)
prev_cache= 0; prev_cache= 0;
if ((tab->cache= new JOIN_CACHE_BNL(join, tab, prev_cache)) && if ((tab->cache= new (root) JOIN_CACHE_BNL(join, tab, prev_cache)) &&
!tab->cache->init(options & SELECT_DESCRIBE)) !tab->cache->init(options & SELECT_DESCRIBE))
{ {
tab->icp_other_tables_ok= FALSE; tab->icp_other_tables_ok= FALSE;
@@ -10906,7 +10907,7 @@ uint check_join_cache_usage(JOIN_TAB *tab,
goto no_join_cache; goto no_join_cache;
if (cache_level == 3) if (cache_level == 3)
prev_cache= 0; prev_cache= 0;
if ((tab->cache= new JOIN_CACHE_BNLH(join, tab, prev_cache)) && if ((tab->cache= new (root) JOIN_CACHE_BNLH(join, tab, prev_cache)) &&
!tab->cache->init(options & SELECT_DESCRIBE)) !tab->cache->init(options & SELECT_DESCRIBE))
{ {
tab->icp_other_tables_ok= FALSE; tab->icp_other_tables_ok= FALSE;
@@ -10927,7 +10928,7 @@ uint check_join_cache_usage(JOIN_TAB *tab,
{ {
if (cache_level == 5) if (cache_level == 5)
prev_cache= 0; prev_cache= 0;
if ((tab->cache= new JOIN_CACHE_BKA(join, tab, flags, prev_cache)) && if ((tab->cache= new (root) JOIN_CACHE_BKA(join, tab, flags, prev_cache)) &&
!tab->cache->init(options & SELECT_DESCRIBE)) !tab->cache->init(options & SELECT_DESCRIBE))
return (6 - MY_TEST(!prev_cache)); return (6 - MY_TEST(!prev_cache));
goto no_join_cache; goto no_join_cache;
@@ -10936,7 +10937,7 @@ uint check_join_cache_usage(JOIN_TAB *tab,
{ {
if (cache_level == 7) if (cache_level == 7)
prev_cache= 0; prev_cache= 0;
if ((tab->cache= new JOIN_CACHE_BKAH(join, tab, flags, prev_cache)) && if ((tab->cache= new (root) JOIN_CACHE_BKAH(join, tab, flags, prev_cache)) &&
!tab->cache->init(options & SELECT_DESCRIBE)) !tab->cache->init(options & SELECT_DESCRIBE))
{ {
tab->idx_cond_fact_out= FALSE; tab->idx_cond_fact_out= FALSE;