List:Commits« Previous MessageNext Message »
From:holyfoot Date:May 10 2006 7:30pm
Subject:bk commit into 5.1 tree (holyfoot:1.2383) BUG#14573
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
  1.2383 06/05/10 22:30:11 holyfoot@deer.(none) +6 -0
  bug #14573 (Error on adding auto_increment to a column with 0 values)

  sql/sql_table.cc
    1.332 06/05/10 22:28:11 holyfoot@stripped +11 -0
    check if the error was in auto_increment

  sql/share/errmsg.txt
    1.99 06/05/10 22:28:11 holyfoot@stripped +2 -0
    message added

  sql/handler.cc
    1.232 06/05/10 22:28:11 holyfoot@stripped +10 -2
    now we return different error message in the case of autoincrement collision

  mysql-test/t/auto_increment.test
    1.25 06/05/10 22:28:11 holyfoot@stripped +11 -0
    testcase

  mysql-test/r/auto_increment.result
    1.38 06/05/10 22:28:11 holyfoot@stripped +6 -0
    result fixed

  include/my_base.h
    1.88 06/05/10 22:28:11 holyfoot@stripped +3 -1
    HA_ERR_ALTER_AUTOINCREMENT declared

# This is a BitKeeper patch.  What follows are the unified diffs for the
# set of deltas contained in the patch.  The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User:	holyfoot
# Host:	deer.(none)
# Root:	/home/hf/work/mysql-5.1.14573

--- 1.87/include/my_base.h	Wed May  3 17:59:11 2006
+++ 1.88/include/my_base.h	Wed May 10 22:28:11 2006
@@ -374,8 +374,10 @@
                                             would lead to a duplicate key
                                             error in some other table. */
 #define HA_ERR_TABLE_NEEDS_UPGRADE 164  /* The table changed in storage engine */
+#define HA_ERR_ALTER_AUTOINCREMENT 165	/* ALTER TABLE with AUTO_INCREMENT */
+                                        /* caused duplicating keys         */
 
-#define HA_ERR_LAST              164  /*Copy last error nr.*/
+#define HA_ERR_LAST              165  /*Copy last error nr.*/
 /* Add error numbers before HA_ERR_LAST and change it accordingly. */
 #define HA_ERR_ERRORS            (HA_ERR_LAST - HA_ERR_FIRST + 1)
 

--- 1.231/sql/handler.cc	Fri May  5 22:08:36 2006
+++ 1.232/sql/handler.cc	Wed May 10 22:28:11 2006
@@ -1853,8 +1853,10 @@
     textno=ER_WRONG_MRG_TABLE;
     break;
   case HA_ERR_FOUND_DUPP_KEY:
+  case HA_ERR_ALTER_AUTOINCREMENT:
   {
-    uint key_nr=get_dup_key(error);
+    uint key_nr= (error == HA_ERR_FOUND_DUPP_KEY) ?
+                  get_dup_key(error) : 0;
     if ((int) key_nr >= 0)
     {
       /* Write the duplicated key in the error message */
@@ -1868,7 +1870,13 @@
 	str.length(max_length-4);
 	str.append(STRING_WITH_LEN("..."));
       }
-      my_error(ER_DUP_ENTRY, MYF(0), str.c_ptr(), table->key_info[key_nr].name);
+      if (error == HA_ERR_FOUND_DUPP_KEY)
+        my_error(ER_DUP_ENTRY, MYF(0), str.c_ptr(),
+                 table->key_info[key_nr].name);
+      else
+        my_printf_error(ER_DUP_ENTRY, ER(ER_DUP_ENTRY_AUTOINCREMENT_CASE),
+                        MYF(0), str.c_ptr(), table->key_info[0].name);
+
       DBUG_VOID_RETURN;
     }
     textno=ER_DUP_KEY;

--- 1.331/sql/sql_table.cc	Fri May  5 22:08:37 2006
+++ 1.332/sql/sql_table.cc	Wed May 10 22:28:11 2006
@@ -6323,6 +6323,17 @@
 	  (error != HA_ERR_FOUND_DUPP_KEY &&
 	   error != HA_ERR_FOUND_DUPP_UNIQUE))
       {
+        if (error == HA_ERR_FOUND_DUPP_KEY)
+        {
+          uint key_nr= to->file->get_dup_key(error);
+          if (key_nr == 0 &&
+              (to->key_info[0].key_part[0].field->flags &
+               AUTO_INCREMENT_FLAG))
+          {
+            to->file->print_error(HA_ERR_ALTER_AUTOINCREMENT, MYF(0));
+            break;
+          }
+        }
 	to->file->print_error(error,MYF(0));
 	break;
       }

--- 1.98/sql/share/errmsg.txt	Thu May  4 21:39:43 2006
+++ 1.99/sql/share/errmsg.txt	Wed May 10 22:28:11 2006
@@ -5842,3 +5842,5 @@
         swe "Felaktigt partitionsnamn"
 ER_CANT_CHANGE_TX_ISOLATION 25001
 	eng "Transaction isolation level can't be changed while a transaction is in progress"
+ER_DUP_ENTRY_AUTOINCREMENT_CASE
+	eng "ALTER TABLE causes resequencing with MyISAM, causing Duplicate entry '%-.64s' for
key '%-.64s'"

--- 1.37/mysql-test/r/auto_increment.result	Mon Jan 23 15:16:57 2006
+++ 1.38/mysql-test/r/auto_increment.result	Wed May 10 22:28:11 2006
@@ -394,3 +394,9 @@
 2	1
 3	1
 drop table t1;
+CREATE TABLE t1 (t1 INT(10) PRIMARY KEY, t2 INT(10));
+INSERT INTO t1 VALUES(0, 0);
+INSERT INTO t1 VALUES(1, 1);
+ALTER TABLE t1 CHANGE t1 t1 INT(10) auto_increment;
+ERROR 23000: ALTER TABLE causes resequencing with MyISAM, causing Duplicate entry '1' for
key 'PRIMARY'
+DROP TABLE t1;

--- 1.24/mysql-test/t/auto_increment.test	Thu Jul 28 19:09:48 2005
+++ 1.25/mysql-test/t/auto_increment.test	Wed May 10 22:28:11 2006
@@ -256,3 +256,14 @@
 insert into t1 (val) values (1);
 select * from t1;
 drop table t1;
+
+#
+# Test key duplications with auto-increment in ALTER TABLE
+# bug #14573
+#
+CREATE TABLE t1 (t1 INT(10) PRIMARY KEY, t2 INT(10));
+INSERT INTO t1 VALUES(0, 0);
+INSERT INTO t1 VALUES(1, 1);
+--error ER_DUP_ENTRY
+ALTER TABLE t1 CHANGE t1 t1 INT(10) auto_increment;
+DROP TABLE t1;
Thread
bk commit into 5.1 tree (holyfoot:1.2383) BUG#14573holyfoot10 May