List:Commits« Previous MessageNext Message »
From:holyfoot Date:December 6 2007 12:39pm
Subject:bk commit into 5.1 tree (holyfoot:1.2645) BUG#32247
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 repository of hf. When hf does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet@stripped, 2007-12-06 16:39:42+04:00, holyfoot@stripped +6 -0
  Bug #32247 Test reports wrong value of "AUTO_INCREMENT" (on a partitioned InnoDB table).
  
  ha_partition::update_create_info() just calls update_create_info
  of a first partition, so only get the autoincrement maximum
  of the first partition, so SHOW CREATE TABLE can show
  small AUTO_INCREMENT parameters.
  Fixed by implementing ha_partition::update_create_info() in a way
  other handlers work.
  HA_ARCHIVE:stats.auto_increment handling made consistent with other engines

  mysql-test/r/archive.result@stripped, 2007-12-06 16:39:40+04:00, holyfoot@stripped +1 -1
    Bug #32247 Test reports wrong value of "AUTO_INCREMENT" (on a partitioned InnoDB table).
    
    test result fixed

  mysql-test/r/partition.result@stripped, 2007-12-06 16:39:40+04:00, holyfoot@stripped +15 -0
    Bug #32247 Test reports wrong value of "AUTO_INCREMENT" (on a partitioned InnoDB table).
    
    test result

  mysql-test/suite/rpl/r/rpl_innodb_bug28430.result@stripped, 2007-12-06 16:39:40+04:00, holyfoot@stripped +1 -1
    Bug #32247 Test reports wrong value of "AUTO_INCREMENT" (on a partitioned InnoDB table).
    
    test result fixed

  mysql-test/t/partition.test@stripped, 2007-12-06 16:39:40+04:00, holyfoot@stripped +21 -0
    Bug #32247 Test reports wrong value of "AUTO_INCREMENT" (on a partitioned InnoDB table).
    
    test added as rpl_innodb_bug28430 is INNOBASE specific while
    the bug is not

  sql/ha_partition.cc@stripped, 2007-12-06 16:39:40+04:00, holyfoot@stripped +5 -1
    Bug #32247 Test reports wrong value of "AUTO_INCREMENT" (on a partitioned InnoDB table).
    
    ha_partition::update_create_info() implemented

  storage/archive/ha_archive.cc@stripped, 2007-12-06 16:39:40+04:00, holyfoot@stripped +14 -23
    Bug #32247 Test reports wrong value of "AUTO_INCREMENT" (on a partitioned InnoDB table).
    
    ha_archive.stats.auto_increment now contains next (not last used) value
    of auto_increment to be consistent with other engines

diff -Nrup a/mysql-test/r/archive.result b/mysql-test/r/archive.result
--- a/mysql-test/r/archive.result	2007-10-28 01:27:44 +05:00
+++ b/mysql-test/r/archive.result	2007-12-06 16:39:40 +04:00
@@ -12665,7 +12665,7 @@ t6	CREATE TABLE `t6` (
   `b` tinyblob,
   `c` int(11) DEFAULT NULL,
   KEY `a` (`a`)
-) ENGINE=ARCHIVE DEFAULT CHARSET=latin1
+) ENGINE=ARCHIVE AUTO_INCREMENT=36 DEFAULT CHARSET=latin1
 DROP TABLE t1, t2, t4, t5, t6;
 create table t1 (i int) engine=archive;
 insert into t1 values (1);
diff -Nrup a/mysql-test/r/partition.result b/mysql-test/r/partition.result
--- a/mysql-test/r/partition.result	2007-11-12 14:26:07 +04:00
+++ b/mysql-test/r/partition.result	2007-12-06 16:39:40 +04:00
@@ -1291,4 +1291,19 @@ t1	CREATE TABLE `t1` (
   `b` int(11) DEFAULT NULL
 ) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (b) (PARTITION p1 VALUES LESS THAN (10) ENGINE = MyISAM, PARTITION p2 VALUES LESS THAN (20) ENGINE = MyISAM) */
 drop table t1, t2;
+CREATE TABLE t1(id MEDIUMINT NOT NULL AUTO_INCREMENT,
+user CHAR(25), PRIMARY KEY(id))
+PARTITION BY RANGE(id)
+SUBPARTITION BY hash(id) subpartitions 2
+(PARTITION pa1 values less than (10),
+PARTITION pa2 values less than (20),
+PARTITION pa11 values less than MAXVALUE);
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `id` mediumint(9) NOT NULL AUTO_INCREMENT,
+  `user` char(25) DEFAULT NULL,
+  PRIMARY KEY (`id`)
+) ENGINE=MyISAM AUTO_INCREMENT=16 DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (id) SUBPARTITION BY HASH (id) SUBPARTITIONS 2 (PARTITION pa1 VALUES LESS THAN (10) ENGINE = MyISAM, PARTITION pa2 VALUES LESS THAN (20) ENGINE = MyISAM, PARTITION pa11 VALUES LESS THAN MAXVALUE ENGINE = MyISAM) */
+drop table t1;
 End of 5.1 tests
