List:Commits« Previous MessageNext Message »
From:Satya B Date:July 8 2009 12:11pm
Subject:bzr commit into mysql-5.1-bugteam branch (satya.bn:3013) Bug#35111
View as plain text  
#At file:///home/satya/WORK/35111/mysql-5.1-bugteam-35111/ based on revid:joro@stripped

 3013 Satya B	2009-07-08
      Bug#35111 - Truncate a MyISAM partitioned table does not reset
      the auto_increment value
            
      This is an alternative patch that instead of allowing RECREATE TABLE
      on TRUNCATE TABLE it implements reset_auto_increment that is called
      after delete_all_rows.
      
      Note: this bug was fixed by Mattias Jonsson:
      Pusing this patch: http://lists.mysql.com/commits/70370
      modified:
        mysql-test/suite/parts/r/partition_auto_increment_memory.result
        mysql-test/suite/parts/r/partition_auto_increment_myisam.result
        sql/ha_partition.cc
        storage/heap/ha_heap.cc
        storage/heap/ha_heap.h
        storage/myisam/ha_myisam.cc
        storage/myisam/ha_myisam.h

per-file messages:
  mysql-test/suite/parts/r/partition_auto_increment_memory.result
    Bug#35111: Truncate a MyISAM partitioned table does not reset
    the auto_increment value
  mysql-test/suite/parts/r/partition_auto_increment_myisam.result
    Bug#35111: Truncate a MyISAM partitioned table does not reset
    the auto_increment value
  sql/ha_partition.cc
    Bug#35111: Truncate a MyISAM partitioned table does not reset
    the auto_increment value
    
    Added reset_auto_increment, to be used after delete_all_rows
    to simulate truncate.
  storage/heap/ha_heap.cc
    Bug#35111: Truncate a MyISAM partitioned table does not reset
    the auto_increment value
    
    Added reset_auto_increment, to be used after delete_all_rows
    to simulate truncate
  storage/heap/ha_heap.h
    Bug#35111: Truncate a MyISAM partitioned table does not reset
    the auto_increment value
    
    Added reset_auto_increment, to be used after delete_all_rows
    to simulate truncate
  storage/myisam/ha_myisam.cc
    Bug#35111: Truncate a MyISAM partitioned table does not reset
    the auto_increment value
    
    Added reset_auto_increment, to be used after delete_all_rows
    to simulate truncate.
  storage/myisam/ha_myisam.h
    Bug#35111: Truncate a MyISAM partitioned table does not reset
    the auto_increment value
    
    Added reset_auto_increment, to be used after delete_all_rows
    to simulate truncate.
=== modified file 'mysql-test/suite/parts/r/partition_auto_increment_memory.result'
--- a/mysql-test/suite/parts/r/partition_auto_increment_memory.result	2009-02-05 17:47:24 +0000
+++ b/mysql-test/suite/parts/r/partition_auto_increment_memory.result	2009-07-08 12:11:34 +0000
@@ -381,12 +381,12 @@ Table	Create Table
 t1	CREATE TABLE `t1` (
   `c1` int(11) NOT NULL AUTO_INCREMENT,
   PRIMARY KEY (`c1`)
-) ENGINE=MEMORY AUTO_INCREMENT=28 DEFAULT CHARSET=latin1
+) ENGINE=MEMORY AUTO_INCREMENT=2 DEFAULT CHARSET=latin1
 /*!50100 PARTITION BY HASH (c1)
 PARTITIONS 2 */
 SELECT * FROM t1 ORDER BY c1;
 c1
-27
+1
 INSERT INTO t1 VALUES (100);
 INSERT INTO t1 VALUES (NULL);
 DELETE FROM t1 WHERE c1 >= 100;

=== modified file 'mysql-test/suite/parts/r/partition_auto_increment_myisam.result'
--- a/mysql-test/suite/parts/r/partition_auto_increment_myisam.result	2009-02-05 17:47:24 +0000
+++ b/mysql-test/suite/parts/r/partition_auto_increment_myisam.result	2009-07-08 12:11:34 +0000
@@ -381,12 +381,12 @@ Table	Create Table
 t1	CREATE TABLE `t1` (
   `c1` int(11) NOT NULL AUTO_INCREMENT,
   PRIMARY KEY (`c1`)
-) ENGINE=MyISAM AUTO_INCREMENT=28 DEFAULT CHARSET=latin1
+) ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=latin1
 /*!50100 PARTITION BY HASH (c1)
 PARTITIONS 2 */
 SELECT * FROM t1 ORDER BY c1;
 c1
