summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbell@sanja.is.com.ua <>2002-10-08 00:26:15 +0300
committerbell@sanja.is.com.ua <>2002-10-08 00:26:15 +0300
commit8d252004dc49d4ba1243e21fd190227bdbbe89a2 (patch)
tree1f656592d377f96fbe4e104ca29476b1bc3f5a71
parent33c27caeb5f5625c4e4799f710f53ad2236119a3 (diff)
downloadmariadb-git-8d252004dc49d4ba1243e21fd190227bdbbe89a2.tar.gz
fixed query cache with system database
FN_NO_CASE_SENCE used instead of __WIN__ in table name handling of quary cache
-rw-r--r--mysql-test/r/query_cache.result10
-rw-r--r--mysql-test/t/query_cache.test14
-rw-r--r--sql/sql_cache.cc22
3 files changed, 41 insertions, 5 deletions
diff --git a/mysql-test/r/query_cache.result b/mysql-test/r/query_cache.result
index 7c53074b6da..a09f4608142 100644
--- a/mysql-test/r/query_cache.result
+++ b/mysql-test/r/query_cache.result
@@ -526,3 +526,13 @@ show status like "Qcache_queries_in_cache";
Variable_name Value
Qcache_queries_in_cache 2
drop table t1, t2, t3;
+use mysql;
+select * from db;
+show status like "Qcache_queries_in_cache";
+Variable_name Value
+Qcache_queries_in_cache 0
+use test;
+select * from mysql.db;
+show status like "Qcache_queries_in_cache";
+Variable_name Value
+Qcache_queries_in_cache 0
diff --git a/mysql-test/t/query_cache.test b/mysql-test/t/query_cache.test
index 5dc6d1047f4..a0d2a34ee76 100644
--- a/mysql-test/t/query_cache.test
+++ b/mysql-test/t/query_cache.test
@@ -367,3 +367,17 @@ show status like "Qcache_queries_in_cache";
select * from t3;
show status like "Qcache_queries_in_cache";
drop table t1, t2, t3;
+
+#
+# system databse test
+#
+use mysql;
+disable_result_log;
+select * from db;
+enable_result_log;
+show status like "Qcache_queries_in_cache";
+use test;
+disable_result_log;
+select * from mysql.db;
+enable_result_log;
+show status like "Qcache_queries_in_cache";
diff --git a/sql/sql_cache.cc b/sql/sql_cache.cc
index 149b10ecc99..0b9caf4e6c3 100644
--- a/sql/sql_cache.cc
+++ b/sql/sql_cache.cc
@@ -342,6 +342,12 @@ TODO list:
#define DUMP(C)
#endif
+#ifdef FN_NO_CASE_SENCE
+#define DB_NAME_PREPROCESS(C) tolower(C)
+#else
+#define DB_NAME_PREPROCESS(C) (C)
+#endif
+
const char *query_cache_type_names[]= { "OFF", "ON", "DEMAND",NullS };
TYPELIB query_cache_type_typelib=
{
@@ -1378,11 +1384,11 @@ ulong Query_cache::init_cache()
VOID(hash_init(&queries,def_query_hash_size, 0, 0,
query_cache_query_get_key, 0, 0));
-#ifndef __WIN__
+#ifndef FN_NO_CASE_SENCE
VOID(hash_init(&tables,def_table_hash_size, 0, 0,
query_cache_table_get_key, 0, 0));
#else
- // windows case insensitive file names work around
+ // windows, OS/2 or other case insensitive file names work around
VOID(hash_init(&tables,def_table_hash_size, 0, 0,
query_cache_table_get_key, 0,
(lower_case_table_names?0:HASH_CASE_INSENSITIVE)));
@@ -2432,7 +2438,7 @@ TABLE_COUNTER_TYPE Query_cache::is_cacheable(THD *thd, uint32 query_len,
lex->select->options,
(int) thd->variables.query_cache_type));
- for (; tables_used; tables_used=tables_used->next)
+ for (; tables_used; tables_used= tables_used->next)
{
tables++;
DBUG_PRINT("qcache", ("table %s, db %s, type %u",
@@ -2442,10 +2448,16 @@ TABLE_COUNTER_TYPE Query_cache::is_cacheable(THD *thd, uint32 query_len,
tables_used->table->file->has_transactions());
if (tables_used->table->db_type == DB_TYPE_MRG_ISAM ||
- tables_used->table->tmp_table != NO_TMP_TABLE)
+ tables_used->table->tmp_table != NO_TMP_TABLE ||
+ (tables_used->db_length == 5 &&
+ DB_NAME_PREPROCESS(tables_used->db[0])=='m' &&
+ DB_NAME_PREPROCESS(tables_used->db[1])=='y' &&
+ DB_NAME_PREPROCESS(tables_used->db[2])=='s' &&
+ DB_NAME_PREPROCESS(tables_used->db[3])=='q' &&
+ DB_NAME_PREPROCESS(tables_used->db[4])=='l'))
{
DBUG_PRINT("qcache",
- ("select not cacheable: used MRG_ISAM or temporary table(s)"));
+ ("select not cacheable: used MRG_ISAM, temporary or system table(s)"));
DBUG_RETURN(0);
}
if (tables_used->table->db_type == DB_TYPE_MRG_MYISAM)