#At file:///home/thek/Development/cpp/mysqlbzr/mysql-5.1-bug40386/
2690 Kristofer Pettersson 2008-10-31
Bug#40386 Not flushing query cache after truncate
This patch solves a regression which caused TRUNCATE TABLE on an InnoDB table
to to keep an invalid result set in the query cache.
added:
mysql-test/r/innodb_querycache.result
mysql-test/t/innodb_querycache.test
modified:
sql/sql_delete.cc
per-file messages:
sql/sql_delete.cc
* Always invalidate query cache since we don't know if any rows were removed.
=== added file 'mysql-test/r/innodb_querycache.result'
--- a/mysql-test/r/innodb_querycache.result 1970-01-01 00:00:00 +0000
+++ b/mysql-test/r/innodb_querycache.result 2008-10-31 14:52:01 +0000
@@ -0,0 +1,33 @@
+SET GLOBAL query_cache_size=1024*512;
+CREATE TABLE t1 (c1 int) ENGINE InnoDB;
+INSERT INTO t1 VALUES (12345);
+FLUSH STATUS;
+SELECT * FROM t1;
+c1
+12345
+SHOW STATUS LIKE 'Qcache_queries_in_cache';
+Variable_name Value
+Qcache_queries_in_cache 1
+SELECT * FROM t1;
+c1
+12345
+SHOW STATUS LIKE 'Qcache_queries_in_cache';
+Variable_name Value
+Qcache_queries_in_cache 1
+SHOW STATUS LIKE 'Qcache_hits';
+Variable_name Value
+Qcache_hits 1
+TRUNCATE TABLE t1;
+SHOW STATUS LIKE 'Qcache_queries_in_cache';
+Variable_name Value
+Qcache_queries_in_cache 0
+SELECT * FROM t1;
+c1
+SHOW STATUS LIKE 'Qcache_queries_in_cache';
+Variable_name Value
+Qcache_queries_in_cache 1
+SHOW STATUS LIKE 'Qcache_hits';
+Variable_name Value
+Qcache_hits 1
+DROP TABLE t1;
+SET GLOBAL query_cache_size=0;
=== added file 'mysql-test/t/innodb_querycache.test'
--- a/mysql-test/t/innodb_querycache.test 1970-01-01 00:00:00 +0000
+++ b/mysql-test/t/innodb_querycache.test 2008-10-31 14:52:01 +0000
@@ -0,0 +1,23 @@
+--source include/have_query_cache.inc
+--source include/have_innodb.inc
+
+#
+# Bug#40386 Not flushing query cache after truncate
+#
+SET GLOBAL query_cache_size=1024*512;
+CREATE TABLE t1 (c1 int) ENGINE InnoDB;
+INSERT INTO t1 VALUES (12345);
+FLUSH STATUS;
+SELECT * FROM t1;
+SHOW STATUS LIKE 'Qcache_queries_in_cache';
+SELECT * FROM t1;
+SHOW STATUS LIKE 'Qcache_queries_in_cache';
+SHOW STATUS LIKE 'Qcache_hits';
+TRUNCATE TABLE t1;
+SHOW STATUS LIKE 'Qcache_queries_in_cache';
+SELECT * FROM t1;
+SHOW STATUS LIKE 'Qcache_queries_in_cache';
+SHOW STATUS LIKE 'Qcache_hits';
+DROP TABLE t1;
+SET GLOBAL query_cache_size=0;
+
=== modified file 'sql/sql_delete.cc'
--- a/sql/sql_delete.cc 2008-07-17 18:26:55 +0000
+++ b/sql/sql_delete.cc 2008-10-31 14:52:01 +0000
@@ -355,13 +355,10 @@ bool mysql_delete(THD *thd, TABLE_LIST *
cleanup:
/*
- Invalidate the table in the query cache if something changed. This must
- be before binlog writing and ha_autocommit_...
+ Invalidate the table in the query cache because we don't know if something
+ changed. This must be before binlog writing and ha_autocommit_...
*/
- if (deleted)
- {
- query_cache_invalidate3(thd, table_list, 1);
- }
+ query_cache_invalidate3(thd, table_list, 1);
delete select;
transactional_table= table->file->has_transactions();
| Thread |
|---|
| • bzr commit into mysql-5.1 branch (kristofer.pettersson:2690) Bug#40386 | Kristofer Pettersson | 31 Oct |