mySQL 5.0.11 sources for tomato
[tomato.git] / release / src / router / mysql / mysql-test / suite / rpl / t / rpl_loadfile.test
blobced0054c52c082592b1f942af2302686bec65260
1 #############################################################################
2 # Original Author: JBM                                                      #
3 # Original Date: Aug/18/2005                                                #
4 #############################################################################
5 # TEST: To test the LOAD_FILE() in rbr                                      #
6 #############################################################################
7 # Change Author: JBM
8 # Change Date: 2006-01-16
9 # Change: Added Order by for NDB
10 ##########
12 # Includes
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
20 #  DESCRIPTION
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.
28 #    Solution:
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.
35 #  IMPLEMENTATION
37 #    The test is implemented as follows:
39 #      On Master,
40 #       i) write to file the desired content.
41 #      ii) create table and stored procedure with load_file
42 #     iii) stop slave
43 #     iii) execute load_file 
44 #      iv) remove file
46 #      On Slave,
47 #       v) start slave
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 
59 #          table are the same
61 --source include/rpl_reset.inc
63 connection master;
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'
69 disable_warnings;
70 DROP TABLE IF EXISTS t1;
71 enable_warnings;
73 CREATE TABLE t1 (t text);
74 DELIMITER |;
75 CREATE PROCEDURE p(file varchar(4096)) 
76   BEGIN
77     INSERT INTO t1 VALUES (LOAD_FILE(file));
78   END|
79 DELIMITER ;|
81 # stop slave before issuing the load_file on master
82 connection slave;
83 source include/stop_slave.inc;
85 connection master;
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
93 remove_file $file;
95 # now that the file is removed it is safe (regarding what we want to test) 
96 # to start slave
97 connection slave;
98 source include/start_slave.inc;
100 connection master;
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;
110 # CLEAN UP
111 --connection master
112 DROP TABLE t1;
113 DROP PROCEDURE p;
115 --source include/rpl_end.inc