diff -Nrup a/mysql-test/suite/rpl/r/rpl_innodb_bug28430.result b/mysql-test/suite/rpl/r/rpl_innodb_bug28430.result
--- a/mysql-test/suite/rpl/r/rpl_innodb_bug28430.result	2007-09-13 21:34:17 +05:00
+++ b/mysql-test/suite/rpl/r/rpl_innodb_bug28430.result	2007-12-06 16:39:40 +04:00
@@ -113,7 +113,7 @@ Create Table	CREATE TABLE `byrange_tbl` 
   `fkid` mediumint(9) DEFAULT NULL,
   `filler` varchar(255) DEFAULT NULL,
   PRIMARY KEY (`id`)
-) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (id) SUBPARTITION BY HASH (id) SUBPARTITIONS 2 (PARTITION pa1 VALUES LESS THAN (10) ENGINE = InnoDB, PARTITION pa2 VALUES LESS THAN (20) ENGINE = InnoDB, PARTITION pa3 VALUES LESS THAN (30) ENGINE = InnoDB, PARTITION pa4 VALUES LESS THAN (40) ENGINE = InnoDB, PARTITION pa5 VALUES LESS THAN (50) ENGINE = InnoDB, PARTITION pa6 VALUES LESS THAN (60) ENGINE = InnoDB, PARTITION pa7 VALUES LESS THAN (70) ENGINE = InnoDB, PARTITION pa8 VALUES LESS THAN (80) ENGINE = InnoDB, PARTITION pa9 VALUES LESS THAN (90) ENGINE = InnoDB, PARTITION pa10 VALUES LESS THAN (100) ENGINE = InnoDB, PARTITION pa11 VALUES LESS THAN MAXVALUE ENGINE = InnoDB) */
+) ENGINE=InnoDB AUTO_INCREMENT=1001 DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (id) SUBPARTITION BY HASH (id) SUBPARTITIONS 2 (PARTITION pa1 VALUES LESS THAN (10) ENGINE = InnoDB, PARTITION pa2 VALUES LESS THAN (20) ENGINE = InnoDB, PARTITION pa3 VALUES LESS THAN (30) ENGINE = InnoDB, PARTITION pa4 VALUES LESS THAN (40) ENGINE = InnoDB, PARTITION pa5 VALUES LESS THAN (50) ENGINE = InnoDB, PARTITION pa6 VALUES LESS THAN (60) ENGINE = InnoDB, PARTITION pa7 VALUES LESS THAN (70) ENGINE = InnoDB, PARTITION pa8 VALUES LESS THAN (80) ENGINE = InnoDB, PARTITION pa9 VALUES LESS THAN (90) ENGINE = InnoDB, PARTITION pa10 VALUES LESS THAN (100) ENGINE = InnoDB, PARTITION pa11 VALUES LESS THAN MAXVALUE ENGINE = InnoDB) */
 show slave status;
 Slave_IO_State	Waiting for master to send event
 Master_Host	127.0.0.1
