From c1e1764fc4b913ee688b383aac2698b83661d64c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Sat, 2 Feb 2019 12:49:04 +0200 Subject: [PATCH] Fix embedded innodb_plugin after 560799ebd8efe11f4c4ae1bb9ed4d39185e03800 wsrep_certification_rules: Define as a weak global symbol. While there are separate _embedded.a for statically linked storage engine plugins, there is only one ha_innodb.so which is supposed to work with both values of WITH_WSREP. The merge from 10.0-galera introduced a reference to a global variable that is only defined when the server is built WITH_WSREP. We must define that symbol as weak global, so that when a dynamically linked InnoDB or XtraDB is used with the embedded server (which never includes write-set replication patches), the variable will be read as 0, instead of causing a failure to load the InnoDB or XtraDB plugin. --- sql/wsrep_mysqld_c.h | 6 +++++- storage/innobase/row/row0ins.cc | 6 +++++- storage/xtradb/row/row0ins.cc | 6 +++++- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/sql/wsrep_mysqld_c.h b/sql/wsrep_mysqld_c.h index 15ca0ae2a6d..235a871c113 100644 --- a/sql/wsrep_mysqld_c.h +++ b/sql/wsrep_mysqld_c.h @@ -21,6 +21,10 @@ enum enum_wsrep_certification_rules { WSREP_CERTIFICATION_RULES_OPTIMIZED }; -extern ulong wsrep_certification_rules; +/* This is intentionally declared as a weak global symbol, so that +the same ha_innodb.so can be used with the embedded server +(which does not link to the definition of this variable) +and with the regular server built WITH_WSREP. */ +extern ulong wsrep_certification_rules __attribute__((weak)); #endif /* WSREP_MYSQLD_C_H */ diff --git a/storage/innobase/row/row0ins.cc b/storage/innobase/row/row0ins.cc index 22588d33418..65a27ebeb37 100644 --- a/storage/innobase/row/row0ins.cc +++ b/storage/innobase/row/row0ins.cc @@ -56,6 +56,7 @@ Created 4/20/1996 Heikki Tuuri #include "m_string.h" #ifdef WITH_WSREP +#include #include "../../../wsrep/wsrep_api.h" #include "wsrep_mysqld_c.h" #endif /* WITH_WSREP */ @@ -1645,6 +1646,9 @@ run_again: if (check_ref) { err = DB_SUCCESS; #ifdef WITH_WSREP + if (!wsrep_on(trx->mysql_thd)) { + goto end_scan; + } enum wsrep_key_type key_type; if (upd_node != NULL) { key_type = WSREP_KEY_SHARED; @@ -1661,7 +1665,7 @@ run_again: } err = wsrep_append_foreign_key( - thr_get_trx(thr), + trx, foreign, rec, check_index, diff --git a/storage/xtradb/row/row0ins.cc b/storage/xtradb/row/row0ins.cc index b14d43e4f42..476c18680f3 100644 --- a/storage/xtradb/row/row0ins.cc +++ b/storage/xtradb/row/row0ins.cc @@ -56,6 +56,7 @@ Created 4/20/1996 Heikki Tuuri #include "m_string.h" #ifdef WITH_WSREP +#include #include "../../../wsrep/wsrep_api.h" #include "wsrep_mysqld_c.h" #endif /* WITH_WSREP */ @@ -1657,6 +1658,9 @@ run_again: if (check_ref) { err = DB_SUCCESS; #ifdef WITH_WSREP + if (!wsrep_on(trx->mysql_thd)) { + goto end_scan; + } enum wsrep_key_type key_type; if (upd_node != NULL) { key_type = WSREP_KEY_SHARED; @@ -1673,7 +1677,7 @@ run_again: } err = wsrep_append_foreign_key( - thr_get_trx(thr), + trx, foreign, rec, check_index,