From: Bjorn Munch Date: November 8 2011 3:03pm Subject: bzr push into mysql-trunk-mtr branch (bjorn.munch:3133 to 3134) List-Archive: http://lists.mysql.com/commits/141859 Message-Id: <201111081503.pA8F3BwX005362@acsmt358.oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 3134 Bjorn Munch 2011-11-08 [merge] upmerge 13055685,13096353 modified: client/mysqltest.cc mysql-test/include/wait_for_slave_io_error.inc mysql-test/r/mysqltest.result mysql-test/suite/rpl/r/rpl_packet.result mysql-test/suite/rpl/t/rpl_packet.test mysql-test/t/mysqltest.test 3133 Bjorn Munch 2011-11-04 [merge] merge trunk => trunk-mtr removed: BUILD/compile-alpha-debug BUILD/compile-darwin-mwcc BUILD/compile-irix-mips64-mipspro BUILD/compile-pentium-icc BUILD/compile-pentium-icc-valgrind-max BUILD/compile-pentium-icc-yassl BUILD/compile-pentium-pgcc mysys/my_new.cc added: mysys/my_isnan.c unittest/gunit/stdcxx-t.cc renamed: mysys/psi_noop.cc => mysys/psi_noop.c sql/udf_example.c => sql/udf_example.cc modified: BUILD/SETUP.sh BUILD/build_mccge.sh BUILD/compile-dist BUILD/compile-solaris-amd64 BUILD/compile-solaris-amd64-forte BUILD/compile-solaris-amd64-forte-debug BUILD/compile-solaris-sparc BUILD/compile-solaris-sparc-debug BUILD/compile-solaris-sparc-forte BUILD/compile-solaris-sparc-purify VERSION client/CMakeLists.txt client/mysql.cc client/mysql_upgrade.c client/mysqlbinlog.cc client/mysqldump.c client/mysqltest.cc client/sql_string.cc cmake/build_configurations/mysql_release.cmake cmake/configure.pl cmake/info_macros.cmake.in cmake/os/Windows.cmake cmake/readline.cmake config.h.cmake configure.cmake dbug/dbug.c include/m_string.h include/my_global.h include/my_pthread.h include/mysql.h include/mysql/psi/mysql_thread.h include/mysql/psi/psi.h include/mysql/psi/psi_abi_v1.h include/mysql_com.h include/waiting_threads.h libmysql/libmysql.c libmysqld/lib_sql.cc mysql-test/mysql-test-run.pl mysql-test/r/case.result mysql-test/r/udf.result mysql-test/t/case.test mysql-test/t/disabled.def mysql-test/t/mysql_plugin.test mysql-test/t/udf.test mysys/CMakeLists.txt mysys/array.c mysys/default.c mysys/lf_alloc-pin.c mysys/lf_dynarray.c mysys/mf_format.c mysys/mf_iocache.c mysys/my_alloc.c mysys/my_bitmap.c mysys/my_compare.c mysys/my_compress.c mysys/my_file.c mysys/stacktrace.c mysys/waiting_threads.c sql-common/client.c sql-common/client_plugin.c sql-common/my_time.c sql/CMakeLists.txt sql/binlog.cc sql/debug_sync.cc sql/field.cc sql/field.h sql/filesort.cc sql/ha_partition.cc sql/handler.cc sql/handler.h sql/item.cc sql/item_buff.cc sql/item_cmpfunc.cc sql/item_func.cc sql/item_func.h sql/item_strfunc.cc sql/item_strfunc.h sql/item_sum.cc sql/item_timefunc.cc sql/item_timefunc.h sql/key.cc sql/log.cc sql/log_event.cc sql/log_event.h sql/log_event_old.cc sql/mdl.cc sql/mdl.h sql/mysqld.cc sql/net_serv.cc sql/opt_range.cc sql/opt_range.h sql/opt_trace.cc sql/opt_trace.h sql/protocol.cc sql/rpl_mi.cc sql/rpl_record.cc sql/rpl_rli.cc sql/rpl_slave.cc sql/rpl_utility.cc sql/rpl_utility.h sql/set_var.cc sql/set_var.h sql/sp_head.cc sql/spatial.h sql/sql_acl.cc sql/sql_analyse.cc sql/sql_cache.cc sql/sql_class.cc sql/sql_client.cc sql/sql_connect.cc sql/sql_const.h sql/sql_error.cc sql/sql_join_cache.cc sql/sql_load.cc sql/sql_parse.cc sql/sql_partition.cc sql/sql_plugin.cc sql/sql_plugin.h sql/sql_prepare.cc sql/sql_profile.cc sql/sql_select.cc sql/sql_select.h sql/sql_show.cc sql/sql_string.cc sql/sql_table.cc sql/sql_table.h sql/sql_yacc.yy sql/thr_malloc.cc sql/tztime.cc sql/udf_example.def sql/unireg.cc storage/csv/ha_tina.cc storage/federated/ha_federated.cc storage/heap/hp_create.c storage/heap/hp_static.c storage/heap/hp_test2.c storage/innobase/sync/sync0rw.c storage/myisam/ha_myisam.cc storage/myisam/mi_cache.c storage/myisam/mi_check.c storage/myisam/mi_create.c storage/myisam/mi_dynrec.c storage/myisam/mi_extra.c storage/myisam/mi_open.c storage/myisam/mi_packrec.c storage/myisam/mi_static.c storage/myisam/myisamlog.c storage/myisam/myisampack.c storage/myisam/rt_mbr.c storage/myisam/sort.c storage/myisammrg/ha_myisammrg.cc strings/ctype-big5.c strings/ctype-bin.c strings/ctype-gbk.c strings/ctype-mb.c strings/ctype-simple.c strings/ctype-tis620.c strings/ctype-uca.c strings/ctype-ucs2.c strings/ctype-utf8.c strings/ctype.c strings/decimal.c strings/dtoa.c strings/my_vsnprintf.c support-files/mysql.spec.sh tests/mysql_client_test.c unittest/gunit/CMakeLists.txt unittest/gunit/gunit_test_main.cc unittest/gunit/item-t.cc unittest/mysys/lf-t.c unittest/mysys/my_atomic-t.c unittest/mysys/thr_template.c unittest/mysys/waiting_threads-t.c vio/viosocket.c win/create_def_file.js mysys/psi_noop.c sql/udf_example.cc === modified file 'client/mysqltest.cc' --- a/client/mysqltest.cc 2011-10-28 12:45:35 +0000 +++ b/client/mysqltest.cc 2011-11-08 15:01:50 +0000 @@ -516,6 +516,31 @@ struct st_command *curr_command= 0; char builtin_echo[FN_REFLEN]; +struct st_replace_regex +{ +DYNAMIC_ARRAY regex_arr; /* stores a list of st_regex subsitutions */ + +/* +Temporary storage areas for substitutions. To reduce unnessary copying +and memory freeing/allocation, we pre-allocate two buffers, and alternate +their use, one for input/one for output, the roles changing on the next +st_regex substition. At the end of substitutions buf points to the +one containing the final result. +*/ +char* buf; +char* even_buf; +char* odd_buf; +int even_buf_len; +int odd_buf_len; +}; + +struct st_replace_regex *glob_replace_regex= 0; + +struct st_replace; +struct st_replace *glob_replace= 0; +void replace_strings_append(struct st_replace *rep, DYNAMIC_STRING* ds, +const char *from, int len); + static void cleanup_and_exit(int exit_code) __attribute__((noreturn)); void die(const char *fmt, ...) @@ -545,6 +570,7 @@ void str_to_file2(const char *fname, cha void fix_win_paths(const char *val, int len); const char *get_errname_from_code (uint error_code); +int multi_reg_replace(struct st_replace_regex* r,char* val); #ifdef __WIN__ void free_tmp_sh_file(); @@ -2453,7 +2479,23 @@ void var_query_set(VAR *var, const char if (row[i]) { /* Add column to tab separated string */ - dynstr_append_mem(&result, row[i], lengths[i]); + char *val= row[i]; + int len= lengths[i]; + + if (glob_replace_regex) + { + /* Regex replace */ + if (!multi_reg_replace(glob_replace_regex, (char*)val)) + { + val= glob_replace_regex->buf; + len= strlen(val); + } + } + + if (glob_replace) + replace_strings_append(glob_replace, &result, val, len); + else + dynstr_append_mem(&result, val, len); } dynstr_append_mem(&result, "\t", 1); } @@ -3332,8 +3374,9 @@ void do_copy_file(struct st_command *com ' '); DBUG_PRINT("info", ("Copy %s to %s", ds_from_file.str, ds_to_file.str)); + /* MY_HOLD_ORIGINAL_MODES prevents attempts to chown the file */ error= (my_copy(ds_from_file.str, ds_to_file.str, - MYF(MY_DONT_OVERWRITE_FILE)) != 0); + MYF(MY_DONT_OVERWRITE_FILE | MY_HOLD_ORIGINAL_MODES)) != 0); handle_command_error(command, error); dynstr_free(&ds_from_file); dynstr_free(&ds_to_file); @@ -9226,16 +9269,11 @@ typedef struct st_pointer_array { /* wh uint array_allocs,max_count,length,max_length; } POINTER_ARRAY; -struct st_replace; struct st_replace *init_replace(char * *from, char * *to, uint count, char * word_end_chars); int insert_pointer_name(reg1 POINTER_ARRAY *pa,char * name); -void replace_strings_append(struct st_replace *rep, DYNAMIC_STRING* ds, - const char *from, int len); void free_pointer_array(POINTER_ARRAY *pa); -struct st_replace *glob_replace; - /* Get arguments for replace. The syntax is: replace from to [from to ...] @@ -9379,26 +9417,6 @@ struct st_regex int icase; /* true if the match is case insensitive */ }; -struct st_replace_regex -{ - DYNAMIC_ARRAY regex_arr; /* stores a list of st_regex subsitutions */ - - /* - Temporary storage areas for substitutions. To reduce unnessary copying - and memory freeing/allocation, we pre-allocate two buffers, and alternate - their use, one for input/one for output, the roles changing on the next - st_regex substition. At the end of substitutions buf points to the - one containing the final result. - */ - char* buf; - char* even_buf; - char* odd_buf; - int even_buf_len; - int odd_buf_len; -}; - -struct st_replace_regex *glob_replace_regex= 0; - int reg_replace(char** buf_p, int* buf_len_p, char *pattern, char *replace, char *string, int icase); @@ -9597,7 +9615,13 @@ void do_get_replace_regex(struct st_comm { char *expr= command->first_argument; free_replace_regex(); - if (!(glob_replace_regex=init_replace_regex(expr))) + /* Allow variable for the *entire* list of replacements */ + if (*expr == '$') + { + VAR *val= var_get(expr, NULL, 0, 1); + expr= val ? val->str_val : NULL; + } + if (expr && *expr && !(glob_replace_regex=init_replace_regex(expr))) die("Could not init replace_regex"); command->last_argument= command->end; } === modified file 'mysql-test/include/wait_for_slave_io_error.inc' --- a/mysql-test/include/wait_for_slave_io_error.inc 2011-02-07 15:31:01 +0000 +++ b/mysql-test/include/wait_for_slave_io_error.inc 2011-11-08 15:01:50 +0000 @@ -33,6 +33,10 @@ # (e.g., temporary connection error) and does not cause the slave # IO thread to stop. # +# $slave_io_error_replace +# If set, one or more regex patterns for replacing variable +# text in the error message. Syntax as --replace-regex +# # $slave_timeout # See include/wait_for_slave_param.inc # @@ -72,6 +76,7 @@ if ($show_slave_io_error) { --let $_wait_for_slave_io_error_error= query_get_value("SHOW SLAVE STATUS", Last_IO_Error, 1) # remove timestamp and mask absolute path + --replace_regex $slave_io_error_replace --let $_wait_for_slave_io_error_error= `SELECT REPLACE("$_wait_for_slave_io_error_error", '$MYSQL_TEST_DIR', 'MYSQL_TEST_DIR')` --echo Last_IO_Error = '$_wait_for_slave_io_error_error' } === modified file 'mysql-test/r/mysqltest.result' --- a/mysql-test/r/mysqltest.result 2011-10-19 07:29:57 +0000 +++ b/mysql-test/r/mysqltest.result 2011-11-08 15:01:50 +0000 @@ -548,6 +548,7 @@ mysqltest: At line 1: Wrong column numbe select "LONG_STRING" as x; x LONG_STRING +dog mysqltest: At line 1: Invalid integer argument "10!" mysqltest: At line 1: Invalid integer argument "a" mysqltest: At line 1: Missing required argument 'connection name' to command 'connect' @@ -661,6 +662,11 @@ a D 1 1 1 4 drop table t1; +y +txt +b is b and more is more +txt +a is a and less is more create table t2 ( a char(10)); garbage; ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'garbage' at line 1 === modified file 'mysql-test/suite/rpl/r/rpl_packet.result' --- a/mysql-test/suite/rpl/r/rpl_packet.result 2011-10-28 21:22:19 +0000 +++ b/mysql-test/suite/rpl/r/rpl_packet.result 2011-11-08 15:01:50 +0000 @@ -37,6 +37,7 @@ DROP TABLE t1; CREATE TABLE t1 (f1 int PRIMARY KEY, f2 LONGTEXT, f3 LONGTEXT) ENGINE=MyISAM; INSERT INTO t1(f1, f2, f3) VALUES(1, REPEAT('a', @@global.max_allowed_packet), REPEAT('b', @@global.max_allowed_packet)); include/wait_for_slave_io_error.inc [errno=1236] +Last_IO_Error = 'Got fatal error 1236 from master when reading data from binary log: 'log event entry exceeded max_allowed_packet; Increase max_allowed_packet on master; the last event was read from 'master-bin.000001' at XXX, the last byte read was read from 'master-bin.000001' at XXX.'' STOP SLAVE; RESET SLAVE; RESET MASTER; === modified file 'mysql-test/suite/rpl/t/rpl_packet.test' --- a/mysql-test/suite/rpl/t/rpl_packet.test 2011-10-28 21:22:19 +0000 +++ b/mysql-test/suite/rpl/t/rpl_packet.test 2011-11-08 15:01:50 +0000 @@ -144,12 +144,8 @@ connection slave; # The slave I/O thread must stop after receiving # 1236=ER_MASTER_FATAL_ERROR_READING_BINLOG error message from master. --let $slave_io_errno= 1236 -# -# Win and Unix path is printed differently: BUG#13055685. So -# show_slave_io_error is made 0 until the bug fixes provide necessary -# facilities -# ---let $show_slave_io_error= 0 +# Mask line numbers, and whether master-bin is preceded by "./" or "." +--let $slave_io_error_replace= / at [0-9]*/ at XXX/ /\.\/*master-bin/master-bin/ --source include/wait_for_slave_io_error.inc # Remove the bad binlog and clear error status on slave. === modified file 'mysql-test/t/mysqltest.test' --- a/mysql-test/t/mysqltest.test 2011-10-19 07:29:57 +0000 +++ b/mysql-test/t/mysqltest.test 2011-11-08 15:01:50 +0000 @@ -1735,6 +1735,12 @@ let $long_rep= $long_rep,$long_rep; --replace_result $long_rep LONG_STRING eval select "$long_rep" as x; +# Test replace within `` + +--replace_result cat dog +--let $animal= `select "cat" as pet` +--echo $animal + # ---------------------------------------------------------------------------- # Test sync_with_master # ---------------------------------------------------------------------------- @@ -2055,6 +2061,23 @@ insert into t1 values (2,4); select * from t1; drop table t1; +# Test usage with `` + +--replace_regex /x/y/ +--let $result= `select "x" as col` +--echo $result + +# Test usage with a variable as pattern list + +--disable_query_log +--let $patt= /a /b / /less/more/ +--replace_regex $patt +select "a is a and less is more" as txt; +--let $patt= +--replace_regex $patt +select "a is a and less is more" as txt; +--enable_query_log + #------------------------------------------------------------------------- # BUG #11754855 : Passing variable to --error #------------------------------------------------------------------------- No bundle (reason: useless for push emails).