diff -Nrup a/mysql-test/t/partition.test b/mysql-test/t/partition.test
--- a/mysql-test/t/partition.test	2007-11-12 14:26:07 +04:00
+++ b/mysql-test/t/partition.test	2007-12-06 16:39:40 +04:00
@@ -1528,4 +1528,25 @@ PARTITION BY RANGE (b) (
 show create table t1;
 drop table t1, t2;
 
+#
+# Bug #32247 Test reports wrong value of "AUTO_INCREMENT" (on a partitioned InnoDB table)
+#
+
+CREATE TABLE t1(id MEDIUMINT NOT NULL AUTO_INCREMENT,
+                user CHAR(25), PRIMARY KEY(id))
+                   PARTITION BY RANGE(id)
+                   SUBPARTITION BY hash(id) subpartitions 2
+                   (PARTITION pa1 values less than (10),
+                    PARTITION pa2 values less than (20),
+                    PARTITION pa11 values less than MAXVALUE);
+--disable_query_log
+let $n= 15;
+while ($n)
+{
+  insert into t1 (user) values ('mysql');
+  dec $n;
+}
+--enable_query_log
+show create table t1;
+drop table t1;
 --echo End of 5.1 tests
diff -Nrup a/sql/ha_partition.cc b/sql/ha_partition.cc
--- a/sql/ha_partition.cc	2007-10-23 19:02:24 +05:00
+++ b/sql/ha_partition.cc	2007-12-06 16:39:40 +04:00
@@ -1598,7 +1598,11 @@ error:
 
 void ha_partition::update_create_info(HA_CREATE_INFO *create_info)
 {
-  m_file[0]->update_create_info(create_info);
+  info(HA_STATUS_AUTO);
+
+  if (!(create_info->used_fields & HA_CREATE_USED_AUTO))
+    create_info->auto_increment_value= stats.auto_increment_value;
+
   return;
 }
 
diff -Nrup a/storage/archive/ha_archive.cc b/storage/archive/ha_archive.cc
--- a/storage/archive/ha_archive.cc	2007-10-28 02:29:15 +05:00
+++ b/storage/archive/ha_archive.cc	2007-12-06 16:39:40 +04:00
@@ -357,7 +357,7 @@ ARCHIVE_SHARE *ha_archive::get_share(con
     {
       DBUG_RETURN(NULL);
     }
-    stats.auto_increment_value= archive_tmp.auto_increment;
+    stats.auto_increment_value= archive_tmp.auto_increment + 1;
     share->rows_recorded= (ha_rows)archive_tmp.rows;
     share->crashed= archive_tmp.dirty;
     azclose(&archive_tmp);
@@ -586,9 +586,7 @@ int ha_archive::create(const char *name,
 
   DBUG_ENTER("ha_archive::create");
 
-  stats.auto_increment_value= (create_info->auto_increment_value ?
-                               create_info->auto_increment_value -1 :
-                               (ulonglong) 0);
+  stats.auto_increment_value= create_info->auto_increment_value;
 
   for (uint key= 0; key < table_arg->s->keys; key++)
   {
@@ -673,7 +671,8 @@ int ha_archive::create(const char *name,
       Yes you need to do this, because the starting value 
       for the autoincrement may not be zero.
     */
-    create_stream.auto_increment= stats.auto_increment_value;
+    create_stream.auto_increment= stats.auto_increment_value ?
+                                    stats.auto_increment_value - 1 : 0;
     if (azclose(&create_stream))
     {
       error= errno;
@@ -871,8 +870,8 @@ int ha_archive::write_row(uchar *buf)
     else
     {
       if (temp_auto > share->archive_write.auto_increment)
-        stats.auto_increment_value= share->archive_write.auto_increment= 
-          temp_auto;
+        stats.auto_increment_value=
+          (share->archive_write.auto_increment= temp_auto) + 1;
     }
   }
 
@@ -896,7 +895,7 @@ void ha_archive::get_auto_increment(ulon
                                     ulonglong *first_value,
                                     ulonglong *nb_reserved_values)
 {
-  *nb_reserved_values= 1;
+  *nb_reserved_values= ULONGLONG_MAX;
   *first_value= share->archive_write.auto_increment + 1;
 }
 
@@ -1315,7 +1314,8 @@ int ha_archive::optimize(THD* thd, HA_CH
     if (!rc)
     {
       share->rows_recorded= 0;
-      stats.auto_increment_value= share->archive_write.auto_increment= 0;
+      stats.auto_increment_value= 1;
+      share->archive_write.auto_increment= 0;
       my_bitmap_map *org_bitmap= dbug_tmp_use_all_columns(table, table->read_set);
 
       while (!(rc= get_row(&archive, table->record[0])))
@@ -1332,8 +1332,8 @@ int ha_archive::optimize(THD* thd, HA_CH
             (ulonglong) field->val_int(table->record[0] +
                                        field->offset(table->record[0]));
           if (share->archive_write.auto_increment < auto_value)
-            stats.auto_increment_value= share->archive_write.auto_increment=
-              auto_value;
+            stats.auto_increment_value=
+              (share->archive_write.auto_increment= auto_value) + 1;
         }
       }
 
@@ -1418,18 +1418,9 @@ void ha_archive::update_create_info(HA_C
   DBUG_ENTER("ha_archive::update_create_info");
 
   ha_archive::info(HA_STATUS_AUTO);
-  if (create_info->used_fields & HA_CREATE_USED_AUTO)
+  if (!(create_info->used_fields & HA_CREATE_USED_AUTO))
   {
-    /* 
-      Internally Archive keeps track of last used, not next used.
-      To make the output look like MyISAM we add 1 here.
-
-      This is not completely compatible with MYISAM though, since
-      MyISAM will record on "SHOW CREATE TABLE" the last position,
-      where we will report the original position the table was
-      created with.
-    */
-    create_info->auto_increment_value= stats.auto_increment_value + 1;
+    create_info->auto_increment_value= stats.auto_increment_value;
   }
 
   if (!(my_readlink(share->real_path, share->data_file_name, MYF(0))))
@@ -1494,7 +1485,7 @@ int ha_archive::info(uint flag)
     pthread_mutex_lock(&share->mutex);
     azflush(&archive, Z_SYNC_FLUSH);
     pthread_mutex_unlock(&share->mutex);
-    stats.auto_increment_value= archive.auto_increment;
+    stats.auto_increment_value= archive.auto_increment + 1;
   }
 
   DBUG_RETURN(0);
Thread
bk commit into 5.1 tree (holyfoot:1.2645) BUG#32247holyfoot6 Dec