summaryrefslogtreecommitdiff
path: root/sql/sql_table.cc
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mariadb.org>2022-10-13 23:06:17 +0200
committerSergei Golubchik <serg@mariadb.org>2022-10-13 23:09:01 +0200
commitdef8bc1b1e4536679a8ef9a9be4b98c2899fe2cb (patch)
treec6c26832e7347d408de093989778b2d57a24245c /sql/sql_table.cc
parentc360eadb8c92624419b94ec0601ebf3e6bb64374 (diff)
downloadmariadb-git-bb-10.10-MDEV-16329.tar.gz
fixup! MDEV-28943bb-10.10-MDEV-16329
MDEV-29056 Replica SQL thread stops with 1846 error on ALTER ONLINE after LOCK WRITE every ALTER TABLE variant that succeeds without LOCK TABLE must succeed under LOCK TABLE every ALTER TABLE variant that fails without LOCK TABLE must fail under LOCK TABLE
Diffstat (limited to 'sql/sql_table.cc')
-rw-r--r--sql/sql_table.cc19
1 files changed, 9 insertions, 10 deletions
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index 3fde2d1f2d3..91d1354a6b7 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -9904,7 +9904,6 @@ bool mysql_alter_table(THD *thd, const LEX_CSTRING *new_db,
if (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
|| ignore
|| alter_info->algorithm(thd) > Alter_info::ALTER_TABLE_ALGORITHM_COPY)
@@ -10035,16 +10034,13 @@ bool mysql_alter_table(THD *thd, const LEX_CSTRING *new_db,
set of tables from the old table or to open a new TABLE object for
an extended list and verify that they belong to locked tables.
*/
- if (thd->locked_tables_mode == LTM_LOCK_TABLES ||
- thd->locked_tables_mode == LTM_PRELOCKED_UNDER_LOCK_TABLES)
+ if ((thd->locked_tables_mode == LTM_LOCK_TABLES ||
+ thd->locked_tables_mode == LTM_PRELOCKED_UNDER_LOCK_TABLES) &&
+ (create_info->used_fields & HA_CREATE_USED_UNION) &&
+ (table->s->tmp_table == NO_TMP_TABLE))
{
- if ((create_info->used_fields & HA_CREATE_USED_UNION) &&
- (table->s->tmp_table == NO_TMP_TABLE))
- {
- my_error(ER_LOCK_OR_ACTIVE_TRANSACTION, MYF(0));
- DBUG_RETURN(true);
- }
- alter_info->requested_lock= Alter_info::ALTER_TABLE_LOCK_DEFAULT;
+ my_error(ER_LOCK_OR_ACTIVE_TRANSACTION, MYF(0));
+ DBUG_RETURN(true);
}
/* Check that we are not trying to rename to an existing table */
@@ -10767,6 +10763,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))