-27
+1
 INSERT INTO t1 VALUES (100);
 INSERT INTO t1 VALUES (NULL);
 DELETE FROM t1 WHERE c1 >= 100;

=== modified file 'sql/ha_partition.cc'
--- a/sql/ha_partition.cc	2009-02-20 15:56:32 +0000
+++ b/sql/ha_partition.cc	2009-07-08 12:11:34 +0000
@@ -3179,6 +3179,7 @@ int ha_partition::delete_row(const uchar
 int ha_partition::delete_all_rows()
 {
   int error;
+  bool truncate= FALSE;
   handler **file;
   THD *thd= ha_thd();
   DBUG_ENTER("ha_partition::delete_all_rows");
@@ -3190,12 +3191,16 @@ int ha_partition::delete_all_rows()
     ha_data->next_auto_inc_val= 0;
     ha_data->auto_inc_initialized= FALSE;
     unlock_auto_increment();
+    truncate= TRUE;
   }
   file= m_file;
   do
   {
     if ((error= (*file)->ha_delete_all_rows()))
       DBUG_RETURN(error);
+    /* Ignore the error */
+    if (truncate)
+      (void) (*file)->ha_reset_auto_increment(0);
   } while (*(++file));
   DBUG_RETURN(0);
 }

=== modified file 'storage/heap/ha_heap.cc'
--- a/storage/heap/ha_heap.cc	2008-12-16 12:12:22 +0000
+++ b/storage/heap/ha_heap.cc	2009-07-08 12:11:34 +0000
@@ -419,6 +419,14 @@ int ha_heap::delete_all_rows()
   return 0;
 }
 
+
+int ha_heap::reset_auto_increment(ulonglong value)
+{
+  file->s->auto_increment= value;
+  return 0;
+}
+
+
 int ha_heap::external_lock(THD *thd, int lock_type)
 {
   return 0;					// No external locking

=== modified file 'storage/heap/ha_heap.h'
--- a/storage/heap/ha_heap.h	2007-08-13 13:11:25 +0000
+++ b/storage/heap/ha_heap.h	2009-07-08 12:11:34 +0000
@@ -98,6 +98,7 @@ public:
   int reset();
   int external_lock(THD *thd, int lock_type);
   int delete_all_rows(void);
+  int reset_auto_increment(ulonglong value);
   int disable_indexes(uint mode);
   int enable_indexes(uint mode);
   int indexes_are_disabled(void);

=== modified file 'storage/myisam/ha_myisam.cc'
--- a/storage/myisam/ha_myisam.cc	2009-06-29 14:00:47 +0000
+++ b/storage/myisam/ha_myisam.cc	2009-07-08 12:11:34 +0000
@@ -1870,6 +1870,12 @@ int ha_myisam::delete_all_rows()
   return mi_delete_all_rows(file);
 }
 
+int ha_myisam::reset_auto_increment(ulonglong value)
+{
+  file->s->state.auto_increment= value;
+  return 0;
+}
+
 int ha_myisam::delete_table(const char *name)
 {
   return mi_delete_table(name);

=== modified file 'storage/myisam/ha_myisam.h'
--- a/storage/myisam/ha_myisam.h	2007-11-15 19:25:43 +0000
+++ b/storage/myisam/ha_myisam.h	2009-07-08 12:11:34 +0000
@@ -101,6 +101,7 @@ class ha_myisam: public handler
   int reset(void);
   int external_lock(THD *thd, int lock_type);
   int delete_all_rows(void);
+  int reset_auto_increment(ulonglong value);
   int disable_indexes(uint mode);
   int enable_indexes(uint mode);
   int indexes_are_disabled(void);

Thread
bzr commit into mysql-5.1-bugteam branch (satya.bn:3013) Bug#35111Satya B8 Jul