List:Commits« Previous MessageNext Message »
From:Chuck Bell Date:November 6 2009 4:10pm
Subject:bzr commit into mysql-6.0-backup branch (charles.bell:2888) Bug#47879
View as plain text  
#At file:///Users/cbell/source/bzr/mysql-6.0-bug-47879/ based on revid:charles.bell@stripped

 2888 Chuck Bell	2009-11-06
      BUG#47879 : Backup of partitioned tables with subpartitions can crash server
      
      Tables with subpartitions cause backup to crash the server. 
      
      The reason is the code is not designed to detect subpartitions 
      and tries to access a member of a struct that does not exist.
      
      This patch detects when subpartions exist and reassign the 
      pointers in the loop to traverse the subpartitions list 
      instead when subpartitions are detected.
     @ mysql-test/suite/backup_engines/r/backup_partition.result
        Corrected result file.
     @ mysql-test/suite/backup_engines/t/backup_partition.test
        New tables added to test backup of tables with subpartitions.
     @ sql/backup/backup_info.cc
        Code added to detect subpartitions and traverse those
        lists instead.

    modified:
      mysql-test/suite/backup_engines/r/backup_partition.result
      mysql-test/suite/backup_engines/t/backup_partition.test
      sql/backup/backup_info.cc
=== modified file 'mysql-test/suite/backup_engines/r/backup_partition.result'
--- a/mysql-test/suite/backup_engines/r/backup_partition.result	2009-03-05 20:05:02 +0000
+++ b/mysql-test/suite/backup_engines/r/backup_partition.result	2009-11-06 16:10:48 +0000
@@ -19,6 +19,36 @@ t1_autoinc	t1_uuid
 3	ccc
 4	ddd
 #
+# Now let's test partition tables with subpartitions.
+#
+CREATE TABLE backup_part.my_tbl (f1 int) 
+PARTITION BY LIST(f1) subpartition by hash (f1) (
+PARTITION part1 VALUES IN (1,2,3,4) (
+SUBPARTITION subpart11, 
+SUBPARTITION subpart12
+), 
+PARTITION part2 VALUES IN (5,6,7,8) (
+SUBPARTITION subpart21, 
+SUBPARTITION subpart22
+)
+);
+CREATE TABLE backup_part.ts (id INT, purchased DATE)
+PARTITION BY RANGE( YEAR(purchased) )
+SUBPARTITION BY HASH( TO_DAYS(purchased) ) (
+PARTITION p0 VALUES LESS THAN (1990) (
+SUBPARTITION s0,
+SUBPARTITION s1
+),
+PARTITION p1 VALUES LESS THAN (2000) (
+SUBPARTITION s2,
+SUBPARTITION s3
+),
+PARTITION p2 VALUES LESS THAN MAXVALUE (
+SUBPARTITION s4,
+SUBPARTITION s5
+)
+);
+#
 # Perform backup
 #
 # Show drivers. 

=== modified file 'mysql-test/suite/backup_engines/t/backup_partition.test'
--- a/mysql-test/suite/backup_engines/t/backup_partition.test	2009-03-12 19:50:43 +0000
+++ b/mysql-test/suite/backup_engines/t/backup_partition.test	2009-11-06 16:10:48 +0000
@@ -45,6 +45,38 @@ INSERT INTO backup_part.t1(t1_uuid) VALU
 SELECT * FROM backup_part.t1 ORDER BY t1_autoinc;
 
 --echo #
+--echo # Now let's test partition tables with subpartitions.
+--echo #
+CREATE TABLE backup_part.my_tbl (f1 int) 
+  PARTITION BY LIST(f1) subpartition by hash (f1) (
+    PARTITION part1 VALUES IN (1,2,3,4) (
+      SUBPARTITION subpart11, 
+      SUBPARTITION subpart12
+     ), 
+    PARTITION part2 VALUES IN (5,6,7,8) (
+      SUBPARTITION subpart21, 
+      SUBPARTITION subpart22
+    )
+  );
+
+CREATE TABLE backup_part.ts (id INT, purchased DATE)
+  PARTITION BY RANGE( YEAR(purchased) )
+  SUBPARTITION BY HASH( TO_DAYS(purchased) ) (
+    PARTITION p0 VALUES LESS THAN (1990) (
+      SUBPARTITION s0,
+      SUBPARTITION s1
+    ),
+    PARTITION p1 VALUES LESS THAN (2000) (
+      SUBPARTITION s2,
+      SUBPARTITION s3
+    ),
+    PARTITION p2 VALUES LESS THAN MAXVALUE (
+      SUBPARTITION s4,
+      SUBPARTITION s5
+    )
+  );
+
+--echo #
 --echo # Perform backup
 --replace_column 1 #
 let $bup_id= `BACKUP DATABASE backup_part TO 'partition.bak'`;

=== modified file 'sql/backup/backup_info.cc'
--- a/sql/backup/backup_info.cc	2009-10-23 15:41:56 +0000
+++ b/sql/backup/backup_info.cc	2009-11-06 16:10:48 +0000
@@ -68,6 +68,16 @@ storage_engine_ref get_storage_engine(TH
 
       while ((p_el= p_it++))
       {
+        /*
+          If this partition has subpartitions, we must traverse the subpartitions
+          list instead of the partitions list.
+        */
+        List_iterator<partition_element> p_sub_it(p_el->subpartitions);
+        if (!p_el->engine_type)
+        {
+          p_el= p_sub_it++;
+          p_it= p_sub_it;
+        }
         if (!se_tmp)
         {
           se_tmp= hton2plugin[p_el->engine_type->slot];


Attachment: [text/bzr-bundle] bzr/charles.bell@sun.com-20091106161048-tj9cmfy9ekbfllws.bundle
Thread
bzr commit into mysql-6.0-backup branch (charles.bell:2888) Bug#47879Chuck Bell6 Nov
  • Re: bzr commit into mysql-6.0-backup branch (charles.bell:2888)Bug#47879Ingo Strüwing12 Nov
    • Re: bzr commit into mysql-6.0-backup branch (charles.bell:2888)Bug#47879Charles Bell12 Nov
      • Re: bzr commit into mysql-6.0-backup branch (charles.bell:2888)Bug#47879Ingo Strüwing13 Nov