summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorIgor Babaev <igor@askmonty.org>2014-06-10 12:45:20 -0700
committerIgor Babaev <igor@askmonty.org>2014-06-10 12:45:20 -0700
commit1f7e68044cf9d615a877b2da2df6005c12a7b04a (patch)
tree2d1e22ea5050aee766fded6ae553c53714415c39 /sql
parent6b84ecdc3791c6e73359bf695496d0b0f42daff6 (diff)
parentd42e6d3a9966803336a3edbb356d344647b31b98 (diff)
downloadmariadb-git-1f7e68044cf9d615a877b2da2df6005c12a7b04a.tar.gz
Merge.
Diffstat (limited to 'sql')
-rw-r--r--sql/sql_join_cache.cc36
-rw-r--r--sql/sql_join_cache.h15
-rw-r--r--sql/sql_select.cc8
3 files changed, 37 insertions, 22 deletions
diff --git a/sql/sql_join_cache.cc b/sql/sql_join_cache.cc
index abd23c344c2..cab9628837c 100644
--- a/sql/sql_join_cache.cc
+++ b/sql/sql_join_cache.cc
@@ -929,6 +929,9 @@ int JOIN_CACHE::alloc_buffer()
join->shrink_join_buffers(join_tab, curr_buff_space_sz,
join_buff_space_limit))))
goto fail;
+
+ if (for_explain_only)
+ return 0;
for (ulong buff_size_decr= (buff_size-min_buff_size)/4 + 1; ; )
{
@@ -1023,6 +1026,7 @@ int JOIN_CACHE::realloc_buffer()
SYNOPSIS
init()
+ for_explain join buffer is initialized for explain only
DESCRIPTION
The function initializes the join cache structure. It supposed to be called
@@ -1044,10 +1048,12 @@ int JOIN_CACHE::realloc_buffer()
1 otherwise
*/
-int JOIN_CACHE::init()
+int JOIN_CACHE::init(bool for_explain)
{
DBUG_ENTER("JOIN_CACHE::init");
+ for_explain_only= for_explain;
+
calc_record_fields();
collect_info_on_key_args();
@@ -2632,6 +2638,7 @@ void JOIN_CACHE_BKAH::save_explain_data(struct st_explain_bka_type *explain)
SYNOPSIS
init()
+ for_explain join buffer is initialized for explain only
DESCRIPTION
The function initializes the cache structure with a hash table in it.
@@ -2651,7 +2658,7 @@ void JOIN_CACHE_BKAH::save_explain_data(struct st_explain_bka_type *explain)
1 otherwise
*/
-int JOIN_CACHE_HASHED::init()
+int JOIN_CACHE_HASHED::init(bool for_explain)
{
int rc= 0;
TABLE_REF *ref= &join_tab->ref;
@@ -2663,8 +2670,8 @@ int JOIN_CACHE_HASHED::init()
key_length= ref->key_length;
- if ((rc= JOIN_CACHE::init()))
- DBUG_RETURN (rc);
+ if ((rc= JOIN_CACHE::init(for_explain)) || for_explain)
+ DBUG_RETURN (rc);
if (!(key_buff= (uchar*) sql_alloc(key_length)))
DBUG_RETURN(1);
@@ -3572,6 +3579,7 @@ void JOIN_CACHE_BNL::read_next_candidate_for_match(uchar *rec_ptr)
SYNOPSIS
init
+ for_explain join buffer is initialized for explain only
DESCRIPTION
The function initializes the cache structure. It is supposed to be called
@@ -3586,14 +3594,14 @@ void JOIN_CACHE_BNL::read_next_candidate_for_match(uchar *rec_ptr)
1 otherwise
*/
-int JOIN_CACHE_BNL::init()
+int JOIN_CACHE_BNL::init(bool for_explain)
{
DBUG_ENTER("JOIN_CACHE_BNL::init");
if (!(join_tab_scan= new JOIN_TAB_SCAN(join, join_tab)))
DBUG_RETURN(1);
- DBUG_RETURN(JOIN_CACHE::init());
+ DBUG_RETURN(JOIN_CACHE::init(for_explain));
}
@@ -3758,6 +3766,7 @@ void JOIN_CACHE_BNLH::read_next_candidate_for_match(uchar *rec_ptr)
SYNOPSIS
init
+ for_explain join buffer is initialized for explain only
DESCRIPTION
The function initializes the cache structure. It is supposed to be called
@@ -3772,14 +3781,14 @@ void JOIN_CACHE_BNLH::read_next_candidate_for_match(uchar *rec_ptr)
1 otherwise
*/
-int JOIN_CACHE_BNLH::init()
+int JOIN_CACHE_BNLH::init(bool for_explain)
{
DBUG_ENTER("JOIN_CACHE_BNLH::init");
if (!(join_tab_scan= new JOIN_TAB_SCAN(join, join_tab)))
DBUG_RETURN(1);
- DBUG_RETURN(JOIN_CACHE_HASHED::init());
+ DBUG_RETURN(JOIN_CACHE_HASHED::init(for_explain));
}
@@ -4176,6 +4185,8 @@ Initialize the BKA join cache
SYNOPSIS
init
+ for_explain join buffer is initialized for explain only
+
DESCRIPTION
The function initializes the cache structure. It is supposed to be called
@@ -4190,7 +4201,7 @@ RETURN VALUE
1 otherwise
*/
-int JOIN_CACHE_BKA::init()
+int JOIN_CACHE_BKA::init(bool for_explain)
{
int res;
bool check_only_first_match= join_tab->check_only_first_match();
@@ -4209,7 +4220,7 @@ if (!(join_tab_scan= jsm= new JOIN_TAB_SCAN_MRR(join, join_tab,
mrr_mode, rs_funcs)))
DBUG_RETURN(1);
-if ((res= JOIN_CACHE::init()))
+if ((res= JOIN_CACHE::init(for_explain)))
DBUG_RETURN(res);
if (use_emb_key)
@@ -4570,6 +4581,7 @@ if (no_association &&
SYNOPSIS
init
+ for_explain join buffer is initialized for explain only
DESCRIPTION
The function initializes the cache structure. It is supposed to be called
@@ -4584,7 +4596,7 @@ if (no_association &&
1 otherwise
*/
-int JOIN_CACHE_BKAH::init()
+int JOIN_CACHE_BKAH::init(bool for_explain)
{
bool check_only_first_match= join_tab->check_only_first_match();
@@ -4603,7 +4615,7 @@ int JOIN_CACHE_BKAH::init()
mrr_mode, rs_funcs)))
DBUG_RETURN(1);
- DBUG_RETURN(JOIN_CACHE_HASHED::init());
+ DBUG_RETURN(JOIN_CACHE_HASHED::init(for_explain));
}
diff --git a/sql/sql_join_cache.h b/sql/sql_join_cache.h
index 568cc91ecf7..a3e69f92e34 100644
--- a/sql/sql_join_cache.h
+++ b/sql/sql_join_cache.h
@@ -99,6 +99,9 @@ private:
/* Size of the offset of a field within a record in the cache */
uint size_of_fld_ofs;
+ /* This structure is used only for explain, not for execution */
+ bool for_explain_only;
+
protected:
/* 3 functions below actually do not use the hidden parameter 'this' */
@@ -595,7 +598,7 @@ public:
JOIN_CACHE *next_cache;
/* Shall initialize the join cache structure */
- virtual int init();
+ virtual int init(bool for_explain);
/* Get the current size of the cache join buffer */
size_t get_join_buffer_size() { return buff_size; }
@@ -991,7 +994,7 @@ protected:
public:
/* Initialize a hashed join cache */
- int init();
+ int init(bool for_explain);
/* Reset the buffer of a hashed join cache for reading/writing */
void reset(bool for_writing);
@@ -1127,7 +1130,7 @@ public:
:JOIN_CACHE(j, tab, prev) {}
/* Initialize the BNL cache */
- int init();
+ int init(bool for_explain);
enum Join_algorithm get_join_alg() { return BNL_JOIN_ALG; }
@@ -1194,7 +1197,7 @@ public:
: JOIN_CACHE_HASHED(j, tab, prev) {}
/* Initialize the BNLH cache */
- int init();
+ int init(bool for_explain);
enum Join_algorithm get_join_alg() { return BNLH_JOIN_ALG; }
@@ -1325,7 +1328,7 @@ public:
uchar **get_curr_association_ptr() { return &curr_association; }
/* Initialize the BKA cache */
- int init();
+ int init(bool for_explain);
enum Join_algorithm get_join_alg() { return BKA_JOIN_ALG; }
@@ -1421,7 +1424,7 @@ public:
uchar **get_curr_association_ptr() { return &curr_matching_chain; }
/* Initialize the BKAH cache */
- int init();
+ int init(bool for_explain);
enum Join_algorithm get_join_alg() { return BKAH_JOIN_ALG; }
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 692138fcddd..c0afaec6e0f 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -10542,7 +10542,7 @@ uint check_join_cache_usage(JOIN_TAB *tab,
if (cache_level == 1)
prev_cache= 0;
if ((tab->cache= new JOIN_CACHE_BNL(join, tab, prev_cache)) &&
- ((options & SELECT_DESCRIBE) || !tab->cache->init()))
+ !tab->cache->init(options & SELECT_DESCRIBE))
{
tab->icp_other_tables_ok= FALSE;
return (2 - MY_TEST(!prev_cache));
@@ -10577,7 +10577,7 @@ uint check_join_cache_usage(JOIN_TAB *tab,
if (cache_level == 3)
prev_cache= 0;
if ((tab->cache= new JOIN_CACHE_BNLH(join, tab, prev_cache)) &&
- ((options & SELECT_DESCRIBE) || !tab->cache->init()))
+ !tab->cache->init(options & SELECT_DESCRIBE))
{
tab->icp_other_tables_ok= FALSE;
return (4 - MY_TEST(!prev_cache));
@@ -10598,7 +10598,7 @@ uint check_join_cache_usage(JOIN_TAB *tab,
if (cache_level == 5)
prev_cache= 0;
if ((tab->cache= new JOIN_CACHE_BKA(join, tab, flags, prev_cache)) &&
- ((options & SELECT_DESCRIBE) || !tab->cache->init()))
+ !tab->cache->init(options & SELECT_DESCRIBE))
return (6 - MY_TEST(!prev_cache));
goto no_join_cache;
}
@@ -10607,7 +10607,7 @@ uint check_join_cache_usage(JOIN_TAB *tab,
if (cache_level == 7)
prev_cache= 0;
if ((tab->cache= new JOIN_CACHE_BKAH(join, tab, flags, prev_cache)) &&
- ((options & SELECT_DESCRIBE) || !tab->cache->init()))
+ !tab->cache->init(options & SELECT_DESCRIBE))
{
tab->idx_cond_fact_out= FALSE;
return (8 - MY_TEST(!prev_cache));