From 790a8274cd0ea471a81652aef932191660deb64b Mon Sep 17 00:00:00 2001 From: sjaakola Date: Wed, 22 Feb 2017 23:10:36 +0200 Subject: [PATCH] Refs: MW-360 * reverted WSREP_TO_ISOLATION macros back to original form --- sql/sql_parse.cc | 14 +++++++++++++- sql/sql_parse.h | 29 +++++++++++++++++++++++------ sql/sql_partition_admin.cc | 4 ++-- sql/sql_truncate.cc | 6 +++--- sql/wsrep_mysqld.cc | 4 ++-- sql/wsrep_mysqld.h | 20 +------------------- 6 files changed, 44 insertions(+), 33 deletions(-) diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index d63a61e0ab1..e381f14f627 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -4040,7 +4040,19 @@ end_with_restore_list: slave_ddl_exec_mode_options == SLAVE_EXEC_MODE_IDEMPOTENT) lex->check_exists= 1; - WSREP_TO_ISOLATION_BEGIN(NULL, NULL, all_tables); +#ifdef WITH_WSREP + for (TABLE_LIST *table= all_tables; table; table= table->next_global) + { + if (!lex->drop_temporary && + (!thd->is_current_stmt_binlog_format_row() || + !find_temporary_table(thd, table))) + { + WSREP_TO_ISOLATION_BEGIN(NULL, NULL, all_tables); + break; + } + } +#endif /* WITH_WSREP */ + /* DDL and binlog write order are protected by metadata locks. */ res= mysql_rm_table(thd, first_table, lex->check_exists, lex->drop_temporary); diff --git a/sql/sql_parse.h b/sql/sql_parse.h index c2dbb950f2a..306ceed1863 100644 --- a/sql/sql_parse.h +++ b/sql/sql_parse.h @@ -209,12 +209,29 @@ inline bool is_supported_parser_charset(CHARSET_INFO *cs) return MY_TEST(cs->mbminlen == 1); } -#ifndef WITH_WSREP -#define WSREP_TO_ISOLATION_BEGIN(db_, table_, table_list_) -#define WSREP_TO_ISOLATION_BEGIN_QUERY(db_, query_, table_, table_list_) -#define WSREP_TO_ISOLATION_END -#define WSREP_TO_ISOLATION_BEGIN_WRTCHK(db_, query_, table_, table_list_) -#endif /* !WITH_WSREP */ +#ifdef WITH_WSREP +#define WSREP_MYSQL_DB (char *)"mysql" +#define WSREP_TO_ISOLATION_BEGIN(db_, table_, table_list_) \ + if (WSREP(thd) && wsrep_to_isolation_begin(thd, db_, table_, table_list_)) goto error; + +#define WSREP_TO_ISOLATION_END \ + if (WSREP(thd) || (thd && thd->wsrep_exec_mode==TOTAL_ORDER)) \ + wsrep_to_isolation_end(thd); + +/* Checks if lex->no_write_to_binlog is set for statements that use + LOCAL or NO_WRITE_TO_BINLOG +*/ +#define WSREP_TO_ISOLATION_BEGIN_WRTCHK(db_, table_, table_list_) \ + if (WSREP(thd) && !thd->lex->no_write_to_binlog \ + && wsrep_to_isolation_begin(thd, db_, table_, table_list_)) goto error; + +#else + +#define WSREP_TO_ISOLATION_BEGIN(db_, table_, table_list_) +#define WSREP_TO_ISOLATION_END +#define WSREP_TO_ISOLATION_BEGIN_WRTCHK(db_, table_, table_list_) + +#endif /* WITH_WSREP */ #endif /* SQL_PARSE_INCLUDED */ diff --git a/sql/sql_partition_admin.cc b/sql/sql_partition_admin.cc index d50fe0379f3..56c9c5bf3bf 100644 --- a/sql/sql_partition_admin.cc +++ b/sql/sql_partition_admin.cc @@ -537,7 +537,7 @@ bool Sql_cmd_alter_table_exchange_partition:: if ((!thd->is_current_stmt_binlog_format_row() || /* TODO: Do we really need to check for temp tables in this case? */ !find_temporary_table(thd, table_list)) && - wsrep_to_isolation_begin(thd, NULL, table_list->db, table_list->table_name, + wsrep_to_isolation_begin(thd, table_list->db, table_list->table_name, NULL)) { WSREP_WARN("ALTER TABLE EXCHANGE PARTITION isolation failure"); @@ -785,7 +785,7 @@ bool Sql_cmd_alter_table_truncate_partition::execute(THD *thd) if (WSREP(thd) && (!thd->is_current_stmt_binlog_format_row() || !find_temporary_table(thd, first_table)) && wsrep_to_isolation_begin( - thd, NULL, first_table->db, first_table->table_name, NULL) + thd, first_table->db, first_table->table_name, NULL) ) { WSREP_WARN("ALTER TABLE TRUNCATE PARTITION isolation failure"); diff --git a/sql/sql_truncate.cc b/sql/sql_truncate.cc index d047186b2cf..5182b35d80f 100644 --- a/sql/sql_truncate.cc +++ b/sql/sql_truncate.cc @@ -487,9 +487,9 @@ bool Sql_cmd_truncate_table::truncate_table(THD *thd, TABLE_LIST *table_ref) bool hton_can_recreate; #ifdef WITH_WSREP - if (WSREP(thd) && wsrep_to_isolation_begin(thd, NULL, - table_ref->db, - table_ref->table_name, NULL)) + if (WSREP(thd) && wsrep_to_isolation_begin(thd, + table_ref->db, + table_ref->table_name, NULL)) DBUG_RETURN(TRUE); #endif /* WITH_WSREP */ if (lock_table(thd, table_ref, &hton_can_recreate)) diff --git a/sql/wsrep_mysqld.cc b/sql/wsrep_mysqld.cc index fa8991709db..cf8ac25aa6a 100644 --- a/sql/wsrep_mysqld.cc +++ b/sql/wsrep_mysqld.cc @@ -1523,7 +1523,7 @@ static void wsrep_RSU_end(THD *thd) thd->variables.wsrep_on = 1; } -int wsrep_to_isolation_begin(THD *thd, const char *query, char *db_, char *table_, +int wsrep_to_isolation_begin(THD *thd, char *db_, char *table_, const TABLE_LIST* table_list) { @@ -1579,7 +1579,7 @@ int wsrep_to_isolation_begin(THD *thd, const char *query, char *db_, char *table { switch (thd->variables.wsrep_OSU_method) { case WSREP_OSU_TOI: - ret = wsrep_TOI_begin(thd, query, db_, table_, table_list); + ret = wsrep_TOI_begin(thd, thd->query(), db_, table_, table_list); break; case WSREP_OSU_RSU: ret = wsrep_RSU_begin(thd, db_, table_); diff --git a/sql/wsrep_mysqld.h b/sql/wsrep_mysqld.h index ea7e7df9e10..1cda5d23986 100644 --- a/sql/wsrep_mysqld.h +++ b/sql/wsrep_mysqld.h @@ -320,7 +320,7 @@ extern PSI_mutex_key key_LOCK_wsrep_slave_threads; extern PSI_mutex_key key_LOCK_wsrep_desync; #endif /* HAVE_PSI_INTERFACE */ struct TABLE_LIST; -int wsrep_to_isolation_begin(THD *thd, const char * query, char *db_, char *table_, +int wsrep_to_isolation_begin(THD *thd, char *db_, char *table_, const TABLE_LIST* table_list); void wsrep_to_isolation_end(THD *thd); void wsrep_cleanup_transaction(THD *thd); @@ -338,22 +338,4 @@ void wsrep_init_sidno(const wsrep_uuid_t&); bool wsrep_node_is_donor(); bool wsrep_node_is_synced(); -#define WSREP_MYSQL_DB (char *)"mysql" -#define WSREP_TO_ISOLATION_BEGIN(db_, table_, table_list_) \ - if (WSREP(thd) && wsrep_to_isolation_begin(thd, NULL, db_, table_, table_list_)) goto error; - -#define WSREP_TO_ISOLATION_BEGIN_QUERY(query, db_, table_, table_list_) \ - (WSREP(thd) && wsrep_to_isolation_begin(thd, query, db_, table_, table_list_)) - -#define WSREP_TO_ISOLATION_END \ - if (WSREP(thd) || (thd && thd->wsrep_exec_mode==TOTAL_ORDER)) \ - wsrep_to_isolation_end(thd); - -/* Checks if lex->no_write_to_binlog is set for statements that use - LOCAL or NO_WRITE_TO_BINLOG -*/ -#define WSREP_TO_ISOLATION_BEGIN_WRTCHK(db_, table_, table_list_) \ - if (WSREP(thd) && !thd->lex->no_write_to_binlog \ - && wsrep_to_isolation_begin(thd, NULL, db_, table_, table_list_)) goto error; - #endif /* WSREP_MYSQLD_H */