# ==== Purpose ====
#
# This test calls CHANGE MASTER in order to check if replication can
# restart from where SQL thread left, not from where I/O thread left.
#  
# This file tests the case when master_info is stored in a file.
#
# ==== See also ====
#
# rpl_change_master_crash_safe.test

--source include/master-slave.inc
--source extra/rpl_tests/rpl_change_master.test


# BUG#11758581 - 50801: CHANGE MASTER ACCEPTS BOGUS VARIABLES
# We want to check if CHANGE MASTER values have newline characters.
--source include/rpl_reset.inc
connection slave;

###
### This should fail with error ER_WRONG_ARGUMENTS due to empty MASTER_HOST
### value.
###
--source include/stop_slave.inc
--replace_result $MASTER_MYPORT MASTER_PORT
--replace_column 2 ####
--error ER_WRONG_ARGUMENTS
eval CHANGE MASTER TO MASTER_USER='root', MASTER_HOST='', MASTER_PORT=$MASTER_MYPORT;

###
### This should fail with error ER_SYNTAX_ERROR due to newline
### in string values.
###
--replace_result $MASTER_MYPORT MASTER_PORT
--replace_column 2 ####
--error ER_WRONG_VALUE
eval CHANGE MASTER TO MASTER_USER='root', MASTER_HOST='127.0.0.1\n127.0.0.1', MASTER_PORT=$MASTER_MYPORT;

--replace_result $MASTER_MYPORT MASTER_PORT
--replace_column 2 ####
--error ER_WRONG_VALUE
eval CHANGE MASTER TO MASTER_USER='root\n', MASTER_HOST='master2.mycompany.com', MASTER_PORT=$MASTER_MYPORT, MASTER_USER='replication', MASTER_PASSWORD='bigs3cret', MASTER_LOG_FILE='master2-bin.001', MASTER_LOG_POS=4;

--replace_result $MASTER_MYPORT MASTER_PORT
--replace_column 2 ####
--error ER_WRONG_VALUE
eval CHANGE MASTER TO MASTER_USER='root', MASTER_HOST='master2.mycompany.com', MASTER_PORT=$MASTER_MYPORT, MASTER_USER='repli\ncation', MASTER_PASSWORD='bigs3cret', MASTER_LOG_FILE='master2-bin.001', MASTER_LOG_POS=4;

--replace_result $MASTER_MYPORT MASTER_PORT
--replace_column 2 ####
--error ER_WRONG_VALUE
eval CHANGE MASTER TO MASTER_USER='root', MASTER_HOST='master2.mycompany.com', MASTER_PORT=$MASTER_MYPORT, MASTER_USER='replication', MASTER_PASSWORD='bigs3cret', MASTER_LOG_FILE='master2-bin.\n001', MASTER_LOG_POS=4;

###
### This should be accepted.
###
--replace_result $MASTER_MYPORT MASTER_PORT
--replace_column 2 ####
eval CHANGE MASTER TO MASTER_USER='root', MASTER_HOST='127.0.0.1', MASTER_PORT=$MASTER_MYPORT;

--source include/start_slave.inc
--let $status_items= Master_Host
--source include/show_slave_status.inc
--source include/rpl_reset.inc

--source include/rpl_end.inc
