diff --git a/client/mysqltest.cc b/client/mysqltest.cc index d43b1c79f1ffe..ddc0075c381ac 100644 --- a/client/mysqltest.cc +++ b/client/mysqltest.cc @@ -5340,7 +5340,7 @@ void do_sync_with_master(struct st_command *command) long offset= 0; char *p= command->first_argument; const char *offset_start= p; - char *start, *buff= 0; + char *start, *buff= 0, *str; start= const_cast(""); if (*offset_start) @@ -5358,15 +5358,15 @@ void do_sync_with_master(struct st_command *command) p++; while (*p && my_isspace(charset_info, *p)) p++; - start= buff= (char*)my_malloc(PSI_NOT_INSTRUMENTED, strlen(p)+1, - MYF(MY_WME|MY_FAE)); - get_string(&buff, &p, command); + str= buff= (char*)my_malloc(PSI_NOT_INSTRUMENTED, strlen(p)+1, + MYF(MY_WME|MY_FAE)); + start= get_string(&str, &p, command); } command->last_argument= p; } do_sync_with_master2(command, offset, start); if (buff) - my_free(start); + my_free(buff); return; } @@ -8417,7 +8417,7 @@ void do_get_errcodes(struct st_command *command) /* - Get a string; Return ptr to end of string + Get a string; Return ptr to start of string Strings may be surrounded by " or ' If string is a '$variable', return the value of the variable. diff --git a/mysql-test/suite/rpl/r/mysqltest_sync_with_master_named.result b/mysql-test/suite/rpl/r/mysqltest_sync_with_master_named.result new file mode 100644 index 0000000000000..a18d242788b98 --- /dev/null +++ b/mysql-test/suite/rpl/r/mysqltest_sync_with_master_named.result @@ -0,0 +1,21 @@ +connect master, 127.0.0.1, root, , , $MASTER_MYPORT; +FLUSH BINARY LOGS; +connect slave, 127.0.0.1, root, , , $SLAVE_MYPORT; +SET @@SESSION.default_master_connection= 'literal'; +CHANGE MASTER TO +master_host='127.0.0.1', master_port=MASTER_MYPORT, master_user='root'; +include/start_slave.inc +include/stop_slave.inc +RESET SLAVE ALL; +# MDEV-40996 +connection master; +FLUSH BINARY LOGS; +connection slave; +SET @@SESSION.default_master_connection= 'variable'; +CHANGE MASTER TO +master_host='127.0.0.1', master_port=MASTER_MYPORT, master_user='root'; +include/start_slave.inc +include/stop_slave.inc +RESET SLAVE ALL; +disconnect master; +disconnect slave; diff --git a/mysql-test/suite/rpl/t/mysqltest_sync_with_master_named.test b/mysql-test/suite/rpl/t/mysqltest_sync_with_master_named.test new file mode 100644 index 0000000000000..104e420a4bac3 --- /dev/null +++ b/mysql-test/suite/rpl/t/mysqltest_sync_with_master_named.test @@ -0,0 +1,42 @@ +--source include/have_binlog_format_mixed.inc # format-agnostic + + +--connect (master, 127.0.0.1, root, , , $MASTER_MYPORT) +FLUSH BINARY LOGS; +--save_master_pos + +--connect (slave, 127.0.0.1, root, , , $SLAVE_MYPORT) +SET @@SESSION.default_master_connection= 'literal'; +--replace_result $MASTER_MYPORT MASTER_MYPORT +eval CHANGE MASTER TO + master_host='127.0.0.1', master_port=$MASTER_MYPORT, master_user='root'; +--source include/start_slave.inc + +--sync_with_master 0, literal + +--source include/stop_slave.inc +RESET SLAVE ALL; + + +--echo # MDEV-40996 + +--connection master +FLUSH BINARY LOGS; +--save_master_pos + +--connection slave +--let $connection= variable +--eval SET @@SESSION.default_master_connection= '$connection' +--replace_result $MASTER_MYPORT MASTER_MYPORT +eval CHANGE MASTER TO + master_host='127.0.0.1', master_port=$MASTER_MYPORT, master_user='root'; +--source include/start_slave.inc + +--sync_with_master 0, $connection + +--source include/stop_slave.inc +RESET SLAVE ALL; + + +--disconnect master +--disconnect slave