List:Commits« Previous MessageNext Message »
From:Kristofer Pettersson Date:November 3 2008 9:51am
Subject:bzr commit into mysql-5.1 branch (kristofer.pettersson:2690) Bug#40386
View as plain text  
#At file:///home/thek/Development/cpp/mysqlbzr/mysql-5.1-bug40386/

 2690 Kristofer Pettersson	2008-11-03
      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:
  mysql-test/r/innodb_querycache.result
    * Added test case
  mysql-test/t/innodb_querycache.test
    * Added test case
  sql/sql_delete.cc
    * Additional call to query_cache_invalidate to work around the fact that
    InnoDB doesn't report the number of rows deleted when a TRUNCATE command is
    issued.
=== 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-11-03 08:59:26 +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-11-03 08:59:26 +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-11-03 08:59:26 +0000
@@ -1070,5 +1070,13 @@ trunc_by_del:
   ha_commit(thd);
   thd->options= save_options;
   thd->current_stmt_binlog_row_based= save_binlog_row_based;
+
+  /*
+    Even though the query cache is suppose to be invalidated in mysql_delete
+    we need to add an extra invalidation call here because InnoDB doesn't
+    properly report the number of rows deleted when an SQLCOM_TRUNCATE
+    command is issued.
+  */
+  query_cache_invalidate3(thd, table_list, 0);
   DBUG_RETURN(error);
 }

Thread
bzr commit into mysql-5.1 branch (kristofer.pettersson:2690) Bug#40386Kristofer Pettersson3 Nov