13
13
-- source include/master-slave.inc
16
# Begin clean up test section
19
DROP PROCEDURE IF EXISTS test.p1;
20
DROP TABLE IF EXISTS test.t1;
25
CREATE TABLE test.t1 (a INT, blob_column LONGBLOB, PRIMARY KEY(a));
26
INSERT INTO test.t1 VALUES(1,'test');
27
UPDATE test.t1 SET blob_column=LOAD_FILE('../std_data_ln/words2.dat') WHERE a=1;
29
create procedure test.p1()
31
INSERT INTO test.t1 VALUES(2,'test');
32
UPDATE test.t1 SET blob_column=LOAD_FILE('../std_data_ln/words2.dat') WHERE a=2;
37
SELECT * FROM test.t1 ORDER BY blob_column;
39
sync_slave_with_master;
41
# Need to allow some time when NDB engine is used for
42
# the injector thread to have time to populate binlog
43
let $wait_condition= SELECT INSTR(blob_column,'aberration') > 0 FROM test.t1 WHERE a = 2;
44
--source include/wait_condition.inc
45
SELECT * FROM test.t1 ORDER BY blob_column;
49
DROP PROCEDURE IF EXISTS test.p1;
51
sync_slave_with_master;
53
# End of 5.0 test case
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
62
source include/reset_master_and_slave.inc;
65
let $file= $MYSQLTEST_VARDIR/tmp/bug_39701.data;
67
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
68
--eval SELECT repeat('x',20) INTO OUTFILE '$file'
71
DROP TABLE IF EXISTS t1;
74
CREATE TABLE t1 (t text);
76
CREATE PROCEDURE p(file varchar(4096))
78
INSERT INTO t1 VALUES (LOAD_FILE(file));
82
# stop slave before issuing the load_file on master
84
source include/stop_slave.inc;
88
# test: check that logging falls back to rbr.
89
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
90
--eval CALL p('$file')
92
# test: remove the file from the filesystem and assert that slave still
93
# gets the loaded file
96
# now that the file is removed it is safe (regarding what we want to test)
99
source include/start_slave.inc;
102
sync_slave_with_master;
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_table_1=master:test.t1;
109
let $diff_table_2=slave:test.t1;
110
source include/diff_tables.inc;
115
sync_slave_with_master;