diff options
author | Thirunarayanan Balathandayuthapani <thiru@mariadb.com> | 2020-04-25 14:27:00 +0530 |
---|---|---|
committer | Thirunarayanan Balathandayuthapani <thiru@mariadb.com> | 2020-05-04 09:35:38 +0530 |
commit | ec9908b2577758ffb3cb0d1b06400f12ff47b81c (patch) | |
tree | a18426dce230626e84f752cf5d966d8e205f530b /sql/sql_table.cc | |
parent | f98017bb6df0110aa0a359ab4378cc97f6a95473 (diff) | |
download | mariadb-git-ec9908b2577758ffb3cb0d1b06400f12ff47b81c.tar.gz |
MDEV-16288 ALTER TABLE…ALGORITHM=DEFAULT does not override alter_algorithm
- ALTER_ALGORITHM should be substituted when there is no mention of
algorithm in alter statement.
- Introduced algorithm(thd) in Alter_info. It returns the
user requested algorithm. If user doesn't specify algorithm explicitly then
it returns alter_algorithm variable.
- changed algorithm() to get_algorithm(thd) to return algorithm name for
displaying the error.
- set_requested_algorithm(algo_value) to avoid direct assignment on
requested_algorithm variable.
- Avoid direct access of requested_algorithm to encapsulate
requested_algorithm variable
Diffstat (limited to 'sql/sql_table.cc')
-rw-r--r-- | sql/sql_table.cc | 18 |
1 files changed, 10 insertions, 8 deletions
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, |