Commit 4b5a9d8e authored by Thirunarayanan Balathandayuthapani's avatar Thirunarayanan Balathandayuthapani Committed by Marko Mäkelä

Bug #23475211 COMBINING ALTER OPERATIONS TRIGGERS TABLE REBUILD

Problem:
=======
Inplace alter algorithm determines the table to be rebuild if the table
undergoes row format change, key block size if handler flag contains only
change table create option. If alter with inplace ignore flag operations and change table create options then it leads to table rebuild operation.

Solution:
========
During the check for rebuild, ignore the inplace ignore flag and check for
table create options.
Reviewed-by: default avatarJimmy Yang <jimmy.yang@oracle.com>
Reviewed-by: default avatarMarko Makela <marko.makela@oracle.com>
RB: 13172
parent d66c171e
# INPLACE ALTER WITH INPLACE_IGNORE FLAG AND CHANGE CREATE OPTION
# CHANGE THE COLUMN DEFAULT (INPLACE_IGNORE)
# AND TABLE CHARSET(CHANGE CREATE)
CREATE TABLE t1(
id INT PRIMARY KEY,
f1 INT NOT NULL DEFAULT 0)ENGINE=INNODB;
INSERT INTO t1 VALUES(1, 2);
SET SQL_MODE='STRICT_ALL_TABLES';
ALTER TABLE t1 MODIFY COLUMN f1 INT NOT NULL DEFAULT 0,
DEFAULT CHARSET=latin1, ALGORITHM=INPLACE;
DROP TABLE t1;
# CHANGE THE COMMENT OF COLUMN(INPLACE IGNORE)
# AND TABLE CHARSET(CHANGE CREATE)
CREATE TABLE t1(id INT COMMENT 'independence day')ENGINE=INNODB;
INSERT INTO t1 values(1);
ALTER TABLE t1 MODIFY COLUMN id INT COMMENT 'identifier',
DEFAULT CHARSET=latin1, ALGORITHM=INPLACE;
DROP TABLE t1;
# RENAME THE TABLE(INPLACE IGNORE)
# AND CHANGE TABLE CHARSET(CHANGE CREATE)
CREATE TABLE t1(
f1 INT NOT NULL,
f2 INT NOT NULL)ENGINE=INNODB;
INSERT INTO t1 VALUES(1, 2);
ALTER TABLE t1 RENAME t2, DEFAULT CHARSET=latin1, ALGORITHM=INPLACE;
DROP TABLE t2;
--source include/have_innodb.inc
--echo # INPLACE ALTER WITH INPLACE_IGNORE FLAG AND CHANGE CREATE OPTION
--echo # CHANGE THE COLUMN DEFAULT (INPLACE_IGNORE)
--echo # AND TABLE CHARSET(CHANGE CREATE)
CREATE TABLE t1(
id INT PRIMARY KEY,
f1 INT NOT NULL DEFAULT 0)ENGINE=INNODB;
INSERT INTO t1 VALUES(1, 2);
let id_before_alter =`SELECT table_id FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES WHERE name="test/t1"`;
# Allow the following operation to report errors.
SET SQL_MODE='STRICT_ALL_TABLES';
ALTER TABLE t1 MODIFY COLUMN f1 INT NOT NULL DEFAULT 0,
DEFAULT CHARSET=latin1, ALGORITHM=INPLACE;
let id_after_alter =`SELECT table_id FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES WHERE name="test/t1"`;
if ($id_before_alter != $id_after_alter)
{
--echo "Table rebuild happened";
}
DROP TABLE t1;
--echo # CHANGE THE COMMENT OF COLUMN(INPLACE IGNORE)
--echo # AND TABLE CHARSET(CHANGE CREATE)
CREATE TABLE t1(id INT COMMENT 'independence day')ENGINE=INNODB;
INSERT INTO t1 values(1);
let id_before_alter =`SELECT table_id FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES WHERE name="test/t1"`;
ALTER TABLE t1 MODIFY COLUMN id INT COMMENT 'identifier',
DEFAULT CHARSET=latin1, ALGORITHM=INPLACE;
let id_after_alter =`SELECT table_id FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES WHERE name="test/t1"`;
if ($id_before_alter != $id_after_alter)
{
--echo "Table rebuild happened";
}
DROP TABLE t1;
--echo # RENAME THE TABLE(INPLACE IGNORE)
--echo # AND CHANGE TABLE CHARSET(CHANGE CREATE)
CREATE TABLE t1(
f1 INT NOT NULL,
f2 INT NOT NULL)ENGINE=INNODB;
INSERT INTO t1 VALUES(1, 2);
let id_before_alter =`SELECT table_id FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES WHERE name="test/t1"`;
ALTER TABLE t1 RENAME t2, DEFAULT CHARSET=latin1, ALGORITHM=INPLACE;
let id_after_alter =`SELECT table_id FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES WHERE name="test/t2"`;
if ($id_before_alter != $id_after_alter)
{
--echo "Table rebuild happened";
}
DROP TABLE t2;
......@@ -400,7 +400,10 @@ innobase_need_rebuild(
const Alter_inplace_info* ha_alter_info,
const TABLE* altered_table)
{
if (ha_alter_info->handler_flags
Alter_inplace_info::HA_ALTER_FLAGS alter_inplace_flags =
ha_alter_info->handler_flags & ~(INNOBASE_INPLACE_IGNORE);
if (alter_inplace_flags
== Alter_inplace_info::CHANGE_CREATE_OPTION
&& !(ha_alter_info->create_info->used_fields
& (HA_CREATE_USED_ROW_FORMAT
......@@ -6082,7 +6085,7 @@ ha_innobase::prepare_inplace_alter_table(
}
if (!(ha_alter_info->handler_flags & INNOBASE_ALTER_DATA)
|| (ha_alter_info->handler_flags
|| ((ha_alter_info->handler_flags & ~INNOBASE_INPLACE_IGNORE)
== Alter_inplace_info::CHANGE_CREATE_OPTION
&& !innobase_need_rebuild(ha_alter_info, table))) {
......@@ -6346,7 +6349,7 @@ ha_innobase::inplace_alter_table(
DBUG_RETURN(false);
}
if (ha_alter_info->handler_flags
if ((ha_alter_info->handler_flags & ~INNOBASE_INPLACE_IGNORE)
== Alter_inplace_info::CHANGE_CREATE_OPTION
&& !innobase_need_rebuild(ha_alter_info, table)) {
goto ok_exit;
......
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