diff options
author | Sergei Golubchik <sergii@pisem.net> | 2012-09-27 20:09:46 +0200 |
---|---|---|
committer | Sergei Golubchik <sergii@pisem.net> | 2012-09-27 20:09:46 +0200 |
commit | 474fe6d9d9e0b4d8803bdf439dd017ba0c729729 (patch) | |
tree | 6b088655217934bf0cbb6cdf85df0a217ef1d939 /mysql-test/include/filter_file.inc | |
parent | cd9f773020c6ddfc1ea39e9037e4258b8bc32a08 (diff) | |
download | mariadb-git-474fe6d9d9e0b4d8803bdf439dd017ba0c729729.tar.gz |
fixes for test failures
and small collateral changes
mysql-test/lib/My/Test.pm:
somehow with "print" we get truncated writes sometimes
mysql-test/suite/perfschema/r/digest_table_full.result:
md5 hashes of statement digests differ, because yacc token codes are different in mariadb
mysql-test/suite/perfschema/r/dml_handler.result:
host table is not ported over yet
mysql-test/suite/perfschema/r/information_schema.result:
host table is not ported over yet
mysql-test/suite/perfschema/r/nesting.result:
this differs, because we don't rewrite general log queries, and multi-statement
packets are logged as a one entry. this result file is identical to what mysql-5.6.5
produces with the --log-raw option.
mysql-test/suite/perfschema/r/relaylog.result:
MariaDB modifies the binlog index file directly, while MySQL 5.6 has a feature "crash-safe binlog index" and modifies a special "crash-safe" shadow copy of the index file and then moves it over. That's why this test shows "NONE" index file writes in MySQL and "MANY" in MariaDB.
mysql-test/suite/perfschema/r/server_init.result:
MariaDB initializes the "manager" resources from the "manager" thread, and starts this thread only when --flush-time is not 0. MySQL 5.6 initializes "manager" resources unconditionally on server startup.
mysql-test/suite/perfschema/r/stage_mdl_global.result:
this differs, because MariaDB disables query cache when query_cache_size=0. MySQL does not
do that, and this causes useless mutex locks and waits.
mysql-test/suite/perfschema/r/statement_digest.result:
md5 hashes of statement digests differ, because yacc token codes are different in mariadb
mysql-test/suite/perfschema/r/statement_digest_consumers.result:
md5 hashes of statement digests differ, because yacc token codes are different in mariadb
mysql-test/suite/perfschema/r/statement_digest_long_query.result:
md5 hashes of statement digests differ, because yacc token codes are different in mariadb
mysql-test/suite/rpl/r/rpl_mixed_drop_create_temp_table.result:
will be updated to match 5.6 when alfranio.correia@oracle.com-20110512172919-c1b5kmum4h52g0ni and anders.song@greatopensource.com-20110105052107-zoab0bsf5a6xxk2y are merged
mysql-test/suite/rpl/r/rpl_non_direct_mixed_mixing_engines.result:
will be updated to match 5.6 when anders.song@greatopensource.com-20110105052107-zoab0bsf5a6xxk2y is merged
Diffstat (limited to 'mysql-test/include/filter_file.inc')
-rw-r--r-- | mysql-test/include/filter_file.inc | 145 |
1 files changed, 145 insertions, 0 deletions
diff --git a/mysql-test/include/filter_file.inc b/mysql-test/include/filter_file.inc new file mode 100644 index 00000000000..17c7c1985d7 --- /dev/null +++ b/mysql-test/include/filter_file.inc @@ -0,0 +1,145 @@ +# ==== Purpose ==== +# +# Read the contents of a file, filter it through a perl script, and +# write it back. +# +# This is useful in conjunction with include/write_result_to_file.inc +# and cat_file or include/read_file_to_var.inc. See +# e.g. include/show_events.inc for an example. +# +# ==== Usage ==== +# +# --let $input_file= <FILE_NAME> +# [--let $output_file= <FILE_NAME>] +# --let $script= <PERL_SCRIPT> +# [--let $select_columns= <LIST OF NUMBERS>] +# [--let $pre_script= <PERL_SCRIPT>] +# [--let $rpl_debug= 1] +# --source include/filter_file.inc +# +# Parameters: +# +# $input_file +# File to read from. +# +# $output_file +# File to write to. If omitted, writes to $input_file. +# +# $script +# This script will be executed once for each line in $input_file. +# +# When the script starts, the perl variable $_ will be set to the +# current row (including the terminating newline). The script can +# modify $_ in any way it likes, and the result will be appended +# to $output_file. It is even possible to remove a row by setting +# $_ to '', or to generate extra rows by appending "\n" to $_. +# +# Since mysqltest is incapable of properly escaping dollar +# characters, you have to replace any '$' in your script by +# 'DOLLAR' (otherwise mysqltest would try to interpolate parts of +# your script). filter_file.inc will replace 'DOLLAR' by '$' +# before evaluating your script. +# +# $select_columns +# For convenience, if you set this to a space-separated list of +# numbers, it will print only the numbered columns, in the given +# order. +# +# $pre_script +# This script will be evaluated before starting to iterate over +# the lines of $input_file. It can be useful if you need some +# sort of initialization; for example, you can define a subroutine +# here and call it from $script. +# +# $rpl_debug +# If set, verbose debug info is printed. + +--let $include_filename= filter_file.inc +--source include/begin_include_file.inc + +if ($rpl_debug) +{ + --echo pre_script='$pre_script' + --echo script='$script' + --echo select_columns='$select_columns' + --echo input_file='$input_file' output_file='$output_file' +} + +--let _FF_PRE_SCRIPT= $pre_script +--let _FF_SCRIPT= $script +--let _FF_INPUT_FILE= $input_file +--let _FF_OUTPUT_FILE= $output_file +--let _FF_SELECT_COLUMNS= $select_columns +--let _FF_DEBUG= $rpl_debug +if (!$output_file) +{ + --let _FF_OUTPUT_FILE= $input_file +} +perl; + my $pre_script = $ENV{'_FF_PRE_SCRIPT'}; + $pre_script =~ s/DOLLAR/\$/g; + my $script = $ENV{'_FF_SCRIPT'}; + $script =~ s/DOLLAR/\$/g; + my $input_file = $ENV{'_FF_INPUT_FILE'}; + my $output_file = $ENV{'_FF_OUTPUT_FILE'}; + my $select_columns = $ENV{'_FF_SELECT_COLUMNS'}; + my $debug = $ENV{'_FF_DEBUG'}; + if ($select_columns) + { + chomp($select_columns); + $select_columns =~ s/[, ]+/,/g; + $script = ' + chomp; + my @cols = split(/\t/, $_); + $_ = join("\t", map { $cols[$_ - 1] } ('.$select_columns.'))."\n"; + ' . $script; + } + unless ($keep_quotes) + { + $pre_script = 'my %unquote = ("n"=>"\n","t"=>"\t","\\\\"=>"\\\\");' . $pre_script; + $script .= 's{\\\\(.)}{$unquote{$1}}ge;'; + } + if ($debug) + { + $script = 'print "BEFORE:\'$_\'";' . $script . 'print "AFTER:\'$_\'";' + } + # Generate a script (perl is faster if we avoid many calls to eval). + my $full_script = +' + open FILE, "< $input_file" or die "Error opening $input_file: $!"; + my $filtered_contents = ""; + my %column_names = (); + '.$pre_script.'; + while (<FILE>) + { + chomp; + s/\r//g; + if (!%column_names) + { + my $n = 1; + %column_names = map { $_ => $n++ } split(/\t/, $_); + } + else + { + ' . $script . ' + } + $filtered_contents .= $_."\n"; + } + close FILE or die "Error closing $input_file: $!"; + open FILE, "> $output_file" or die "Error opening $output_file: $!"; + binmode FILE; + print FILE $filtered_contents or die "Error writing filtered contents to $output_file: $!"; + close FILE or die "Error closing $output_file: $!"; + return 0; +'; + if ($debug) + { + print STDOUT "full_script=<<END_OF_SCRIPT\n${full_script}END_OF_SCRIPT\n" + } + my $eval_ret = eval($full_script); + defined($eval_ret) or die "Parse error or 'die' invoked when evaluating perl script '$full_script': $@"; + $eval_ret == 0 or die "Non-zero exit value $eval_ret from script '$script'"; +EOF + +--let $include_filename= filter_file.inc +--source include/end_include_file.inc |