Commit b17793f5 authored by unknown's avatar unknown

merge

parents e45709df 0cc6dd83
...@@ -1005,5 +1005,58 @@ Qcache_inserts 0 ...@@ -1005,5 +1005,58 @@ Qcache_inserts 0
show status like "Qcache_hits"; show status like "Qcache_hits";
Variable_name Value Variable_name Value
Qcache_hits 0 Qcache_hits 0
drop table t1;
create table t1 (a int);
insert into t1 values (1);
reset query cache;
flush status;
select * from (select * from t1) a;
a
1
show status like "Qcache_queries_in_cache";
Variable_name Value
Qcache_queries_in_cache 1
show status like "Qcache_inserts";
Variable_name Value
Qcache_inserts 1
show status like "Qcache_hits";
Variable_name Value
Qcache_hits 0
select * from (select * from t1) a;
a
1
show status like "Qcache_queries_in_cache";
Variable_name Value
Qcache_queries_in_cache 1
show status like "Qcache_inserts";
Variable_name Value
Qcache_inserts 1
show status like "Qcache_hits";
Variable_name Value
Qcache_hits 1
insert into t1 values (2);
show status like "Qcache_queries_in_cache";
Variable_name Value
Qcache_queries_in_cache 0
show status like "Qcache_inserts";
Variable_name Value
Qcache_inserts 1
show status like "Qcache_hits";
Variable_name Value
Qcache_hits 1
select * from (select * from t1) a;
a
1
2
show status like "Qcache_queries_in_cache";
Variable_name Value
Qcache_queries_in_cache 1
show status like "Qcache_inserts";
Variable_name Value
Qcache_inserts 2
show status like "Qcache_hits";
Variable_name Value
Qcache_hits 1
drop table t1; drop table t1;
set GLOBAL query_cache_size=0; set GLOBAL query_cache_size=0;
...@@ -749,4 +749,29 @@ show status like "Qcache_inserts"; ...@@ -749,4 +749,29 @@ show status like "Qcache_inserts";
show status like "Qcache_hits"; show status like "Qcache_hits";
drop table t1; drop table t1;
#
# queries with subquery in the FROM clause (BUG#11522)
#
create table t1 (a int);
insert into t1 values (1);
reset query cache;
flush status;
select * from (select * from t1) a;
show status like "Qcache_queries_in_cache";
show status like "Qcache_inserts";
show status like "Qcache_hits";
select * from (select * from t1) a;
show status like "Qcache_queries_in_cache";
show status like "Qcache_inserts";
show status like "Qcache_hits";
insert into t1 values (2);
show status like "Qcache_queries_in_cache";
show status like "Qcache_inserts";
show status like "Qcache_hits";
select * from (select * from t1) a;
show status like "Qcache_queries_in_cache";
show status like "Qcache_inserts";
show status like "Qcache_hits";
drop table t1;
set GLOBAL query_cache_size=0; set GLOBAL query_cache_size=0;
...@@ -2114,6 +2114,13 @@ my_bool Query_cache::register_all_tables(Query_cache_block *block, ...@@ -2114,6 +2114,13 @@ my_bool Query_cache::register_all_tables(Query_cache_block *block,
for (n=0; tables_used; tables_used=tables_used->next, n++, block_table++) for (n=0; tables_used; tables_used=tables_used->next, n++, block_table++)
{ {
if (tables_used->derived)
{
DBUG_PRINT("qcache", ("derived table skipped"));
n--;
block_table--;
continue;
}
DBUG_PRINT("qcache", DBUG_PRINT("qcache",
("table %s, db %s, openinfo at 0x%lx, keylen %u, key at 0x%lx", ("table %s, db %s, openinfo at 0x%lx, keylen %u, key at 0x%lx",
tables_used->real_name, tables_used->db, tables_used->real_name, tables_used->db,
...@@ -2671,7 +2678,8 @@ TABLE_COUNTER_TYPE Query_cache::is_cacheable(THD *thd, uint32 query_len, ...@@ -2671,7 +2678,8 @@ TABLE_COUNTER_TYPE Query_cache::is_cacheable(THD *thd, uint32 query_len,
table_alias_charset used here because it depends of table_alias_charset used here because it depends of
lower_case_table_names variable lower_case_table_names variable
*/ */
if (tables_used->table->tmp_table != NO_TMP_TABLE || if ((tables_used->table->tmp_table != NO_TMP_TABLE &&
!tables_used->derived) ||
(*tables_type & HA_CACHE_TBL_NOCACHE) || (*tables_type & HA_CACHE_TBL_NOCACHE) ||
(tables_used->db_length == 5 && (tables_used->db_length == 5 &&
my_strnncoll(table_alias_charset, (uchar*)tables_used->db, 6, my_strnncoll(table_alias_charset, (uchar*)tables_used->db, 6,
...@@ -2682,7 +2690,12 @@ TABLE_COUNTER_TYPE Query_cache::is_cacheable(THD *thd, uint32 query_len, ...@@ -2682,7 +2690,12 @@ TABLE_COUNTER_TYPE Query_cache::is_cacheable(THD *thd, uint32 query_len,
other non-cacheable table(s)")); other non-cacheable table(s)"));
DBUG_RETURN(0); DBUG_RETURN(0);
} }
if (tables_used->table->db_type == DB_TYPE_MRG_MYISAM) if (tables_used->derived)
{
table_count--;
DBUG_PRINT("qcache", ("derived table skipped"));
}
else if (tables_used->table->db_type == DB_TYPE_MRG_MYISAM)
{ {
ha_myisammrg *handler = (ha_myisammrg *)tables_used->table->file; ha_myisammrg *handler = (ha_myisammrg *)tables_used->table->file;
MYRG_INFO *file = handler->myrg_info(); MYRG_INFO *file = handler->myrg_info();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment