Skip to content

Commit

Permalink
MDEV-7390 alter online table xxxx (no options) should be possible
Browse files Browse the repository at this point in the history
Merge branch 'openquery:mdev-7390-alter-online-table-xx-possible-10.0' into 10.0
  • Loading branch information
vuvova committed May 3, 2015
2 parents a229750 + 532de70 commit c8c51ce
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 17 deletions.
2 changes: 2 additions & 0 deletions mysql-test/r/alter_table.result
Original file line number Diff line number Diff line change
Expand Up @@ -1693,8 +1693,10 @@ INSERT INTO tm1 VALUES (1,1,1), (2,2,2);
INSERT INTO tm2 VALUES (1,1,1), (2,2,2);
ALTER TABLE ti1;
affected rows: 0
info: Records: 0 Duplicates: 0 Warnings: 0
ALTER TABLE tm1;
affected rows: 0
info: Records: 0 Duplicates: 0 Warnings: 0
ALTER TABLE ti1 ADD COLUMN d VARCHAR(200);
affected rows: 0
info: Records: 0 Duplicates: 0 Warnings: 0
Expand Down
4 changes: 4 additions & 0 deletions mysql-test/r/alter_table_online.result
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ alter online table t1 comment "new comment";
ERROR 0A000: LOCK=NONE/SHARED is not supported for this operation. Try LOCK=EXCLUSIVE.
alter online table t1 rename to t2;
ERROR 0A000: LOCK=NONE/SHARED is not supported for this operation. Try LOCK=EXCLUSIVE.
alter online table t1 algorithm=INPLACE, lock=NONE;
alter online table t1;
alter table t1 algorithm=INPLACE;
alter table t1 lock=NONE;
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);
Expand Down
1 change: 1 addition & 0 deletions mysql-test/r/innodb_mysql_sync.result
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,7 @@ SET DEBUG_SYNC= 'RESET';
# This should not do anything
ALTER TABLE t1;
affected rows: 0
info: Records: 0 Duplicates: 0 Warnings: 0
SET DEBUG_SYNC = 'row_log_table_apply1_before SIGNAL rebuild';
# Check that we rebuild the table
ALTER TABLE t1 engine=innodb;
Expand Down
9 changes: 8 additions & 1 deletion mysql-test/t/alter_table_online.test
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
drop table if exists t1,t2,t3;
--enable_warnings
#
# Test of things that can be done online
# Test of things that can not be done online
#

create table t1 (a int not null primary key, b int, c varchar(80), e enum('a','b'));
Expand All @@ -24,6 +24,13 @@ alter online table t1 comment "new comment";
--error ER_ALTER_OPERATION_NOT_SUPPORTED
alter online table t1 rename to t2;

# No OPs

alter online table t1 algorithm=INPLACE, lock=NONE;
alter online table t1;
alter table t1 algorithm=INPLACE;
alter table t1 lock=NONE;

drop table t1;

#
Expand Down
33 changes: 17 additions & 16 deletions sql/sql_table.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8429,6 +8429,23 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name,
mysql_audit_alter_table(thd, table_list);

THD_STAGE_INFO(thd, stage_setup);

handle_if_exists_options(thd, table, alter_info);

/*
Look if we have to do anything at all.
ALTER can become NOOP after handling
the IF (NOT) EXISTS options.
*/
if (alter_info->flags == 0)
{
my_snprintf(alter_ctx.tmp_name, sizeof(alter_ctx.tmp_name),
ER(ER_INSERT_INFO), 0L, 0L,
thd->get_stmt_da()->current_statement_warn_count());
my_ok(thd, 0L, 0L, alter_ctx.tmp_name);
DBUG_RETURN(false);
}

if (!(alter_info->flags & ~(Alter_info::ALTER_RENAME |
Alter_info::ALTER_KEYS_ONOFF)) &&
alter_info->requested_algorithm !=
Expand All @@ -8449,22 +8466,6 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name,
DBUG_RETURN(res);
}

handle_if_exists_options(thd, table, alter_info);

/*
Look if we have to do anything at all.
Normally ALTER can become NOOP only after handling
the IF (NOT) EXISTS options.
*/
if (alter_info->flags == 0)
{
my_snprintf(alter_ctx.tmp_name, sizeof(alter_ctx.tmp_name),
ER(ER_INSERT_INFO), 0L, 0L,
thd->get_stmt_da()->current_statement_warn_count());
my_ok(thd, 0L, 0L, alter_ctx.tmp_name);
DBUG_RETURN(false);
}

/* We have to do full alter table. */

#ifdef WITH_PARTITION_STORAGE_ENGINE
Expand Down

0 comments on commit c8c51ce

Please sign in to comment.