Debian Codegraph @

mysql-test/suite/rpl/t/rpl_loadfile.test

raw
1 #
2 # This include file is used by more than one test suite
3 # (currently rpl and binlog_encryption).
4 # Please check all dependent tests after modifying it
5 #
6
7 #############################################################################
8 # Original Author: JBM #
9 # Original Date: Aug/18/2005 #
10 #############################################################################
11 # TEST: To test the LOAD_FILE() in rbr #
12 #############################################################################
13 # Change Author: JBM
14 # Change Date: 2006-01-16
15 ##########
16
17 # Includes
18 -- source include/have_binlog_format_mixed_or_row.inc
19 -- source include/master-slave.inc
20
21 -- source suite/rpl/include/rpl_loadfile.test
22
23 # BUG#39701: Mixed binlog format does not switch to row mode on LOAD_FILE
24 #
25 # DESCRIPTION
26 #
27 # Problem: when using load_file string function and mixed binlogging format
28 # there was no switch to row based binlogging format. This leads
29 # to scenarios on which the slave replicates the statement and it
30 # will try to load the file from local file system, which in most
31 # likely it will not exist.
32 #
33 # Solution:
34 # Marking this function as unsafe for statement format, makes the
35 # statement using it to be logged in row based format. As such, data
36 # replicated from the master, becomes the content of the loaded file.
37 # Consequently, the slave receives the necessary data to complete
38 # the load_file instruction correctly.
39 #
40 # IMPLEMENTATION
41 #
42 # The test is implemented as follows:
43 #
44 # On Master,
45 # i) write to file the desired content.
46 # ii) create table and stored procedure with load_file
47 # iii) stop slave
48 # iii) execute load_file
49 # iv) remove file
50 #
51 # On Slave,
52 # v) start slave
53 # vi) sync it with master so that it gets the updates from binlog (which
54 # should have bin logged in row format).
55 #
56 # If the the binlog format does not change to row, then the assertion
57 # done in the following step fails. This happens because tables differ
58 # since the file does not exist anymore, meaning that when slave
59 # attempts to execute LOAD_FILE statement it inserts NULL on table
60 # instead of the same contents that the master loaded when it executed
61 # the procedure (which was executed when file existed).
62 #
63 # vii) assert that the contents of master and slave
64 # table are the same
65
66 --source include/rpl_reset.inc
67
68 connection master;
69 let $file= $MYSQLTEST_VARDIR/tmp/bug_39701.data;
70
71 --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
72 --eval SELECT repeat('x',20) INTO OUTFILE '$file'
73
74 CREATE TABLE t1 (t text);
75 DELIMITER |;
76 CREATE PROCEDURE p(file varchar(4096))
77 BEGIN
78 INSERT INTO t1 VALUES (LOAD_FILE(file));
79 END|
80 DELIMITER ;|
81
82 # stop slave before issuing the load_file on master
83 connection slave;
84 source include/stop_slave.inc;
85
86 connection master;
87
88 # test: check that logging falls back to rbr.
89 --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
90 --eval CALL p('$file')
91
92 # test: remove the file from the filesystem and assert that slave still
93 # gets the loaded file
94 remove_file $file;
95
96 # now that the file is removed it is safe (regarding what we want to test)
97 # to start slave
98 connection slave;
99 source include/start_slave.inc;
100
101 connection master;
102 sync_slave_with_master;
103
104 # assertion: assert that the slave got the updates even
105 # if the file was removed before the slave started,
106 # meaning that contents were indeed transfered
107 # through binlog (in row format)
108 let $diff_tables= master:t1, slave:t1;
109 source include/diff_tables.inc;
110
111 # CLEAN UP
112 --connection master
113 DROP TABLE t1;
114 DROP PROCEDURE p;
115
116 --source include/rpl_end.inc