From 90ead99572c8168583cb0943792d964cc2a6abd2 Mon Sep 17 00:00:00 2001
From: Nirbhay Choubey <nirbhay@skysql.com>
Date: Tue, 10 Jun 2014 16:33:57 -0400
Subject: [PATCH] bzr merge -r3980..3984 codership/5.5

---
 scripts/wsrep_sst_common.sh    | 10 +++++-----
 scripts/wsrep_sst_mysqldump.sh | 13 +++++++++----
 sql/wsrep_sst.cc               |  9 +++++----
 storage/innobase/row/row0ins.c |  8 ++++----
 storage/xtradb/row/row0ins.c   |  8 ++++----
 5 files changed, 27 insertions(+), 21 deletions(-)

diff --git a/scripts/wsrep_sst_common.sh b/scripts/wsrep_sst_common.sh
index f9a08c1c695..b6c10ba4e7d 100644
--- a/scripts/wsrep_sst_common.sh
+++ b/scripts/wsrep_sst_common.sh
@@ -20,6 +20,7 @@ set -u
 
 WSREP_SST_OPT_BYPASS=0
 WSREP_SST_OPT_DATA=""
+WSREP_SST_OPT_AUTH=""
 
 while [ $# -gt 0 ]; do
 case "$1" in
@@ -55,7 +56,7 @@ case "$1" in
         shift
         ;;
     '--password')
-        readonly WSREP_SST_OPT_PSWD="$2"
+        WSREP_SST_OPT_PSWD="$2"
         shift
         ;;
     '--port')
@@ -71,7 +72,7 @@ case "$1" in
         shift
         ;;
     '--user')
-        readonly WSREP_SST_OPT_USER="$2"
+        WSREP_SST_OPT_USER="$2"
         shift
         ;;
     '--gtid')
@@ -88,8 +89,8 @@ done
 readonly WSREP_SST_OPT_BYPASS
 
 # For Bug:1200727
-if my_print_defaults -c $WSREP_SST_OPT_CONF sst | grep -q "wsrep_sst_auth";then 
-    if [ -z $WSREP_SST_OPT_AUTH -o $WSREP_SST_OPT_AUTH = "(null)" ];then 
+if my_print_defaults -c $WSREP_SST_OPT_CONF sst | grep -q "wsrep_sst_auth";then
+    if [ -z "$WSREP_SST_OPT_AUTH" -o "$WSREP_SST_OPT_AUTH" = "(null)" ];then
             WSREP_SST_OPT_AUTH=$(my_print_defaults -c $WSREP_SST_OPT_CONF sst | grep -- "--wsrep_sst_auth" | cut -d= -f2)
     fi
 fi
@@ -124,4 +125,3 @@ wsrep_cleanup_progress_file()
 {
     [ -n "$SST_PROGRESS_FILE" ] && rm -f "$SST_PROGRESS_FILE" 2>/dev/null
 }
-
diff --git a/scripts/wsrep_sst_mysqldump.sh b/scripts/wsrep_sst_mysqldump.sh
index cf4f55df98e..3db1d73bb9c 100644
--- a/scripts/wsrep_sst_mysqldump.sh
+++ b/scripts/wsrep_sst_mysqldump.sh
@@ -1,15 +1,15 @@
-#!/bin/sh -e
+#!/bin/bash -e
 # Copyright (C) 2009 Codership Oy
-# 
+#
 # 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; see the file COPYING. If not, write to the
 # Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston
@@ -61,6 +61,11 @@ then
     exit $EINVAL
 fi
 
+# For Bug:1293798
+if [ -z "$WSREP_SST_OPT_PSWD" -a -n "$WSREP_SST_OPT_AUTH" ]; then
+    WSREP_SST_OPT_USER=$(echo $WSREP_SST_OPT_AUTH | cut -d: -f1)
+    WSREP_SST_OPT_PSWD=$(echo $WSREP_SST_OPT_AUTH | cut -d: -f2)
+fi
 AUTH="-u$WSREP_SST_OPT_USER"
 if test -n "$WSREP_SST_OPT_PSWD"; then AUTH="$AUTH -p$WSREP_SST_OPT_PSWD"; fi
 
diff --git a/sql/wsrep_sst.cc b/sql/wsrep_sst.cc
index 37c55707b28..1b57b63131c 100644
--- a/sql/wsrep_sst.cc
+++ b/sql/wsrep_sst.cc
@@ -110,7 +110,7 @@ bool  wsrep_sst_receive_address_check (sys_var *self, THD* thd, set_var* var)
     return 0;
 }
 
