List:Commits« Previous MessageNext Message »
From:Jon Olav Hauglid Date:October 27 2011 10:59am
Subject:bzr push into mysql-trunk-wl5534 branch (jon.hauglid:3414 to 3415) WL#5534
View as plain text  
 3415 Jon Olav Hauglid	2011-10-27
      WL#5534 Online ALTER, Phase 1.
        
      Patch #41:
      Polishing patch. Remove duplicated code for
      handler::print_keydup_error().

    modified:
      sql/handler.cc
      sql/handler.h
      sql/sql_table.cc
 3414 Jon Olav Hauglid	2011-10-26
      WL#5534 Online ALTER, Phase 1.
        
      Patch #40:
      Fix for a deadlock scenario involving thr_lock.c and
      ALTER TABLE RENAME / ENABLE KEYS / DISABLE KEYS.
      Release the thr_lock.c lock before trying to upgrade
      the metadata lock then acquire it again after the
      metadata lock has been upgraded.

    modified:
      mysql-test/r/alter_table.result
      mysql-test/t/alter_table.test
      sql/sql_table.cc
=== modified file 'sql/handler.cc'
--- a/sql/handler.cc	2011-10-22 09:41:04 +0000
+++ b/sql/handler.cc	2011-10-27 10:58:28 +0000
@@ -2909,40 +2909,11 @@ void handler::ha_release_auto_increment(
 }
 
 
-void handler::print_keydup_error(uint key_nr, const char *msg)
-{
-  /* Write the duplicated key in the error message */
-  char key[MAX_KEY_LENGTH];
-  String str(key,sizeof(key),system_charset_info);
-
-  if (key_nr == MAX_KEY)
-  {
-    /* Key is unknown */
-    str.copy("", 0, system_charset_info);
-    my_printf_error(ER_DUP_ENTRY, msg, MYF(0), str.c_ptr(), "*UNKNOWN*");
-  }
-  else
-  {
-    /* Table is opened and defined at this point */
-    key_unpack(&str,table, &table->key_info[key_nr]);
-    uint max_length=MYSQL_ERRMSG_SIZE-(uint) strlen(msg);
-    if (str.length() >= max_length)
-    {
-      str.length(max_length-4);
-      str.append(STRING_WITH_LEN("..."));
-    }
-    my_printf_error(ER_DUP_ENTRY, msg,
-		    MYF(0), str.c_ptr_safe(), table->key_info[key_nr].name);
-  }
-}
-
-
-void handler::print_keydup_error(KEY *key)
+void handler::print_keydup_error(KEY *key, const char *msg)
 {
   /* Write the duplicated key in the error message */
   char key_buff[MAX_KEY_LENGTH];
   String str(key_buff,sizeof(key_buff),system_charset_info);
-  const char *msg= ER(ER_DUP_ENTRY_WITH_KEY_NAME);
 
   if (key == NULL)
   {
@@ -2966,6 +2937,12 @@ void handler::print_keydup_error(KEY *ke
 }
 
 
+void handler::print_keydup_error(KEY *key)
+{
+  print_keydup_error(key, ER(ER_DUP_ENTRY_WITH_KEY_NAME));
+}
+
+
 /**
   Print error that we got from handler function.
 
@@ -3005,7 +2982,7 @@ void handler::print_error(int error, myf
     uint key_nr=get_dup_key(error);
     if ((int) key_nr >= 0)
     {
-      print_keydup_error(key_nr, ER(ER_DUP_ENTRY_WITH_KEY_NAME));
+      print_keydup_error(key_nr == MAX_KEY ? NULL : &table->key_info[key_nr]);
       DBUG_VOID_RETURN;
     }
     textno=ER_DUP_KEY;

=== modified file 'sql/handler.h'
--- a/sql/handler.h	2011-10-26 08:08:16 +0000
+++ b/sql/handler.h	2011-10-27 10:58:28 +0000
@@ -1661,7 +1661,7 @@ public:
 
   void adjust_next_insert_id_after_explicit_value(ulonglong nr);
   int update_auto_increment();
-  void print_keydup_error(uint key_nr, const char *msg);
+  void print_keydup_error(KEY *key, const char *msg);
   void print_keydup_error(KEY *key);
   virtual void print_error(int error, myf errflag);
   virtual bool get_error_message(int error, String *buf);

=== modified file 'sql/sql_table.cc'
--- a/sql/sql_table.cc	2011-10-26 12:56:30 +0000
+++ b/sql/sql_table.cc	2011-10-27 10:58:28 +0000
@@ -7950,7 +7950,7 @@ copy_data_between_tables(TABLE *from,TAB
                  (to->key_info[0].key_part[0].field->flags &
                   AUTO_INCREMENT_FLAG))
                err_msg= ER(ER_DUP_ENTRY_AUTOINCREMENT_CASE);
-             to->file->print_keydup_error(key_nr, err_msg);
+             to->file->print_keydup_error(&to->key_info[key_nr], err_msg);
              break;
            }
          }

No bundle (reason: useless for push emails).
Thread
bzr push into mysql-trunk-wl5534 branch (jon.hauglid:3414 to 3415) WL#5534Jon Olav Hauglid27 Oct