--source include/master-slave.inc
--source include/have_debug.inc

--echo **** On Master ****
CREATE TABLE t1 (a INT);

INSERT INTO t1 VALUES (1),(2),(3);
SELECT * FROM t1;

# This will generate an incident log event and store it in the binary
# log before the replace statement.
REPLACE INTO t1 VALUES (4);
--save_master_pos
SELECT * FROM t1;

connection slave;
source include/wait_for_slave_sql_to_stop.inc;

# The 4 should not be inserted into the table, since the incident log
# event should have stop the slave.
--echo **** On Slave ****
#### BEGIN DEBUG INFO ADDED BY SVEN 2008-07-18 -- SEE BUG#38077 ####
let $tables= query_get_value(SHOW TABLES, Tables_in_test, 1);
if (`SELECT '$tables' != 't1'`)
{
  --echo **** TEST CASE BUG! PRINTING DEBUG INFO! ****
  --echo **** Dear developer, if you see this in the output of a test
  --echo **** case run, please add all the information below as a
  --echo **** comment to BUG#38077. If it's a pushbuild failure, please
  --echo **** include a link to the push page.
  --echo **** Thank you! /Sven
  SHOW BINLOG EVENTS;
  --echo **** master binlog ****
  --error 0,1
  --exec $MYSQL_BINLOG --hexdump $MYSQLTEST_VARDIR/log/master-bin.000001
  --echo **** slave binlog ****
  --error 0,1
  --exec $MYSQL_BINLOG --hexdump $MYSQLTEST_VARDIR/log/slave-bin.000001
  --echo **** slave status ****
  query_vertical SHOW SLAVE STATUS;
  --echo **** slave's master status ****
  SHOW MASTER STATUS;
  --echo **** slave binlog events ****
  --echo [on master]
  connection master;
  --echo **** master status ****
  SHOW MASTER STATUS;
  --echo **** master binlog events ****
  SHOW BINLOG EVENTS;
  exit;
}
#### END DEBUG INFO ####
SELECT * FROM t1;

--replace_result $MASTER_MYPORT MASTER_PORT
--replace_column 1 # 6 # 7 # 8 # 9 # 22 # 23 # 33 #
--query_vertical SHOW SLAVE STATUS

SET GLOBAL SQL_SLAVE_SKIP_COUNTER=1;
START SLAVE;
--sync_with_master

# Now, we should have inserted the row into the table and the slave
# should be running. We should also have rotated to a new binary log.

SELECT * FROM t1;
--replace_result $MASTER_MYPORT MASTER_PORT
--replace_column 1 # 6 # 7 # 8 # 9 # 22 # 23 # 33 #
--query_vertical SHOW SLAVE STATUS

connection master;
DROP TABLE t1;
--sync_slave_with_master