-bool wsrep_sst_receive_address_update (sys_var *self, THD* thd, 
+bool wsrep_sst_receive_address_update (sys_var *self, THD* thd,
                                        enum_var_type type)
 {
     return 0;
@@ -135,7 +135,7 @@ static bool sst_auth_real_set (const char* value)
           {
             my_free ((void*)wsrep_sst_auth);
             wsrep_sst_auth = my_strdup(WSREP_SST_AUTH_MASK, MYF(0));
-            //strncpy (wsrep_sst_auth, WSREP_SST_AUTH_MASK, 
+            //strncpy (wsrep_sst_auth, WSREP_SST_AUTH_MASK,
             //     sizeof(wsrep_sst_auth) - 1);
           }
           else
@@ -717,10 +717,11 @@ static int sst_donate_mysqldump (const char*         addr,
               WSREP_SST_OPT_LPORT" '%u' "
               WSREP_SST_OPT_SOCKET" '%s' "
               WSREP_SST_OPT_DATA" '%s' "
+              WSREP_SST_OPT_CONF" '%s' "
               WSREP_SST_OPT_GTID" '%s:%lld'"
               "%s",
               user, pswd, host, port, mysqld_port, mysqld_unix_port,
-              mysql_real_data_home, uuid_str,
+              mysql_real_data_home, wsrep_defaults_file, uuid_str,
               (long long)seqno, bypass ? " "WSREP_SST_OPT_BYPASS : "");
 
     WSREP_DEBUG("Running: '%s'", cmd_str);
@@ -754,7 +755,7 @@ static int run_sql_command(THD *thd, const char *query)
     int const err= thd->stmt_da->sql_errno();
     WSREP_WARN ("error executing '%s': %d (%s)%s",
                 query, err, thd->stmt_da->message(),
-                err == ER_UNKNOWN_SYSTEM_VARIABLE ? 
+                err == ER_UNKNOWN_SYSTEM_VARIABLE ?
                 ". Was mysqld built with --with-innodb-disallow-writes ?" : "");
     thd->clear_error();
     return -1;
diff --git a/storage/innobase/row/row0ins.c b/storage/innobase/row/row0ins.c
index c6525ebcc93..3419297f059 100644
--- a/storage/innobase/row/row0ins.c
+++ b/storage/innobase/row/row0ins.c
@@ -1696,6 +1696,10 @@ row_ins_scan_sec_index_for_duplicate(
 	mem_heap_t*	heap		= NULL;
 	ulint		offsets_[REC_OFFS_NORMAL_SIZE];
 	ulint*		offsets		= offsets_;
+#ifdef WITH_WSREP
+	/* appliers don't need dupkey checks */
+	if (wsrep_thd_is_BF(thr_get_trx(thr)->mysql_thd, 0)) return(DB_SUCCESS);
+#endif /* WITH_WSREP */
 	rec_offs_init(offsets_);
 
 	n_unique = dict_index_get_n_unique(index);
@@ -1760,10 +1764,6 @@ row_ins_scan_sec_index_for_duplicate(
 				lock_type, block, rec, index, offsets, thr);
 		} else {
 
-#ifdef WITH_WSREP
-		  /* appliers don't need dupkey checks */
-		  if (!wsrep_thd_is_BF(thr_get_trx(thr)->mysql_thd, 0))
-#endif /* WITH_WSREP */
 			err = row_ins_set_shared_rec_lock(
 				lock_type, block, rec, index, offsets, thr);
 		}
diff --git a/storage/xtradb/row/row0ins.c b/storage/xtradb/row/row0ins.c
index 36cbed9eea5..a1ee411b8cd 100644
--- a/storage/xtradb/row/row0ins.c
+++ b/storage/xtradb/row/row0ins.c
@@ -1705,6 +1705,10 @@ row_ins_scan_sec_index_for_duplicate(
 	mem_heap_t*	heap		= NULL;
 	ulint		offsets_[REC_OFFS_NORMAL_SIZE];
 	ulint*		offsets		= offsets_;
+#ifdef WITH_WSREP
+	/* appliers don't need dupkey checks */
+	if (wsrep_thd_is_BF(thr_get_trx(thr)->mysql_thd, 0)) return(DB_SUCCESS);
+#endif /* WITH_WSREP */
 	rec_offs_init(offsets_);
 
 	n_unique = dict_index_get_n_unique(index);
@@ -1769,10 +1773,6 @@ row_ins_scan_sec_index_for_duplicate(
 				lock_type, block, rec, index, offsets, thr);
 		} else {
 
-#ifdef WITH_WSREP
-		  /* appliers don't need dupkey checks */
-		  if (!wsrep_thd_is_BF(thr_get_trx(thr)->mysql_thd, 0))
-#endif /* WITH_WSREP */
 			err = row_ins_set_shared_rec_lock(
 				lock_type, block, rec, index, offsets, thr);
 		}
-- 
2.30.9