summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
Diffstat (limited to 'sql')
-rw-r--r--sql/CMakeLists.txt2
-rw-r--r--sql/mdl.cc16
-rw-r--r--sql/sql_base.cc2
-rw-r--r--sql/sql_class.cc2
-rw-r--r--sql/sql_plugin_services.h41
-rw-r--r--sql/wsrep_dummy.cc126
-rw-r--r--sql/wsrep_mysqld.cc144
-rw-r--r--sql/wsrep_mysqld.h71
-rw-r--r--sql/wsrep_thd.cc20
-rw-r--r--sql/wsrep_thd.h5
-rw-r--r--sql/wsrep_utils.cc3
11 files changed, 295 insertions, 137 deletions
diff --git a/sql/CMakeLists.txt b/sql/CMakeLists.txt
index b02389ccc17..32499662a7c 100644
--- a/sql/CMakeLists.txt
+++ b/sql/CMakeLists.txt
@@ -29,6 +29,8 @@ IF(WITH_WSREP AND NOT EMBEDDED_LIBRARY)
wsrep_thd.cc
)
SET(WSREP_LIB wsrep)
+ELSE()
+ SET(WSREP_SOURCES wsrep_dummy.cc)
ENDIF()
INCLUDE_DIRECTORIES(
diff --git a/sql/mdl.cc b/sql/mdl.cc
index 15428c96d73..42f12a47afd 100644
--- a/sql/mdl.cc
+++ b/sql/mdl.cc
@@ -1501,7 +1501,7 @@ void MDL_lock::Ticket_list::add_ticket(MDL_ticket *ticket)
DBUG_ASSERT(ticket->get_lock());
#ifdef WITH_WSREP
if ((this == &(ticket->get_lock()->m_waiting)) &&
- wsrep_thd_is_BF((void *)(ticket->get_ctx()->get_thd()), false))
+ wsrep_thd_is_BF(ticket->get_ctx()->get_thd(), false))
{
Ticket_iterator itw(ticket->get_lock()->m_waiting);
Ticket_iterator itg(ticket->get_lock()->m_granted);
@@ -1513,10 +1513,10 @@ void MDL_lock::Ticket_list::add_ticket(MDL_ticket *ticket)
while ((waiting= itw++) && !added)
{
- if (!wsrep_thd_is_BF((void *)(waiting->get_ctx()->get_thd()), true))
+ if (!wsrep_thd_is_BF(waiting->get_ctx()->get_thd(), true))
{
WSREP_DEBUG("MDL add_ticket inserted before: %lu %s",
- wsrep_thd_thread_id(waiting->get_ctx()->get_thd()),
+ thd_get_thread_id(waiting->get_ctx()->get_thd()),
wsrep_thd_query(waiting->get_ctx()->get_thd()));
m_list.insert_after(prev, ticket);
added= true;
@@ -1911,11 +1911,11 @@ MDL_lock::can_grant_lock(enum_mdl_type type_arg,
ticket->is_incompatible_when_granted(type_arg))
{
#ifdef WITH_WSREP
- if (wsrep_thd_is_BF((void *)(requestor_ctx->get_thd()),false) &&
+ if (wsrep_thd_is_BF(requestor_ctx->get_thd(),false) &&
key.mdl_namespace() == MDL_key::GLOBAL)
{
WSREP_DEBUG("global lock granted for BF: %lu %s",
- wsrep_thd_thread_id(requestor_ctx->get_thd()),
+ thd_get_thread_id(requestor_ctx->get_thd()),
wsrep_thd_query(requestor_ctx->get_thd()));
can_grant = true;
}
@@ -1945,12 +1945,12 @@ MDL_lock::can_grant_lock(enum_mdl_type type_arg,
}
else
{
- if (wsrep_thd_is_BF((void *)(requestor_ctx->get_thd()), false) &&
+ if (wsrep_thd_is_BF(requestor_ctx->get_thd(), false) &&
key.mdl_namespace() == MDL_key::GLOBAL)
{
WSREP_DEBUG("global lock granted for BF (waiting queue): %lu %s",
- wsrep_thd_thread_id(requestor_ctx->get_thd()),
- wsrep_thd_query(requestor_ctx->get_thd()));
+ thd_get_thread_id(requestor_ctx->get_thd()),
+ wsrep_thd_query(requestor_ctx->get_thd()));
can_grant = true;
}
}
diff --git a/sql/sql_base.cc b/sql/sql_base.cc
index 00689aad1f3..356f672657e 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -9019,7 +9019,7 @@ bool mysql_notify_thread_having_shared_lock(THD *thd, THD *in_use,
if (!thd_table->needs_reopen())
{
signalled|= mysql_lock_abort_for_thread(thd, thd_table);
- if (thd && WSREP(thd) && wsrep_thd_is_BF((void *)thd, true))
+ if (thd && WSREP(thd) && wsrep_thd_is_BF(thd, true))
{
WSREP_DEBUG("remove_table_from_cache: %llu",
(unsigned long long) thd->real_id);
diff --git a/sql/sql_class.cc b/sql/sql_class.cc
index 56c14613829..782e4a27317 100644
--- a/sql/sql_class.cc
+++ b/sql/sql_class.cc
@@ -1949,7 +1949,7 @@ bool THD::notify_shared_lock(MDL_context_owner *ctx_in_use,
if (!thd_table->needs_reopen())
{
signalled|= mysql_lock_abort_for_thread(this, thd_table);
- if (this && WSREP(this) && wsrep_thd_is_BF((void *)this, FALSE))
+ if (this && WSREP(this) && wsrep_thd_is_BF(this, FALSE))
{
WSREP_DEBUG("remove_table_from_cache: %llu",
(unsigned long long) this->real_id);
diff --git a/sql/sql_plugin_services.h b/sql/sql_plugin_services.h
index 417c16c1112..399de854218 100644
--- a/sql/sql_plugin_services.h
+++ b/sql/sql_plugin_services.h
@@ -16,6 +16,7 @@
/* support for Services */
#include <service_versions.h>
+#include <mysql/service_wsrep.h>
struct st_service_ref {
const char *name;
@@ -99,6 +100,45 @@ static struct thd_error_context_service_st thd_error_conext_handler= {
thd_get_error_context_description
};
+static struct wsrep_service_st wsrep_handler = {
+ get_wsrep,
+ get_wsrep_certify_nonPK,
+ get_wsrep_debug,
+ get_wsrep_drupal_282555_workaround,
+ get_wsrep_load_data_splitting,
+ get_wsrep_log_conflicts,
+ get_wsrep_protocol_version,
+ wsrep_aborting_thd_contains,
+ wsrep_aborting_thd_enqueue,
+ wsrep_consistency_check,
+ wsrep_is_wsrep_xid,
+ wsrep_lock_rollback,
+ wsrep_on,
+ wsrep_post_commit,
+ wsrep_prepare_key,
+ wsrep_run_wsrep_commit,
+ wsrep_thd_LOCK,
+ wsrep_thd_UNLOCK,
+ wsrep_thd_awake,
+ wsrep_thd_conflict_state,
+ wsrep_thd_conflict_state_str,
+ wsrep_thd_exec_mode,
+ wsrep_thd_exec_mode_str,
+ wsrep_thd_get_conflict_state,
+ wsrep_thd_is_BF,
+ wsrep_thd_is_wsrep,
+ wsrep_thd_query,
+ wsrep_thd_query_state,
+ wsrep_thd_query_state_str,
+ wsrep_thd_retry_counter,
+ wsrep_thd_set_conflict_state,
+ wsrep_thd_trx_seqno,
+ wsrep_thd_ws_handle,
+ wsrep_trx_is_aborting,
+ wsrep_trx_order_before,
+ wsrep_unlock_rollback
+};
+
static struct st_service_ref list_of_services[]=
{
{ "my_snprintf_service", VERSION_my_snprintf, &my_snprintf_handler },
@@ -112,6 +152,7 @@ static struct st_service_ref list_of_services[]=
{ "my_md5_service", VERSION_my_md5, &my_md5_handler},
{ "logger_service", VERSION_logger, &logger_service_handler },
{ "thd_autoinc_service", VERSION_thd_autoinc, &thd_autoinc_handler },
+ { "wsrep_service", VERSION_wsrep, &wsrep_handler },
{ "thd_error_context_service", VERSION_thd_error_context, &thd_error_conext_handler },
};
diff --git a/sql/wsrep_dummy.cc b/sql/wsrep_dummy.cc
new file mode 100644
index 00000000000..e937ef9be5c
--- /dev/null
+++ b/sql/wsrep_dummy.cc
@@ -0,0 +1,126 @@
+/* Copyright (C) 2014 SkySQL Ab.
+
+ 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
+ the Free Software Foundation; version 2 of the License.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with this program; if not, write to the Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */
+
+#include <my_global.h>
+#include <sql_class.h>
+#include <mysql/service_wsrep.h>
+
+my_bool wsrep_thd_is_BF(THD *, my_bool)
+{ return 0; }
+
+int wsrep_trx_order_before(THD *, THD *)
+{ return 0; }
+
+enum wsrep_conflict_state wsrep_thd_conflict_state(THD *, my_bool)
+{ return NO_CONFLICT; }
+
+int wsrep_is_wsrep_xid(const XID*)
+{ return 0; }
+
+bool wsrep_prepare_key(const uchar*, size_t, const uchar*, size_t, struct wsrep_buf*, size_t*)
+{ return 0; }
+
+struct wsrep *get_wsrep()
+{ return 0; }
+
+my_bool get_wsrep_certify_nonPK()
+{ return 0; }
+
+my_bool get_wsrep_debug()
+{ return 0; }
+
+my_bool get_wsrep_drupal_282555_workaround()
+{ return 0; }
+
+my_bool get_wsrep_load_data_splitting()
+{ return 0; }
+
+my_bool get_wsrep_log_conflicts()
+{ return 0; }
+
+long get_wsrep_protocol_version()
+{ return 0; }
+
+my_bool wsrep_aborting_thd_contains(THD *)
+{ return 0; }
+
+void wsrep_aborting_thd_enqueue(THD *)
+{ }
+
+bool wsrep_consistency_check(THD *)
+{ return 0; }
+
+void wsrep_lock_rollback()
+{ }
+
+int wsrep_on(THD *thd)
+{ return 0; }
+
+void wsrep_post_commit(THD*, bool)
+{ }
+
+enum wsrep_trx_status wsrep_run_wsrep_commit(THD *, handlerton *, bool)
+{ return WSREP_TRX_ERROR; }
+
+void wsrep_thd_LOCK(THD *)
+{ }
+
+void wsrep_thd_UNLOCK(THD *)
+{ }
+
+void wsrep_thd_awake(THD *, my_bool)
+{ }
+
+const char *wsrep_thd_conflict_state_str(THD *)
+{ return 0; }
+
+enum wsrep_exec_mode wsrep_thd_exec_mode(THD *)
+{ return LOCAL_STATE; }
+
+const char *wsrep_thd_exec_mode_str(THD *)
+{ return NULL; }
+
+enum wsrep_conflict_state wsrep_thd_get_conflict_state(THD *)
+{ return NO_CONFLICT; }
+
+my_bool wsrep_thd_is_wsrep(THD *)
+{ return 0; }
+
+char *wsrep_thd_query(THD *)
+{ return 0; }
+
+enum wsrep_query_state wsrep_thd_query_state(THD *)
+{ return QUERY_IDLE; }
+
+const char *wsrep_thd_query_state_str(THD *)
+{ return 0; }
+
+int wsrep_thd_retry_counter(THD *)
+{ return 0; }
+
+void wsrep_thd_set_conflict_state(THD *, enum wsrep_conflict_state)
+{ }
+
+longlong wsrep_thd_trx_seqno(THD *)
+{ return -1; }
+
+struct wsrep_ws_handle* wsrep_thd_ws_handle(THD *)
+{ return 0; }
+
+int wsrep_trx_is_aborting(THD *)
+{ return 0; }
+
+void wsrep_unlock_rollback()
+{ }
diff --git a/sql/wsrep_mysqld.cc b/sql/wsrep_mysqld.cc
index f47310ba49f..0dd273a0df7 100644
--- a/sql/wsrep_mysqld.cc
+++ b/sql/wsrep_mysqld.cc
@@ -782,14 +782,15 @@ int wsrep_init()
return rcode;
}
-extern int wsrep_on(void *);
-
void wsrep_init_startup (bool first)
{
if (wsrep_init()) unireg_abort(1);
- wsrep_thr_lock_init(wsrep_thd_is_BF, wsrep_abort_thd,
- wsrep_debug, wsrep_convert_LOCK_to_trx, wsrep_on);
+ wsrep_thr_lock_init(
+ (wsrep_thd_is_brute_force_fun)wsrep_thd_is_BF,
+ (wsrep_abort_thd_fun)wsrep_abort_thd,
+ wsrep_debug, wsrep_convert_LOCK_to_trx,
+ (wsrep_on_fun)wsrep_on);
/* Skip replication start if no cluster address */
if (!wsrep_cluster_address || strlen(wsrep_cluster_address) == 0) return;
@@ -1187,12 +1188,9 @@ err:
}
-bool wsrep_prepare_key_for_innodb(const uchar* cache_key,
- size_t cache_key_len,
- const uchar* row_id,
- size_t row_id_len,
- wsrep_buf_t* key,
- size_t* key_len)
+bool wsrep_prepare_key(const uchar* cache_key, size_t cache_key_len,
+ const uchar* row_id, size_t row_id_len,
+ wsrep_buf_t* key, size_t* key_len)
{
if (*key_len < 3) return false;
@@ -2112,9 +2110,9 @@ int wsrep_create_sp(THD *thd, uchar** buf, size_t* buf_len)
}
-extern int wsrep_on(void *thd)
+extern int wsrep_on(THD *thd)
{
- return (int)(WSREP(((THD*)thd)));
+ return (int)(WSREP(thd));
}
@@ -2124,9 +2122,9 @@ extern "C" bool wsrep_thd_is_wsrep_on(THD *thd)
}
-extern "C" bool wsrep_consistency_check(void *thd)
+bool wsrep_consistency_check(THD *thd)
{
- return ((THD*)thd)->wsrep_consistency_check == CONSISTENCY_CHECK_RUNNING;
+ return thd->wsrep_consistency_check == CONSISTENCY_CHECK_RUNNING;
}
@@ -2143,20 +2141,19 @@ extern "C" void wsrep_thd_set_query_state(
}
-extern "C" void wsrep_thd_set_conflict_state(
- THD *thd, enum wsrep_conflict_state state)
+void wsrep_thd_set_conflict_state(THD *thd, enum wsrep_conflict_state state)
{
thd->wsrep_conflict_state= state;
}
-extern "C" enum wsrep_exec_mode wsrep_thd_exec_mode(THD *thd)
+enum wsrep_exec_mode wsrep_thd_exec_mode(THD *thd)
{
return thd->wsrep_exec_mode;
}
-extern "C" const char *wsrep_thd_exec_mode_str(THD *thd)
+const char *wsrep_thd_exec_mode_str(THD *thd)
{
return
(!thd) ? "void" :
@@ -2167,13 +2164,13 @@ extern "C" const char *wsrep_thd_exec_mode_str(THD *thd)
}
-extern "C" enum wsrep_query_state wsrep_thd_query_state(THD *thd)
+enum wsrep_query_state wsrep_thd_query_state(THD *thd)
{
return thd->wsrep_query_state;
}
-extern "C" const char *wsrep_thd_query_state_str(THD *thd)
+const char *wsrep_thd_query_state_str(THD *thd)
{
return
(!thd) ? "void" :
@@ -2185,13 +2182,13 @@ extern "C" const char *wsrep_thd_query_state_str(THD *thd)
}
-extern "C" enum wsrep_conflict_state wsrep_thd_conflict_state(THD *thd)
+enum wsrep_conflict_state wsrep_thd_get_conflict_state(THD *thd)
{
return thd->wsrep_conflict_state;
}
-extern "C" const char *wsrep_thd_conflict_state_str(THD *thd)
+const char *wsrep_thd_conflict_state_str(THD *thd)
{
return
(!thd) ? "void" :
@@ -2205,19 +2202,19 @@ extern "C" const char *wsrep_thd_conflict_state_str(THD *thd)
}
-extern "C" wsrep_ws_handle_t* wsrep_thd_ws_handle(THD *thd)
+wsrep_ws_handle_t* wsrep_thd_ws_handle(THD *thd)
{
return &thd->wsrep_ws_handle;
}
-extern "C" void wsrep_thd_LOCK(THD *thd)
+void wsrep_thd_LOCK(THD *thd)
{
mysql_mutex_lock(&thd->LOCK_wsrep_thd);
}
-extern "C" void wsrep_thd_UNLOCK(THD *thd)
+void wsrep_thd_UNLOCK(THD *thd)
{
mysql_mutex_unlock(&thd->LOCK_wsrep_thd);
}
@@ -2234,14 +2231,7 @@ extern "C" uint32 wsrep_thd_wsrep_rand(THD *thd)
return thd->wsrep_rand;
}
-
-extern "C" my_thread_id wsrep_thd_thread_id(THD *thd)
-{
- return thd->thread_id;
-}
-
-
-extern "C" wsrep_seqno_t wsrep_thd_trx_seqno(THD *thd)
+longlong wsrep_thd_trx_seqno(THD *thd)
{
return (thd) ? thd->wsrep_trx_meta.gtid.seqno : WSREP_SEQNO_UNDEFINED;
}
@@ -2253,7 +2243,7 @@ extern "C" query_id_t wsrep_thd_query_id(THD *thd)
}
-extern "C" char *wsrep_thd_query(THD *thd)
+char *wsrep_thd_query(THD *thd)
{
return (thd) ? thd->query() : NULL;
}
@@ -2288,30 +2278,29 @@ extern "C" void wsrep_thd_awake(THD *thd, my_bool signal)
}
-extern "C" int wsrep_thd_retry_counter(THD *thd)
+int wsrep_thd_retry_counter(THD *thd)
{
return(thd->wsrep_retry_counter);
}
extern int
-wsrep_trx_order_before(void *thd1, void *thd2)
+wsrep_trx_order_before(THD *thd1, THD *thd2)
{
- if (wsrep_thd_trx_seqno((THD*)thd1) < wsrep_thd_trx_seqno((THD*)thd2)) {
+ if (wsrep_thd_trx_seqno(thd1) < wsrep_thd_trx_seqno(thd2)) {
WSREP_DEBUG("BF conflict, order: %lld %lld\n",
- (long long)wsrep_thd_trx_seqno((THD*)thd1),
- (long long)wsrep_thd_trx_seqno((THD*)thd2));
+ (long long)wsrep_thd_trx_seqno(thd1),
+ (long long)wsrep_thd_trx_seqno(thd2));
return 1;
}
WSREP_DEBUG("waiting for BF, trx order: %lld %lld\n",
- (long long)wsrep_thd_trx_seqno((THD*)thd1),
- (long long)wsrep_thd_trx_seqno((THD*)thd2));
+ (long long)wsrep_thd_trx_seqno(thd1),
+ (long long)wsrep_thd_trx_seqno(thd2));
return 0;
}
-extern "C" int
-wsrep_trx_is_aborting(void *thd_ptr)
+int wsrep_trx_is_aborting(THD *thd_ptr)
{
if (thd_ptr) {
if ((((THD *)thd_ptr)->wsrep_conflict_state == MUST_ABORT) ||
@@ -2456,3 +2445,72 @@ int wsrep_create_trigger_query(THD *thd, uchar** buf, size_t* buf_len)
return wsrep_to_buf_helper(thd, stmt_query.c_ptr(), stmt_query.length(),
buf, buf_len);
}
+
+/***** callbacks for wsrep service ************/
+
+my_bool get_wsrep_debug()
+{
+ return wsrep_debug;
+}
+
+my_bool get_wsrep_load_data_splitting()
+{
+ return wsrep_load_data_splitting;
+}
+
+long get_wsrep_protocol_version()
+{
+ return wsrep_protocol_version;
+}
+
+my_bool get_wsrep_drupal_282555_workaround()
+{
+ return wsrep_drupal_282555_workaround;
+}
+
+my_bool get_wsrep_log_conflicts()
+{
+ return wsrep_log_conflicts;
+}
+
+wsrep_t *get_wsrep()
+{
+ return wsrep;
+}
+
+my_bool get_wsrep_certify_nonPK()
+{
+ return wsrep_certify_nonPK;
+}
+
+void wsrep_lock_rollback()
+{
+ mysql_mutex_lock(&LOCK_wsrep_rollback);
+}
+
+void wsrep_unlock_rollback()
+{
+ mysql_cond_signal(&COND_wsrep_rollback);
+ mysql_mutex_unlock(&LOCK_wsrep_rollback);
+}
+
+my_bool wsrep_aborting_thd_contains(THD *thd)
+{
+ wsrep_aborting_thd_t abortees = wsrep_aborting_thd;
+ while (abortees)
+ {
+ if (abortees->aborting_thd == thd)
+ return true;
+ abortees = abortees->next;
+ }
+ return false;
+}
+
+void wsrep_aborting_thd_enqueue(THD *thd)
+{
+ wsrep_aborting_thd_t aborting = (wsrep_aborting_thd_t)
+ my_malloc(sizeof(struct wsrep_aborting_thd), MYF(0));
+ aborting->aborting_thd = thd;
+ aborting->next = wsrep_aborting_thd;
+ wsrep_aborting_thd = aborting;
+}
diff --git a/sql/wsrep_mysqld.h b/sql/wsrep_mysqld.h
index c81ed794659..ce12c13b5a8 100644
--- a/sql/wsrep_mysqld.h
+++ b/sql/wsrep_mysqld.h
@@ -18,6 +18,9 @@
#ifndef WSREP_MYSQLD_H
#define WSREP_MYSQLD_H
+#include <mysql/plugin.h>
+#include <mysql/service_wsrep.h>
+
#ifdef WITH_WSREP
typedef struct st_mysql_show_var SHOW_VAR;
@@ -33,32 +36,6 @@ typedef struct st_mysql_show_var SHOW_VAR;
class set_var;
class THD;
-enum wsrep_exec_mode {
- LOCAL_STATE,
- REPL_RECV,
- TOTAL_ORDER,
- LOCAL_COMMIT
-};
-
-enum wsrep_query_state {
- QUERY_IDLE,
- QUERY_EXEC,
- QUERY_COMMITTING,
- QUERY_EXITING,
- QUERY_ROLLINGBACK,
-};
-
-enum wsrep_conflict_state {
- NO_CONFLICT,
- MUST_ABORT,
- ABORTING,
- ABORTED,
- MUST_REPLAY,
- REPLAYING,
- RETRY_AUTOCOMMIT,
- CERT_FAILURE,
-};
-
enum wsrep_consistency_check_mode {
NO_CONSISTENCY_CHECK,
CONSISTENCY_CHECK_DECLARED,
@@ -90,27 +67,21 @@ extern const char* wsrep_data_home_dir;
extern const char* wsrep_dbug_option;
extern long wsrep_slave_threads;
extern int wsrep_slave_count_change;
-extern MYSQL_PLUGIN_IMPORT my_bool wsrep_debug;
extern my_bool wsrep_convert_LOCK_to_trx;
extern ulong wsrep_retry_autocommit;
extern my_bool wsrep_auto_increment_control;
-extern my_bool wsrep_drupal_282555_workaround;
extern my_bool wsrep_incremental_data_collection;
extern const char* wsrep_start_position;
extern ulong wsrep_max_ws_size;
extern ulong wsrep_max_ws_rows;
extern const char* wsrep_notify_cmd;
-extern my_bool wsrep_certify_nonPK;
extern long wsrep_max_protocol_version;
-extern long wsrep_protocol_version;
extern ulong wsrep_forced_binlog_format;
extern ulong wsrep_OSU_method_options;
extern my_bool wsrep_desync;
extern my_bool wsrep_recovery;
extern my_bool wsrep_replicate_myisam;
-extern my_bool wsrep_log_conflicts;
extern ulong wsrep_mysql_replication_bundle;
-extern my_bool wsrep_load_data_splitting;
extern my_bool wsrep_restart_slave;
extern my_bool wsrep_restart_slave_activated;
extern my_bool wsrep_slave_FK_checks;
@@ -157,34 +128,18 @@ void wsrep_init_startup(bool before);
// Other wsrep global variables
extern my_bool wsrep_inited; // whether wsrep is initialized ?
-extern "C" enum wsrep_exec_mode wsrep_thd_exec_mode(THD *thd);
-extern "C" enum wsrep_conflict_state wsrep_thd_conflict_state(THD *thd);
-extern "C" enum wsrep_query_state wsrep_thd_query_state(THD *thd);
-extern "C" const char * wsrep_thd_exec_mode_str(THD *thd);
-extern "C" const char * wsrep_thd_conflict_state_str(THD *thd);
-extern "C" const char * wsrep_thd_query_state_str(THD *thd);
-extern "C" wsrep_ws_handle_t* wsrep_thd_ws_handle(THD *thd);
extern "C" void wsrep_thd_set_exec_mode(THD *thd, enum wsrep_exec_mode mode);
extern "C" void wsrep_thd_set_query_state(
THD *thd, enum wsrep_query_state state);
-extern "C" void wsrep_thd_set_conflict_state(
- THD *thd, enum wsrep_conflict_state state);
extern "C" void wsrep_thd_set_trx_to_replay(THD *thd, uint64 trx_id);
-extern "C" void wsrep_thd_LOCK(THD *thd);
-extern "C" void wsrep_thd_UNLOCK(THD *thd);
extern "C" uint32 wsrep_thd_wsrep_rand(THD *thd);
extern "C" time_t wsrep_thd_query_start(THD *thd);
-extern "C" my_thread_id wsrep_thd_thread_id(THD *thd);
-extern "C" int64_t wsrep_thd_trx_seqno(THD *thd);
extern "C" query_id_t wsrep_thd_query_id(THD *thd);
-extern "C" char * wsrep_thd_query(THD *thd);
extern "C" query_id_t wsrep_thd_wsrep_last_query_id(THD *thd);
extern "C" void wsrep_thd_set_wsrep_last_query_id(THD *thd, query_id_t id);
-extern "C" void wsrep_thd_awake(THD *thd, my_bool signal);
-extern "C" int wsrep_thd_retry_counter(THD *thd);
extern void wsrep_close_client_connections(my_bool wait_to_end);
@@ -231,7 +186,7 @@ extern wsrep_seqno_t wsrep_locked_seqno;
"%s: \n " \
" THD: %lu, mode: %s, state: %s, conflict: %s, seqno: %lld\n " \
" SQL: %s", \
- role, wsrep_thd_thread_id(thd), wsrep_thd_exec_mode_str(thd), \
+ role, thd_get_thread_id(thd), wsrep_thd_exec_mode_str(thd), \
wsrep_thd_query_state_str(thd), \
wsrep_thd_conflict_state_str(thd), (long long)wsrep_thd_trx_seqno(thd), \
wsrep_thd_query(thd) \
@@ -252,24 +207,12 @@ extern wsrep_seqno_t wsrep_locked_seqno;
extern void wsrep_ready_wait();
-enum wsrep_trx_status {
- WSREP_TRX_OK,
- WSREP_TRX_CERT_FAIL, /* certification failure, must abort */
- WSREP_TRX_SIZE_EXCEEDED, /* trx size exceeded */
- WSREP_TRX_ERROR, /* native mysql error */
-};
-
-extern enum wsrep_trx_status
-wsrep_run_wsrep_commit(THD *thd, handlerton *hton, bool all);
class Ha_trx_info;
struct THD_TRANS;
void wsrep_register_hton(THD* thd, bool all);
-void wsrep_post_commit(THD* thd, bool all);
void wsrep_brute_force_killer(THD *thd);
int wsrep_hire_brute_force_killer(THD *thd, uint64_t trx_id);
-extern "C" bool wsrep_consistency_check(void *thd_ptr);
-
/* this is visible for client build so that innodb plugin gets this */
typedef struct wsrep_aborting_thd {
struct wsrep_aborting_thd *next;
@@ -335,10 +278,6 @@ void wsrep_init_sidno(const wsrep_uuid_t&);
void wsrep_xid_init(xid_t*, const wsrep_uuid_t*, wsrep_seqno_t);
const wsrep_uuid_t* wsrep_xid_uuid(const xid_t*);
wsrep_seqno_t wsrep_xid_seqno(const xid_t*);
-extern "C" int wsrep_is_wsrep_xid(const void* xid);
-
-extern "C" my_thread_id wsrep_thd_thread_id(THD *thd);
-extern "C" char *wsrep_thd_query(THD *thd);
extern bool
wsrep_grant_mdl_exception(MDL_context *requestor_ctx,
@@ -375,7 +314,6 @@ int wsrep_create_trigger_query(THD *thd, uchar** buf, size_t* buf_len);
#define WSREP_CLIENT(thd) (0)
#define wsrep_emulate_bin_log (0)
#define wsrep_xid_seqno(X) (0)
-#define wsrep_is_wsrep_xid(X) (0)
#define wsrep_to_isolation (0)
#define wsrep_recovery (0)
#define wsrep_init() (1)
@@ -385,7 +323,6 @@ int wsrep_create_trigger_query(THD *thd, uchar** buf, size_t* buf_len);
#define wsrep_sync_wait(...) (0)
#define wsrep_to_isolation_begin(...) (0)
#define wsrep_register_hton(...) do { } while(0)
-#define wsrep_post_commit(...) do { } while(0)
#define wsrep_check_opts() (0)
#define wsrep_stop_replication(X) do { } while(0)
#define wsrep_inited (0)
diff --git a/sql/wsrep_thd.cc b/sql/wsrep_thd.cc
index 0779535d7fb..b9ff0ecf8a8 100644
--- a/sql/wsrep_thd.cc
+++ b/sql/wsrep_thd.cc
@@ -491,12 +491,11 @@ void wsrep_thd_set_PA_safe(void *thd_ptr, my_bool safe)
}
}
-int wsrep_thd_conflict_state(void *thd_ptr, my_bool sync)
+enum wsrep_conflict_state wsrep_thd_conflict_state(THD *thd, my_bool sync)
{
- int state = -1;
- if (thd_ptr)
+ enum wsrep_conflict_state state = NO_CONFLICT;
+ if (thd)
{
- THD* thd = (THD*)thd_ptr;
if (sync) mysql_mutex_lock(&thd->LOCK_wsrep_thd);
state = thd->wsrep_conflict_state;
@@ -505,26 +504,23 @@ int wsrep_thd_conflict_state(void *thd_ptr, my_bool sync)
return state;
}
-my_bool wsrep_thd_is_wsrep(void *thd_ptr)
+my_bool wsrep_thd_is_wsrep(THD *thd)
{
my_bool status = FALSE;
- if (thd_ptr)
+ if (thd)
{
- THD* thd = (THD*)thd_ptr;
-
status = (WSREP(thd) && WSREP_PROVIDER_EXISTS);
}
return status;
}
-my_bool wsrep_thd_is_BF(void *thd_ptr, my_bool sync)
+my_bool wsrep_thd_is_BF(THD *thd, my_bool sync)
{
my_bool status = FALSE;
- if (thd_ptr)
+ if (thd)
{
- THD* thd = (THD*)thd_ptr;
// THD can be BF only if provider exists
- if (wsrep_thd_is_wsrep(thd_ptr))
+ if (wsrep_thd_is_wsrep(thd))
{
if (sync)
mysql_mutex_lock(&thd->LOCK_wsrep_thd);
diff --git a/sql/wsrep_thd.h b/sql/wsrep_thd.h
index cc3a7c7b9d1..9914e98dcdb 100644
--- a/sql/wsrep_thd.h
+++ b/sql/wsrep_thd.h
@@ -32,11 +32,10 @@ int wsrep_abort_thd(void *bf_thd_ptr, void *victim_thd_ptr,
my_bool signal);
extern void wsrep_thd_set_PA_safe(void *thd_ptr, my_bool safe);
-extern my_bool wsrep_thd_is_BF(void *thd_ptr, my_bool sync);
+extern my_bool wsrep_thd_is_BF(THD *thd, my_bool sync);
extern my_bool wsrep_thd_is_wsrep(void *thd_ptr);
-extern int wsrep_thd_conflict_state(void *thd_ptr, my_bool sync);
-//extern "C" my_bool wsrep_thd_is_BF(void *thd_ptr, my_bool sync);
+enum wsrep_conflict_state wsrep_thd_conflict_state(void *thd_ptr, my_bool sync);
extern "C" my_bool wsrep_thd_is_BF_or_commit(void *thd_ptr, my_bool sync);
extern "C" my_bool wsrep_thd_is_local(void *thd_ptr, my_bool sync);
extern "C" int wsrep_thd_in_locking_session(void *thd_ptr);
diff --git a/sql/wsrep_utils.cc b/sql/wsrep_utils.cc
index cdee1c2cece..e7509d393d8 100644
--- a/sql/wsrep_utils.cc
+++ b/sql/wsrep_utils.cc
@@ -514,9 +514,8 @@ wsrep_seqno_t wsrep_xid_seqno(const XID* xid)
}
extern
-int wsrep_is_wsrep_xid(const void* xid_ptr)
+int wsrep_is_wsrep_xid(const XID* xid)
{
- const XID* xid= reinterpret_cast<const XID*>(xid_ptr);
return (xid->formatID == 1 &&
xid->gtrid_length == WSREP_XID_GTRID_LEN &&
xid->bqual_length == 0 &&