summaryrefslogtreecommitdiff
path: root/sql/sql_cache.cc
diff options
context:
space:
mode:
Diffstat (limited to 'sql/sql_cache.cc')
-rw-r--r--sql/sql_cache.cc44
1 files changed, 20 insertions, 24 deletions
diff --git a/sql/sql_cache.cc b/sql/sql_cache.cc
index 42b80d9b143..6d1a8efaf22 100644
--- a/sql/sql_cache.cc
+++ b/sql/sql_cache.cc
@@ -1999,36 +1999,32 @@ lookup:
for (; block_table != block_table_end; block_table++)
{
TABLE_LIST table_list;
- TABLE *tmptable;
+ TMP_TABLE_SHARE *tmptable;
Query_cache_table *table = block_table->parent;
/*
- Check that we have not temporary tables with same names of tables
- of this query. If we have such tables, we will not send data from
- query cache, because temporary tables hide real tables by which
+ Check that we do not have temporary tables with same names as that of
+ base tables from this query. If we have such tables, we will not send
+ data from query cache, because temporary tables hide real tables by which
query in query cache was made.
*/
- for (tmptable= thd->temporary_tables; tmptable ; tmptable= tmptable->next)
+ if ((tmptable=
+ thd->find_tmp_table_share_w_base_key((char *) table->data(),
+ table->key_length())))
{
- if (tmptable->s->table_cache_key.length - TMP_TABLE_KEY_EXTRA ==
- table->key_length() &&
- !memcmp(tmptable->s->table_cache_key.str, table->data(),
- table->key_length()))
- {
- DBUG_PRINT("qcache",
- ("Temporary table detected: '%s.%s'",
- tmptable->s->db.str, tmptable->alias.c_ptr()));
- unlock();
- /*
- We should not store result of this query because it contain
- temporary tables => assign following variable to make check
- faster.
- */
- thd->query_cache_is_applicable= 0; // Query can't be cached
- thd->lex->safe_to_cache_query= 0; // For prepared statements
- BLOCK_UNLOCK_RD(query_block);
- DBUG_RETURN(-1);
- }
+ DBUG_PRINT("qcache",
+ ("Temporary table detected: '%s.%s'",
+ tmptable->db.str, tmptable->table_name.str));
+ unlock();
+ /*
+ We should not store result of this query because it contain
+ temporary tables => assign following variable to make check
+ faster.
+ */
+ thd->query_cache_is_applicable= 0; // Query can't be cached
+ thd->lex->safe_to_cache_query= 0; // For prepared statements
+ BLOCK_UNLOCK_RD(query_block);
+ DBUG_RETURN(-1);
}
bzero((char*) &table_list,sizeof(table_list));