List:Commits« Previous MessageNext Message »
From:Mattias Jonsson Date:May 2 2011 2:12pm
Subject:bzr commit into mysql-5.1 branch (mattias.jonsson:3680) Bug#59976
Bug#11766780
View as plain text  
#At file:///C:/ade/mysql-bzr/b11766780-51/ based on revid:vasil.dimov@stripped

 3680 Mattias Jonsson	2011-05-02
      Bug#11766780 Bug#59976:
      TEMPORARY FILES REMAIN AFTER CHECK AND
      ADDING PARTITION
      
      The partition element state was not reset to PART_NORMAL
      after admin statements either it failed or not,
      resulting in extra files created and
      not cleaned up in following alter statements.
      
      Fixed by not using PART_CHANGED for admin state, but
      a new (from 5.5) PART_ADMIN instead.
      
      Also setting state to PART_NORMAL for unaffected partitions
      in set_part_state.

    modified:
      mysql-test/r/partition_myisam.result
      mysql-test/t/partition_myisam.test
      sql/ha_partition.cc
      sql/partition_element.h
      sql/sql_partition.cc
      sql/sql_table.cc
=== modified file 'mysql-test/r/partition_myisam.result'
--- a/mysql-test/r/partition_myisam.result	2011-04-27 15:51:06 +0000
+++ b/mysql-test/r/partition_myisam.result	2011-05-02 14:12:27 +0000
@@ -1,4 +1,26 @@
 DROP TABLE IF EXISTS t1, t2;
+#
+# Bug#11766780: Bug#59976: TEMPORARY FILES REMAIN AFTER CHECK AND
+#                          ADDING PARTITION
+#
+CREATE TABLE t1 (
+a INT UNSIGNED NOT NULL,
+b VARCHAR(50),
+PRIMARY KEY (a, b)
+) ENGINE = MyISAM
+PARTITION BY RANGE(a)
+(PARTITION p1 VALUES LESS THAN (10));
+ALTER TABLE t1 CHECK PARTITION p1;
+Table	Op	Msg_type	Msg_text
+test.t1	check	status	OK
+ALTER TABLE t1 ADD PARTITION (PARTITION p2 VALUES LESS THAN (20));
+t1#P#p1.MYD
+t1#P#p1.MYI
+t1#P#p2.MYD
+t1#P#p2.MYI
+t1.frm
+t1.par
+DROP TABLE t1;
 # Bug#30102 test
 CREATE TABLE t1 (a INT)
 PARTITION BY RANGE (a)

=== modified file 'mysql-test/t/partition_myisam.test'
--- a/mysql-test/t/partition_myisam.test	2011-04-27 15:51:06 +0000
+++ b/mysql-test/t/partition_myisam.test	2011-05-02 14:12:27 +0000
@@ -4,6 +4,23 @@ DROP TABLE IF EXISTS t1, t2;
 --enable_warnings
 let $MYSQLD_DATADIR= `SELECT @@datadir`;
 
+--echo #
+--echo # Bug#11766780: Bug#59976: TEMPORARY FILES REMAIN AFTER CHECK AND
+--echo #                          ADDING PARTITION
+--echo #
+CREATE TABLE t1 (
+  a INT UNSIGNED NOT NULL,
+  b VARCHAR(50),
+  PRIMARY KEY (a, b)
+) ENGINE = MyISAM
+PARTITION BY RANGE(a)
+(PARTITION p1 VALUES LESS THAN (10));
+
+ALTER TABLE t1 CHECK PARTITION p1;
+ALTER TABLE t1 ADD PARTITION (PARTITION p2 VALUES LESS THAN (20));
+--list_files $MYSQLD_DATADIR/test t1*
+DROP TABLE t1;
+
 #
 # Bug#30102: rename table does corrupt tables with partition files on failure
 #

