mirror of
https://github.com/MariaDB/server.git
synced 2025-01-22 23:04:20 +01:00
6dff801284
LOAD_FILE LOAD_FILE is not safe to replicate in STATEMENT mode, because it depends on a file (which is loaded on master and may not exist in slave(s)). This leads to scenarios on which the slave replicates the statement with 'load_file' and it will try to load the file from local file system. Given that the file may not exist in the slave filesystem the operation will not succeed (probably returning NULL), causing master and slave(s) to diverge. However, when using MIXED mode replication, this can be made to work, if the statement including LOAD_FILE is marked as unsafe, triggering a switch to ROW mode, meaning that the contents of the file are written to binlog as row events. Consequently, the contents from the file in the master will reach the slave via the binlog. This patch addresses this bug by marking the load_file function as unsafe. When in mixed mode and when LOAD_FILE is issued, there will be a switch to row mode. Furthermore, when in statement mode, the LOAD_FILE will raise a warning that the statement is unsafe in that mode.
36 lines
1 KiB
Text
36 lines
1 KiB
Text
# Begin clean up test section
|
|
--disable_warnings
|
|
connection master;
|
|
DROP PROCEDURE IF EXISTS test.p1;
|
|
DROP TABLE IF EXISTS test.t1;
|
|
--enable_warnings
|
|
|
|
# Section 1 test
|
|
|
|
CREATE TABLE test.t1 (a INT, blob_column LONGBLOB, PRIMARY KEY(a));
|
|
INSERT INTO test.t1 VALUES(1,'test');
|
|
UPDATE test.t1 SET blob_column=LOAD_FILE('../../std_data/words2.dat') WHERE a=1;
|
|
delimiter |;
|
|
create procedure test.p1()
|
|
begin
|
|
INSERT INTO test.t1 VALUES(2,'test');
|
|
UPDATE test.t1 SET blob_column=LOAD_FILE('../../std_data/words2.dat') WHERE a=2;
|
|
end|
|
|
delimiter ;|
|
|
|
|
CALL test.p1();
|
|
SELECT * FROM test.t1 ORDER BY blob_column;
|
|
save_master_pos;
|
|
sync_slave_with_master;
|
|
connection slave;
|
|
# Need to allow some time when NDB engine is used for
|
|
# the injector thread to have time to populate binlog
|
|
let $wait_condition= SELECT INSTR(blob_column,'aberration') > 0 FROM test.t1 WHERE a = 2;
|
|
--source include/wait_condition.inc
|
|
SELECT * FROM test.t1 ORDER BY blob_column;
|
|
|
|
# Cleanup
|
|
connection master;
|
|
DROP PROCEDURE IF EXISTS test.p1;
|
|
DROP TABLE test.t1;
|
|
sync_slave_with_master;
|