#At file:///home/acorreia/workspace.sun/repository.mysql/bzrwork/bug-38174/mysql-5.1-bugteam/ based on revid:alfranio.correia@stripped
2769 Alfranio Correia 2009-02-12
BUG#38174 secure-file-priv breaks LOAD DATA INFILE replication in statement mode
Post-fix.
removed:
mysql-test/suite/rpl/t/rpl_bug38174-slave.opt
modified:
mysql-test/suite/rpl/r/rpl_bug38174.result
mysql-test/suite/rpl/t/rpl_bug38174.test
sql/sql_load.cc
=== modified file 'mysql-test/suite/rpl/r/rpl_bug38174.result'
--- a/mysql-test/suite/rpl/r/rpl_bug38174.result 2009-02-11 15:39:04 +0000
+++ b/mysql-test/suite/rpl/r/rpl_bug38174.result 2009-02-12 16:57:09 +0000
@@ -5,80 +5,14 @@ reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
start slave;
drop table if exists t1;
-stop slave;
-CREATE TABLE t1 (
-`pk` int(11) NOT NULL AUTO_INCREMENT,
-`int_nokey` int(11) NOT NULL,
-`int_key` int(11) NOT NULL,
-`date_key` date NOT NULL,
-`date_nokey` date NOT NULL,
-`time_key` time NOT NULL,
-`time_nokey` time NOT NULL,
-`datetime_key` datetime NOT NULL,
-`datetime_nokey` datetime NOT NULL,
-`varchar_key` varchar(1) NOT NULL,
-`varchar_nokey` varchar(1) NOT NULL,
-PRIMARY KEY (`pk`),
-KEY `int_key` (`int_key`),
-KEY `date_key` (`date_key`),
-KEY `time_key` (`time_key`),
-KEY `datetime_key` (`datetime_key`),
-KEY `varchar_key` (`varchar_key`)
-);
-INSERT INTO t1 VALUES (1,8,5,'0000-00-00','0000-00-00','10:37:38','10:37:38','0000-00-00 00:00:00','0000-00-00 00:00:00','p','p'),
-(2,1,6,'2005-12-23','2005-12-23','02:24:28','02:24:28','0000-00-00 00:00:00','0000-00-00 00:00:00','g','g'),
-(3,0,3,'2009-09-14','2009-09-14','00:00:00','00:00:00','2000-01-30 16:39:40','2000-01-30 16:39:40','q','q'),
-(4,1,4,'2002-12-03','2002-12-03','20:34:58','20:34:58','2009-10-28 09:46:21','2009-10-28 09:46:21','g','g'),
-(5,1,6,'2007-03-29','2007-03-29','15:49:00','15:49:00','0000-00-00 00:00:00','0000-00-00 00:00:00','m','m'),
-(6,4,0,'2002-12-04','2002-12-04','00:00:00','00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','o','o'),
-(7,9,0,'2005-01-28','2005-01-28','00:00:00','00:00:00','2001-05-18 00:00:00','2001-05-18 00:00:00','w','w'),
-(8,6,0,'0000-00-00','0000-00-00','06:57:25','06:57:25','0000-00-00 00:00:00','0000-00-00 00:00:00','m','m'),
-(9,0,0,'0000-00-00','0000-00-00','00:00:00','00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','z','z'),
-(10,4,6,'2006-08-15','2006-08-15','00:00:00','00:00:00','2002-04-12 14:44:25','2002-04-12 14:44:25','j','j'),
-(11,0,5,'2006-12-20','2006-12-20','10:13:53','10:13:53','2008-07-22 00:00:00','2008-07-22 00:00:00','y','y'),
-(12,9,7,'0000-00-00','0000-00-00','00:00:00','00:00:00','2004-07-05 00:00:00','2004-07-05 00:00:00','{','{'),
-(13,4,3,'2007-01-26','2007-01-26','23:00:51','23:00:51','2001-05-16 00:00:00','2001-05-16 00:00:00','f','f'),
-(14,7,0,'2004-03-27','2004-03-27','00:00:00','00:00:00','2005-01-24 03:30:37','2005-01-24 03:30:37','',''),
-(15,6,0,'2006-07-26','2006-07-26','18:43:57','18:43:57','0000-00-00 00:00:00','0000-00-00 00:00:00','{','{'),
-(16,0,6,'2000-01-14','2000-01-14','00:00:00','00:00:00','2000-09-21 00:00:00','2000-09-21 00:00:00','o','o'),
-(17,9,8,'0000-00-00','0000-00-00','21:15:08','21:15:08','0000-00-00 00:00:00','0000-00-00 00:00:00','a','a'),
-(18,2,0,'2004-10-27','2004-10-27','00:00:00','00:00:00','2004-03-24 22:13:43','2004-03-24 22:13:43','',''),
-(19,7,4,'0000-00-00','0000-00-00','08:38:27','08:38:27','2002-03-18 19:51:44','2002-03-18 19:51:44','t','t'),
-(20,5,3,'2008-03-07','2008-03-07','03:29:07','03:29:07','2007-12-01 18:44:44','2007-12-01 18:44:44','t','t'),
-(77,6,0,'2009-05-19','2009-05-19','14:56:44','14:56:44','2007-09-09 22:47:39','2007-09-09 22:47:39','',''),
-(35,6,3,'0000-00-00','0000-00-00','09:38:22','09:38:22','0000-00-00 00:00:00','0000-00-00 00:00:00','i','i'),
-(39,8,8,'0000-00-00','0000-00-00','10:25:31','10:25:31','2003-01-24 10:45:23','2003-01-24 10:45:23','',''),
-(29,5,6,'0000-00-00','0000-00-00','00:21:35','00:21:35','0000-00-00 00:00:00','0000-00-00 00:00:00','y','y'),
-(53,3,5,'0000-00-00','0000-00-00','00:00:00','00:00:00','2007-11-05 23:51:21','2007-11-05 23:51:21','p','p'),
-(60,0,2,'2009-09-11','2009-09-11','23:56:26','23:56:26','2003-12-24 04:28:32','2003-12-24 04:28:32','n','n'),
-(93,7,2,'2007-08-18','2007-08-18','00:00:00','00:00:00','2009-02-01 00:00:00','2009-02-01 00:00:00','y','y');
-SELECT * FROM t1 ORDER BY RAND () INTO OUTFILE "MYSQL_TEST_DIR/var/tmp/bug38174-1.test";
-drop table if exists t1;
-start slave;
-CREATE TABLE t1 (
-`pk` int(11) NOT NULL AUTO_INCREMENT,
-`int_nokey` int(11) NOT NULL,
-`int_key` int(11) NOT NULL,
-`date_key` date NOT NULL,
-`date_nokey` date NOT NULL,
-`time_key` time NOT NULL,
-`time_nokey` time NOT NULL,
-`datetime_key` datetime NOT NULL,
-`datetime_nokey` datetime NOT NULL,
-`varchar_key` varchar(1) NOT NULL,
-`varchar_nokey` varchar(1) NOT NULL,
-PRIMARY KEY (`pk`),
-KEY `int_key` (`int_key`),
-KEY `date_key` (`date_key`),
-KEY `time_key` (`time_key`),
-KEY `datetime_key` (`datetime_key`),
-KEY `varchar_key` (`varchar_key`)
-);
-LOAD DATA INFILE "MYSQL_TEST_DIR/var/tmp/bug38174-1.test" REPLACE INTO TABLE t1;
-select count(*) from t1;
-count(*)
-27
-select count(*) from t1;
-count(*)
-27
+create table t1(a int not null auto_increment, b int, primary key(a));
+load data infile '../../std_data/rpl_loaddata.dat' into table t1;
+select * from t1;
+a b
+1 10
+2 15
+select * from t1;
+a b
+1 10
+2 15
drop table t1;
=== removed file 'mysql-test/suite/rpl/t/rpl_bug38174-slave.opt'
--- a/mysql-test/suite/rpl/t/rpl_bug38174-slave.opt 2009-02-11 15:39:04 +0000
+++ b/mysql-test/suite/rpl/t/rpl_bug38174-slave.opt 1970-01-01 00:00:00 +0000
@@ -1 +0,0 @@
---secure-file-priv=/tmp
=== modified file 'mysql-test/suite/rpl/t/rpl_bug38174.test'
--- a/mysql-test/suite/rpl/t/rpl_bug38174.test 2009-02-11 15:39:04 +0000
+++ b/mysql-test/suite/rpl/t/rpl_bug38174.test 2009-02-12 16:57:09 +0000
@@ -2,12 +2,9 @@
# This test verifies if a slave is able to process a "LOAD DATA INFILE"
# event while the "--secure-file-priv" option is set.
#
-# The test is divided in five steps:
-# 1 - Stops replication
-# 2 - Creates a file in the master from which a table should be populate
-# 3 - Starts replication.
-# 4 - Creates a table and populates it through "LOAD DATA INFILE".
-# 5 - Compares the master and slave.
+# The test is divided in two steps:
+# 1 - Creates a table and populates it through "LOAD DATA INFILE".
+# 2 - Compares the master and slave.
##########################################################################
##########################################################################
@@ -21,105 +18,12 @@ drop table if exists t1;
--enable_warnings
##########################################################################
-# Stopping Replication
+# Loading data
##########################################################################
-connection slave;
-
-stop slave;
-source include/wait_for_slave_to_stop.inc;
-
-connection master;
-
-##########################################################################
-# Creating Load File
-##########################################################################
-CREATE TABLE t1 (
- `pk` int(11) NOT NULL AUTO_INCREMENT,
- `int_nokey` int(11) NOT NULL,
- `int_key` int(11) NOT NULL,
- `date_key` date NOT NULL,
- `date_nokey` date NOT NULL,
- `time_key` time NOT NULL,
- `time_nokey` time NOT NULL,
- `datetime_key` datetime NOT NULL,
- `datetime_nokey` datetime NOT NULL,
- `varchar_key` varchar(1) NOT NULL,
- `varchar_nokey` varchar(1) NOT NULL,
- PRIMARY KEY (`pk`),
- KEY `int_key` (`int_key`),
- KEY `date_key` (`date_key`),
- KEY `time_key` (`time_key`),
- KEY `datetime_key` (`datetime_key`),
- KEY `varchar_key` (`varchar_key`)
-);
-
-INSERT INTO t1 VALUES (1,8,5,'0000-00-00','0000-00-00','10:37:38','10:37:38','0000-00-00 00:00:00','0000-00-00 00:00:00','p','p'),
-(2,1,6,'2005-12-23','2005-12-23','02:24:28','02:24:28','0000-00-00 00:00:00','0000-00-00 00:00:00','g','g'),
-(3,0,3,'2009-09-14','2009-09-14','00:00:00','00:00:00','2000-01-30 16:39:40','2000-01-30 16:39:40','q','q'),
-(4,1,4,'2002-12-03','2002-12-03','20:34:58','20:34:58','2009-10-28 09:46:21','2009-10-28 09:46:21','g','g'),
-(5,1,6,'2007-03-29','2007-03-29','15:49:00','15:49:00','0000-00-00 00:00:00','0000-00-00 00:00:00','m','m'),
-(6,4,0,'2002-12-04','2002-12-04','00:00:00','00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','o','o'),
-(7,9,0,'2005-01-28','2005-01-28','00:00:00','00:00:00','2001-05-18 00:00:00','2001-05-18 00:00:00','w','w'),
-(8,6,0,'0000-00-00','0000-00-00','06:57:25','06:57:25','0000-00-00 00:00:00','0000-00-00 00:00:00','m','m'),
-(9,0,0,'0000-00-00','0000-00-00','00:00:00','00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','z','z'),
-(10,4,6,'2006-08-15','2006-08-15','00:00:00','00:00:00','2002-04-12 14:44:25','2002-04-12 14:44:25','j','j'),
-(11,0,5,'2006-12-20','2006-12-20','10:13:53','10:13:53','2008-07-22 00:00:00','2008-07-22 00:00:00','y','y'),
-(12,9,7,'0000-00-00','0000-00-00','00:00:00','00:00:00','2004-07-05 00:00:00','2004-07-05 00:00:00','{','{'),
-(13,4,3,'2007-01-26','2007-01-26','23:00:51','23:00:51','2001-05-16 00:00:00','2001-05-16 00:00:00','f','f'),
-(14,7,0,'2004-03-27','2004-03-27','00:00:00','00:00:00','2005-01-24 03:30:37','2005-01-24 03:30:37','',''),
-(15,6,0,'2006-07-26','2006-07-26','18:43:57','18:43:57','0000-00-00 00:00:00','0000-00-00 00:00:00','{','{'),
-(16,0,6,'2000-01-14','2000-01-14','00:00:00','00:00:00','2000-09-21 00:00:00','2000-09-21 00:00:00','o','o'),
-(17,9,8,'0000-00-00','0000-00-00','21:15:08','21:15:08','0000-00-00 00:00:00','0000-00-00 00:00:00','a','a'),
-(18,2,0,'2004-10-27','2004-10-27','00:00:00','00:00:00','2004-03-24 22:13:43','2004-03-24 22:13:43','',''),
-(19,7,4,'0000-00-00','0000-00-00','08:38:27','08:38:27','2002-03-18 19:51:44','2002-03-18 19:51:44','t','t'),
-(20,5,3,'2008-03-07','2008-03-07','03:29:07','03:29:07','2007-12-01 18:44:44','2007-12-01 18:44:44','t','t'),
-(77,6,0,'2009-05-19','2009-05-19','14:56:44','14:56:44','2007-09-09 22:47:39','2007-09-09 22:47:39','',''),
-(35,6,3,'0000-00-00','0000-00-00','09:38:22','09:38:22','0000-00-00 00:00:00','0000-00-00 00:00:00','i','i'),
-(39,8,8,'0000-00-00','0000-00-00','10:25:31','10:25:31','2003-01-24 10:45:23','2003-01-24 10:45:23','',''),
-(29,5,6,'0000-00-00','0000-00-00','00:21:35','00:21:35','0000-00-00 00:00:00','0000-00-00 00:00:00','y','y'),
-(53,3,5,'0000-00-00','0000-00-00','00:00:00','00:00:00','2007-11-05 23:51:21','2007-11-05 23:51:21','p','p'),
-(60,0,2,'2009-09-11','2009-09-11','23:56:26','23:56:26','2003-12-24 04:28:32','2003-12-24 04:28:32','n','n'),
-(93,7,2,'2007-08-18','2007-08-18','00:00:00','00:00:00','2009-02-01 00:00:00','2009-02-01 00:00:00','y','y');
-
---replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
---eval SELECT * FROM t1 ORDER BY RAND () INTO OUTFILE "$MYSQL_TEST_DIR/var/tmp/bug38174-1.test"
-
-drop table if exists t1;
-##########################################################################
-# Starting Replication
-##########################################################################
-connection slave;
-
-start slave;
-source include/wait_for_slave_to_start.inc;
-
connection master;
-##########################################################################
-# Populating a table through "LOAD DATA INFILE"
-##########################################################################
-CREATE TABLE t1 (
- `pk` int(11) NOT NULL AUTO_INCREMENT,
- `int_nokey` int(11) NOT NULL,
- `int_key` int(11) NOT NULL,
- `date_key` date NOT NULL,
- `date_nokey` date NOT NULL,
- `time_key` time NOT NULL,
- `time_nokey` time NOT NULL,
- `datetime_key` datetime NOT NULL,
- `datetime_nokey` datetime NOT NULL,
- `varchar_key` varchar(1) NOT NULL,
- `varchar_nokey` varchar(1) NOT NULL,
- PRIMARY KEY (`pk`),
- KEY `int_key` (`int_key`),
- KEY `date_key` (`date_key`),
- KEY `time_key` (`time_key`),
- KEY `datetime_key` (`datetime_key`),
- KEY `varchar_key` (`varchar_key`)
-);
-
---replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
---eval LOAD DATA INFILE "$MYSQL_TEST_DIR/var/tmp/bug38174-1.test" REPLACE INTO TABLE t1
+create table t1(a int not null auto_increment, b int, primary key(a));
+load data infile '../../std_data/rpl_loaddata.dat' into table t1;
##########################################################################
# Checking Consistency
@@ -129,17 +33,15 @@ connection slave;
sync_with_master;
connection master;
-select count(*) from t1;
+select * from t1;
connection slave;
-select count(*) from t1;
-
-connection master;
---replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
---remove_file $MYSQL_TEST_DIR/var/tmp/bug38174-1.test
+select * from t1;
##########################################################################
-# Clean up
+# Clean up
##########################################################################
+connection master;
+
drop table t1;
save_master_pos;
=== modified file 'sql/sql_load.cc'
--- a/sql/sql_load.cc 2009-02-11 15:39:04 +0000
+++ b/sql/sql_load.cc 2009-02-12 16:57:09 +0000
@@ -89,6 +89,10 @@ static bool write_execute_load_query_log
THD::killed_state killed_status);
#endif /* EMBEDDED_LIBRARY */
+#if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT)
+ char check_slave_dir[FN_REFLEN] = {0};
+#endif
+
/*
Execute LOAD DATA query
@@ -312,18 +316,30 @@ int mysql_load(THD *thd,sql_exchange *ex
if (thd->slave_thread)
{
-#ifdef HAVE_REPLICATION
- char buf[FN_REFLEN];
- fn_format(buf, PREFIX_SQL_LOAD, slave_load_tmpdir, "",
- MY_PACK_FILENAME | MY_UNPACK_FILENAME |
- MY_RETURN_REAL_PATH);
- to_unix_path(buf);
+#if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT)
+ if (!check_slave_dir)
+ {
+ fn_format(check_slave_dir, PREFIX_SQL_LOAD, slave_load_tmpdir, "",
+ MY_PACK_FILENAME | MY_UNPACK_FILENAME |
+ MY_RETURN_REAL_PATH);
+ to_unix_path(check_slave_dir);
+ /*
+ This removes the PREFIX_SQL_LOAD and keeps the FULL PATH.
+ */
+ check_slave_dir[strlen(check_slave_dir) - strlen(PREFIX_SQL_LOAD)] = '\0';
+ }
- if (strncmp(buf, name, strlen(buf)))
+ if (strncmp(check_slave_dir, name, strlen(check_slave_dir)))
{
+ /*
+ LOAD DATA INFILE in the slave SQL Thread can only read from
+ --slave-load-tmpdir"
+ */
my_error(ER_OPTION_PREVENTS_STATEMENT, MYF(0), "--slave-load-tmpdir");
DBUG_RETURN(TRUE);
}
+#else
+ DBUG_ASSERT(FALSE); // This is impossible
#endif
}
else if (opt_secure_file_priv &&