From: Jon Olav Hauglid Date: July 16 2012 7:41am Subject: bzr push into mysql-trunk branch (jon.hauglid:4056 to 4057) List-Archive: http://lists.mysql.com/commits/144452 Message-Id: <20120716074141.1193.57485.4057@atum08.no.oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 4057 Jon Olav Hauglid 2012-07-16 [merge] Merge from mysql-5.6 to mysql-trunk No conflicts modified: sql/ha_partition.cc sql/handler.h sql/sql_partition.cc sql/sql_table.cc 4056 Nirbhay Choubey 2012-07-13 [merge] Null merge. === modified file 'sql/ha_partition.cc' --- a/sql/ha_partition.cc 2012-06-15 15:32:44 +0000 +++ b/sql/ha_partition.cc 2012-07-16 07:21:48 +0000 @@ -7585,6 +7585,7 @@ err: Alter_inplace_info drop_info(ha_alter_info->create_info, ha_alter_info->alter_info, NULL, 0, + ha_alter_info->modified_part_info, ha_alter_info->ignore); if (ha_alter_info->handler_flags & Alter_inplace_info::ADD_INDEX) === modified file 'sql/handler.h' --- a/sql/handler.h 2012-06-11 11:30:25 +0000 +++ b/sql/handler.h 2012-07-16 07:21:48 +0000 @@ -1169,6 +1169,30 @@ public: // Change the column format of column static const HA_ALTER_FLAGS ALTER_COLUMN_COLUMN_FORMAT = 1L << 20; + // Add partition + static const HA_ALTER_FLAGS ADD_PARTITION = 1L << 21; + + // Drop partition + static const HA_ALTER_FLAGS DROP_PARTITION = 1L << 22; + + // Changing partition options + static const HA_ALTER_FLAGS ALTER_PARTITION = 1L << 23; + + // Coalesce partition + static const HA_ALTER_FLAGS COALESCE_PARTITION = 1L << 24; + + // Reorganize partition ... into + static const HA_ALTER_FLAGS REORGANIZE_PARTITION = 1L << 25; + + // Reorganize partition + static const HA_ALTER_FLAGS ALTER_TABLE_REORG = 1L << 26; + + // Remove partitioning + static const HA_ALTER_FLAGS ALTER_REMOVE_PARTITIONING = 1L << 27; + + // Partition operation with ALL keyword + static const HA_ALTER_FLAGS ALTER_ALL_PARTITION = 1L << 28; + /** Create options (like MAX_ROWS) for the new version of table. @@ -1244,12 +1268,21 @@ public: */ HA_ALTER_FLAGS handler_flags; + /** + Partition_info taking into account the partition changes to be performed. + Contains all partitions which are present in the old version of the table + with partitions to be dropped or changed marked as such + all partitions + to be added in the new version of table marked as such. + */ + partition_info *modified_part_info; + /** true for ALTER IGNORE TABLE ... */ const bool ignore; Alter_inplace_info(HA_CREATE_INFO *create_info_arg, Alter_info *alter_info_arg, KEY *key_info_arg, uint key_count_arg, + partition_info *modified_part_info_arg, bool ignore_arg) : create_info(create_info_arg), alter_info(alter_info_arg), @@ -1261,6 +1294,7 @@ public: index_add_buffer(NULL), handler_ctx(NULL), handler_flags(0), + modified_part_info(modified_part_info_arg), ignore(ignore_arg) {} === modified file 'sql/sql_partition.cc' --- a/sql/sql_partition.cc 2012-06-21 09:50:01 +0000 +++ b/sql/sql_partition.cc 2012-07-16 07:21:48 +0000 @@ -4768,8 +4768,16 @@ uint prep_alter_part_table(THD *thd, TAB if (alter_info->flags & Alter_info::ALTER_TABLE_REORG) { uint new_part_no, curr_part_no; + /* + 'ALTER TABLE t REORG PARTITION' only allowed with auto partition + if default partitioning is used. + */ + if (tab_part_info->part_type != HASH_PARTITION || - tab_part_info->use_default_num_partitions) + ((table->s->db_type()->partition_flags() & HA_USE_AUTO_PARTITION) && + !tab_part_info->use_default_num_partitions) || + ((!(table->s->db_type()->partition_flags() & HA_USE_AUTO_PARTITION)) && + tab_part_info->use_default_num_partitions)) { my_error(ER_REORG_NO_PARAM_ERROR, MYF(0)); goto err; @@ -4783,9 +4791,23 @@ uint prep_alter_part_table(THD *thd, TAB after the change as before. Thus we can reply ok immediately without any changes at all. */ - *fast_alter_table= true; - /* Force table re-open for consistency with the main case. */ - table->m_needs_reopen= true; + flags= table->file->alter_table_flags(alter_info->flags); + if (flags & (HA_FAST_CHANGE_PARTITION | HA_PARTITION_ONE_PHASE)) + { + *fast_alter_table= true; + /* Force table re-open for consistency with the main case. */ + table->m_needs_reopen= true; + } + else + { + /* + Create copy of partition_info to avoid modifying original + TABLE::part_info, to keep it safe for later use. + */ + if (!(tab_part_info= tab_part_info->get_clone())) + DBUG_RETURN(TRUE); + } + thd->work_part_info= tab_part_info; DBUG_RETURN(FALSE); } === modified file 'sql/sql_table.cc' --- a/sql/sql_table.cc 2012-07-13 14:17:49 +0000 +++ b/sql/sql_table.cc 2012-07-16 07:41:02 +0000 @@ -5422,6 +5422,23 @@ static bool fill_alter_inplace_info(THD ha_alter_info->handler_flags|= Alter_inplace_info::CHANGE_CREATE_OPTION; if (alter_info->flags & Alter_info::ALTER_RENAME) ha_alter_info->handler_flags|= Alter_inplace_info::ALTER_RENAME; + /* Check partition changes */ + if (alter_info->flags & Alter_info::ALTER_ADD_PARTITION) + ha_alter_info->handler_flags|= Alter_inplace_info::ADD_PARTITION; + if (alter_info->flags & Alter_info::ALTER_DROP_PARTITION) + ha_alter_info->handler_flags|= Alter_inplace_info::DROP_PARTITION; + if (alter_info->flags & Alter_info::ALTER_PARTITION) + ha_alter_info->handler_flags|= Alter_inplace_info::ALTER_PARTITION; + if (alter_info->flags & Alter_info::ALTER_COALESCE_PARTITION) + ha_alter_info->handler_flags|= Alter_inplace_info::COALESCE_PARTITION; + if (alter_info->flags & Alter_info::ALTER_REORGANIZE_PARTITION) + ha_alter_info->handler_flags|= Alter_inplace_info::REORGANIZE_PARTITION; + if (alter_info->flags & Alter_info::ALTER_TABLE_REORG) + ha_alter_info->handler_flags|= Alter_inplace_info::ALTER_TABLE_REORG; + if (alter_info->flags & Alter_info::ALTER_REMOVE_PARTITIONING) + ha_alter_info->handler_flags|= Alter_inplace_info::ALTER_REMOVE_PARTITIONING; + if (alter_info->flags & Alter_info::ALTER_ALL_PARTITION) + ha_alter_info->handler_flags|= Alter_inplace_info::ALTER_ALL_PARTITION; /* If we altering table with old VARCHAR fields we will be automatically @@ -7229,14 +7246,18 @@ bool mysql_alter_table(THD *thd,char *ne - old_alter_table system variable is set without in-place requested using the ALGORITHM clause. - Or if in-place is impossible for given operation. - - A partition will be changed. + - Changes to partitioning which were not handled by fast_alter_part_table() + needs to be handled using table copying algorithm unless the engine + supports auto-partitioning as such engines can do some changes + using in-place API. */ if ((thd->variables.old_alter_table && alter_info->requested_algorithm != Alter_info::ALTER_TABLE_ALGORITHM_INPLACE) || is_inplace_alter_impossible(table, create_info, alter_info) #ifdef WITH_PARTITION_STORAGE_ENGINE - || partition_changed + || (partition_changed && + !(table->s->db_type()->partition_flags() & HA_USE_AUTO_PARTITION)) #endif ) { @@ -7362,7 +7383,13 @@ bool mysql_alter_table(THD *thd,char *ne if (alter_info->requested_algorithm != Alter_info::ALTER_TABLE_ALGORITHM_COPY) { Alter_inplace_info ha_alter_info(create_info, alter_info, - key_info, key_count, ignore); + key_info, key_count, +#ifdef WITH_PARTITION_STORAGE_ENGINE + thd->work_part_info, +#else + NULL, +#endif + ignore); TABLE *altered_table= NULL; bool use_inplace= true; No bundle (reason: useless for push emails).