summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbell@sanja.is.com.ua <>2004-09-10 16:28:18 +0300
committerbell@sanja.is.com.ua <>2004-09-10 16:28:18 +0300
commit24e1464d5a669d8c30127deaf61551a110533958 (patch)
tree573d6d013fae80ebbea92e5e615b4368be394ec1
parent69695656a165a197ef1a48e615d430afda95451d (diff)
downloadmariadb-git-24e1464d5a669d8c30127deaf61551a110533958.tar.gz
information about different variables agged to query cache (BUG#5515, BUG#5394)
-rw-r--r--mysql-test/r/query_cache.result56
-rw-r--r--mysql-test/t/query_cache.test34
-rw-r--r--sql/mysql_priv.h3
-rw-r--r--sql/sql_cache.cc8
-rw-r--r--sql/sql_cache.h4
5 files changed, 100 insertions, 5 deletions
diff --git a/mysql-test/r/query_cache.result b/mysql-test/r/query_cache.result
index a93ea1aa7fe..ee4b97b8ea8 100644
--- a/mysql-test/r/query_cache.result
+++ b/mysql-test/r/query_cache.result
@@ -851,4 +851,60 @@ select @@character_set_results;
@@character_set_results
NULL
set character_set_results=default;
+set GLOBAL query_cache_size=1355776;
+create table t1 (id int auto_increment primary key, c char(25));
+insert into t1 set c = repeat('x',24);
+insert into t1 set c = concat(repeat('x',24),'x');
+insert into t1 set c = concat(repeat('x',24),'w');
+insert into t1 set c = concat(repeat('x',24),'y');
+set max_sort_length=200;
+select c from t1 order by c, id;
+c
+xxxxxxxxxxxxxxxxxxxxxxxx
+xxxxxxxxxxxxxxxxxxxxxxxxw
+xxxxxxxxxxxxxxxxxxxxxxxxx
+xxxxxxxxxxxxxxxxxxxxxxxxy
+reset query cache;
+set max_sort_length=20;
+select c from t1 order by c, id;
+c
+xxxxxxxxxxxxxxxxxxxxxxxx
+xxxxxxxxxxxxxxxxxxxxxxxxx
+xxxxxxxxxxxxxxxxxxxxxxxxw
+xxxxxxxxxxxxxxxxxxxxxxxxy
+set max_sort_length=200;
+select c from t1 order by c, id;
+c
+xxxxxxxxxxxxxxxxxxxxxxxx
+xxxxxxxxxxxxxxxxxxxxxxxxw
+xxxxxxxxxxxxxxxxxxxxxxxxx
+xxxxxxxxxxxxxxxxxxxxxxxxy
+set max_sort_length=default;
+select '1' || '3' from t1;
+'1' || '3'
+1
+1
+1
+1
+set SQL_MODE=oracle;
+select '1' || '3' from t1;
+'1' || '3'
+13
+13
+13
+13
+set SQL_MODE=default;
+drop table t1;
+create table t1 (a varchar(20), b int);
+insert into t1 values ('12345678901234567890', 1);
+set group_concat_max_len=10;
+select group_concat(a) FROM t1 group by b;
+group_concat(a)
+1234567890
+set group_concat_max_len=1024;
+select group_concat(a) FROM t1 group by b;
+group_concat(a)
+12345678901234567890
+set group_concat_max_len=default;
+drop table t1;
SET GLOBAL query_cache_size=0;
diff --git a/mysql-test/t/query_cache.test b/mysql-test/t/query_cache.test
index b3111b614c6..66e9f31823a 100644
--- a/mysql-test/t/query_cache.test
+++ b/mysql-test/t/query_cache.test
@@ -627,4 +627,38 @@ set character_set_results=null;
select @@character_set_results;
set character_set_results=default;
+#
+# query cache and environment variables
+#
+# max_sort_length
+set GLOBAL query_cache_size=1355776;
+create table t1 (id int auto_increment primary key, c char(25));
+insert into t1 set c = repeat('x',24);
+insert into t1 set c = concat(repeat('x',24),'x');
+insert into t1 set c = concat(repeat('x',24),'w');
+insert into t1 set c = concat(repeat('x',24),'y');
+set max_sort_length=200;
+select c from t1 order by c, id;
+reset query cache;
+set max_sort_length=20;
+select c from t1 order by c, id;
+set max_sort_length=200;
+select c from t1 order by c, id;
+set max_sort_length=default;
+# sql_mode
+select '1' || '3' from t1;
+set SQL_MODE=oracle;
+select '1' || '3' from t1;
+set SQL_MODE=default;
+drop table t1;
+# group_concat_max_len
+create table t1 (a varchar(20), b int);
+insert into t1 values ('12345678901234567890', 1);
+set group_concat_max_len=10;
+select group_concat(a) FROM t1 group by b;
+set group_concat_max_len=1024;
+select group_concat(a) FROM t1 group by b;
+set group_concat_max_len=default;
+drop table t1;
+
SET GLOBAL query_cache_size=0;
diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h
index b1b184eb9eb..e47807dd36e 100644
--- a/sql/mysql_priv.h
+++ b/sql/mysql_priv.h
@@ -390,6 +390,9 @@ struct Query_cache_query_flags
uint collation_connection_num;
ha_rows limit;
Time_zone *time_zone;
+ ulong sql_mode;
+ ulong max_sort_length;
+ ulong group_concat_max_len;
};
#define QUERY_CACHE_FLAGS_SIZE sizeof(Query_cache_query_flags)
#include "sql_cache.h"
diff --git a/sql/sql_cache.cc b/sql/sql_cache.cc
index 5fe21d79aa0..235558a759d 100644
--- a/sql/sql_cache.cc
+++ b/sql/sql_cache.cc
@@ -787,6 +787,9 @@ void Query_cache::store_query(THD *thd, TABLE_LIST *tables_used)
thd->variables.collation_connection->number;
flags.limit= thd->variables.select_limit;
flags.time_zone= thd->variables.time_zone;
+ flags.sql_mode= thd->variables.sql_mode;
+ flags.max_sort_length= thd->variables.max_sort_length;
+ flags.group_concat_max_len= thd->variables.group_concat_max_len;
STRUCT_LOCK(&structure_guard_mutex);
if (query_cache_size == 0)
@@ -974,8 +977,11 @@ Query_cache::send_result_to_client(THD *thd, char *sql, uint query_length)
flags.collation_connection_num= thd->variables.collation_connection->number;
flags.limit= thd->variables.select_limit;
flags.time_zone= thd->variables.time_zone;
+ flags.sql_mode= thd->variables.sql_mode;
+ flags.max_sort_length= thd->variables.max_sort_length;
+ flags.group_concat_max_len= thd->variables.group_concat_max_len;
memcpy((void *)(sql + (tot_length - QUERY_CACHE_FLAGS_SIZE)),
- &flags, QUERY_CACHE_FLAGS_SIZE);
+ &flags, QUERY_CACHE_FLAGS_SIZE);
query_block = (Query_cache_block *) hash_search(&queries, (byte*) sql,
tot_length);
/* Quick abort on unlocked data */
diff --git a/sql/sql_cache.h b/sql/sql_cache.h
index 432c7659aa5..fc458f39e29 100644
--- a/sql/sql_cache.h
+++ b/sql/sql_cache.h
@@ -53,10 +53,6 @@
of list of free blocks */
#define QUERY_CACHE_MEM_BIN_TRY 5
-/* query flags masks */
-#define QUERY_CACHE_CLIENT_LONG_FLAG_MASK 0x80
-#define QUERY_CACHE_CHARSET_CONVERT_MASK 0x7F
-
/* packing parameters */
#define QUERY_CACHE_PACK_ITERATION 2
#define QUERY_CACHE_PACK_LIMIT (512*1024L)