summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2021-07-02 11:48:51 +0300
committerMarko Mäkelä <marko.makela@mariadb.com>2021-07-02 11:48:51 +0300
commitc294443b41bff54eb11ac68f23b9366c0cb9ef90 (patch)
treede182800e46ac22dbd6ac3ae510b12f6fcf94837 /sql
parentfa8eb4de554152a673658fed7b3284c76009e208 (diff)
parent05f7fd571fca15faecd898c5da8d98455e97c294 (diff)
downloadmariadb-git-c294443b41bff54eb11ac68f23b9366c0cb9ef90.tar.gz
Merge 10.3 into 10.4
Diffstat (limited to 'sql')
-rw-r--r--sql/sql_table.cc9
-rw-r--r--sql/transaction.cc38
2 files changed, 16 insertions, 31 deletions
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index 8fe1f34256c..dbe5ac15172 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -10214,9 +10214,12 @@ do_continue:;
if (alter_info->requested_lock == Alter_info::ALTER_TABLE_LOCK_NONE)
ha_alter_info.online= true;
// Ask storage engine whether to use copy or in-place
- ha_alter_info.inplace_supported=
- table->file->check_if_supported_inplace_alter(&altered_table,
- &ha_alter_info);
+ {
+ Check_level_instant_set check_level_save(thd, CHECK_FIELD_WARN);
+ ha_alter_info.inplace_supported=
+ table->file->check_if_supported_inplace_alter(&altered_table,
+ &ha_alter_info);
+ }
if (alter_info->supports_algorithm(thd, &ha_alter_info) ||
alter_info->supports_lock(thd, &ha_alter_info))
diff --git a/sql/transaction.cc b/sql/transaction.cc
index 135d274e6c6..e98672eaa9d 100644
--- a/sql/transaction.cc
+++ b/sql/transaction.cc
@@ -1,4 +1,5 @@
/* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
+ Copyright (c) 2009, 2021, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -622,33 +623,6 @@ bool trans_rollback_to_savepoint(THD *thd, LEX_CSTRING name)
if (thd->transaction.xid_state.check_has_uncommitted_xa())
DBUG_RETURN(TRUE);
- /**
- Checking whether it is safe to release metadata locks acquired after
- savepoint, if rollback to savepoint is successful.
-
- Whether it is safe to release MDL after rollback to savepoint depends
- on storage engines participating in transaction:
-
- - InnoDB doesn't release any row-locks on rollback to savepoint so it
- is probably a bad idea to release MDL as well.
- - Binary log implementation in some cases (e.g when non-transactional
- tables involved) may choose not to remove events added after savepoint
- from transactional cache, but instead will write them to binary
- log accompanied with ROLLBACK TO SAVEPOINT statement. Since the real
- write happens at the end of transaction releasing MDL on tables
- mentioned in these events (i.e. acquired after savepoint and before
- rollback ot it) can break replication, as concurrent DROP TABLES
- statements will be able to drop these tables before events will get
- into binary log,
-
- For backward-compatibility reasons we always release MDL if binary
- logging is off.
- */
- bool mdl_can_safely_rollback_to_savepoint=
- (!((WSREP_EMULATE_BINLOG_NNULL(thd) || mysql_bin_log.is_open())
- && thd->variables.sql_log_bin) ||
- ha_rollback_to_savepoint_can_release_mdl(thd));
-
if (ha_rollback_to_savepoint(thd, sv))
res= TRUE;
else if (((thd->variables.option_bits & OPTION_KEEP_LOG) ||
@@ -660,7 +634,15 @@ bool trans_rollback_to_savepoint(THD *thd, LEX_CSTRING name)
thd->transaction.savepoints= sv;
- if (!res && mdl_can_safely_rollback_to_savepoint)
+ if (res)
+ /* An error occurred during rollback; we cannot release any MDL */;
+ else if (thd->variables.sql_log_bin &&
+ (WSREP_EMULATE_BINLOG_NNULL(thd) || mysql_bin_log.is_open()))
+ /* In some cases (such as with non-transactional tables) we may
+ choose to preserve events that were added after the SAVEPOINT,
+ delimiting them by SAVEPOINT and ROLLBACK TO SAVEPOINT statements.
+ Prematurely releasing MDL on such objects would break replication. */;
+ else if (ha_rollback_to_savepoint_can_release_mdl(thd))
thd->mdl_context.rollback_to_savepoint(sv->mdl_savepoint);
DBUG_RETURN(MY_TEST(res));