List:Commits« Previous MessageNext Message »
From:Dmitry Lenev Date:June 15 2012 11:30am
Subject:bzr push into mysql-trunk branch (Dmitry.Lenev:4017 to 4018) Bug#14096759
View as plain text  
 4018 Dmitry Lenev	2012-06-15
      Fix for bug#14096759 "INPLACE ALTER, FIELD_FLAG FIELD_IN_ADD_INDEX HAS 
      BEEN REMOVED FROM SERVER".
      
      After WL@5534 "Online ALTER, Phase 1" has introduced new in-place ALTER
      TABLE API semantics of FIELD_IN_ADD_INDEX flag became unclear and thus
      this flag was removed from the code.
      
      It turns out that Cluster's implementation of Online ALTER still needs
      this flag as it allows to avoid extra iterations through keys list.
      
      This patch re-introduces this flag with a new, clearly defined 
      semantics:
      - it is now set for fields in TABLE object which correspond to 
        new version of altered table.
      - it is set for all fields which participate in newly added keys,
        including fields that exist in old version of table and fields 
        that were added by the same ALTER TABLE.

    modified:
      include/mysql_com.h
      sql/sql_table.cc
 4017 Marko Mäkelä	2012-06-15
      Bug#14198766 row_drop_table_for_mysql() releases dict_operation_lock latch
      while holding record locks on data dictionary tables
      
      This bug mostly affects a table rebuild, such as ADD PRIMARY KEY.
      
      ha_innobase::commit_inplace_alter_table(): Invoke
      dict_stats_wait_bg_to_stop_using_tables() on both tables upfront.
      
      row_drop_table_for_mysql(): Do not invoke
      dict_stats_wait_bg_to_stop_using_tables() if data dictionary locks
      were already acquired by the caller (signalled by a new parameter,
      nonatomic=false). Remove the code that waits for the full-text-search
      related background threads to exit. According to Jimmy, this is stale
      code that should be removed. Add a debug assertion to enforce
      !table->fts->add_wq.
      
      row_merge_drop_table(): Add the parameter nonatomic.
      
      rb:1112 approved by Jimmy Yang

    modified:
      storage/innobase/handler/handler0alter.cc
      storage/innobase/include/row0merge.h
      storage/innobase/include/row0mysql.h
      storage/innobase/row/row0merge.cc
      storage/innobase/row/row0mysql.cc
=== modified file 'include/mysql_com.h'
--- a/include/mysql_com.h	2012-06-04 15:35:18 +0000
+++ b/include/mysql_com.h	2012-06-15 11:29:52 +0000
@@ -114,10 +114,11 @@ enum enum_server_command
 #define BINCMP_FLAG	131072		/* Intern: Used by sql_yacc */
 #define GET_FIXED_FIELDS_FLAG (1 << 18) /* Used to get fields in item tree */
 #define FIELD_IN_PART_FUNC_FLAG (1 << 19)/* Field part of partition func */
-/*
-  #define FIELD_IN_ADD_INDEX (1<< 20)
-  Was part of old online ALTER API, flag is now unused.
+/**
+  Intern: Field in TABLE object for new version of altered table,
+          which participates in a newly added index.
 */
+#define FIELD_IN_ADD_INDEX (1 << 20)
 #define FIELD_IS_RENAMED (1<< 21)       /* Intern: Field is being renamed */
 #define FIELD_FLAGS_STORAGE_MEDIA 22    /* Field storage media, bit 22-23 */
 #define FIELD_FLAGS_STORAGE_MEDIA_MASK (3 << FIELD_FLAGS_STORAGE_MEDIA)

=== modified file 'sql/sql_table.cc'
--- a/sql/sql_table.cc	2012-06-10 10:49:24 +0000
+++ b/sql/sql_table.cc	2012-06-15 11:29:52 +0000
@@ -5696,6 +5696,46 @@ static bool fill_alter_inplace_info(THD
 
 
 /**
+  Mark fields participating in newly added indexes in TABLE object which
+  corresponds to new version of altered table.
+
+  @param ha_alter_info  Alter_inplace_info describing in-place ALTER.
+  @param altered_table  TABLE object for new version of TABLE in which
+                        fields should be marked.
+*/
+
+static void update_altered_table(const Alter_inplace_info &ha_alter_info,
+                                 TABLE *altered_table)
+{
+  uint field_idx, add_key_idx;
+  KEY *key;
+  KEY_PART_INFO *end, *key_part;
+
+  /*
+    Clear marker for all fields, as we are going to set it only
+    for fields which participate in new indexes.
+  */
+  for (field_idx= 0; field_idx < altered_table->s->fields; ++field_idx)
+    altered_table->field[field_idx]->flags&= ~FIELD_IN_ADD_INDEX;
+
+  /*
+    Go through array of newly added indexes and mark fields
+    participating in them.
+  */
+  for (add_key_idx= 0; add_key_idx < ha_alter_info.index_add_count;
+       add_key_idx++)
+  {
+    key= ha_alter_info.key_info_buffer +
+         ha_alter_info.index_add_buffer[add_key_idx];
+
+    end= key->key_part + key->key_parts;
+    for (key_part= key->key_part; key_part < end; key_part++)
+      altered_table->field[key_part->fieldnr]->flags|= FIELD_IN_ADD_INDEX;
+  }
+}
+
+
+/**
   Compare two tables to see if their metadata are compatible.
   One table specified by a TABLE instance, the other using Alter_info
   and HA_CREATE_INFO.
@@ -7296,6 +7336,9 @@ bool mysql_alter_table(THD *thd,char *ne
                                              true, false)))
       goto err_new_table_cleanup;
 
+    /* Set markers for fields in TABLE object for altered table. */
+    update_altered_table(ha_alter_info, altered_table);
+
     if (ha_alter_info.handler_flags == 0)
     {
       /*

No bundle (reason: useless for push emails).
Thread
bzr push into mysql-trunk branch (Dmitry.Lenev:4017 to 4018) Bug#14096759Dmitry Lenev18 Jun