diff --git a/include/wsrep.h b/include/wsrep.h
index c261d9c..8b3efb9 100644
--- a/include/wsrep.h
+++ b/include/wsrep.h
@@ -17,42 +17,84 @@
 #define WSERP_INCLUDED
 
 #ifdef WITH_WSREP
+#ifndef IF_WSREP
 #define IF_WSREP(A,B) A
+#endif
+
+#ifndef DBUG_ASSERT_IF_WSREP
 #define DBUG_ASSERT_IF_WSREP(A) DBUG_ASSERT(A)
+#endif
 
 #if !defined(EMBEDDED_LIBRARY)
+#ifndef WSREP_FORMAT
 #define WSREP_FORMAT(my_format)                           \
   ((wsrep_forced_binlog_format != BINLOG_FORMAT_UNSPEC) ? \
    wsrep_forced_binlog_format : my_format)
+#endif
 #else
+#ifndef WSREP_FORMAT
 #define WSREP_FORMAT(my_format) my_format
+#endif
 #endif /* && !EMBEDDED_LIBRARY */
 
+#ifndef WSREP_MYSQL_DB
 #define WSREP_MYSQL_DB (char *)"mysql"
+#endif
+
+#ifndef WSREP_TO_ISOLATION_BEGIN
 #define WSREP_TO_ISOLATION_BEGIN(db_, table_, table_list_)                   \
   if (WSREP_ON && WSREP(thd) && wsrep_to_isolation_begin(thd, db_, table_, table_list_)) \
     goto error;
+#endif
 
+#ifndef WSREP_TO_ISOLATION_END
 #define WSREP_TO_ISOLATION_END                                              \
   if (WSREP_ON && (WSREP(thd) || (thd && thd->wsrep_exec_mode==TOTAL_ORDER))) \
     wsrep_to_isolation_end(thd);
+#endif
 
