List:Commits« Previous MessageNext Message »
From:Jon Olav Hauglid Date:October 5 2011 1:03pm
Subject:bzr push into mysql-trunk-wl5534 branch (jon.hauglid:3400 to 3401) WL#5534
View as plain text  
 3401 Jon Olav Hauglid	2011-10-05
      WL#5534 Online ALTER, Phase 1.
        
      Patch #29:
      - Don't promote unique keys to primary keys if the index
        contains column prefixes. Update the ALTER TABLE logic
        to match logic already present in open_binary_frm().

    modified:
      sql/sql_table.cc
 3400 Jon Olav Hauglid	2011-10-03
      WL#5534 Online ALTER, Phase 1.
        
      Patch #28:
      - Allow duplicate key error reporting using KEY rather
        than key number.

    modified:
      sql/handler.cc
      sql/handler.h
      sql/key.cc
      sql/key.h
=== modified file 'sql/sql_table.cc'
--- a/sql/sql_table.cc	2011-09-28 09:12:26 +0000
+++ b/sql/sql_table.cc	2011-10-05 13:02:47 +0000
@@ -5303,13 +5303,15 @@ compare_tables(THD *thd,
       be promoted to primary key if the original primary key is dropped.
     */
     not_nullable= true;
+    bool prefix_key= false;
     for (table_part= table_key->key_part;
          table_part < table_part_end;
          table_part++)
     {
       not_nullable= not_nullable && (! table_part->field->maybe_null());
+      prefix_key= prefix_key || (table_part->key_part_flag & HA_PART_KEY_SEG);
     }
-    if ((table_key->flags & HA_NOSAME) && not_nullable)
+    if ((table_key->flags & HA_NOSAME) && not_nullable && !prefix_key)
       candidate_key_count++;
   }
 
@@ -5447,7 +5449,8 @@ compare_tables(THD *thd,
           *alter_flags|= HA_DROP_INDEX;
           if ((!my_strcasecmp(system_charset_info,
                               new_key->name, primary_key_name)) ||
-              (no_pk && candidate_key_count == 0 && is_not_null))
+              (no_pk && candidate_key_count == 0 && is_not_null &&
+               !(new_key->flags & HA_KEY_HAS_PART_KEY_SEG)))
             *alter_flags|= HA_ADD_PK_INDEX;
           else
             *alter_flags|= HA_ADD_UNIQUE_INDEX;
@@ -5572,7 +5575,8 @@ compare_tables(THD *thd,
         DBUG_PRINT("info",("no_pk %s, candidate_key_count %u, is_not_null %s", (no_pk)?"yes":"no", candidate_key_count, (is_not_null)?"yes":"no"));
         if ((!my_strcasecmp(system_charset_info,
                             new_key->name, primary_key_name)) ||
-            (no_pk && candidate_key_count == 0 && is_not_null))
+            (no_pk && candidate_key_count == 0 && is_not_null &&
+             !(new_key->flags & HA_KEY_HAS_PART_KEY_SEG)))
           *alter_flags|= HA_ADD_PK_INDEX;
         else
           *alter_flags|= HA_ADD_UNIQUE_INDEX;

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