List:Commits« Previous MessageNext Message »
From:He Zhenxing Date:November 16 2009 4:16am
Subject:Re: bzr commit into mysql-5.1-bugteam branch (Dao-Gang.Qu:3196)
Bug#43913
View as plain text  
Hi Daogang,

Nice work, Patch approved after considering the following comments.

1) Please make sure the test run OK on Windows
2) Please also see some minor comments below.

Dao-Gang.Qu@stripped wrote:
> #At file:///home/daogangqu/mysql/bzrwork/bug43913/mysql-5.1-bugteam/ based on
> revid:dao-gang.qu@stripped
> 
>  3196 Dao-Gang.Qu@stripped	2009-11-13
>       Bug #43913  	rpl_cross_version can't pass on conflicts complainig clash with
> --slave-load-tm
>             
>       The 'slave_patternload_file' is assigned to the real path of the load data file
> 
>       when initializing the object of Relay_log_info. But the path of the load data
>       file is not formatted to real path when executing event from relay log. So the
> 
>       error will be encountered if the path of the load data file is a symbolic
> link.
>       
>       Actually the global 'opt_secure_file_priv' is not formatted to real path when 
>       loading data from file. So the same thing will happen too.
>       
>             
>       To fix these errors, the path of the load data file should be formatted to 
>       real path when executing event from relay log. And the 'opt_secure_file_priv' 
>       should be formatted to real path when loading data infile.
>      @ mysql-test/suite/rpl/r/rpl_loaddata_symlink.result
>         Test result for bug#43913.
>      @ mysql-test/suite/rpl/t/rpl_loaddata_symlink.test
>         Added the test file to verify if loading data infile will work fine 
>         if the path of the load data file is a symbolic link.
>      @ sql/rpl_rli.cc
>         Added call 'my_realpath' function for avoiding sometimes the 'fn_format' 
>         function can't format real path rightly.
> 
>     added:
>       mysql-test/suite/rpl/r/rpl_loaddata_symlink.result
>       mysql-test/suite/rpl/t/rpl_loaddata_symlink-master.opt
>       mysql-test/suite/rpl/t/rpl_loaddata_symlink.test
>     modified:
>       sql/rpl_rli.cc
>       sql/sql_load.cc
> === added file 'mysql-test/suite/rpl/r/rpl_loaddata_symlink.result'
> --- a/mysql-test/suite/rpl/r/rpl_loaddata_symlink.result	1970-01-01 00:00:00 +0000
> +++ b/mysql-test/suite/rpl/r/rpl_loaddata_symlink.result	2009-11-12 20:25:58 +0000
> @@ -0,0 +1,19 @@
> +stop slave;
> +drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
> +reset master;
> +reset slave;
> +drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
> +start slave;
> +Link created successfully
> +create table t1(a int not null auto_increment, b int, primary key(a) );
> +load data infile '/tmp/std_data_43913_link/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;
> +Unlink successfully
> 
> === added file 'mysql-test/suite/rpl/t/rpl_loaddata_symlink-master.opt'
> --- a/mysql-test/suite/rpl/t/rpl_loaddata_symlink-master.opt	1970-01-01 00:00:00
> +0000
> +++ b/mysql-test/suite/rpl/t/rpl_loaddata_symlink-master.opt	2009-11-12 20:25:58
> +0000
> @@ -0,0 +1 @@
> +--secure-file-priv=/tmp/std_data_43913
> 
> === added file 'mysql-test/suite/rpl/t/rpl_loaddata_symlink.test'
> --- a/mysql-test/suite/rpl/t/rpl_loaddata_symlink.test	1970-01-01 00:00:00 +0000
> +++ b/mysql-test/suite/rpl/t/rpl_loaddata_symlink.test	2009-11-12 20:25:58 +0000
> @@ -0,0 +1,51 @@
> +#
> +# BUG#43913
> +# This test verifies if loading data infile will work fine 
> +# if the path of the load data file is a symbolic link.
> +#
> +
> +--source include/not_windows.inc
> +--source include/master-slave.inc
> +--source include/have_binlog_format_statement.inc
> +
> +--mkdir /tmp/std_data_43913
> +perl;
> +$existing_file ="/tmp/std_data_43913";
> +$new_file = "/tmp/std_data_43913_link";

I'd suggest:
  $existing_file => $load_datadir
  $new_file => $load_datadir_link

