List:Commits« Previous MessageNext Message »
From:Mattias Jonsson Date:April 4 2011 10:01am
Subject:bzr commit into mysql-5.1 branch (mattias.jonsson:3642) Bug#60681
Bug#11933226
View as plain text  
#At file:///C:/ade/mysql-bzr/b11933226-51/ based on revid:jon.hauglid@stripped

 3642 Mattias Jonsson	2011-04-04
      BUG#11933226 - Bug#60681: CHECKSUM TABLE RETURNS 0 FOR PARTITIONED TABLE
      
      ha_partition::checksum() was not implemented, but HA_HAS_CHECKSUM table flag
      was returned if the underlying handlers supported it, resulting in CHECKSUM TABLE
      returned 0 when checksum was enabled.
      
      Fixed by implementing ha_partition::checksum() by adding all partitions checksums
      together.
      
      (even compiles with this commit :)

    modified:
      mysql-test/r/partition.result
      mysql-test/t/partition.test
      sql/ha_partition.cc
      sql/ha_partition.h
=== modified file 'mysql-test/r/partition.result'
--- a/mysql-test/r/partition.result	2011-03-09 17:12:23 +0000
+++ b/mysql-test/r/partition.result	2011-04-04 10:01:30 +0000
@@ -1,5 +1,63 @@
 drop table if exists t1, t2;
 #
+# BUG#11933226 - 60681: CHECKSUM TABLE RETURNS 0 FOR PARTITIONED TABLE
+#
+CREATE TABLE t1 (
+i INT
+) ENGINE=MyISAM
+PARTITION BY RANGE (i) (
+PARTITION p3 VALUES LESS THAN (3),
+PARTITION p5 VALUES LESS THAN (5),
+PARTITION pMax VALUES LESS THAN MAXVALUE);
+INSERT INTO t1 VALUES (1), (2), (3), (4), (5), (6);
+CHECKSUM TABLE t1;
+Table	Checksum
+test.t1	2653438147
+ALTER TABLE t1 CHECKSUM = 1;
+CHECKSUM TABLE t1 EXTENDED;
+Table	Checksum
+test.t1	2653438147
+# Before patch this returned 0!
+CHECKSUM TABLE t1;
+Table	Checksum
+test.t1	2653438147
+SHOW CREATE TABLE t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `i` int(11) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1 CHECKSUM=1
+/*!50100 PARTITION BY RANGE (i)
+(PARTITION p3 VALUES LESS THAN (3) ENGINE = MyISAM,
+ PARTITION p5 VALUES LESS THAN (5) ENGINE = MyISAM,
+ PARTITION pMax VALUES LESS THAN MAXVALUE ENGINE = MyISAM) */
+DROP TABLE t1;
+# Same test without partitioning
+CREATE TABLE t1 (
+i INT
+) ENGINE=MyISAM;
+SHOW CREATE TABLE t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `i` int(11) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+INSERT INTO t1 VALUES (1), (2), (3), (4), (5), (6);
+CHECKSUM TABLE t1;
+Table	Checksum
+test.t1	2653438147
+ALTER TABLE t1 CHECKSUM = 1;
+CHECKSUM TABLE t1 EXTENDED;
+Table	Checksum
+test.t1	2653438147
+CHECKSUM TABLE t1;
+Table	Checksum
+test.t1	2653438147
+SHOW CREATE TABLE t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `i` int(11) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1 CHECKSUM=1
+DROP TABLE t1;
+#
 # Bug#59297: Can't find record in 'tablename' on update inner join
 #
 CREATE TABLE t1 (

=== modified file 'mysql-test/t/partition.test'
--- a/mysql-test/t/partition.test	2011-03-09 17:12:23 +0000
+++ b/mysql-test/t/partition.test	2011-04-04 10:01:30 +0000
@@ -15,6 +15,38 @@ drop table if exists t1, t2;
 --enable_warnings
 
 --echo #
+--echo # BUG#11933226 - 60681: CHECKSUM TABLE RETURNS 0 FOR PARTITIONED TABLE
+--echo #
+CREATE TABLE t1 (
+  i INT
+) ENGINE=MyISAM
+  PARTITION BY RANGE (i) (
+    PARTITION p3 VALUES LESS THAN (3),
+    PARTITION p5 VALUES LESS THAN (5),
+    PARTITION pMax VALUES LESS THAN MAXVALUE);
+INSERT INTO t1 VALUES (1), (2), (3), (4), (5), (6);
+CHECKSUM TABLE t1;
+ALTER TABLE t1 CHECKSUM = 1;
+CHECKSUM TABLE t1 EXTENDED;
+--echo # Before patch this returned 0!
+CHECKSUM TABLE t1;
+SHOW CREATE TABLE t1;
+DROP TABLE t1;
+
+--echo # Same test without partitioning
+CREATE TABLE t1 (
+  i INT
+) ENGINE=MyISAM;
+SHOW CREATE TABLE t1;
+INSERT INTO t1 VALUES (1), (2), (3), (4), (5), (6);
+CHECKSUM TABLE t1;
+ALTER TABLE t1 CHECKSUM = 1;
+CHECKSUM TABLE t1 EXTENDED;
+CHECKSUM TABLE t1;
+SHOW CREATE TABLE t1;
+DROP TABLE t1;
+
+--echo #
 --echo # Bug#59297: Can't find record in 'tablename' on update inner join
 --echo #
 

=== modified file 'sql/ha_partition.cc'
--- a/sql/ha_partition.cc	2011-01-24 12:41:44 +0000
+++ b/sql/ha_partition.cc	2011-04-04 10:01:30 +0000
@@ -6664,6 +6664,27 @@ void ha_partition::init_table_handle_for
 }
 
 
+/**
+  Return the checksum of the table (all partitions)
+*/
+
+uint ha_partition::checksum() const
+{
+  ha_checksum sum= 0;
+
+  DBUG_ENTER("ha_partition::checksum");
+  if ((table_flags() & HA_HAS_CHECKSUM))
+  {
+    handler **file= m_file;
+    do
+    {
+      sum+= (*file)->checksum();
+    } while (*(++file));
+  }
+  DBUG_RETURN(sum);
+}
+
+
 /****************************************************************************
                 MODULE enable/disable indexes
 ****************************************************************************/

=== modified file 'sql/ha_partition.h'
--- a/sql/ha_partition.h	2010-10-01 11:39:49 +0000
+++ b/sql/ha_partition.h	2011-04-04 10:01:30 +0000
@@ -1100,8 +1100,8 @@ public:
     virtual int preload_keys(THD *thd, HA_CHECK_OPT *check_opt);
     virtual int dump(THD* thd, int fd = -1);
     virtual int net_read_dump(NET* net);
-    virtual uint checksum() const;
   */
+    virtual uint checksum() const;
 
   /*
     -------------------------------------------------------------------------


Attachment: [text/bzr-bundle] bzr/mattias.jonsson@oracle.com-20110404100130-a5v56soukiuxffa0.bundle
Thread
bzr commit into mysql-5.1 branch (mattias.jonsson:3642) Bug#60681Bug#11933226Mattias Jonsson4 Apr