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;
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);
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;
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');
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";
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;
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;
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);
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;
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');
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);
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);
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;
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;
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 add index (b);
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;
ERROR HY000: Can't execute the given 'ALTER' command as online
drop table t1;
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);
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;
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');
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);
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);
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;
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;
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 add index (b);
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;
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;
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));
......
#
# Test of alter online table
# Test of ALTER ONLINE TABLE syntax
#
--source include/have_innodb.inc
......@@ -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'));
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;
--error ER_CANT_DO_ONLINE
--error ER_ALTER_OPERATION_NOT_SUPPORTED
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');
--error ER_CANT_DO_ONLINE
--error ER_ALTER_OPERATION_NOT_SUPPORTED
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;
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'));
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;
--error ER_CANT_DO_ONLINE
--error ER_ALTER_OPERATION_NOT_SUPPORTED
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');
--error ER_CANT_DO_ONLINE
--error ER_ALTER_OPERATION_NOT_SUPPORTED
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);
--error ER_CANT_DO_ONLINE
--error ER_ALTER_OPERATION_NOT_SUPPORTED
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 table t1 engine=innodb;
alter table t1 add index (b);
--error ER_CANT_DO_ONLINE
alter online table t1 add index c (c);
--error ER_CANT_DO_ONLINE
alter online table t1 drop index b;
drop table t1;
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);
--error ER_CANT_DO_ONLINE
--error ER_ALTER_OPERATION_NOT_SUPPORTED
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;
--error ER_CANT_DO_ONLINE
--error ER_ALTER_OPERATION_NOT_SUPPORTED
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);
--error ER_CANT_DO_ONLINE
--error ER_ALTER_OPERATION_NOT_SUPPORTED
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;
--error ER_CANT_DO_ONLINE
--error ER_ALTER_OPERATION_NOT_SUPPORTED
alter online table t1 engine=memory;
alter table t1 engine=innodb;
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);
--error ER_CANT_DO_ONLINE
--error ER_ALTER_OPERATION_NOT_SUPPORTED
alter online table t1 drop index b;
drop table t1;
......
......@@ -2363,7 +2363,7 @@ struct LEX: public Query_tables_list
enum enum_yes_no_unknown tx_chain, tx_release;
bool safe_to_cache_query;
bool subqueries, ignore, online;
bool subqueries, ignore;
st_parsing_options parsing_options;
Alter_info alter_info;
/*
......
......@@ -6878,41 +6878,40 @@ string_list:
*/
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;
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,
if (!Lex->select_lex.add_table_to_list(YYTHD, $5, NULL,
TL_OPTION_UPDATING,
TL_READ_NO_INSERT,
MDL_SHARED_UPGRADABLE))
MYSQL_YYABORT;
lex->col_list.empty();
lex->select_lex.init_order();
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);
Lex->select_lex.db= (Lex->select_lex.table_list.first)->db;
Lex->create_last_non_select_table= Lex->last_table();
}
alter_commands
{
THD *thd= YYTHD;
LEX *lex= thd->lex;
if (!lex->m_sql_cmd)
if (!Lex->m_sql_cmd)
{
/* Create a generic ALTER TABLE statment. */
lex->m_sql_cmd= new (thd->mem_root) Sql_cmd_alter_table();
if (lex->m_sql_cmd == NULL)
Lex->m_sql_cmd= new (YYTHD->mem_root) Sql_cmd_alter_table();
if (Lex->m_sql_cmd == NULL)
MYSQL_YYABORT;
}
}
......@@ -7586,7 +7585,7 @@ opt_ignore:
;
alter_options:
{ Lex->ignore= Lex->online= 0;} alter_options_part2
{ Lex->ignore= 0;} alter_options_part2
;
alter_options_part2:
......@@ -7601,7 +7600,11 @@ alter_option_list:
alter_option:
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:
......
......@@ -1616,14 +1616,15 @@ void ha_myisammrg::append_create_info(String *packet)
}
bool ha_myisammrg::check_if_incompatible_data(HA_CREATE_INFO *info,
uint table_changes)
enum_alter_inplace_result
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
is trivial to do
We always support inplace ALTER in the new API, because old
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
void append_create_info(String *packet);
MYRG_INFO *myrg_info() { return file; }
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);
ha_rows records();
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