diff options
-rw-r--r-- | mysql-test/suite/innodb/r/alter_algorithm,INPLACE.rdiff | 21 | ||||
-rw-r--r-- | mysql-test/suite/innodb/r/alter_algorithm,INSTANT.rdiff | 21 | ||||
-rw-r--r-- | mysql-test/suite/innodb/r/alter_algorithm,NOCOPY.rdiff | 21 | ||||
-rw-r--r-- | mysql-test/suite/innodb/r/alter_algorithm.result | 6 | ||||
-rw-r--r-- | mysql-test/suite/innodb/r/alter_algorithm2.result | 20 | ||||
-rw-r--r-- | mysql-test/suite/innodb/t/alter_algorithm.test | 4 | ||||
-rw-r--r-- | mysql-test/suite/innodb/t/alter_algorithm2.test | 12 | ||||
-rw-r--r-- | sql/sql_alter.cc | 34 | ||||
-rw-r--r-- | sql/sql_alter.h | 26 | ||||
-rw-r--r-- | sql/sql_partition.cc | 2 | ||||
-rw-r--r-- | sql/sql_table.cc | 18 | ||||
-rw-r--r-- | sql/sql_yacc.yy | 4 | ||||
-rw-r--r-- | sql/sql_yacc_ora.yy | 4 |
13 files changed, 143 insertions, 50 deletions
diff --git a/mysql-test/suite/innodb/r/alter_algorithm,INPLACE.rdiff b/mysql-test/suite/innodb/r/alter_algorithm,INPLACE.rdiff index 805ccdb563c..a176a9af29e 100644 --- a/mysql-test/suite/innodb/r/alter_algorithm,INPLACE.rdiff +++ b/mysql-test/suite/innodb/r/alter_algorithm,INPLACE.rdiff @@ -1,6 +1,6 @@ ---- alter_algorithm.result -+++ alter_algorithm.reject -@@ -7,40 +7,40 @@ +--- alter_algorithm.result 2020-04-30 21:39:48.923115511 +0530 ++++ alter_algorithm.reject 2020-04-30 21:45:04.131642093 +0530 +@@ -7,43 +7,43 @@ INSERT INTO t1(f1, f2, f3) VALUES(1, 1, 1); SELECT @@alter_algorithm; @@alter_algorithm @@ -55,10 +55,15 @@ -info: Records: 1 Duplicates: 0 Warnings: 0 +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 + ALTER TABLE t1 FORCE, ALGORITHM=DEFAULT; +-affected rows: 1 +-info: Records: 1 Duplicates: 0 Warnings: 0 ++affected rows: 0 ++info: Records: 0 Duplicates: 0 Warnings: 0 DROP TABLE t1; affected rows: 0 CREATE TABLE t1(f1 INT PRIMARY KEY, f2 INT NOT NULL, -@@ -53,22 +53,22 @@ +@@ -56,22 +56,22 @@ FOREIGN KEY fidx(f1) REFERENCES t1(f1))ENGINE=INNODB; INSERT INTO t1(f1, f2, f4, f5) VALUES(1, 2, 3, 4); ALTER TABLE t1 ADD INDEX idx1(f4), page_compressed=1; @@ -91,7 +96,7 @@ DROP TABLE t2, t1; affected rows: 0 CREATE TABLE t1(f1 INT NOT NULL, -@@ -81,27 +81,27 @@ +@@ -84,28 +84,27 @@ INSERT INTO t1(f1, f2) VALUES(1, 1); # Add column at the end of the table ALTER TABLE t1 ADD COLUMN f4 char(100) default 'BIG WALL'; @@ -119,7 +124,9 @@ +info: Records: 0 Duplicates: 0 Warnings: 0 # Rename table ALTER TABLE t1 RENAME t3; - affected rows: 0 +-affected rows: 1 +-info: Records: 1 Duplicates: 0 Warnings: 0 ++affected rows: 0 # Drop Virtual Column ALTER TABLE t3 DROP COLUMN vcol; -affected rows: 1 @@ -129,7 +136,7 @@ # Column length varies ALTER TABLE t2 CHANGE f3 f3 VARCHAR(20); affected rows: 0 -@@ -109,12 +109,12 @@ +@@ -113,12 +112,12 @@ SET foreign_key_checks = 0; affected rows: 0 ALTER TABLE t3 ADD FOREIGN KEY fidx(f2) REFERENCES t2(f1); diff --git a/mysql-test/suite/innodb/r/alter_algorithm,INSTANT.rdiff b/mysql-test/suite/innodb/r/alter_algorithm,INSTANT.rdiff index 6d2ee160e46..414b7dc8b0c 100644 --- a/mysql-test/suite/innodb/r/alter_algorithm,INSTANT.rdiff +++ b/mysql-test/suite/innodb/r/alter_algorithm,INSTANT.rdiff @@ -1,6 +1,6 @@ ---- alter_algorithm.result -+++ alter_algorithm.reject -@@ -7,40 +7,32 @@ +--- alter_algorithm.result 2020-04-30 21:39:48.923115511 +0530 ++++ alter_algorithm.reject 2020-04-30 21:47:08.245465018 +0530 +@@ -7,43 +7,35 @@ INSERT INTO t1(f1, f2, f3) VALUES(1, 1, 1); SELECT @@alter_algorithm; @@alter_algorithm @@ -47,10 +47,15 @@ -affected rows: 1 -info: Records: 1 Duplicates: 0 Warnings: 0 +Got one of the listed errors + ALTER TABLE t1 FORCE, ALGORITHM=DEFAULT; +-affected rows: 1 +-info: Records: 1 Duplicates: 0 Warnings: 0 ++affected rows: 0 ++info: Records: 0 Duplicates: 0 Warnings: 0 DROP TABLE t1; affected rows: 0 CREATE TABLE t1(f1 INT PRIMARY KEY, f2 INT NOT NULL, -@@ -53,22 +45,17 @@ +@@ -56,22 +48,17 @@ FOREIGN KEY fidx(f1) REFERENCES t1(f1))ENGINE=INNODB; INSERT INTO t1(f1, f2, f4, f5) VALUES(1, 2, 3, 4); ALTER TABLE t1 ADD INDEX idx1(f4), page_compressed=1; @@ -78,7 +83,7 @@ DROP TABLE t2, t1; affected rows: 0 CREATE TABLE t1(f1 INT NOT NULL, -@@ -81,27 +68,27 @@ +@@ -84,28 +71,27 @@ INSERT INTO t1(f1, f2) VALUES(1, 1); # Add column at the end of the table ALTER TABLE t1 ADD COLUMN f4 char(100) default 'BIG WALL'; @@ -106,7 +111,9 @@ +info: Records: 0 Duplicates: 0 Warnings: 0 # Rename table ALTER TABLE t1 RENAME t3; - affected rows: 0 +-affected rows: 1 +-info: Records: 1 Duplicates: 0 Warnings: 0 ++affected rows: 0 # Drop Virtual Column ALTER TABLE t3 DROP COLUMN vcol; -affected rows: 1 @@ -116,7 +123,7 @@ # Column length varies ALTER TABLE t2 CHANGE f3 f3 VARCHAR(20); affected rows: 0 -@@ -109,12 +96,12 @@ +@@ -113,12 +99,12 @@ SET foreign_key_checks = 0; affected rows: 0 ALTER TABLE t3 ADD FOREIGN KEY fidx(f2) REFERENCES t2(f1); diff --git a/mysql-test/suite/innodb/r/alter_algorithm,NOCOPY.rdiff b/mysql-test/suite/innodb/r/alter_algorithm,NOCOPY.rdiff index c6ce83b5d9f..2aa8c72265a 100644 --- a/mysql-test/suite/innodb/r/alter_algorithm,NOCOPY.rdiff +++ b/mysql-test/suite/innodb/r/alter_algorithm,NOCOPY.rdiff @@ -1,6 +1,6 @@ ---- alter_algorithm.result -+++ alter_algorithm.reject -@@ -7,40 +7,32 @@ +--- alter_algorithm.result 2020-04-30 21:39:48.923115511 +0530 ++++ alter_algorithm.reject 2020-04-30 21:52:10.785967739 +0530 +@@ -7,43 +7,35 @@ INSERT INTO t1(f1, f2, f3) VALUES(1, 1, 1); SELECT @@alter_algorithm; @@alter_algorithm @@ -47,10 +47,15 @@ -affected rows: 1 -info: Records: 1 Duplicates: 0 Warnings: 0 +Got one of the listed errors + ALTER TABLE t1 FORCE, ALGORITHM=DEFAULT; +-affected rows: 1 +-info: Records: 1 Duplicates: 0 Warnings: 0 ++affected rows: 0 ++info: Records: 0 Duplicates: 0 Warnings: 0 DROP TABLE t1; affected rows: 0 CREATE TABLE t1(f1 INT PRIMARY KEY, f2 INT NOT NULL, -@@ -53,22 +45,22 @@ +@@ -56,22 +48,22 @@ FOREIGN KEY fidx(f1) REFERENCES t1(f1))ENGINE=INNODB; INSERT INTO t1(f1, f2, f4, f5) VALUES(1, 2, 3, 4); ALTER TABLE t1 ADD INDEX idx1(f4), page_compressed=1; @@ -83,7 +88,7 @@ DROP TABLE t2, t1; affected rows: 0 CREATE TABLE t1(f1 INT NOT NULL, -@@ -81,27 +73,27 @@ +@@ -84,28 +76,27 @@ INSERT INTO t1(f1, f2) VALUES(1, 1); # Add column at the end of the table ALTER TABLE t1 ADD COLUMN f4 char(100) default 'BIG WALL'; @@ -111,7 +116,9 @@ +info: Records: 0 Duplicates: 0 Warnings: 0 # Rename table ALTER TABLE t1 RENAME t3; - affected rows: 0 +-affected rows: 1 +-info: Records: 1 Duplicates: 0 Warnings: 0 ++affected rows: 0 # Drop Virtual Column ALTER TABLE t3 DROP COLUMN vcol; -affected rows: 1 @@ -121,7 +128,7 @@ # Column length varies ALTER TABLE t2 CHANGE f3 f3 VARCHAR(20); affected rows: 0 -@@ -109,12 +101,12 @@ +@@ -113,12 +104,12 @@ SET foreign_key_checks = 0; affected rows: 0 ALTER TABLE t3 ADD FOREIGN KEY fidx(f2) REFERENCES t2(f1); diff --git a/mysql-test/suite/innodb/r/alter_algorithm.result b/mysql-test/suite/innodb/r/alter_algorithm.result index bcfbe3355f9..717d31de6a0 100644 --- a/mysql-test/suite/innodb/r/alter_algorithm.result +++ b/mysql-test/suite/innodb/r/alter_algorithm.result @@ -41,6 +41,9 @@ info: Records: 1 Duplicates: 0 Warnings: 0 ALTER TABLE t1 ENGINE=INNODB; affected rows: 1 info: Records: 1 Duplicates: 0 Warnings: 0 +ALTER TABLE t1 FORCE, ALGORITHM=DEFAULT; +affected rows: 1 +info: Records: 1 Duplicates: 0 Warnings: 0 DROP TABLE t1; affected rows: 0 CREATE TABLE t1(f1 INT PRIMARY KEY, f2 INT NOT NULL, @@ -97,7 +100,8 @@ affected rows: 1 info: Records: 1 Duplicates: 0 Warnings: 0 # Rename table ALTER TABLE t1 RENAME t3; -affected rows: 0 +affected rows: 1 +info: Records: 1 Duplicates: 0 Warnings: 0 # Drop Virtual Column ALTER TABLE t3 DROP COLUMN vcol; affected rows: 1 diff --git a/mysql-test/suite/innodb/r/alter_algorithm2.result b/mysql-test/suite/innodb/r/alter_algorithm2.result index 1cea3f4cd43..350c1c51482 100644 --- a/mysql-test/suite/innodb/r/alter_algorithm2.result +++ b/mysql-test/suite/innodb/r/alter_algorithm2.result @@ -54,3 +54,23 @@ DROP PROCEDURE p1; affected rows: 0 DROP PROCEDURE p2; affected rows: 0 +CREATE TABLE t1(id INT PRIMARY KEY, +col1 INT UNSIGNED NOT NULL UNIQUE)ENGINE=InnoDB; +affected rows: 0 +INSERT INTO t1 VALUES(1,1),(2,2),(3,3); +affected rows: 3 +info: Records: 3 Duplicates: 0 Warnings: 0 +SET ALTER_ALGORITHM=INSTANT; +affected rows: 0 +ALTER TABLE t1 DROP COLUMN col1; +ERROR 0A000: ALGORITHM=INSTANT is not supported for this operation. Try ALGORITHM=INPLACE +ALTER TABLE t1 DROP COLUMN col1, ALGORITHM=NOCOPY; +ERROR 0A000: ALGORITHM=NOCOPY is not supported for this operation. Try ALGORITHM=INPLACE +ALTER TABLE t1 DROP COLUMN col1, ALGORITHM=DEFAULT; +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 +ALTER TABLE t1 DROP PRIMARY KEY, ALGORITHM=DEFAULT; +affected rows: 3 +info: Records: 3 Duplicates: 0 Warnings: 0 +DROP TABLE t1; +affected rows: 0 diff --git a/mysql-test/suite/innodb/t/alter_algorithm.test b/mysql-test/suite/innodb/t/alter_algorithm.test index d410a15154d..08c23b505f3 100644 --- a/mysql-test/suite/innodb/t/alter_algorithm.test +++ b/mysql-test/suite/innodb/t/alter_algorithm.test @@ -55,6 +55,10 @@ ALTER TABLE t1 ROW_FORMAT=COMPRESSED; --error $error_code ALTER TABLE t1 ENGINE=INNODB; +# Irrespective of alter_algorithm value, the following command +# should succeed because of explicitly mentioning ALGORTHM=DEFAULT +ALTER TABLE t1 FORCE, ALGORITHM=DEFAULT; + DROP TABLE t1; --disable_info diff --git a/mysql-test/suite/innodb/t/alter_algorithm2.test b/mysql-test/suite/innodb/t/alter_algorithm2.test index 02b49c797bc..cf538e30196 100644 --- a/mysql-test/suite/innodb/t/alter_algorithm2.test +++ b/mysql-test/suite/innodb/t/alter_algorithm2.test @@ -44,4 +44,16 @@ call p1(); DROP TABLE t1; DROP PROCEDURE p1; DROP PROCEDURE p2; + +CREATE TABLE t1(id INT PRIMARY KEY, + col1 INT UNSIGNED NOT NULL UNIQUE)ENGINE=InnoDB; +INSERT INTO t1 VALUES(1,1),(2,2),(3,3); +SET ALTER_ALGORITHM=INSTANT; +--error ER_ALTER_OPERATION_NOT_SUPPORTED +ALTER TABLE t1 DROP COLUMN col1; +--error ER_ALTER_OPERATION_NOT_SUPPORTED +ALTER TABLE t1 DROP COLUMN col1, ALGORITHM=NOCOPY; +ALTER TABLE t1 DROP COLUMN col1, ALGORITHM=DEFAULT; +ALTER TABLE t1 DROP PRIMARY KEY, ALGORITHM=DEFAULT; +DROP TABLE t1; --disable_info diff --git a/sql/sql_alter.cc b/sql/sql_alter.cc index b3a036eda9e..a68dcb31a4c 100644 --- a/sql/sql_alter.cc +++ b/sql/sql_alter.cc @@ -69,6 +69,10 @@ bool Alter_info::set_requested_algorithm(const LEX_CSTRING *str) return false; } +void Alter_info::set_requested_algorithm(enum_alter_table_algorithm algo_val) +{ + requested_algorithm= algo_val; +} bool Alter_info::set_requested_lock(const LEX_CSTRING *str) { @@ -86,13 +90,16 @@ bool Alter_info::set_requested_lock(const LEX_CSTRING *str) return false; } -const char* Alter_info::algorithm() const +const char* Alter_info::algorithm_clause(THD *thd) const { - switch (requested_algorithm) { + switch (algorithm(thd)) { case ALTER_TABLE_ALGORITHM_INPLACE: return "ALGORITHM=INPLACE"; case ALTER_TABLE_ALGORITHM_COPY: return "ALGORITHM=COPY"; + case ALTER_TABLE_ALGORITHM_NONE: + DBUG_ASSERT(0); + /* Fall through */ case ALTER_TABLE_ALGORITHM_DEFAULT: return "ALGORITHM=DEFAULT"; case ALTER_TABLE_ALGORITHM_NOCOPY: @@ -123,9 +130,6 @@ const char* Alter_info::lock() const bool Alter_info::supports_algorithm(THD *thd, enum_alter_inplace_result result, const Alter_inplace_info *ha_alter_info) { - if (requested_algorithm == Alter_info::ALTER_TABLE_ALGORITHM_DEFAULT) - requested_algorithm = (Alter_info::enum_alter_table_algorithm) thd->variables.alter_algorithm; - switch (result) { case HA_ALTER_INPLACE_EXCLUSIVE_LOCK: case HA_ALTER_INPLACE_SHARED_LOCK: @@ -134,16 +138,16 @@ bool Alter_info::supports_algorithm(THD *thd, enum_alter_inplace_result result, return false; case HA_ALTER_INPLACE_COPY_NO_LOCK: case HA_ALTER_INPLACE_COPY_LOCK: - if (requested_algorithm >= Alter_info::ALTER_TABLE_ALGORITHM_NOCOPY) + if (algorithm(thd) >= Alter_info::ALTER_TABLE_ALGORITHM_NOCOPY) { - ha_alter_info->report_unsupported_error(algorithm(), + ha_alter_info->report_unsupported_error(algorithm_clause(thd), "ALGORITHM=INPLACE"); return true; } return false; case HA_ALTER_INPLACE_NOCOPY_NO_LOCK: case HA_ALTER_INPLACE_NOCOPY_LOCK: - if (requested_algorithm == Alter_info::ALTER_TABLE_ALGORITHM_INSTANT) + if (algorithm(thd) == Alter_info::ALTER_TABLE_ALGORITHM_INSTANT) { ha_alter_info->report_unsupported_error("ALGORITHM=INSTANT", "ALGORITHM=NOCOPY"); @@ -151,9 +155,9 @@ bool Alter_info::supports_algorithm(THD *thd, enum_alter_inplace_result result, } return false; case HA_ALTER_INPLACE_NOT_SUPPORTED: - if (requested_algorithm >= Alter_info::ALTER_TABLE_ALGORITHM_INPLACE) + if (algorithm(thd) >= Alter_info::ALTER_TABLE_ALGORITHM_INPLACE) { - ha_alter_info->report_unsupported_error(algorithm(), + ha_alter_info->report_unsupported_error(algorithm_clause(thd), "ALGORITHM=COPY"); return true; } @@ -174,7 +178,7 @@ bool Alter_info::supports_lock(THD *thd, enum_alter_inplace_result result, case HA_ALTER_INPLACE_EXCLUSIVE_LOCK: // If SHARED lock and no particular algorithm was requested, use COPY. if (requested_lock == Alter_info::ALTER_TABLE_LOCK_SHARED && - requested_algorithm == Alter_info::ALTER_TABLE_ALGORITHM_DEFAULT && + algorithm(thd) == Alter_info::ALTER_TABLE_ALGORITHM_DEFAULT && thd->variables.alter_algorithm == Alter_info::ALTER_TABLE_ALGORITHM_DEFAULT) return false; @@ -237,6 +241,14 @@ bool Alter_info::vers_prohibited(THD *thd) const return false; } +Alter_info::enum_alter_table_algorithm +Alter_info::algorithm(const THD *thd) const +{ + if (requested_algorithm == ALTER_TABLE_ALGORITHM_NONE) + return (Alter_info::enum_alter_table_algorithm) thd->variables.alter_algorithm; + return requested_algorithm; +} + Alter_table_ctx::Alter_table_ctx() : datetime_field(NULL), error_if_not_empty(false), diff --git a/sql/sql_alter.h b/sql/sql_alter.h index 10aafe1ab37..53d0c8438f8 100644 --- a/sql/sql_alter.h +++ b/sql/sql_alter.h @@ -57,7 +57,10 @@ public: ALTER_TABLE_ALGORITHM_NOCOPY, // Instant should allow any operation that changes metadata only. - ALTER_TABLE_ALGORITHM_INSTANT + ALTER_TABLE_ALGORITHM_INSTANT, + + // When there is no specification of algorithm during alter table. + ALTER_TABLE_ALGORITHM_NONE }; @@ -104,8 +107,11 @@ public: List<const char> partition_names; // Number of partitions. uint num_parts; +private: // Type of ALTER TABLE algorithm. enum_alter_table_algorithm requested_algorithm; + +public: // Type of ALTER TABLE lock. enum_alter_table_lock requested_lock; @@ -114,7 +120,7 @@ public: flags(0), partition_flags(0), keys_onoff(LEAVE_AS_IS), num_parts(0), - requested_algorithm(ALTER_TABLE_ALGORITHM_DEFAULT), + requested_algorithm(ALTER_TABLE_ALGORITHM_NONE), requested_lock(ALTER_TABLE_LOCK_DEFAULT) {} @@ -130,7 +136,7 @@ public: keys_onoff= LEAVE_AS_IS; num_parts= 0; partition_names.empty(); - requested_algorithm= ALTER_TABLE_ALGORITHM_DEFAULT; + requested_algorithm= ALTER_TABLE_ALGORITHM_NONE; requested_lock= ALTER_TABLE_LOCK_DEFAULT; } @@ -178,9 +184,15 @@ public: bool set_requested_lock(const LEX_CSTRING *str); /** + Set the requested algorithm to the given algorithm value + @param algo_value algorithm to be set + */ + void set_requested_algorithm(enum_alter_table_algorithm algo_value); + + /** Returns the algorithm value in the format "algorithm=value" */ - const char* algorithm() const; + const char* algorithm_clause(THD *thd) const; /** Returns the lock value in the format "lock=value" @@ -216,6 +228,12 @@ public: bool supports_lock(THD *thd, enum_alter_inplace_result result, const Alter_inplace_info *ha_alter_info); + /** + Return user requested algorithm. If user does not specify + algorithm then return alter_algorithm variable value. + */ + enum_alter_table_algorithm algorithm(const THD *thd) const; + private: Alter_info &operator=(const Alter_info &rhs); // not implemented Alter_info(const Alter_info &rhs); // not implemented diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc index 5fdca153ef7..c557f438b41 100644 --- a/sql/sql_partition.cc +++ b/sql/sql_partition.cc @@ -6008,7 +6008,7 @@ the generated partition syntax in a correct manner. */ if (alter_info->partition_flags != ALTER_PARTITION_INFO || !table->part_info || - alter_info->requested_algorithm != + alter_info->algorithm(thd) != Alter_info::ALTER_TABLE_ALGORITHM_INPLACE || !table->part_info->has_same_partitioning(part_info)) { diff --git a/sql/sql_table.cc b/sql/sql_table.cc index ed1c3c401d3..e2a8cafe784 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -9558,7 +9558,7 @@ do_continue:; */ if (!(alter_info->flags & ~(ALTER_RENAME | ALTER_KEYS_ONOFF)) && alter_info->partition_flags == 0 && - alter_info->requested_algorithm != + alter_info->algorithm(thd) != Alter_info::ALTER_TABLE_ALGORITHM_COPY) // No need to touch frm. { bool res; @@ -9636,7 +9636,7 @@ do_continue:; "LOCK=DEFAULT"); DBUG_RETURN(true); } - else if (alter_info->requested_algorithm != + else if (alter_info->algorithm(thd) != Alter_info::ALTER_TABLE_ALGORITHM_DEFAULT) { my_error(ER_ALTER_OPERATION_NOT_SUPPORTED_REASON, MYF(0), @@ -9676,20 +9676,21 @@ do_continue:; using in-place API. */ if ((thd->variables.alter_algorithm == Alter_info::ALTER_TABLE_ALGORITHM_COPY && - alter_info->requested_algorithm != + alter_info->algorithm(thd) != Alter_info::ALTER_TABLE_ALGORITHM_INPLACE) || is_inplace_alter_impossible(table, create_info, alter_info) || IF_PARTITIONING((partition_changed && !(table->s->db_type()->partition_flags() & HA_USE_AUTO_PARTITION)), 0)) { - if (alter_info->requested_algorithm == + if (alter_info->algorithm(thd) == Alter_info::ALTER_TABLE_ALGORITHM_INPLACE) { my_error(ER_ALTER_OPERATION_NOT_SUPPORTED, MYF(0), "ALGORITHM=INPLACE", "ALGORITHM=COPY"); DBUG_RETURN(true); } - alter_info->requested_algorithm= Alter_info::ALTER_TABLE_ALGORITHM_COPY; + alter_info->set_requested_algorithm( + Alter_info::ALTER_TABLE_ALGORITHM_COPY); } /* @@ -9809,7 +9810,7 @@ do_continue:; /* Remember that we have not created table in storage engine yet. */ bool no_ha_table= true; - if (alter_info->requested_algorithm != Alter_info::ALTER_TABLE_ALGORITHM_COPY) + if (alter_info->algorithm(thd) != Alter_info::ALTER_TABLE_ALGORITHM_COPY) { Alter_inplace_info ha_alter_info(create_info, alter_info, key_info, key_count, @@ -9900,7 +9901,7 @@ do_continue:; // If SHARED lock and no particular algorithm was requested, use COPY. if (inplace_supported == HA_ALTER_INPLACE_EXCLUSIVE_LOCK && alter_info->requested_lock == Alter_info::ALTER_TABLE_LOCK_SHARED && - alter_info->requested_algorithm == + alter_info->algorithm(thd) == Alter_info::ALTER_TABLE_ALGORITHM_DEFAULT && thd->variables.alter_algorithm == Alter_info::ALTER_TABLE_ALGORITHM_DEFAULT) @@ -10743,7 +10744,8 @@ bool mysql_recreate_table(THD *thd, TABLE_LIST *table_list, bool table_copy) alter_info.flags= (ALTER_CHANGE_COLUMN | ALTER_RECREATE); if (table_copy) - alter_info.requested_algorithm= Alter_info::ALTER_TABLE_ALGORITHM_COPY; + alter_info.set_requested_algorithm( + Alter_info::ALTER_TABLE_ALGORITHM_COPY); bool res= mysql_alter_table(thd, &null_clex_str, &null_clex_str, &create_info, table_list, &alter_info, 0, diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 2a382dc7666..14d71139dad 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -8531,8 +8531,8 @@ opt_index_lock_algorithm: alter_algorithm_option: ALGORITHM_SYM opt_equal DEFAULT { - Lex->alter_info.requested_algorithm= - Alter_info::ALTER_TABLE_ALGORITHM_DEFAULT; + Lex->alter_info.set_requested_algorithm( + Alter_info::ALTER_TABLE_ALGORITHM_DEFAULT); } | ALGORITHM_SYM opt_equal ident { diff --git a/sql/sql_yacc_ora.yy b/sql/sql_yacc_ora.yy index c8620543d08..d174e02fc24 100644 --- a/sql/sql_yacc_ora.yy +++ b/sql/sql_yacc_ora.yy @@ -8468,8 +8468,8 @@ opt_index_lock_algorithm: alter_algorithm_option: ALGORITHM_SYM opt_equal DEFAULT { - Lex->alter_info.requested_algorithm= - Alter_info::ALTER_TABLE_ALGORITHM_DEFAULT; + Lex->alter_info.set_requested_algorithm( + Alter_info::ALTER_TABLE_ALGORITHM_DEFAULT); } | ALGORITHM_SYM opt_equal ident { |