+#ifndef WSREP_DEBUG
 #define WSREP_DEBUG(...)                                                \
     if (wsrep_debug)     WSREP_LOG(sql_print_information, ##__VA_ARGS__)
+#endif
+#ifndef WSREP_INFO
 #define WSREP_INFO(...)  WSREP_LOG(sql_print_information, ##__VA_ARGS__)
+#endif
+#ifndef WSREP_WARN
 #define WSREP_WARN(...)  WSREP_LOG(sql_print_warning,     ##__VA_ARGS__)
+#endif
+#ifndef WSREP_ERROR
 #define WSREP_ERROR(...) WSREP_LOG(sql_print_error,       ##__VA_ARGS__)
+#endif
 
 #else
+#ifndef IF_WSREP
 #define IF_WSREP(A,B) B
+#endif
+#ifndef DBUG_ASSERT_IF_WSREP
 #define DBUG_ASSERT_IF_WSREP(A)
+#endif
+#ifndef WSREP_DEBUG
 #define WSREP_DEBUG(...)
+#endif
+#ifndef WSREP_INFO
 #define WSREP_INFO(...)
+#endif
+#ifndef WSREP_WARN
 #define WSREP_WARN(...)
+#endif
+#ifndef WSREP_ERROR
 #define WSREP_ERROR(...)
+#endif
+#ifndef WSREP_FORMAT
 #define WSREP_FORMAT(my_format) my_format
+#endif
+#ifndef WSREP_TO_ISOLATION_BEGIN
 #define WSREP_TO_ISOLATION_BEGIN(db_, table_, table_list_)
+#endif
+#ifndef WSREP_TO_ISOLATION_END
 #define WSREP_TO_ISOLATION_END
 #endif
+#endif
 
 #endif /* WSERP_INCLUDED */
diff --git a/libmysqld/CMakeLists.txt b/libmysqld/CMakeLists.txt
index 0920be5..1427225 100644
--- a/libmysqld/CMakeLists.txt
+++ b/libmysqld/CMakeLists.txt
@@ -105,6 +105,7 @@ SET(SQL_EMBEDDED_SOURCES emb_qcache.cc libmysqld.c lib_sql.cc
            ../sql/compat56.cc
            ../sql/table_cache.cc
            ../sql/item_inetfunc.cc
+           ../sql/wsrep_embedded.cc
            ${GEN_SOURCES}
            ${MYSYS_LIBWRAP_SOURCE}
 )
diff --git a/libmysqld/examples/CMakeLists.txt b/libmysqld/examples/CMakeLists.txt
index d47638a..13b6698 100644
--- a/libmysqld/examples/CMakeLists.txt
+++ b/libmysqld/examples/CMakeLists.txt
@@ -32,7 +32,7 @@ IF(UNIX)
   TARGET_LINK_LIBRARIES(mysql_embedded ${MY_READLINE_LIBRARY})
 ENDIF(UNIX)
 
-MYSQL_ADD_EXECUTABLE(mysqltest_embedded ../../client/mysqltest.cc
+MYSQL_ADD_EXECUTABLE(mysqltest_embedded ../../client/mysqltest.cc ../../sql/wsrep_embedded.cc
   COMPONENT Test)
 TARGET_LINK_LIBRARIES(mysqltest_embedded mysqlserver pcre pcreposix)
 
diff --git a/sql/CMakeLists.txt b/sql/CMakeLists.txt
index 803e149..ce2f7b3 100644
--- a/sql/CMakeLists.txt
+++ b/sql/CMakeLists.txt
@@ -32,6 +32,12 @@ IF(WITH_WSREP AND NOT EMBEDDED_LIBRARY)
   SET(WSREP_LIB wsrep)
 ENDIF()
 
+IF(NOT WITH_WSREP)
+  SET(WSREP_INCLUDES ${CMAKE_SOURCE_DIR}/wsrep)
+  SET(WSREP_SOURCES 
+     wsrep_embedded.cc)
+ENDIF()
+
 INCLUDE_DIRECTORIES(
 ${CMAKE_SOURCE_DIR}/include 
 ${CMAKE_SOURCE_DIR}/sql 
diff --git a/sql/wsrep_embedded.cc b/sql/wsrep_embedded.cc
new file mode 100644
index 0000000..3849139
--- /dev/null
+++ b/sql/wsrep_embedded.cc
@@ -0,0 +1,594 @@
+/* Copyright 2014 Codership Oy <http://www.codership.com>
+   Copyright 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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
+
+#ifndef WITH_WSREP
+
+#include "sql_plugin.h"
+#include "sql_priv.h"
+#include "unireg.h"
+typedef class st_select_lex SELECT_LEX;
+#include "sql_parse.h"    // test_if_data_home_dir
+
+#define WITH_WSREP
+#include "wsrep_mysqld.h"
+#include "wsrep_priv.h"
+#include "wsrep_thd.h"
+#include "wsrep_sst.h"
+#include "wsrep_utils.h"
+#include "wsrep_var.h"
+#include "wsrep_binlog.h"
+#include "wsrep_applier.h"
+#undef WITH_WSREP
+#include <cstdio>
+#include <cstdlib>
+#include "log_event.h"
+#include <slave.h>
+
+handlerton    *wsrep_hton=NULL;
+mysql_mutex_t LOCK_wsrep_ready;
+mysql_cond_t  COND_wsrep_ready;
+mysql_mutex_t LOCK_wsrep_sst;
+mysql_cond_t  COND_wsrep_sst;
+mysql_mutex_t LOCK_wsrep_sst_init;
+mysql_cond_t  COND_wsrep_sst_init;
+mysql_mutex_t LOCK_wsrep_rollback;
+mysql_cond_t  COND_wsrep_rollback;
+wsrep_aborting_thd_t wsrep_aborting_thd= NULL;
+mysql_mutex_t LOCK_wsrep_replaying;
+mysql_cond_t  COND_wsrep_replaying;
+mysql_mutex_t LOCK_wsrep_slave_threads;
+mysql_mutex_t LOCK_wsrep_desync;
+int wsrep_replaying= 0;
+ulong  wsrep_running_threads = 0; // # of currently running wsrep threads
+ulong  my_bind_addr;
+const char *wsrep_binlog_format_names[]=
+                                   {"MIXED", "STATEMENT", "ROW", "NONE", NullS};
+
+wsrep_t *wsrep                  = NULL;
+my_bool wsrep_emulate_bin_log   = FALSE;
+#ifdef GTID_SUPPORT
+rpl_sidno wsrep_sidno= -1;
+#endif
+my_bool wsrep_preordered_opt= FALSE;
+
+extern int wsrep_replaying;
+extern ulong wsrep_running_threads;
+extern ulong my_bind_addr;
+extern my_bool plugins_are_initialized;
+extern uint kill_cached_threads;
+extern mysql_cond_t COND_thread_cache;
+
+const char* wsrep_data_home_dir = NULL;
+const char* wsrep_dbug_option   = "";
+
+long    wsrep_slave_threads            = 1; // # of slave action appliers wanted
+int     wsrep_slave_count_change       = 0; // # of appliers to stop or start
+my_bool wsrep_debug                    = 0; // enable debug level logging
+my_bool wsrep_convert_LOCK_to_trx      = 1; // convert locking sessions to trx
+ulong   wsrep_retry_autocommit         = 5; // retry aborted autocommit trx
+my_bool wsrep_auto_increment_control   = 1; // control auto increment variables
+my_bool wsrep_drupal_282555_workaround = 1; // retry autoinc insert after dupkey
+my_bool wsrep_incremental_data_collection = 0; // incremental data collection
+ulong   wsrep_max_ws_size              = 1073741824UL;//max ws (RBR buffer) size
+ulong   wsrep_max_ws_rows              = 65536; // max number of rows in ws
+int     wsrep_to_isolation             = 0; // # of active TO isolation threads
+my_bool wsrep_certify_nonPK            = 1; // certify, even when no primary key
+long    wsrep_max_protocol_version     = 3; // maximum protocol version to use
+ulong   wsrep_forced_binlog_format     = BINLOG_FORMAT_UNSPEC;
+my_bool wsrep_recovery                 = 0; // recovery
+my_bool wsrep_replicate_myisam         = 0; // enable myisam replication
+my_bool wsrep_log_conflicts            = 0;
+ulong   wsrep_mysql_replication_bundle = 0;
+my_bool wsrep_desync                   = 0; // desynchronize the node from the
+                                            // cluster
+my_bool wsrep_load_data_splitting      = 1; // commit load data every 10K intervals
+my_bool wsrep_restart_slave            = 0; // should mysql slave thread be
+                                            // restarted, if node joins back
+my_bool wsrep_restart_slave_activated  = 0; // node has dropped, and slave
+                                            // restart will be needed
+my_bool wsrep_slave_UK_checks          = 0; // slave thread does UK checks
+my_bool wsrep_slave_FK_checks          = 0; // slave thread does FK checks
+/*
+ * End configuration options
+ */
+
+/*
+ * Other wsrep global variables.
+ */
+my_bool wsrep_inited                   = 0; // initialized ?
+
+static const wsrep_uuid_t cluster_uuid = WSREP_UUID_UNDEFINED;
+static char         cluster_uuid_str[40]= { 0, };
+static const char*  cluster_status_str[WSREP_VIEW_MAX] =
+{
+    "Primary",
+    "non-Primary",
+    "Disconnected"
+};
+
+static char provider_name[256]= { 0, };
+static char provider_version[256]= { 0, };
+static char provider_vendor[256]= { 0, };
+
+/*
+ * wsrep status variables
+ */
+my_bool     wsrep_connected          = FALSE;
+my_bool     wsrep_ready              = FALSE; // node can accept queries
+const char* wsrep_cluster_state_uuid = cluster_uuid_str;
+long long   wsrep_cluster_conf_id    = WSREP_SEQNO_UNDEFINED;
+const char* wsrep_cluster_status = cluster_status_str[WSREP_VIEW_DISCONNECTED];
+long        wsrep_cluster_size       = 0;
+long        wsrep_local_index        = -1;
+long long   wsrep_local_bf_aborts    = 0;
+const char* wsrep_provider_name      = provider_name;
+const char* wsrep_provider_version   = provider_version;
+const char* wsrep_provider_vendor    = provider_vendor;
+/* End wsrep status variables */
+
+wsrep_uuid_t     local_uuid   = WSREP_UUID_UNDEFINED;
+wsrep_seqno_t    local_seqno  = WSREP_SEQNO_UNDEFINED;
+wsp::node_status local_status;
+long             wsrep_protocol_version = 3;
+
+// Boolean denoting if server is in initial startup phase. This is needed
+// to make sure that main thread waiting in wsrep_sst_wait() is signaled
+// if there was no state gap on receiving first view event.
+static my_bool   wsrep_startup = TRUE;
+
+void wsrep_set_SE_checkpoint(XID* xid)
+{
+  DBUG_ASSERT(0);
+}
+
+void wsrep_get_SE_checkpoint(XID* xid)
+{
+  DBUG_ASSERT(0);
+}
+
+void wsrep_init_sidno(const wsrep_uuid_t& uuid)
+{
+  DBUG_ASSERT(0);
+}
+
+void wsrep_ready_set (my_bool x)
+{
+  DBUG_ASSERT(0);
+}
+
+// Wait until wsrep has reached ready state
+void wsrep_ready_wait ()
+{
+  DBUG_ASSERT(0);
+}
+
+extern char* my_bind_addr_str;
+
+int wsrep_init()
+{
+  DBUG_ASSERT(0);
+  return 0;
+}
+
+extern int wsrep_on(void *);
+
+void wsrep_init_startup (bool first)
+{
+  DBUG_ASSERT(0);
+}
+
+void wsrep_deinit(bool free_options)
+{
+  DBUG_ASSERT(0);
+}
+
+void wsrep_recover()
+{
+  DBUG_ASSERT(0);
+}
+
+
+void wsrep_stop_replication(THD *thd)
+{
+  DBUG_ASSERT(0);
+}
+
+/* This one is set to true when --wsrep-new-cluster is found in the command
+ * line arguments */
+static my_bool wsrep_new_cluster= FALSE;
+#define WSREP_NEW_CLUSTER "--wsrep-new-cluster"
+/* Finds and hides --wsrep-new-cluster from the arguments list
+ * by moving it to the end of the list and decrementing argument count */
+void wsrep_filter_new_cluster (int* argc, char* argv[])
+{
+  DBUG_ASSERT(0);
+}
+
+bool wsrep_start_replication()
+{
+  DBUG_ASSERT(0);
+  return false;
+}
+
+bool wsrep_sync_wait (THD* thd, uint mask)
+{
+  DBUG_ASSERT(0);
+  return false;
+}
+
+/*
+ * Helpers to deal with TOI key arrays
+ */
+typedef struct wsrep_key_arr
+{
+    wsrep_key_t* keys;
+    size_t       keys_len;
+} wsrep_key_arr_t;
+
+
+
+
+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)
+{
+  DBUG_ASSERT(0);
+  return true;
+}
+
+
+/*
+ * Construct Query_log_Event from thd query and serialize it
+ * into buffer.
+ *
+ * Return 0 in case of success, 1 in case of error.
+ */
+int wsrep_to_buf_helper(
+    THD* thd, const char *query, uint query_len, uchar** buf, size_t* buf_len)
+{
+  DBUG_ASSERT(0);
+  return 0;
+}
+
+
+int wsrep_to_isolation_begin(THD *thd, char *db_, char *table_,
+                             const TABLE_LIST* table_list)
+{
+  DBUG_ASSERT(0);
+  return 0;
+}
+
+void wsrep_to_isolation_end(THD *thd)
+{
+  DBUG_ASSERT(0);
+}
+
+#define WSREP_MDL_LOG(severity, msg, req, gra)
+
+bool
+wsrep_grant_mdl_exception(MDL_context *requestor_ctx,
+                          MDL_ticket *ticket) 
+{
+  DBUG_ASSERT(0);
+  return FALSE;
+}
+
+
+pthread_handler_t start_wsrep_THD(void *arg)
+{
+  DBUG_ASSERT(0);
+  return(NULL);
+}
+
+
+
+int wsrep_wait_committing_connections_close(int wait_time)
+{
+  DBUG_ASSERT(0);
+  return 0;
+}
+
+
+void wsrep_close_client_connections(my_bool wait_to_end)
+{
+  DBUG_ASSERT(0);
+}
+
+
+void wsrep_close_applier(THD *thd)
+{
+  DBUG_ASSERT(0);
+}
+
+
+void wsrep_close_threads(THD *thd)
+{
+  DBUG_ASSERT(0);
+}
+
+void wsrep_wait_appliers_close(THD *thd)
+{
+  DBUG_ASSERT(0);
+}
+
+
+void wsrep_kill_mysql(THD *thd)
+{
+  DBUG_ASSERT(0);
+}
+
+
+int wsrep_create_sp(THD *thd, uchar** buf, size_t* buf_len)
+{
+  DBUG_ASSERT(0);
+  return 0;
+}
+
+
+extern int wsrep_on(void *thd)
+{
+  return (0);
+}
+
+
+extern "C" bool wsrep_thd_is_wsrep_on(THD *thd)
+{
+  return false;
+}
+
+
+extern "C" bool wsrep_consistency_check(void *thd)
+{
+  return false;
+}
+
+
+extern "C" void wsrep_thd_set_exec_mode(THD *thd, enum wsrep_exec_mode mode)
+{
+  DBUG_ASSERT(0);
+}
+
+
+extern "C" void wsrep_thd_set_query_state(
+	THD *thd, enum wsrep_query_state state)
+{
+  DBUG_ASSERT(0);
+}
+
+
+extern "C" void wsrep_thd_set_conflict_state(
+	THD *thd, enum wsrep_conflict_state state)
+{
+  DBUG_ASSERT(0);
+}
+
+
+extern "C" enum wsrep_exec_mode wsrep_thd_exec_mode(THD *thd)
+{
+  return (enum wsrep_exec_mode) LOCAL_STATE;
+}
+
+
+extern "C" const char *wsrep_thd_exec_mode_str(THD *thd)
+{
+  DBUG_ASSERT(0);
+  return (const char *)NULL;
+}
+
+
+extern "C" enum wsrep_query_state wsrep_thd_query_state(THD *thd)
+{
+  DBUG_ASSERT(0);
+  return (enum wsrep_query_state)0;
+}
+
+
+extern "C" const char *wsrep_thd_query_state_str(THD *thd)
+{
+  DBUG_ASSERT(0);
+  return (const char *)NULL;
+}
+
+
+extern "C" enum wsrep_conflict_state wsrep_thd_conflict_state(THD *thd)
+{
+  DBUG_ASSERT(0);
+  return (enum wsrep_conflict_state)0;
+}
+
+
+extern "C" const char *wsrep_thd_conflict_state_str(THD *thd)
+{
+  DBUG_ASSERT(0);
+  return (const char *)NULL;
+}
+
+
+extern "C" wsrep_ws_handle_t* wsrep_thd_ws_handle(THD *thd)
+{
+  DBUG_ASSERT(0);
+  return NULL;
+}
+
+
+extern "C" void wsrep_thd_LOCK(THD *thd)
+{
+  DBUG_ASSERT(0);
+}
+
+
+extern "C" void wsrep_thd_UNLOCK(THD *thd)
+{
+  DBUG_ASSERT(0);
+}
+
+
+extern "C" time_t wsrep_thd_query_start(THD *thd) 
+{
+  DBUG_ASSERT(0);
+  return (time_t)0;
+}
+
+
+extern "C" uint32 wsrep_thd_wsrep_rand(THD *thd) 
+{
+  DBUG_ASSERT(0);
+  return 0;
+}
+
+
+extern "C" my_thread_id wsrep_thd_thread_id(THD *thd) 
+{
+  DBUG_ASSERT(0);
+  return (my_thread_id)0;
+}
+
+
+extern "C" wsrep_seqno_t wsrep_thd_trx_seqno(THD *thd) 
+{
+  DBUG_ASSERT(0);
+  return (wsrep_seqno_t)0;
+}
+
+
+extern "C" query_id_t wsrep_thd_query_id(THD *thd) 
+{
+  DBUG_ASSERT(0);
+  return (query_id_t)0;
+}
+
+
+extern "C" char *wsrep_thd_query(THD *thd) 
+{
+  DBUG_ASSERT(0);
+  return NULL;
+}
+
+
+extern "C" query_id_t wsrep_thd_wsrep_last_query_id(THD *thd) 
+{
+  DBUG_ASSERT(0);
+  return (query_id_t)0;
+}
+
+
+extern "C" void wsrep_thd_set_wsrep_last_query_id(THD *thd, query_id_t id) 
+{
+  DBUG_ASSERT(0);
+}
+
+
+extern "C" void wsrep_thd_awake(THD *thd, my_bool signal)
+{
+  DBUG_ASSERT(0);
+}
+
+
+extern "C" int wsrep_thd_retry_counter(THD *thd) 
+{
+  DBUG_ASSERT(0);
+  return 0;
+}
+
+
+extern int
+wsrep_trx_order_before(void *thd1, void *thd2)
+{
+  DBUG_ASSERT(0);
+  return 0;
+}
+
+
+extern "C" int
+wsrep_trx_is_aborting(void *thd_ptr)
+{
+  DBUG_ASSERT(0);
+  return 0;
+}
+
+
+my_bool wsrep_read_only_option(THD *thd, TABLE_LIST *all_tables)
+{
+  DBUG_ASSERT(0);
+  return false;
+}
+
+
+void wsrep_copy_query(THD *thd)
+{
+  DBUG_ASSERT(0);
+}
+
+
+bool wsrep_is_show_query(enum enum_sql_command command)
+{
+  DBUG_ASSERT(0);
+  return false;
+}
+
+bool wsrep_create_like_table(THD* thd, TABLE_LIST* table,
+                             TABLE_LIST* src_table,
+                             HA_CREATE_INFO *create_info)
+{
+  DBUG_ASSERT(0);
+  return(false);
+}
+
+
+int wsrep_create_trigger_query(THD *thd, uchar** buf, size_t* buf_len)
+{
+  DBUG_ASSERT(0);
+  return (0);
+}
+
+
+my_bool wsrep_thd_is_BF(void *thd_ptr, my_bool sync)
+{
+  return false;
+}
+
+
+void wsrep_post_commit(THD* thd, bool all)
+{
+  DBUG_ASSERT(0);
+}
+
+
+my_bool wsrep_thd_is_wsrep(void *thd_ptr)
+{
+  return false;
+}
+
+enum wsrep_trx_status wsrep_run_wsrep_commit(THD *thd, handlerton *hton, bool all)
+{
+  DBUG_ASSERT(0);
+  return (wsrep_trx_status)0;
+}
+
+int wsrep_is_wsrep_xid(const void* xid_ptr)
+{
+  return 0;
+}
+
+int wsrep_thd_conflict_state(void *thd_ptr, my_bool sync)
+{
+  return 0;
+}
+
+#endif /* ! WITH_WSREP */
diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc
index 5e20cbc..e3febcd 100644
--- a/storage/innobase/handler/ha_innodb.cc
+++ b/storage/innobase/handler/ha_innodb.cc
@@ -7813,9 +7813,10 @@ translation table rebuild (fter create/drop index) and DMLs that
 						   user_thd);
 
 #ifdef WITH_WSREP
-	if (!error_result && wsrep_thd_exec_mode(user_thd) == LOCAL_STATE &&
-	    wsrep_on(user_thd) && !wsrep_consistency_check(user_thd) &&
-	    (sql_command != SQLCOM_LOAD || 
+	if (!error_result && wsrep_on(user_thd) &&
+	    wsrep_thd_exec_mode(user_thd) == LOCAL_STATE &&
+	    !wsrep_consistency_check(user_thd) &&
+	    (sql_command != SQLCOM_LOAD ||
 	     thd_binlog_format(user_thd) == BINLOG_FORMAT_ROW)) {
 
 		if (wsrep_append_keys(user_thd, false, record, NULL)) {
@@ -8333,9 +8334,9 @@ translation table rebuild (fter create/drop index) and DMLs that
 	innobase_active_small();
 
 #ifdef WITH_WSREP
-	if (error == DB_SUCCESS                          && 
-	    wsrep_thd_exec_mode(user_thd) == LOCAL_STATE &&
-            wsrep_on(user_thd)) {
+	if (error == DB_SUCCESS                          &&
+	    wsrep_on(user_thd)                           &&
+	    wsrep_thd_exec_mode(user_thd) == LOCAL_STATE) {
 
 		DBUG_PRINT("wsrep", ("update row key"));
 
@@ -8398,9 +8399,9 @@ translation table rebuild (fter create/drop index) and DMLs that
 	innobase_active_small();
 
 #ifdef WITH_WSREP
-	if (error == DB_SUCCESS                          && 
-	    wsrep_thd_exec_mode(user_thd) == LOCAL_STATE &&
-            wsrep_on(user_thd)) {
+	if (error == DB_SUCCESS                          &&
+	    wsrep_on(user_thd)                           &&
+	    wsrep_thd_exec_mode(user_thd) == LOCAL_STATE) {
 
 		if (wsrep_append_keys(user_thd, false, record, NULL)) {
 			DBUG_PRINT("wsrep", ("delete fail"));
@@ -9597,11 +9598,12 @@ once the search result (Doc IDs) is available */
 	ulint rcode = DB_SUCCESS;
 	char  cache_key[513] = {'\0'};
 	int   cache_key_len;
-    bool const copy = true;
+	bool const copy = true;
 
 	if (!wsrep_on(trx->mysql_thd) ||
-	    wsrep_thd_exec_mode(thd) != LOCAL_STATE)
+		wsrep_thd_exec_mode(thd) != LOCAL_STATE) {
 		return DB_SUCCESS;
+	}
 
 	if (!thd || !foreign ||
 	    (!foreign->referenced_table && !foreign->foreign_table))
diff --git a/storage/innobase/os/os0file.cc b/storage/innobase/os/os0file.cc
index 971ff14..ea23244 100644
--- a/storage/innobase/os/os0file.cc
+++ b/storage/innobase/os/os0file.cc
@@ -2365,11 +2365,6 @@ Renames a file (can also move it to another directory). It is safest that the
 
 	current_size = 0;
 
-#ifdef UNIV_DEBUG
-	fprintf(stderr, "InnoDB: Note: File %s current_size %lu extended_size %lu\n",
-		name, os_file_get_size(file), size);
-#endif
-
 #ifdef HAVE_POSIX_FALLOCATE
 	if (srv_use_posix_fallocate) {
 
diff --git a/storage/xtradb/os/os0file.cc b/storage/xtradb/os/os0file.cc
index bec3d1b..d67573d 100644
--- a/storage/xtradb/os/os0file.cc
+++ b/storage/xtradb/os/os0file.cc
@@ -2486,12 +2486,6 @@ Renames a file (can also move it to another directory). It is safest that the
 
 	current_size = 0;
 
-#ifdef UNIV_DEBUG
-	fprintf(stderr, "InnoDB: Note: File %s current_size %lu extended_size %lu\n",
-		name, os_file_get_size(file), size);
-#endif
-
-
 #ifdef HAVE_POSIX_FALLOCATE
 	if (srv_use_posix_fallocate) {
 
