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