3423 Jon Olav Hauglid 2011-11-16
WL#5534 Online ALTER, Phase 1.
Patch #47: Review requests from Marko
- Add separate flags for ADD/DROP FOREIGN KEY
- Change handler flags to be of HA_ALTER_FLAGS type
modified:
sql/handler.h
sql/sql_alter.h
sql/sql_partition.cc
sql/sql_table.cc
sql/sql_yacc.yy
3422 Jon Olav Hauglid 2011-11-16
WL#5534 Online ALTER, Phase 1.
Patch #46: Review fixes, part 4.
- Renamed Alter_inplace_information to Alter_inplace_info
- Moved parser flags to Alter_info and documented them
- Moved handler flags to Alter_inplace_info, removed HA_ prefix
and added documentation
- Removed unused parser and handler flags
- Added HA_ALTER_FLAGS member to Alter_inplace_info and
removed it as an explicit parameter in Online alter API calls
- Removed const from ha_alter_info parameter in
handler::check_if_supported_inplace_alter()
- Converted HA_ALTER_FLAGS from Bitmap to ulong and
reverted changes introduced to sql_bitmap
- Added missing DROP_PK_INDEX flag to compatibilty layer
checks.
- Removed setup_ha_alter_flags()
- Renamed compare_tables() to fill_alter_inplace_info()
- Added is_inplace_alter_impossible() to check for operations
that by design cannot be performed using in-place alter.
modified:
sql/ha_partition.cc
sql/ha_partition.h
sql/handler.cc
sql/handler.h
sql/sql_admin.cc
sql/sql_alter.cc
sql/sql_alter.h
sql/sql_bitmap.h
sql/sql_lex.cc
sql/sql_lex.h
sql/sql_partition.cc
sql/sql_partition_admin.cc
sql/sql_table.cc
sql/sql_yacc.yy
=== modified file 'sql/handler.h'
--- a/sql/handler.h 2011-11-16 11:29:51 +0000
+++ b/sql/handler.h 2011-11-16 12:27:09 +0000
@@ -943,56 +943,59 @@ public:
typedef ulong HA_ALTER_FLAGS;
// Add non-unique, non-primary index
- static const ulong ADD_INDEX = 1L << 0;
+ static const HA_ALTER_FLAGS ADD_INDEX = 1L << 0;
// Drop non-unique, non-primary index
- static const ulong DROP_INDEX = 1L << 1;
+ static const HA_ALTER_FLAGS DROP_INDEX = 1L << 1;
// Add unique, non-primary index
- static const ulong ADD_UNIQUE_INDEX = 1L << 2;
+ static const HA_ALTER_FLAGS ADD_UNIQUE_INDEX = 1L << 2;
// Drop unique, non-primary index
- static const ulong DROP_UNIQUE_INDEX = 1L << 3;
+ static const HA_ALTER_FLAGS DROP_UNIQUE_INDEX = 1L << 3;
// Add primary index
- static const ulong ADD_PK_INDEX = 1L << 4;
+ static const HA_ALTER_FLAGS ADD_PK_INDEX = 1L << 4;
// Drop primary index
- static const ulong DROP_PK_INDEX = 1L << 5;
+ static const HA_ALTER_FLAGS DROP_PK_INDEX = 1L << 5;
// Add column
- static const ulong ADD_COLUMN = 1L << 6;
+ static const HA_ALTER_FLAGS ADD_COLUMN = 1L << 6;
// Drop column
- static const ulong DROP_COLUMN = 1L << 7;
+ static const HA_ALTER_FLAGS DROP_COLUMN = 1L << 7;
// General flag for CHANGE [COLUMN] | MODIFY [COLUMN], See ALTER_COLUMN_*
- static const ulong CHANGE_COLUMN = 1L << 8;
+ static const HA_ALTER_FLAGS CHANGE_COLUMN = 1L << 8;
// Rename column
- static const ulong ALTER_COLUMN_NAME = 1L << 9;
+ static const HA_ALTER_FLAGS ALTER_COLUMN_NAME = 1L << 9;
// Change column datatype
- static const ulong ALTER_COLUMN_TYPE = 1L << 10;
+ static const HA_ALTER_FLAGS ALTER_COLUMN_TYPE = 1L << 10;
// Reorder column
- static const ulong ALTER_COLUMN_ORDER = 1L << 11;
+ static const HA_ALTER_FLAGS ALTER_COLUMN_ORDER = 1L << 11;
// Change column from NULL to NOT NULL or vice versa
- static const ulong ALTER_COLUMN_NULLABLE = 1L << 12;
+ static const HA_ALTER_FLAGS ALTER_COLUMN_NULLABLE = 1L << 12;
// Set or remove default column value
- static const ulong COLUMN_DEFAULT_VALUE = 1L << 13;
+ static const HA_ALTER_FLAGS COLUMN_DEFAULT_VALUE = 1L << 13;
- // Add or drop foreign key
- static const ulong ALTER_FOREIGN_KEY = 1L << 14;
+ // Add foreign key
+ static const HA_ALTER_FLAGS ADD_FOREIGN_KEY = 1L << 14;
+
+ // Drop foreign key
+ static const HA_ALTER_FLAGS DROP_FOREIGN_KEY = 1L << 15;
// Change character set
- static const ulong CHANGE_CHARACTER_SET = 1L << 15;
- static const ulong SET_DEFAULT_CHARACTER_SET = 1L << 16;
+ static const HA_ALTER_FLAGS CHANGE_CHARACTER_SET = 1L << 16;
+ static const HA_ALTER_FLAGS SET_DEFAULT_CHARACTER_SET = 1L << 17;
// table_options changed, see HA_CREATE_INFO::used_fields for details.
- static const ulong CHANGE_CREATE_OPTION = 1L << 17;
+ static const HA_ALTER_FLAGS CHANGE_CREATE_OPTION = 1L << 18;
KEY *key_info_buffer;
uint key_count;
@@ -2302,7 +2305,7 @@ public:
}
/*
- Part of old in-place alter table, to be depricated
+ Part of old in-place alter table, to be deprecated
*/
virtual bool check_if_incompatible_data(HA_CREATE_INFO *create_info,
uint table_changes)
=== modified file 'sql/sql_alter.h'
--- a/sql/sql_alter.h 2011-11-16 11:29:51 +0000
+++ b/sql/sql_alter.h 2011-11-16 12:27:09 +0000
@@ -110,17 +110,20 @@ public:
// Set for REMOVE PARTITIONING
static const uint ALTER_REMOVE_PARTITIONING = 1L << 21;
- // Set for ADD FOREIGN KEY | DROP FOREIGN KEY
- static const uint ALTER_FOREIGN_KEY = 1L << 22;
+ // Set for ADD FOREIGN KEY
+ static const uint ADD_FOREIGN_KEY = 1L << 22;
+
+ // Set for DROP FOREIGN KEY
+ static const uint DROP_FOREIGN_KEY = 1L << 23;
// Set for EXCHANGE PARITION
- static const uint ALTER_EXCHANGE_PARTITION = 1L << 23;
+ static const uint ALTER_EXCHANGE_PARTITION = 1L << 24;
// Set by Sql_cmd_alter_table_truncate_partition::execute()
- static const uint ALTER_TRUNCATE_PARTITION = 1L << 24;
+ static const uint ALTER_TRUNCATE_PARTITION = 1L << 25;
// Set for ADD [COLUMN] FIRST | AFTER
- static const uint ALTER_COLUMN_ORDER = 1L << 25;
+ static const uint ALTER_COLUMN_ORDER = 1L << 26;
enum enum_enable_or_disable { LEAVE_AS_IS, ENABLE, DISABLE };
=== modified file 'sql/sql_partition.cc'
--- a/sql/sql_partition.cc 2011-11-16 11:29:51 +0000
+++ b/sql/sql_partition.cc 2011-11-16 12:27:09 +0000
@@ -4663,7 +4663,8 @@ uint prep_alter_part_table(THD *thd, TAB
DBUG_ENTER("prep_alter_part_table");
/* Foreign keys on partitioned tables are not supported, waits for WL#148 */
- if (table->part_info && (alter_info->flags & Alter_info::ALTER_FOREIGN_KEY))
+ if (table->part_info && (alter_info->flags & Alter_info::ADD_FOREIGN_KEY ||
+ alter_info->flags & Alter_info::DROP_FOREIGN_KEY))
{
my_error(ER_FOREIGN_KEY_ON_PARTITIONED, MYF(0));
DBUG_RETURN(TRUE);
=== modified file 'sql/sql_table.cc'
--- a/sql/sql_table.cc 2011-11-16 11:29:51 +0000
+++ b/sql/sql_table.cc 2011-11-16 12:27:09 +0000
@@ -5110,8 +5110,10 @@ static bool fill_alter_inplace_info(THD
ha_alter_info->handler_flags|= Alter_inplace_info::COLUMN_DEFAULT_VALUE;
if (alter_info->flags & Alter_info::ALTER_COLUMN_ORDER)
ha_alter_info->handler_flags|= Alter_inplace_info::ALTER_COLUMN_ORDER;
- if (alter_info->flags & Alter_info::ALTER_FOREIGN_KEY)
- ha_alter_info->handler_flags|= Alter_inplace_info::ALTER_FOREIGN_KEY;
+ if (alter_info->flags & Alter_info::ADD_FOREIGN_KEY)
+ ha_alter_info->handler_flags|= Alter_inplace_info::ADD_FOREIGN_KEY;
+ if (alter_info->flags & Alter_info::DROP_FOREIGN_KEY)
+ ha_alter_info->handler_flags|= Alter_inplace_info::DROP_FOREIGN_KEY;
if (alter_info->flags & Alter_info::ALTER_OPTIONS)
ha_alter_info->handler_flags|= Alter_inplace_info::CHANGE_CREATE_OPTION;
@@ -5151,7 +5153,8 @@ static bool fill_alter_inplace_info(THD
create_info->used_fields & HA_CREATE_USED_PACK_KEYS ||
create_info->used_fields & HA_CREATE_USED_MAX_ROWS ||
(alter_info->flags & (Alter_info::ALTER_RECREATE |
- Alter_info::ALTER_FOREIGN_KEY)) ||
+ Alter_info::ADD_FOREIGN_KEY |
+ Alter_info::DROP_FOREIGN_KEY)) ||
order_num ||
!table->s->mysql_version ||
(table->s->frm_version < FRM_VER_TRUE_VARCHAR && varchar))
@@ -5636,7 +5639,8 @@ mysql_compare_tables(TABLE *table,
create_info->used_fields & HA_CREATE_USED_PACK_KEYS ||
create_info->used_fields & HA_CREATE_USED_MAX_ROWS ||
(alter_info->flags & (Alter_info::ALTER_RECREATE |
- Alter_info::ALTER_FOREIGN_KEY)) ||
+ Alter_info::ADD_FOREIGN_KEY |
+ Alter_info::DROP_FOREIGN_KEY)) ||
order_num ||
!table->s->mysql_version ||
(table->s->frm_version < FRM_VER_TRUE_VARCHAR && varchar))
=== modified file 'sql/sql_yacc.yy'
--- a/sql/sql_yacc.yy 2011-11-16 11:29:51 +0000
+++ b/sql/sql_yacc.yy 2011-11-16 12:27:09 +0000
@@ -5639,7 +5639,7 @@ key_def:
&default_key_create_info, 1))
MYSQL_YYABORT;
/* Only used for ALTER TABLE. Ignored otherwise. */
- lex->alter_info.flags|= Alter_info::ALTER_FOREIGN_KEY;
+ lex->alter_info.flags|= Alter_info::ADD_FOREIGN_KEY;
}
| opt_constraint check_constraint
{
@@ -7042,7 +7042,7 @@ alter_list_item:
| DROP FOREIGN KEY_SYM opt_ident
{
Lex->alter_info.flags|= Alter_info::ALTER_DROP_INDEX |
- Alter_info::ALTER_FOREIGN_KEY;
+ Alter_info::DROP_FOREIGN_KEY;
}
| DROP PRIMARY_SYM KEY_SYM
{
No bundle (reason: useless for push emails).
| Thread |
|---|
| • bzr push into mysql-trunk-wl5534 branch (jon.hauglid:3422 to 3423) WL#5534 | Jon Olav Hauglid | 16 Nov |