Commit 0ce93910 authored by Sergei Golubchik's avatar Sergei Golubchik

fix for alter_table_online test.

Map ALTER ONLINE TABLE to ALTER TABLE ... ALGORITHM=INPLACE.
Make MERGE engine to announce its support of inplace operations.
parent 7ac5a1d3
...@@ -11,61 +11,59 @@ drop table t1; ...@@ -11,61 +11,59 @@ drop table t1;
create temporary table t1 (a int not null primary key, b int, c varchar(80), e enum('a','b')); create temporary table t1 (a int not null primary key, b int, c varchar(80), e enum('a','b'));
insert into t1 (a) values (1),(2),(3); insert into t1 (a) values (1),(2),(3);
alter online table t1 modify b int default 5; alter online table t1 modify b int default 5;
ERROR HY000: Can't execute the given 'ALTER' command as online ERROR 0A000: ALGORITHM=INPLACE is not supported for this operation. Try ALGORITHM=COPY.
alter online table t1 change b new_name int; alter online table t1 change b new_name int;
ERROR HY000: Can't execute the given 'ALTER' command as online ERROR 0A000: ALGORITHM=INPLACE is not supported for this operation. Try ALGORITHM=COPY.
alter online table t1 modify e enum('a','b','c'); alter online table t1 modify e enum('a','b','c');
ERROR HY000: Can't execute the given 'ALTER' command as online ERROR 0A000: ALGORITHM=INPLACE is not supported for this operation. Try ALGORITHM=COPY.
alter online table t1 comment "new comment"; alter online table t1 comment "new comment";
ERROR HY000: Can't execute the given 'ALTER' command as online ERROR 0A000: ALGORITHM=INPLACE is not supported for this operation. Try ALGORITHM=COPY.
alter online table t1 rename to t2; alter online table t1 rename to t2;
ERROR HY000: Can't execute the given 'ALTER' command as online ERROR 0A000: ALGORITHM=INPLACE is not supported for this operation. Try ALGORITHM=COPY.
drop table t1; drop table t1;
create table t1 (a int not null primary key, b int, c varchar(80), e enum('a','b')); create table t1 (a int not null primary key, b int, c varchar(80), e enum('a','b'));
insert into t1 (a) values (1),(2),(3); insert into t1 (a) values (1),(2),(3);
alter online table t1 drop column b, add b int; alter online table t1 drop column b, add b int;
ERROR HY000: Can't execute the given 'ALTER' command as online ERROR 0A000: ALGORITHM=INPLACE is not supported for this operation. Try ALGORITHM=COPY.
alter online table t1 modify b bigint; alter online table t1 modify b bigint;
ERROR HY000: Can't execute the given 'ALTER' command as online ERROR 0A000: ALGORITHM=INPLACE is not supported for this operation. Try ALGORITHM=COPY.
alter online table t1 modify e enum('c','a','b'); alter online table t1 modify e enum('c','a','b');
ERROR HY000: Can't execute the given 'ALTER' command as online ERROR 0A000: ALGORITHM=INPLACE is not supported for this operation. Try ALGORITHM=COPY.
alter online table t1 modify c varchar(50); alter online table t1 modify c varchar(50);
ERROR HY000: Can't execute the given 'ALTER' command as online ERROR 0A000: ALGORITHM=INPLACE is not supported for this operation. Try ALGORITHM=COPY.
alter online table t1 modify c varchar(100); alter online table t1 modify c varchar(100);
ERROR HY000: Can't execute the given 'ALTER' command as online ERROR 0A000: ALGORITHM=INPLACE is not supported for this operation. Try ALGORITHM=COPY.
alter online table t1 add f int; alter online table t1 add f int;
ERROR HY000: Can't execute the given 'ALTER' command as online ERROR 0A000: ALGORITHM=INPLACE is not supported for this operation. Try ALGORITHM=COPY.
alter online table t1 engine=memory; alter online table t1 engine=memory;
ERROR HY000: Can't execute the given 'ALTER' command as online ERROR 0A000: ALGORITHM=INPLACE is not supported for this operation. Try ALGORITHM=COPY.
alter table t1 engine=innodb; alter table t1 engine=innodb;
alter table t1 add index (b); alter table t1 add index (b);
alter online table t1 add index c (c); alter online table t1 add index c (c);
ERROR HY000: Can't execute the given 'ALTER' command as online
alter online table t1 drop index b; alter online table t1 drop index b;
ERROR HY000: Can't execute the given 'ALTER' command as online
drop table t1; drop table t1;
create temporary table t1 (a int not null primary key, b int, c varchar(80), e enum('a','b')); create temporary table t1 (a int not null primary key, b int, c varchar(80), e enum('a','b'));
insert into t1 (a) values (1),(2),(3); insert into t1 (a) values (1),(2),(3);
alter online table t1 drop column b, add b int; alter online table t1 drop column b, add b int;
ERROR HY000: Can't execute the given 'ALTER' command as online ERROR 0A000: ALGORITHM=INPLACE is not supported for this operation. Try ALGORITHM=COPY.
alter online table t1 modify b bigint; alter online table t1 modify b bigint;
ERROR HY000: Can't execute the given 'ALTER' command as online ERROR 0A000: ALGORITHM=INPLACE is not supported for this operation. Try ALGORITHM=COPY.
alter online table t1 modify e enum('c','a','b'); alter online table t1 modify e enum('c','a','b');
ERROR HY000: Can't execute the given 'ALTER' command as online ERROR 0A000: ALGORITHM=INPLACE is not supported for this operation. Try ALGORITHM=COPY.
alter online table t1 modify c varchar(50); alter online table t1 modify c varchar(50);
ERROR HY000: Can't execute the given 'ALTER' command as online ERROR 0A000: ALGORITHM=INPLACE is not supported for this operation. Try ALGORITHM=COPY.
alter online table t1 modify c varchar(100); alter online table t1 modify c varchar(100);
ERROR HY000: Can't execute the given 'ALTER' command as online ERROR 0A000: ALGORITHM=INPLACE is not supported for this operation. Try ALGORITHM=COPY.
alter online table t1 add f int; alter online table t1 add f int;
ERROR HY000: Can't execute the given 'ALTER' command as online ERROR 0A000: ALGORITHM=INPLACE is not supported for this operation. Try ALGORITHM=COPY.
alter online table t1 engine=memory; alter online table t1 engine=memory;
ERROR HY000: Can't execute the given 'ALTER' command as online ERROR 0A000: ALGORITHM=INPLACE is not supported for this operation. Try ALGORITHM=COPY.
alter table t1 engine=innodb; alter table t1 engine=innodb;
alter table t1 add index (b); alter table t1 add index (b);
alter online table t1 add index c (c); alter online table t1 add index c (c);
ERROR HY000: Can't execute the given 'ALTER' command as online ERROR 0A000: ALGORITHM=INPLACE is not supported for this operation. Try ALGORITHM=COPY.
alter online table t1 drop index b; alter online table t1 drop index b;
ERROR HY000: Can't execute the given 'ALTER' command as online ERROR 0A000: ALGORITHM=INPLACE is not supported for this operation. Try ALGORITHM=COPY.
drop table t1; drop table t1;
create table t1 (a int not null primary key, b int, c varchar(80)); create table t1 (a int not null primary key, b int, c varchar(80));
create table t2 (a int not null primary key, b int, c varchar(80)); create table t2 (a int not null primary key, b int, c varchar(80));
......
# #
# Test of alter online table # Test of ALTER ONLINE TABLE syntax
# #
--source include/have_innodb.inc --source include/have_innodb.inc
...@@ -29,15 +29,15 @@ drop table t1; ...@@ -29,15 +29,15 @@ drop table t1;
create temporary table t1 (a int not null primary key, b int, c varchar(80), e enum('a','b')); create temporary table t1 (a int not null primary key, b int, c varchar(80), e enum('a','b'));
insert into t1 (a) values (1),(2),(3); insert into t1 (a) values (1),(2),(3);
--error ER_CANT_DO_ONLINE --error ER_ALTER_OPERATION_NOT_SUPPORTED
alter online table t1 modify b int default 5; alter online table t1 modify b int default 5;
--error ER_CANT_DO_ONLINE --error ER_ALTER_OPERATION_NOT_SUPPORTED
alter online table t1 change b new_name int; alter online table t1 change b new_name int;
--error ER_CANT_DO_ONLINE --error ER_ALTER_OPERATION_NOT_SUPPORTED
alter online table t1 modify e enum('a','b','c'); alter online table t1 modify e enum('a','b','c');
--error ER_CANT_DO_ONLINE --error ER_ALTER_OPERATION_NOT_SUPPORTED
alter online table t1 comment "new comment"; alter online table t1 comment "new comment";
--error ER_CANT_DO_ONLINE --error ER_ALTER_OPERATION_NOT_SUPPORTED
alter online table t1 rename to t2; alter online table t1 rename to t2;
drop table t1; drop table t1;
...@@ -49,52 +49,50 @@ drop table t1; ...@@ -49,52 +49,50 @@ drop table t1;
create table t1 (a int not null primary key, b int, c varchar(80), e enum('a','b')); create table t1 (a int not null primary key, b int, c varchar(80), e enum('a','b'));
insert into t1 (a) values (1),(2),(3); insert into t1 (a) values (1),(2),(3);
--error ER_CANT_DO_ONLINE --error ER_ALTER_OPERATION_NOT_SUPPORTED
alter online table t1 drop column b, add b int; alter online table t1 drop column b, add b int;
--error ER_CANT_DO_ONLINE --error ER_ALTER_OPERATION_NOT_SUPPORTED
alter online table t1 modify b bigint; alter online table t1 modify b bigint;
--error ER_CANT_DO_ONLINE --error ER_ALTER_OPERATION_NOT_SUPPORTED
alter online table t1 modify e enum('c','a','b'); alter online table t1 modify e enum('c','a','b');
--error ER_CANT_DO_ONLINE --error ER_ALTER_OPERATION_NOT_SUPPORTED
alter online table t1 modify c varchar(50); alter online table t1 modify c varchar(50);
--error ER_CANT_DO_ONLINE --error ER_ALTER_OPERATION_NOT_SUPPORTED
alter online table t1 modify c varchar(100); alter online table t1 modify c varchar(100);
--error ER_CANT_DO_ONLINE --error ER_ALTER_OPERATION_NOT_SUPPORTED
alter online table t1 add f int; alter online table t1 add f int;
--error ER_CANT_DO_ONLINE --error ER_ALTER_OPERATION_NOT_SUPPORTED
alter online table t1 engine=memory; alter online table t1 engine=memory;
alter table t1 engine=innodb; alter table t1 engine=innodb;
alter table t1 add index (b); alter table t1 add index (b);
--error ER_CANT_DO_ONLINE
alter online table t1 add index c (c); alter online table t1 add index c (c);
--error ER_CANT_DO_ONLINE
alter online table t1 drop index b; alter online table t1 drop index b;
drop table t1; drop table t1;
create temporary table t1 (a int not null primary key, b int, c varchar(80), e enum('a','b')); create temporary table t1 (a int not null primary key, b int, c varchar(80), e enum('a','b'));
insert into t1 (a) values (1),(2),(3); insert into t1 (a) values (1),(2),(3);
--error ER_CANT_DO_ONLINE --error ER_ALTER_OPERATION_NOT_SUPPORTED
alter online table t1 drop column b, add b int; alter online table t1 drop column b, add b int;
--error ER_CANT_DO_ONLINE --error ER_ALTER_OPERATION_NOT_SUPPORTED
alter online table t1 modify b bigint; alter online table t1 modify b bigint;
--error ER_CANT_DO_ONLINE --error ER_ALTER_OPERATION_NOT_SUPPORTED
alter online table t1 modify e enum('c','a','b'); alter online table t1 modify e enum('c','a','b');
--error ER_CANT_DO_ONLINE --error ER_ALTER_OPERATION_NOT_SUPPORTED
alter online table t1 modify c varchar(50); alter online table t1 modify c varchar(50);
--error ER_CANT_DO_ONLINE --error ER_ALTER_OPERATION_NOT_SUPPORTED
alter online table t1 modify c varchar(100); alter online table t1 modify c varchar(100);
--error ER_CANT_DO_ONLINE --error ER_ALTER_OPERATION_NOT_SUPPORTED
alter online table t1 add f int; alter online table t1 add f int;
--error ER_CANT_DO_ONLINE --error ER_ALTER_OPERATION_NOT_SUPPORTED
alter online table t1 engine=memory; alter online table t1 engine=memory;
alter table t1 engine=innodb; alter table t1 engine=innodb;
alter table t1 add index (b); alter table t1 add index (b);
--error ER_CANT_DO_ONLINE --error ER_ALTER_OPERATION_NOT_SUPPORTED
alter online table t1 add index c (c); alter online table t1 add index c (c);
--error ER_CANT_DO_ONLINE --error ER_ALTER_OPERATION_NOT_SUPPORTED
alter online table t1 drop index b; alter online table t1 drop index b;
drop table t1; drop table t1;
......
...@@ -2363,7 +2363,7 @@ struct LEX: public Query_tables_list ...@@ -2363,7 +2363,7 @@ struct LEX: public Query_tables_list
enum enum_yes_no_unknown tx_chain, tx_release; enum enum_yes_no_unknown tx_chain, tx_release;
bool safe_to_cache_query; bool safe_to_cache_query;
bool subqueries, ignore, online; bool subqueries, ignore;
st_parsing_options parsing_options; st_parsing_options parsing_options;
Alter_info alter_info; Alter_info alter_info;
/* /*
......
...@@ -6878,41 +6878,40 @@ string_list: ...@@ -6878,41 +6878,40 @@ string_list:
*/ */
alter: alter:
ALTER alter_options TABLE_SYM table_ident ALTER
{
Lex->name.str= 0;
Lex->name.length= 0;
Lex->sql_command= SQLCOM_ALTER_TABLE;
Lex->duplicates= DUP_ERROR;
Lex->col_list.empty();
Lex->select_lex.init_order();
bzero(&Lex->create_info, sizeof(Lex->create_info));
Lex->create_info.db_type= 0;
Lex->create_info.default_table_charset= NULL;
Lex->create_info.row_type= ROW_TYPE_NOT_USED;
Lex->alter_info.reset();
Lex->no_write_to_binlog= 0;
Lex->create_info.storage_media= HA_SM_DEFAULT;
DBUG_ASSERT(!Lex->m_sql_cmd);
}
alter_options TABLE_SYM table_ident
{ {
THD *thd= YYTHD; if (!Lex->select_lex.add_table_to_list(YYTHD, $5, NULL,
LEX *lex= thd->lex;
lex->name.str= 0;
lex->name.length= 0;
lex->sql_command= SQLCOM_ALTER_TABLE;
lex->duplicates= DUP_ERROR;
if (!lex->select_lex.add_table_to_list(thd, $4, NULL,
TL_OPTION_UPDATING, TL_OPTION_UPDATING,
TL_READ_NO_INSERT, TL_READ_NO_INSERT,
MDL_SHARED_UPGRADABLE)) MDL_SHARED_UPGRADABLE))
MYSQL_YYABORT; MYSQL_YYABORT;
lex->col_list.empty(); Lex->select_lex.db= (Lex->select_lex.table_list.first)->db;
lex->select_lex.init_order(); Lex->create_last_non_select_table= Lex->last_table();
lex->select_lex.db= (lex->select_lex.table_list.first)->db;
bzero((char*) &lex->create_info,sizeof(lex->create_info));
lex->create_info.db_type= 0;
lex->create_info.default_table_charset= NULL;
lex->create_info.row_type= ROW_TYPE_NOT_USED;
lex->alter_info.reset();
lex->no_write_to_binlog= 0;
lex->create_info.storage_media= HA_SM_DEFAULT;
lex->create_last_non_select_table= lex->last_table();
DBUG_ASSERT(!lex->m_sql_cmd);
} }
alter_commands alter_commands
{ {
THD *thd= YYTHD; if (!Lex->m_sql_cmd)
LEX *lex= thd->lex;
if (!lex->m_sql_cmd)
{ {
/* Create a generic ALTER TABLE statment. */ /* Create a generic ALTER TABLE statment. */
lex->m_sql_cmd= new (thd->mem_root) Sql_cmd_alter_table(); Lex->m_sql_cmd= new (YYTHD->mem_root) Sql_cmd_alter_table();
if (lex->m_sql_cmd == NULL) if (Lex->m_sql_cmd == NULL)
MYSQL_YYABORT; MYSQL_YYABORT;
} }
} }
...@@ -7586,7 +7585,7 @@ opt_ignore: ...@@ -7586,7 +7585,7 @@ opt_ignore:
; ;
alter_options: alter_options:
{ Lex->ignore= Lex->online= 0;} alter_options_part2 { Lex->ignore= 0;} alter_options_part2
; ;
alter_options_part2: alter_options_part2:
...@@ -7601,7 +7600,11 @@ alter_option_list: ...@@ -7601,7 +7600,11 @@ alter_option_list:
alter_option: alter_option:
IGNORE_SYM { Lex->ignore= 1;} IGNORE_SYM { Lex->ignore= 1;}
| ONLINE_SYM { Lex->online= 1;} | ONLINE_SYM
{
Lex->alter_info.requested_algorithm=
Alter_info::ALTER_TABLE_ALGORITHM_INPLACE;
}
opt_restrict: opt_restrict:
......
...@@ -1616,14 +1616,15 @@ void ha_myisammrg::append_create_info(String *packet) ...@@ -1616,14 +1616,15 @@ void ha_myisammrg::append_create_info(String *packet)
} }
bool ha_myisammrg::check_if_incompatible_data(HA_CREATE_INFO *info, enum_alter_inplace_result
uint table_changes) ha_myisammrg::check_if_supported_inplace_alter(TABLE *altered_table,
Alter_inplace_info *ha_alter_info)
{ {
/* /*
For myisammrg, we should always re-generate the mapping file as this We always support inplace ALTER in the new API, because old
is trivial to do HA_NO_COPY_ON_ALTER table_flags() hack prevents non-inplace ALTER anyway.
*/ */
return COMPATIBLE_DATA_NO; return HA_ALTER_INPLACE_EXCLUSIVE_LOCK;
} }
......
...@@ -145,7 +145,8 @@ class ha_myisammrg: public handler ...@@ -145,7 +145,8 @@ class ha_myisammrg: public handler
void append_create_info(String *packet); void append_create_info(String *packet);
MYRG_INFO *myrg_info() { return file; } MYRG_INFO *myrg_info() { return file; }
TABLE *table_ptr() { return table; } TABLE *table_ptr() { return table; }
bool check_if_incompatible_data(HA_CREATE_INFO *info, uint table_changes); enum_alter_inplace_result check_if_supported_inplace_alter(TABLE *,
Alter_inplace_info *);
int check(THD* thd, HA_CHECK_OPT* check_opt); int check(THD* thd, HA_CHECK_OPT* check_opt);
ha_rows records(); ha_rows records();
virtual uint count_query_cache_dependant_tables(uint8 *tables_type); virtual uint count_query_cache_dependant_tables(uint8 *tables_type);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment