summaryrefslogtreecommitdiff
path: root/sql/sql_admin.cc
diff options
context:
space:
mode:
authorOleksandr Byelkin <sanja@mariadb.com>2022-02-01 20:33:04 +0100
committerOleksandr Byelkin <sanja@mariadb.com>2022-02-01 20:33:04 +0100
commitcf63eecef44f189ce2d221612dee9dfc1885ba4e (patch)
tree93b4e6645a1d371bd8012a0aa8e6e3a3d541b2a6 /sql/sql_admin.cc
parentfb40a2fabf8d8cf765c83a0b8e609dd893c75ec3 (diff)
parentc04a203a10e282e1f33fd04d8a1b7ff0b076bce5 (diff)
downloadmariadb-git-cf63eecef44f189ce2d221612dee9dfc1885ba4e.tar.gz
Merge branch '10.4' into 10.5
Diffstat (limited to 'sql/sql_admin.cc')
-rw-r--r--sql/sql_admin.cc62
1 files changed, 9 insertions, 53 deletions
diff --git a/sql/sql_admin.cc b/sql/sql_admin.cc
index b9d0d65df11..060dcc059b5 100644
--- a/sql/sql_admin.cc
+++ b/sql/sql_admin.cc
@@ -432,49 +432,6 @@ dbug_err:
return open_error;
}
-#ifdef WITH_WSREP
- /*
- OPTIMIZE, REPAIR and ALTER may take MDL locks not only for the affected table, but
- also for the table referenced by foreign key constraint.
- This wsrep_toi_replication() function handles TOI replication for OPTIMIZE and REPAIR
- so that certification keys for potential FK parent tables are also appended in the
- write set.
- ALTER TABLE case is handled elsewhere.
- */
-static bool wsrep_toi_replication(THD *thd, TABLE_LIST *tables)
-{
- LEX *lex= thd->lex;
- /* only handle OPTIMIZE and REPAIR here */
- switch (lex->sql_command)
- {
- case SQLCOM_OPTIMIZE:
- case SQLCOM_REPAIR:
- break;
- default:
- return false;
- }
-
- close_thread_tables(thd);
- wsrep::key_array keys;
-
- wsrep_append_fk_parent_table(thd, tables, &keys);
-
- /* now TOI replication, with no locks held */
- if (keys.empty())
- {
- if (!thd->lex->no_write_to_binlog &&
- wsrep_to_isolation_begin(thd, NULL, NULL, tables))
- return true;
- }
- else
- {
- if (!thd->lex->no_write_to_binlog &&
- wsrep_to_isolation_begin(thd, NULL, NULL, tables, NULL, &keys))
- return true;
- }
- return false;
-}
-#endif /* WITH_WSREP */
static void send_read_only_warning(THD *thd, const LEX_CSTRING *msg_status,
@@ -561,16 +518,6 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables,
close_thread_tables(thd);
for (table= tables; table; table= table->next_local)
table->table= NULL;
-#ifdef WITH_WSREP
- if (WSREP(thd))
- {
- if(wsrep_toi_replication(thd, tables))
- {
- WSREP_INFO("wsrep TOI replication of has failed.");
- goto err;
- }
- }
-#endif /* WITH_WSREP */
for (table= tables; table; table= table->next_local)
{
@@ -1497,6 +1444,7 @@ bool Sql_cmd_optimize_table::execute(THD *thd)
FALSE, UINT_MAX, FALSE))
goto error; /* purecov: inspected */
+ WSREP_TO_ISOLATION_BEGIN_WRTCHK(NULL, NULL, first_table);
res= (specialflag & SPECIAL_NO_NEW_FUNC) ?
mysql_recreate_table(thd, first_table, true) :
mysql_admin_table(thd, first_table, &m_lex->check_opt,
@@ -1506,6 +1454,9 @@ bool Sql_cmd_optimize_table::execute(THD *thd)
m_lex->first_select_lex()->table_list.first= first_table;
m_lex->query_tables= first_table;
+#ifdef WITH_WSREP
+wsrep_error_label:
+#endif /* WITH_WSREP */
error:
DBUG_RETURN(res);
}
@@ -1521,6 +1472,8 @@ bool Sql_cmd_repair_table::execute(THD *thd)
if (check_table_access(thd, SELECT_ACL | INSERT_ACL, first_table,
FALSE, UINT_MAX, FALSE))
goto error; /* purecov: inspected */
+
+ WSREP_TO_ISOLATION_BEGIN_WRTCHK(NULL, NULL, first_table);
res= mysql_admin_table(thd, first_table, &m_lex->check_opt, "repair",
TL_WRITE, 1,
MY_TEST(m_lex->check_opt.sql_flags & TT_USEFRM),
@@ -1530,6 +1483,9 @@ bool Sql_cmd_repair_table::execute(THD *thd)
m_lex->first_select_lex()->table_list.first= first_table;
m_lex->query_tables= first_table;
+#ifdef WITH_WSREP
+wsrep_error_label:
+#endif /* WITH_WSREP */
error:
DBUG_RETURN(res);
}