1# ==== Purpose ====
2#
3# Test verifies that continuous streaming of binary log content using the
4# "mysqlbinlog --stop-never" option and sourcing it to mysql client works
5# fine.
6#
7# ==== Implementation ====
8#
9# Steps:
10#    1 - Create a table on a server on which binary log is enabled and insert
11#        a row.
12#    2 - Disable the binary log on the server and drop the table.
13#    3 - Capture the binary log output using "mysqlbinlog --stop_never" option
14#        and source it to mysql client.
15#    4 - Query the PROCESSLIST table to ensure that the dump thread which is
16#        serving "stop_never" option has read entire binlog.
17#    5 - Verify that the table is populated on the server.
18#    6 - Cleanup.
19#
20# ==== References ====
21#
22# MDEV-11154: Write_on_release_cache(log_event.cc) function will not write
23#             "COMMIT", if use "mysqlbinlog ... | mysql ..."
24
25--source include/not_windows.inc
26
27# Test is not specific to any binlog format. Hence Running only for 'row'.
28--source include/have_binlog_format_row.inc
29
30# binlog file name is needed in the test. To use master-bin.000001,
31# RESET MASTER is needed.
32RESET MASTER;
33# kill the dump threads if there any dump threads (may be from previous test)
34--source include/stop_dump_threads.inc
35
36--echo # Step-1: Execute some dummy statements.
37CREATE TABLE t1(i int);
38INSERT INTO t1 values (1);
39
40--echo # Step-2: Disable binary log temporarily and drop the table 't1'.
41set @@SESSION.SQL_LOG_BIN = 0;
42DROP TABLE t1;
43set @@SESSION.SQL_LOG_BIN = 1;
44
45--echo # Step-3: Execute MYSQL_BINLOG with --stop-never and source it to mysql client.
46--write_file $MYSQL_TMP_DIR/mysqlbinlog_stop_never.sh
47(`$MYSQL_BINLOG --read-from-remote-server --stop-never --user=root --host=127.0.0.1 --port=$MASTER_MYPORT  master-bin.000001 | $MYSQL --user=root --protocol=tcp --host=127.0.0.1 --port=$MASTER_MYPORT`) < /dev/null > /dev/null 2>&1  &
48EOF
49--exec /bin/bash $MYSQL_TMP_DIR/mysqlbinlog_stop_never.sh
50
51--echo # Step-4: Wait till dump thread transfer is completed.
52let $wait_condition= SELECT id from information_schema.processlist where processlist.command like '%Binlog%' and state like '%Master has sent%';
53--source include/wait_condition.inc
54
55--echo # Step-5: Check that the data is there.
56let $count= 1;
57let $table= test.t1;
58source include/wait_until_rows_count.inc;
59
60--echo # Step-6: Cleanup
61--echo # kill the dump thread serving the mysqlbinlog --stop-never process
62--source include/stop_dump_threads.inc
63
64DROP TABLE t1;
65--remove_file $MYSQL_TMP_DIR/mysqlbinlog_stop_never.sh
66
67