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:
@@ -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);
|
||||||
|
@@ -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 #
|
||||||
|
|
||||||
|
@@ -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;
|
||||||
/*
|
/*
|
||||||
@@ -1820,19 +1819,17 @@ uint JOIN_CACHE::read_record_field(CACHE_FIELD *copy, bool blob_in_rec_buff)
|
|||||||
*/
|
*/
|
||||||
if (blob_in_rec_buff)
|
if (blob_in_rec_buff)
|
||||||
{
|
{
|
||||||
blob_field->set_image(pos, copy->length+sizeof(char*),
|
blob_field->set_image(pos, copy->length + sizeof(char*),
|
||||||
blob_field->charset());
|
blob_field->charset());
|
||||||
len= copy->length+sizeof(char*);
|
len= copy->length + sizeof(char*);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
blob_field->set_ptr(pos, pos+copy->length);
|
blob_field->set_ptr(pos, pos+copy->length);
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -3927,9 +3923,9 @@ static
|
|||||||
void bka_range_seq_key_info(void *init_params, uint *length,
|
void bka_range_seq_key_info(void *init_params, uint *length,
|
||||||
key_part_map *map)
|
key_part_map *map)
|
||||||
{
|
{
|
||||||
TABLE_REF *ref= &(((JOIN_CACHE*)init_params)->join_tab->ref);
|
TABLE_REF *ref= &(((JOIN_CACHE*)init_params)->join_tab->ref);
|
||||||
*length= ref->key_length;
|
*length= ref->key_length;
|
||||||
*map= (key_part_map(1) << ref->key_parts) - 1;
|
*map= (key_part_map(1) << ref->key_parts) - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -3957,10 +3953,10 @@ RETURN VALUE
|
|||||||
static
|
static
|
||||||
range_seq_t bka_range_seq_init(void *init_param, uint n_ranges, uint flags)
|
range_seq_t bka_range_seq_init(void *init_param, uint n_ranges, uint flags)
|
||||||
{
|
{
|
||||||
DBUG_ENTER("bka_range_seq_init");
|
DBUG_ENTER("bka_range_seq_init");
|
||||||
JOIN_CACHE_BKA *cache= (JOIN_CACHE_BKA *) init_param;
|
JOIN_CACHE_BKA *cache= (JOIN_CACHE_BKA *) init_param;
|
||||||
cache->reset(0);
|
cache->reset(0);
|
||||||
DBUG_RETURN((range_seq_t) init_param);
|
DBUG_RETURN((range_seq_t) init_param);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -3988,12 +3984,12 @@ RETURN VALUE
|
|||||||
static
|
static
|
||||||
bool bka_range_seq_next(range_seq_t rseq, KEY_MULTI_RANGE *range)
|
bool bka_range_seq_next(range_seq_t rseq, KEY_MULTI_RANGE *range)
|
||||||
{
|
{
|
||||||
DBUG_ENTER("bka_range_seq_next");
|
DBUG_ENTER("bka_range_seq_next");
|
||||||
JOIN_CACHE_BKA *cache= (JOIN_CACHE_BKA *) rseq;
|
JOIN_CACHE_BKA *cache= (JOIN_CACHE_BKA *) rseq;
|
||||||
TABLE_REF *ref= &cache->join_tab->ref;
|
TABLE_REF *ref= &cache->join_tab->ref;
|
||||||
key_range *start_key= &range->start_key;
|
key_range *start_key= &range->start_key;
|
||||||
if ((start_key->length= cache->get_next_key((uchar **) &start_key->key)))
|
if ((start_key->length= cache->get_next_key((uchar **) &start_key->key)))
|
||||||
{
|
{
|
||||||
start_key->keypart_map= (1 << ref->key_parts) - 1;
|
start_key->keypart_map= (1 << ref->key_parts) - 1;
|
||||||
start_key->flag= HA_READ_KEY_EXACT;
|
start_key->flag= HA_READ_KEY_EXACT;
|
||||||
range->end_key= *start_key;
|
range->end_key= *start_key;
|
||||||
@@ -4001,8 +3997,8 @@ if ((start_key->length= cache->get_next_key((uchar **) &start_key->key)))
|
|||||||
range->ptr= (char *) cache->get_curr_rec();
|
range->ptr= (char *) cache->get_curr_rec();
|
||||||
range->range_flag= EQ_RANGE;
|
range->range_flag= EQ_RANGE;
|
||||||
DBUG_RETURN(0);
|
DBUG_RETURN(0);
|
||||||
}
|
}
|
||||||
DBUG_RETURN(1);
|
DBUG_RETURN(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -4034,11 +4030,11 @@ RETURN VALUE
|
|||||||
static
|
static
|
||||||
bool bka_range_seq_skip_record(range_seq_t rseq, range_id_t range_info, uchar *rowid)
|
bool bka_range_seq_skip_record(range_seq_t rseq, range_id_t range_info, uchar *rowid)
|
||||||
{
|
{
|
||||||
DBUG_ENTER("bka_range_seq_skip_record");
|
DBUG_ENTER("bka_range_seq_skip_record");
|
||||||
JOIN_CACHE_BKA *cache= (JOIN_CACHE_BKA *) rseq;
|
JOIN_CACHE_BKA *cache= (JOIN_CACHE_BKA *) rseq;
|
||||||
bool res= cache->get_match_flag_by_pos((uchar *) range_info) ==
|
bool res= cache->get_match_flag_by_pos((uchar *) range_info) ==
|
||||||
JOIN_CACHE::MATCH_FOUND;
|
JOIN_CACHE::MATCH_FOUND;
|
||||||
DBUG_RETURN(res);
|
DBUG_RETURN(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -4065,14 +4061,14 @@ RETURN VALUE
|
|||||||
static
|
static
|
||||||
bool bka_skip_index_tuple(range_seq_t rseq, range_id_t range_info)
|
bool bka_skip_index_tuple(range_seq_t rseq, range_id_t range_info)
|
||||||
{
|
{
|
||||||
DBUG_ENTER("bka_skip_index_tuple");
|
DBUG_ENTER("bka_skip_index_tuple");
|
||||||
JOIN_CACHE_BKA *cache= (JOIN_CACHE_BKA *) rseq;
|
JOIN_CACHE_BKA *cache= (JOIN_CACHE_BKA *) rseq;
|
||||||
THD *thd= cache->thd();
|
THD *thd= cache->thd();
|
||||||
bool res;
|
bool res;
|
||||||
status_var_increment(thd->status_var.ha_icp_attempts);
|
status_var_increment(thd->status_var.ha_icp_attempts);
|
||||||
if (!(res= cache->skip_index_tuple(range_info)))
|
if (!(res= cache->skip_index_tuple(range_info)))
|
||||||
status_var_increment(thd->status_var.ha_icp_match);
|
status_var_increment(thd->status_var.ha_icp_match);
|
||||||
DBUG_RETURN(res);
|
DBUG_RETURN(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -4101,10 +4097,10 @@ RETURN VALUE
|
|||||||
|
|
||||||
bool JOIN_CACHE_BKA::prepare_look_for_matches(bool skip_last)
|
bool JOIN_CACHE_BKA::prepare_look_for_matches(bool skip_last)
|
||||||
{
|
{
|
||||||
if (!records)
|
if (!records)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
rem_records= 1;
|
rem_records= 1;
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -4133,10 +4129,10 @@ RETURN VALUE
|
|||||||
|
|
||||||
uchar *JOIN_CACHE_BKA::get_next_candidate_for_match()
|
uchar *JOIN_CACHE_BKA::get_next_candidate_for_match()
|
||||||
{
|
{
|
||||||
if (!rem_records)
|
if (!rem_records)
|
||||||
return 0;
|
return 0;
|
||||||
rem_records--;
|
rem_records--;
|
||||||
return curr_association;
|
return curr_association;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -4161,7 +4157,7 @@ RETURN VALUE
|
|||||||
|
|
||||||
bool JOIN_CACHE_BKA::skip_next_candidate_for_match(uchar *rec_ptr)
|
bool JOIN_CACHE_BKA::skip_next_candidate_for_match(uchar *rec_ptr)
|
||||||
{
|
{
|
||||||
return join_tab->check_only_first_match() &&
|
return join_tab->check_only_first_match() &&
|
||||||
(get_match_flag_by_pos(rec_ptr) == MATCH_FOUND);
|
(get_match_flag_by_pos(rec_ptr) == MATCH_FOUND);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4189,7 +4185,7 @@ RETURN VALUE
|
|||||||
|
|
||||||
void JOIN_CACHE_BKA::read_next_candidate_for_match(uchar *rec_ptr)
|
void JOIN_CACHE_BKA::read_next_candidate_for_match(uchar *rec_ptr)
|
||||||
{
|
{
|
||||||
get_record_by_pos(rec_ptr);
|
get_record_by_pos(rec_ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -4216,30 +4212,29 @@ RETURN VALUE
|
|||||||
|
|
||||||
int JOIN_CACHE_BKA::init(bool for_explain)
|
int JOIN_CACHE_BKA::init(bool for_explain)
|
||||||
{
|
{
|
||||||
int res;
|
int res;
|
||||||
bool check_only_first_match= join_tab->check_only_first_match();
|
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");
|
||||||
|
|
||||||
JOIN_TAB_SCAN_MRR *jsm;
|
JOIN_TAB_SCAN_MRR *jsm;
|
||||||
if (!(join_tab_scan= jsm= new JOIN_TAB_SCAN_MRR(join, join_tab,
|
if (!(join_tab_scan= jsm= new JOIN_TAB_SCAN_MRR(join, join_tab,
|
||||||
mrr_mode, rs_funcs)))
|
mrr_mode, rs_funcs)))
|
||||||
DBUG_RETURN(1);
|
DBUG_RETURN(1);
|
||||||
|
|
||||||
if ((res= JOIN_CACHE::init(for_explain)))
|
if ((res= JOIN_CACHE::init(for_explain)))
|
||||||
DBUG_RETURN(res);
|
DBUG_RETURN(res);
|
||||||
|
|
||||||
if (use_emb_key)
|
if (use_emb_key)
|
||||||
jsm->mrr_mode |= HA_MRR_MATERIALIZED_KEYS;
|
jsm->mrr_mode |= HA_MRR_MATERIALIZED_KEYS;
|
||||||
|
|
||||||
DBUG_RETURN(0);
|
DBUG_RETURN(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -4278,48 +4273,48 @@ RETURN VALUE
|
|||||||
|
|
||||||
uint JOIN_CACHE_BKA::get_next_key(uchar ** key)
|
uint JOIN_CACHE_BKA::get_next_key(uchar ** key)
|
||||||
{
|
{
|
||||||
uint len;
|
uint len;
|
||||||
uint32 rec_len;
|
uint32 rec_len;
|
||||||
uchar *init_pos;
|
uchar *init_pos;
|
||||||
JOIN_CACHE *cache;
|
JOIN_CACHE *cache;
|
||||||
|
|
||||||
start:
|
start:
|
||||||
|
|
||||||
/* Any record in a BKA cache is prepended with its length */
|
/* Any record in a BKA cache is prepended with its length */
|
||||||
DBUG_ASSERT(with_length);
|
DBUG_ASSERT(with_length);
|
||||||
|
|
||||||
if ((pos+size_of_rec_len) > last_rec_pos || !records)
|
if ((pos+size_of_rec_len) > last_rec_pos || !records)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
/* Read the length of the record */
|
/* Read the length of the record */
|
||||||
rec_len= get_rec_length(pos);
|
rec_len= get_rec_length(pos);
|
||||||
pos+= size_of_rec_len;
|
pos+= size_of_rec_len;
|
||||||
init_pos= pos;
|
init_pos= pos;
|
||||||
|
|
||||||
/* Read a reference to the previous cache if any */
|
/* Read a reference to the previous cache if any */
|
||||||
if (prev_cache)
|
if (prev_cache)
|
||||||
pos+= prev_cache->get_size_of_rec_offset();
|
pos+= prev_cache->get_size_of_rec_offset();
|
||||||
|
|
||||||
curr_rec_pos= pos;
|
curr_rec_pos= pos;
|
||||||
|
|
||||||
/* Read all flag fields of the record */
|
/* Read all flag fields of the record */
|
||||||
read_flag_fields();
|
read_flag_fields();
|
||||||
|
|
||||||
if (with_match_flag &&
|
if (with_match_flag &&
|
||||||
(Match_flag) curr_rec_pos[0] == MATCH_IMPOSSIBLE )
|
(Match_flag) curr_rec_pos[0] == MATCH_IMPOSSIBLE )
|
||||||
{
|
{
|
||||||
pos= init_pos+rec_len;
|
pos= init_pos+rec_len;
|
||||||
goto start;
|
goto start;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (use_emb_key)
|
if (use_emb_key)
|
||||||
{
|
{
|
||||||
/* An embedded key is taken directly from the join buffer */
|
/* An embedded key is taken directly from the join buffer */
|
||||||
*key= pos;
|
*key= pos;
|
||||||
len= emb_key_length;
|
len= emb_key_length;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Read key arguments from previous caches if there are any such fields */
|
/* Read key arguments from previous caches if there are any such fields */
|
||||||
if (external_key_arg_fields)
|
if (external_key_arg_fields)
|
||||||
{
|
{
|
||||||
@@ -4361,11 +4356,11 @@ else
|
|||||||
cp_buffer_from_ref(join->thd, join_tab->table, ref);
|
cp_buffer_from_ref(join->thd, join_tab->table, ref);
|
||||||
*key= ref->key_buff;
|
*key= ref->key_buff;
|
||||||
len= ref->key_length;
|
len= ref->key_length;
|
||||||
}
|
}
|
||||||
|
|
||||||
pos= init_pos+rec_len;
|
pos= init_pos+rec_len;
|
||||||
|
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -4407,9 +4402,9 @@ RETURN VALUE
|
|||||||
|
|
||||||
bool JOIN_CACHE_BKA::skip_index_tuple(range_id_t range_info)
|
bool JOIN_CACHE_BKA::skip_index_tuple(range_id_t range_info)
|
||||||
{
|
{
|
||||||
DBUG_ENTER("JOIN_CACHE_BKA::skip_index_tuple");
|
DBUG_ENTER("JOIN_CACHE_BKA::skip_index_tuple");
|
||||||
get_record_by_pos((uchar*)range_info);
|
get_record_by_pos((uchar*)range_info);
|
||||||
DBUG_RETURN(!join_tab->cache_idx_cond->val_int());
|
DBUG_RETURN(!join_tab->cache_idx_cond->val_int());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -4439,10 +4434,10 @@ RETURN VALUE
|
|||||||
static
|
static
|
||||||
range_seq_t bkah_range_seq_init(void *init_param, uint n_ranges, uint flags)
|
range_seq_t bkah_range_seq_init(void *init_param, uint n_ranges, uint flags)
|
||||||
{
|
{
|
||||||
DBUG_ENTER("bkah_range_seq_init");
|
DBUG_ENTER("bkah_range_seq_init");
|
||||||
JOIN_CACHE_BKAH *cache= (JOIN_CACHE_BKAH *) init_param;
|
JOIN_CACHE_BKAH *cache= (JOIN_CACHE_BKAH *) init_param;
|
||||||
cache->reset(0);
|
cache->reset(0);
|
||||||
DBUG_RETURN((range_seq_t) init_param);
|
DBUG_RETURN((range_seq_t) init_param);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -4470,12 +4465,12 @@ RETURN VALUE
|
|||||||
static
|
static
|
||||||
bool bkah_range_seq_next(range_seq_t rseq, KEY_MULTI_RANGE *range)
|
bool bkah_range_seq_next(range_seq_t rseq, KEY_MULTI_RANGE *range)
|
||||||
{
|
{
|
||||||
DBUG_ENTER("bkah_range_seq_next");
|
DBUG_ENTER("bkah_range_seq_next");
|
||||||
JOIN_CACHE_BKAH *cache= (JOIN_CACHE_BKAH *) rseq;
|
JOIN_CACHE_BKAH *cache= (JOIN_CACHE_BKAH *) rseq;
|
||||||
TABLE_REF *ref= &cache->join_tab->ref;
|
TABLE_REF *ref= &cache->join_tab->ref;
|
||||||
key_range *start_key= &range->start_key;
|
key_range *start_key= &range->start_key;
|
||||||
if ((start_key->length= cache->get_next_key((uchar **) &start_key->key)))
|
if ((start_key->length= cache->get_next_key((uchar **) &start_key->key)))
|
||||||
{
|
{
|
||||||
start_key->keypart_map= (1 << ref->key_parts) - 1;
|
start_key->keypart_map= (1 << ref->key_parts) - 1;
|
||||||
start_key->flag= HA_READ_KEY_EXACT;
|
start_key->flag= HA_READ_KEY_EXACT;
|
||||||
range->end_key= *start_key;
|
range->end_key= *start_key;
|
||||||
@@ -4483,8 +4478,8 @@ if ((start_key->length= cache->get_next_key((uchar **) &start_key->key)))
|
|||||||
range->ptr= (char *) cache->get_curr_key_chain();
|
range->ptr= (char *) cache->get_curr_key_chain();
|
||||||
range->range_flag= EQ_RANGE;
|
range->range_flag= EQ_RANGE;
|
||||||
DBUG_RETURN(0);
|
DBUG_RETURN(0);
|
||||||
}
|
}
|
||||||
DBUG_RETURN(1);
|
DBUG_RETURN(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -4513,13 +4508,12 @@ 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;
|
||||||
bool res= cache->check_all_match_flags_for_key((uchar *) range_info);
|
bool res= cache->check_all_match_flags_for_key((uchar *) range_info);
|
||||||
DBUG_RETURN(res);
|
DBUG_RETURN(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -4546,14 +4540,14 @@ RETURN VALUE
|
|||||||
static
|
static
|
||||||
bool bkah_skip_index_tuple(range_seq_t rseq, range_id_t range_info)
|
bool bkah_skip_index_tuple(range_seq_t rseq, range_id_t range_info)
|
||||||
{
|
{
|
||||||
DBUG_ENTER("bka_unique_skip_index_tuple");
|
DBUG_ENTER("bka_unique_skip_index_tuple");
|
||||||
JOIN_CACHE_BKAH *cache= (JOIN_CACHE_BKAH *) rseq;
|
JOIN_CACHE_BKAH *cache= (JOIN_CACHE_BKAH *) rseq;
|
||||||
THD *thd= cache->thd();
|
THD *thd= cache->thd();
|
||||||
bool res;
|
bool res;
|
||||||
status_var_increment(thd->status_var.ha_icp_attempts);
|
status_var_increment(thd->status_var.ha_icp_attempts);
|
||||||
if (!(res= cache->skip_index_tuple(range_info)))
|
if (!(res= cache->skip_index_tuple(range_info)))
|
||||||
status_var_increment(thd->status_var.ha_icp_match);
|
status_var_increment(thd->status_var.ha_icp_match);
|
||||||
DBUG_RETURN(res);
|
DBUG_RETURN(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -4581,8 +4575,8 @@ RETURN VALUE
|
|||||||
|
|
||||||
bool JOIN_CACHE_BKAH::prepare_look_for_matches(bool skip_last)
|
bool JOIN_CACHE_BKAH::prepare_look_for_matches(bool skip_last)
|
||||||
{
|
{
|
||||||
last_matching_rec_ref_ptr= next_matching_rec_ref_ptr= 0;
|
last_matching_rec_ref_ptr= next_matching_rec_ref_ptr= 0;
|
||||||
if (no_association &&
|
if (no_association &&
|
||||||
!(curr_matching_chain= get_matching_chain_by_join_key())) //psergey: added '!'
|
!(curr_matching_chain= get_matching_chain_by_join_key())) //psergey: added '!'
|
||||||
return 1;
|
return 1;
|
||||||
last_matching_rec_ref_ptr= get_next_rec_ref(curr_matching_chain);
|
last_matching_rec_ref_ptr= get_next_rec_ref(curr_matching_chain);
|
||||||
|
@@ -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;
|
||||||
|
Reference in New Issue
Block a user