1 #############################################################################
2 # Original Author: JBM #
3 # Original Date: Aug/18/2005 #
4 #############################################################################
5 # TEST: To test the LOAD_FILE() in rbr #
6 #############################################################################
8 # Change Date: 2006-01-16
9 # Change: Added Order by for NDB
13 -- source include/master-slave.inc
14 -- source include/have_binlog_format_mixed_or_row.inc
16 -- source extra/rpl_tests/rpl_loadfile.test
18 # BUG#39701: Mixed binlog format does not switch to row mode on LOAD_FILE
22 # Problem: when using load_file string function and mixed binlogging format
23 # there was no switch to row based binlogging format. This leads
24 # to scenarios on which the slave replicates the statement and it
25 # will try to load the file from local file system, which in most
26 # likely it will not exist.
29 # Marking this function as unsafe for statement format, makes the
30 # statement using it to be logged in row based format. As such, data
31 # replicated from the master, becomes the content of the loaded file.
32 # Consequently, the slave receives the necessary data to complete
33 # the load_file instruction correctly.
37 # The test is implemented as follows:
40 # i) write to file the desired content.
41 # ii) create table and stored procedure with load_file
43 # iii) execute load_file
48 # vi) sync it with master so that it gets the updates from binlog (which
49 # should have bin logged in row format).
51 # If the the binlog format does not change to row, then the assertion
52 # done in the following step fails. This happens because tables differ
53 # since the file does not exist anymore, meaning that when slave
54 # attempts to execute LOAD_FILE statement it inserts NULL on table
55 # instead of the same contents that the master loaded when it executed
56 # the procedure (which was executed when file existed).
58 # vii) assert that the contents of master and slave
61 --source include/rpl_reset.inc
64 let $file= $MYSQLTEST_VARDIR/tmp/bug_39701.data;
66 --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
67 --eval SELECT repeat('x',20) INTO OUTFILE '$file'
70 DROP TABLE IF EXISTS t1;
73 CREATE TABLE t1 (t text);
75 CREATE PROCEDURE p(file varchar(4096))
77 INSERT INTO t1 VALUES (LOAD_FILE(file));
81 # stop slave before issuing the load_file on master
83 source include/stop_slave.inc;
87 # test: check that logging falls back to rbr.
88 --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
89 --eval CALL p('$file')
91 # test: remove the file from the filesystem and assert that slave still
92 # gets the loaded file
95 # now that the file is removed it is safe (regarding what we want to test)
98 source include/start_slave.inc;
101 sync_slave_with_master;
103 # assertion: assert that the slave got the updates even
104 # if the file was removed before the slave started,
105 # meaning that contents were indeed transfered
106 # through binlog (in row format)
107 let $diff_tables= master:t1, slave:t1;
108 source include/diff_tables.inc;
115 --source include/rpl_end.inc