=== modified file 'sql/ha_partition.cc'
--- a/sql/ha_partition.cc	2011-04-29 07:48:26 +0000
+++ b/sql/ha_partition.cc	2011-05-02 14:12:27 +0000
@@ -1104,7 +1104,7 @@ int ha_partition::handle_opt_partitions(
       it should only do named partitions, otherwise all partitions
     */
     if (!(thd->lex->alter_info.flags & ALTER_ADMIN_PARTITION) ||
-        part_elem->part_state == PART_CHANGED)
+        part_elem->part_state == PART_ADMIN)
     {
       if (m_is_sub_partitioned)
       {
@@ -1136,8 +1136,15 @@ int ha_partition::handle_opt_partitions(
                               "Subpartition %s returned error", 
                               sub_elem->partition_name);
             }
+            /* reset part_state for the remaining partitions */
+            do
+            {
+              if (part_elem->part_state == PART_ADMIN)
+                part_elem->part_state= PART_NORMAL;
+            } while ((part_elem= part_it++));
             DBUG_RETURN(error);
           }
+          part_elem->part_state= PART_NORMAL;
         } while (++j < no_subparts);
       }
       else
@@ -1162,8 +1169,15 @@ int ha_partition::handle_opt_partitions(
                             opt_op_name[flag], "Partition %s returned error", 
                             part_elem->partition_name);
           }
+          /* reset part_state for the remaining partitions */
+          do
+          {
+            if (part_elem->part_state == PART_ADMIN)
+              part_elem->part_state= PART_NORMAL;
+          } while ((part_elem= part_it++));
           DBUG_RETURN(error);
         }
+        part_elem->part_state= PART_NORMAL;
       }
     }
   } while (++i < no_parts);
@@ -5895,7 +5909,7 @@ int ha_partition::extra(enum ha_extra_fu
     0                    Success
 
   DESCRIPTION
-    Called at end of each statement to reste buffers
+    Called at end of each statement to reset buffers
 */
 
 int ha_partition::reset(void)

=== modified file 'sql/partition_element.h'
--- a/sql/partition_element.h	2007-04-13 17:23:02 +0000
+++ b/sql/partition_element.h	2011-05-02 14:12:27 +0000
@@ -32,7 +32,8 @@ enum partition_state {
   PART_REORGED_DROPPED= 5,
   PART_CHANGED= 6,
   PART_IS_CHANGED= 7,
-  PART_IS_ADDED= 8
+  PART_IS_ADDED= 8,
+  PART_ADMIN= 9
 };
 
 /*

=== modified file 'sql/sql_partition.cc'
--- a/sql/sql_partition.cc	2011-02-22 21:03:32 +0000
+++ b/sql/sql_partition.cc	2011-05-02 14:12:27 +0000
@@ -4262,6 +4262,8 @@ uint set_part_state(Alter_info *alter_in
       DBUG_PRINT("info", ("Setting part_state to %u for partition %s",
                           part_state, part_elem->partition_name));
     }
+    else
+      part_elem->part_state= PART_NORMAL;
   } while (++part_count < tab_part_info->no_parts);
   return no_parts_found;
 }
@@ -4392,8 +4394,8 @@ uint prep_alter_part_table(THD *thd, TAB
                         *fast_alter_partition, flags));
     if (((alter_info->flags & ALTER_ADD_PARTITION) ||
          (alter_info->flags & ALTER_REORGANIZE_PARTITION)) &&
-         (thd->work_part_info->part_type != tab_part_info->part_type) &&
-         (thd->work_part_info->part_type != NOT_A_PARTITION))
+        (thd->work_part_info->part_type != tab_part_info->part_type) &&
+        (thd->work_part_info->part_type != NOT_A_PARTITION))
     {
       if (thd->work_part_info->part_type == RANGE_PARTITION)
       {

=== modified file 'sql/sql_table.cc'
--- a/sql/sql_table.cc	2010-11-10 08:32:42 +0000
+++ b/sql/sql_table.cc	2011-05-02 14:12:27 +0000
@@ -4628,7 +4628,7 @@ static bool mysql_admin_table(THD* thd, 
           uint no_parts_found;
           uint no_parts_opt= alter_info->partition_names.elements;
           no_parts_found= set_part_state(alter_info, table->table->part_info,
-                                         PART_CHANGED);
+                                         PART_ADMIN);
           if (no_parts_found != no_parts_opt &&
               (!(alter_info->flags & ALTER_ALL_PARTITION)))
           {


Attachment: [text/bzr-bundle] bzr/mattias.jonsson@oracle.com-20110502141227-gessx7npq7j0ax77.bundle
Thread
bzr commit into mysql-5.1 branch (mattias.jonsson:3680) Bug#59976Bug#11766780Mattias Jonsson2 May