> +$retval = symlink $existing_file, $new_file ;
> +if( $retval == 1 ){
> +  print"Link created successfully\n";
> +}else{
> +  print"Error in creating link $!\n";

I think you missed the variable name there.

> +}
> +EOF
> +
> +--copy_file $MYSQL_TEST_DIR/std_data/rpl_loaddata.dat
> /tmp/std_data_43913/rpl_loaddata.dat
> +
> +connection master;
> +
> +create table t1(a int not null auto_increment, b int, primary key(a) );
> +load data infile '/tmp/std_data_43913_link/rpl_loaddata.dat' into table t1;
> +select * from t1;
> +
> +sync_slave_with_master;
> +connection slave;
> +select * from t1;
> +
> +connection master;
> +drop table t1;
> +sync_slave_with_master;
> +
> +perl;
> +$new_file = "/tmp/std_data_43913_link";
> +$retval = unlink $new_file;
> +if( $retval == 1 ){
> +  print"Unlink successfully\n";
> +}else{
> +  print"Error in unlink $!\n";
> +}
> +EOF
> +
> +--remove_file /tmp/std_data_43913/rpl_loaddata.dat
> +--rmdir /tmp/std_data_43913
> +
> 
> === modified file 'sql/rpl_rli.cc'
> --- a/sql/rpl_rli.cc	2009-11-05 06:07:31 +0000
> +++ b/sql/rpl_rli.cc	2009-11-12 20:25:58 +0000
> @@ -105,7 +105,8 @@ int init_relay_log_info(Relay_log_info* 
>    rli->tables_to_lock_count= 0;
>  
>    char pattern[FN_REFLEN];
> -  if (fn_format(pattern, PREFIX_SQL_LOAD, slave_load_tmpdir, "",
> +  (void) my_realpath(pattern, slave_load_tmpdir, 0);
> +  if (fn_format(pattern, PREFIX_SQL_LOAD, pattern, "",
>              MY_SAFE_PATH | MY_RETURN_REAL_PATH) == NullS)
>    {
>      pthread_mutex_unlock(&rli->data_lock);
> 
> === modified file 'sql/sql_load.cc'
> --- a/sql/sql_load.cc	2009-10-27 15:15:53 +0000
> +++ b/sql/sql_load.cc	2009-11-12 20:25:58 +0000
> @@ -304,7 +304,8 @@ int mysql_load(THD *thd,sql_exchange *ex
>      else
>      {
>        (void) fn_format(name, ex->file_name, mysql_real_data_home, "",
> -		       MY_RELATIVE_PATH | MY_UNPACK_FILENAME);
> +                       MY_RELATIVE_PATH | MY_UNPACK_FILENAME |
> +                       MY_RETURN_REAL_PATH);
>  #if !defined(__WIN__) && ! defined(__NETWARE__)
>        MY_STAT stat_info;
>        if (!my_stat(name,&stat_info,MYF(MY_WME)))
> @@ -347,12 +348,16 @@ int mysql_load(THD *thd,sql_exchange *ex
>          DBUG_ASSERT(FALSE); 
>  #endif
>        }
> -      else if (opt_secure_file_priv &&
> -               strncmp(opt_secure_file_priv, name, strlen(opt_secure_file_priv)))
> +      else if (opt_secure_file_priv)
>        {
> -        /* Read only allowed from within dir specified by secure_file_priv */
> -        my_error(ER_OPTION_PREVENTS_STATEMENT, MYF(0), "--secure-file-priv");
> -        DBUG_RETURN(TRUE);
> +        char secure_file_real_path[FN_REFLEN];
> +        (void) my_realpath(secure_file_real_path, opt_secure_file_priv, 0);
> +        if (strncmp(secure_file_real_path, name, strlen(secure_file_real_path)))
> +        {
> +          /* Read only allowed from within dir specified by secure_file_priv */
> +          my_error(ER_OPTION_PREVENTS_STATEMENT, MYF(0), "--secure-file-priv");
> +          DBUG_RETURN(TRUE);
> +        }
>        }
>  
>      }
> 


Thread
bzr commit into mysql-5.1-bugteam branch (Dao-Gang.Qu:3196) Bug#43913Dao-Gang.Qu12 Nov
  • Re: bzr commit into mysql-5.1-bugteam branch (Dao-Gang.Qu:3196)Bug#43913Luís Soares13 Nov
    • Re: bzr commit into mysql-5.1-bugteam branch (Dao-Gang.Qu:3196)Bug#43913Daogang Qu16 Nov
  • Re: bzr commit into mysql-5.1-bugteam branch (Dao-Gang.Qu:3196)Bug#43913He Zhenxing16 Nov
    • Re: bzr commit into mysql-5.1-bugteam branch (Dao-Gang.Qu:3196)Bug#43913Daogang Qu19 Nov