diff options
author | unknown <thek@adventure.(none)> | 2007-08-17 17:34:18 +0200 |
---|---|---|
committer | unknown <thek@adventure.(none)> | 2007-08-17 17:34:18 +0200 |
commit | 55e514ae8d6d5fbd356ea26fa793c8819d6d8c65 (patch) | |
tree | 9d61ef02a7c374d96a610c5c62f52e8a6d771dcd | |
parent | 8bdb043f087ffbad27ab6daaeba8954b41711b57 (diff) | |
parent | 59c92e263a44b234df4fbf1282bb2ce7b24a73b2 (diff) | |
download | mariadb-git-55e514ae8d6d5fbd356ea26fa793c8819d6d8c65.tar.gz |
Merge kpettersson@bk-internal.mysql.com:/home/bk/mysql-5.1-runtime
into adventure.(none):/home/thek/Development/cpp/mysql-5.1-runtime
-rw-r--r-- | mysql-test/r/query_cache.result | 24 | ||||
-rw-r--r-- | mysql-test/t/query_cache.test | 29 | ||||
-rw-r--r-- | sql/sql_cache.cc | 24 | ||||
-rw-r--r-- | sql/sql_cache.h | 8 |
4 files changed, 78 insertions, 7 deletions
diff --git a/mysql-test/r/query_cache.result b/mysql-test/r/query_cache.result index 2e226ea84bc..4c76f5f83f4 100644 --- a/mysql-test/r/query_cache.result +++ b/mysql-test/r/query_cache.result @@ -1650,6 +1650,30 @@ a (select count(*) from t2) 3 0 4 0 drop table t1,t2; +DROP DATABASE IF EXISTS bug30269; +CREATE DATABASE bug30269; +USE bug30269; +CREATE TABLE test1 (id int, name varchar(23)); +CREATE VIEW view1 AS SELECT id FROM test1; +INSERT INTO test1 VALUES (5, 'testit'); +GRANT SELECT (id) ON TABLE bug30269.test1 TO 'bug30269'@'localhost'; +GRANT SELECT ON TABLE bug30269.view1 TO 'bug30269'@'localhost'; +set global query_cache_size= 81920; +USE bug30269; +show status like 'Qcache_queries_in_cache'; +Variable_name Value +Qcache_queries_in_cache 0 +SELECT id FROM test1 WHERE id>2; +id +5 +SELECT id FROM view1 WHERE id>2; +id +5 +show status like 'Qcache_queries_in_cache'; +Variable_name Value +Qcache_queries_in_cache 0 +DROP DATABASE bug30269; +DROP USER 'bug30269'@'localhost'; set GLOBAL query_cache_type=default; set GLOBAL query_cache_limit=default; set GLOBAL query_cache_min_res_unit=default; diff --git a/mysql-test/t/query_cache.test b/mysql-test/t/query_cache.test index f769d6ad776..9e33004ae02 100644 --- a/mysql-test/t/query_cache.test +++ b/mysql-test/t/query_cache.test @@ -1249,13 +1249,40 @@ connection default; disconnect user1; disconnect user2; disconnect user3; + +# +# Bug #30269 Query cache eats memory +# +--disable_warnings +DROP DATABASE IF EXISTS bug30269; +--enable_warnings +CREATE DATABASE bug30269; +USE bug30269; +CREATE TABLE test1 (id int, name varchar(23)); +CREATE VIEW view1 AS SELECT id FROM test1; +INSERT INTO test1 VALUES (5, 'testit'); +GRANT SELECT (id) ON TABLE bug30269.test1 TO 'bug30269'@'localhost'; +GRANT SELECT ON TABLE bug30269.view1 TO 'bug30269'@'localhost'; +set global query_cache_size= 81920; +connect (bug30269, localhost, bug30269,,); +connection bug30269; +USE bug30269; +show status like 'Qcache_queries_in_cache'; +SELECT id FROM test1 WHERE id>2; +SELECT id FROM view1 WHERE id>2; +show status like 'Qcache_queries_in_cache'; + +connection default; +DROP DATABASE bug30269; +disconnect bug30269; +DROP USER 'bug30269'@'localhost'; + set GLOBAL query_cache_type=default; set GLOBAL query_cache_limit=default; set GLOBAL query_cache_min_res_unit=default; set GLOBAL query_cache_size=default; --echo End of 5.0 tests - # # Bug #28211 RENAME DATABASE and query cache don't play nicely together # diff --git a/sql/sql_cache.cc b/sql/sql_cache.cc index f6b48afc10b..4e5cf157239 100644 --- a/sql/sql_cache.cc +++ b/sql/sql_cache.cc @@ -3222,14 +3222,31 @@ void Query_cache::double_linked_list_join(Query_cache_block *head_tail, >0 number of tables */ -static TABLE_COUNTER_TYPE process_and_count_tables(TABLE_LIST *tables_used, - uint8 *tables_type) +TABLE_COUNTER_TYPE +Query_cache::process_and_count_tables(THD *thd, TABLE_LIST *tables_used, + uint8 *tables_type) { DBUG_ENTER("process_and_count_tables"); TABLE_COUNTER_TYPE table_count = 0; for (; tables_used; tables_used= tables_used->next_global) { table_count++; +#ifdef HAVE_QUERY_CACHE + /* + Disable any attempt to store this statement if there are + column level grants on any referenced tables. + The grant.want_privileges flag was set to 1 in the + check_grant() function earlier if the TABLE_LIST object + had any associated column privileges. + */ + if (tables_used->grant.want_privilege) + { + DBUG_PRINT("qcache", ("Don't cache statement as it refers to " + "tables with column privileges.")); + thd->lex->safe_to_cache_query= 0; + DBUG_RETURN(0); + } +#endif if (tables_used->view) { DBUG_PRINT("qcache", ("view: %s db: %s", @@ -3307,7 +3324,8 @@ Query_cache::is_cacheable(THD *thd, uint32 query_len, char *query, LEX *lex, (long) lex->select_lex.options, (int) thd->variables.query_cache_type)); - if (!(table_count= process_and_count_tables(tables_used, tables_type))) + if (!(table_count= process_and_count_tables(thd, tables_used, + tables_type))) DBUG_RETURN(0); if ((thd->options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)) && diff --git a/sql/sql_cache.h b/sql/sql_cache.h index 645807eecbf..b47e2e9a43b 100644 --- a/sql/sql_cache.h +++ b/sql/sql_cache.h @@ -409,10 +409,12 @@ protected: If query is cacheable return number tables in query (query without tables not cached) */ - static TABLE_COUNTER_TYPE is_cacheable(THD *thd, uint32 query_len, char *query, - LEX *lex, TABLE_LIST *tables_used, - uint8 *tables_type); + LEX *lex, TABLE_LIST *tables_used, + uint8 *tables_type); + TABLE_COUNTER_TYPE process_and_count_tables(THD *thd, + TABLE_LIST *tables_used, + uint8 *tables_type); static my_bool ask_handler_allowance(THD *thd, TABLE_LIST *tables_used); public: |