mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
MDEV-28943 Online alter fails under LOCK TABLE with ER_ALTER_OPERATION_NOT_SUPPORTED_REASON
if ALTER TABLE ... LOCK=xxx is executed under LOCK TABLES, ignore the LOCK clause, because ALTER should not downgrade already taken EXCLUSIVE table lock to SHARED or NONE. This commit preserves the existing behavior (LOCK was de facto ignored), but makes it explicit.
This commit is contained in:
@ -10029,7 +10029,6 @@ bool mysql_alter_table(THD *thd, const LEX_CSTRING *new_db,
|
||||
if (alter_info->requested_lock == Alter_info::ALTER_TABLE_LOCK_SHARED
|
||||
|| alter_info->requested_lock > Alter_info::ALTER_TABLE_LOCK_NONE
|
||||
|| alter_info->flags & ALTER_DROP_SYSTEM_VERSIONING
|
||||
|| thd->locked_tables_mode == LTM_LOCK_TABLES
|
||||
|| thd->lex->sql_command == SQLCOM_OPTIMIZE
|
||||
|| alter_info->algorithm(thd) > Alter_info::ALTER_TABLE_ALGORITHM_COPY)
|
||||
online= false;
|
||||
@ -10906,6 +10905,9 @@ do_continue:;
|
||||
goto err_new_table_cleanup;
|
||||
}
|
||||
|
||||
if (thd->locked_tables_mode == LTM_LOCK_TABLES)
|
||||
online= false;
|
||||
|
||||
// If EXCLUSIVE lock is requested, upgrade already.
|
||||
if (alter_info->requested_lock == Alter_info::ALTER_TABLE_LOCK_EXCLUSIVE &&
|
||||
wait_while_table_is_used(thd, table, HA_EXTRA_FORCE_REOPEN))
|
||||
|
Reference in New Issue
Block a user