mirror of
https://github.com/MariaDB/server.git
synced 2025-03-08 04:03:30 +01:00

into bodhi.local:/opt/local/work/mysql-5.1-runtime-merge BitKeeper/deleted/.del-im_check_os.inc: Auto merged BitKeeper/deleted/.del-im_options_set.imtest~b53d9d60e5684833: Auto merged BitKeeper/deleted/.del-im_options_set.result~59278f56be61d921: Auto merged BitKeeper/deleted/.del-im_options_unset.imtest~768eb186b51d0048: Auto merged configure.in: Auto merged BitKeeper/deleted/.del-im_options_unset.result~20a4790cd3c70a4f: Auto merged include/mysql_com.h: Auto merged mysql-test/lib/mtr_io.pl: Auto merged mysql-test/r/im_daemon_life_cycle.result: Auto merged mysql-test/r/im_life_cycle.result: Auto merged mysql-test/r/im_utils.result: Auto merged mysql-test/r/sp-error.result: Auto merged mysql-test/r/trigger.result: Auto merged mysql-test/r/type_varchar.result: Auto merged mysql-test/r/view.result: Auto merged mysql-test/t/im_daemon_life_cycle.imtest: Auto merged mysql-test/t/im_life_cycle.imtest: Auto merged mysql-test/t/im_utils.imtest: Auto merged mysql-test/t/sp-error.test: Auto merged mysql-test/t/trigger.test: Auto merged mysql-test/t/type_varchar.test: Auto merged mysql-test/t/view.test: Auto merged sql/item.cc: Auto merged sql/item.h: Auto merged sql/item_cmpfunc.cc: Auto merged sql/item_func.cc: Auto merged sql/item_row.cc: Auto merged sql/item_strfunc.cc: Auto merged sql/item_strfunc.h: Auto merged sql/mysql_priv.h: Auto merged sql/net_serv.cc: Auto merged sql/protocol.cc: Auto merged sql/sp_head.cc: Auto merged sql/sql_acl.cc: Auto merged sql/sql_cache.cc: Auto merged sql/sql_cache.h: Auto merged sql/sql_class.cc: Auto merged sql/sql_error.cc: Auto merged sql/sql_parse.cc: Auto merged sql/sql_trigger.h: Auto merged sql/sql_yacc.yy: Auto merged mysql-test/mysql-test-run.pl: Use local. Alik will merge his changes manually. mysql-test/lib/mtr_process.pl: Use local. mysql-test/r/grant.result: Use local. mysql-test/r/sp.result: Use local. mysql-test/r/ps.result: Manual merge. mysql-test/t/grant.test: Manual merge. mysql-test/t/ps.test: Manual merge. mysql-test/t/sp.test: Manual merge. sql/Makefile.am: Manual merge. sql/field.cc: Manual merge. sql/mysqld.cc: Manual merge. sql/share/errmsg.txt: Manual merge. sql/sp.cc: Manual merge. sql/sp_head.h: Manual merge. sql/sql_trigger.cc: Manual merge. sql/sql_view.cc: Manual merge.
173 lines
4.1 KiB
Perl
173 lines
4.1 KiB
Perl
# -*- cperl -*-
|
|
|
|
# This is a library file used by the Perl version of mysql-test-run,
|
|
# and is part of the translation of the Bourne shell script with the
|
|
# same name.
|
|
|
|
use strict;
|
|
|
|
sub mtr_get_pid_from_file ($);
|
|
sub mtr_get_opts_from_file ($);
|
|
sub mtr_fromfile ($);
|
|
sub mtr_tofile ($@);
|
|
sub mtr_tonewfile($@);
|
|
sub mtr_lastlinefromfile($);
|
|
|
|
##############################################################################
|
|
#
|
|
#
|
|
#
|
|
##############################################################################
|
|
|
|
sub mtr_get_pid_from_file ($) {
|
|
my $pid_file_path= shift;
|
|
my $TOTAL_ATTEMPTS= 30;
|
|
my $timeout= 1;
|
|
|
|
# We should read from the file until we get correct pid. As it is
|
|
# stated in BUG#21884, pid file can be empty at some moment. So, we should
|
|
# read it until we get valid data.
|
|
|
|
for (my $cur_attempt= 1; $cur_attempt <= $TOTAL_ATTEMPTS; ++$cur_attempt)
|
|
{
|
|
mtr_debug("Reading pid file '$pid_file_path' " .
|
|
"($cur_attempt of $TOTAL_ATTEMPTS)...");
|
|
|
|
open(FILE, '<', $pid_file_path)
|
|
or mtr_error("can't open file \"$pid_file_path\": $!");
|
|
|
|
my $pid= <FILE>;
|
|
|
|
chomp($pid) if defined $pid;
|
|
|
|
close FILE;
|
|
|
|
return $pid if defined $pid && $pid ne '';
|
|
|
|
mtr_debug("Pid file '$pid_file_path' is empty. " .
|
|
"Sleeping $timeout second(s)...");
|
|
|
|
sleep(1);
|
|
}
|
|
|
|
mtr_error("Pid file '$pid_file_path' is corrupted. " .
|
|
"Can not retrieve PID in " .
|
|
($timeout * $TOTAL_ATTEMPTS) . " seconds.");
|
|
}
|
|
|
|
sub mtr_get_opts_from_file ($) {
|
|
my $file= shift;
|
|
|
|
open(FILE,"<",$file) or mtr_error("can't open file \"$file\": $!");
|
|
my @args;
|
|
while ( <FILE> )
|
|
{
|
|
chomp;
|
|
|
|
# --set-variable=init_connect=set @a='a\\0c'
|
|
s/^\s+//; # Remove leading space
|
|
s/\s+$//; # Remove ending space
|
|
|
|
# This is strange, but we need to fill whitespace inside
|
|
# quotes with something, to remove later. We do this to
|
|
# be able to split on space. Else, we have trouble with
|
|
# options like
|
|
#
|
|
# --someopt="--insideopt1 --insideopt2"
|
|
#
|
|
# But still with this, we are not 100% sure it is right,
|
|
# we need a shell to do it right.
|
|
|
|
# print STDERR "\n";
|
|
# print STDERR "AAA: $_\n";
|
|
|
|
s/\'([^\'\"]*)\'/unspace($1,"\x0a")/ge;
|
|
s/\"([^\'\"]*)\"/unspace($1,"\x0b")/ge;
|
|
s/\'([^\'\"]*)\'/unspace($1,"\x0a")/ge;
|
|
s/\"([^\'\"]*)\"/unspace($1,"\x0b")/ge;
|
|
|
|
# print STDERR "BBB: $_\n";
|
|
|
|
# foreach my $arg (/(--?\w.*?)(?=\s+--?\w|$)/)
|
|
|
|
# FIXME ENV vars should be expanded!!!!
|
|
|
|
foreach my $arg (split(/[ \t]+/))
|
|
{
|
|
$arg =~ tr/\x11\x0a\x0b/ \'\"/; # Put back real chars
|
|
# The outermost quotes has to go
|
|
$arg =~ s/^([^\'\"]*)\'(.*)\'([^\'\"]*)$/$1$2$3/
|
|
or $arg =~ s/^([^\'\"]*)\"(.*)\"([^\'\"]*)$/$1$2$3/;
|
|
$arg =~ s/\\\\/\\/g;
|
|
|
|
$arg =~ s/\$\{(\w+)\}/envsubst($1)/ge;
|
|
$arg =~ s/\$(\w+)/envsubst($1)/ge;
|
|
|
|
# print STDERR "ARG: $arg\n";
|
|
push(@args, $arg);
|
|
}
|
|
}
|
|
close FILE;
|
|
return \@args;
|
|
}
|
|
|
|
sub envsubst {
|
|
my $string= shift;
|
|
|
|
if ( ! defined $ENV{$string} )
|
|
{
|
|
mtr_error("opt file referense \$$string that is unknown");
|
|
}
|
|
|
|
return $ENV{$string};
|
|
}
|
|
|
|
sub unspace {
|
|
my $string= shift;
|
|
my $quote= shift;
|
|
$string =~ s/[ \t]/\x11/g;
|
|
return "$quote$string$quote";
|
|
}
|
|
|
|
sub mtr_fromfile ($) {
|
|
my $file= shift;
|
|
|
|
open(FILE,"<",$file) or mtr_error("can't open file \"$file\": $!");
|
|
my $text= join('', <FILE>);
|
|
close FILE;
|
|
$text =~ s/^\s+//; # Remove starting space, incl newlines
|
|
$text =~ s/\s+$//; # Remove ending space, incl newlines
|
|
return $text;
|
|
}
|
|
|
|
sub mtr_lastlinefromfile ($) {
|
|
my $file= shift;
|
|
my $text;
|
|
|
|
open(FILE,"<",$file) or mtr_error("can't open file \"$file\": $!");
|
|
while (my $line= <FILE>)
|
|
{
|
|
$text= $line;
|
|
}
|
|
close FILE;
|
|
return $text;
|
|
}
|
|
|
|
|
|
sub mtr_tofile ($@) {
|
|
my $file= shift;
|
|
|
|
open(FILE,">>",$file) or mtr_error("can't open file \"$file\": $!");
|
|
print FILE join("", @_);
|
|
close FILE;
|
|
}
|
|
|
|
sub mtr_tonewfile ($@) {
|
|
my $file= shift;
|
|
|
|
open(FILE,">",$file) or mtr_error("can't open file \"$file\": $!");
|
|
print FILE join("", @_);
|
|
close FILE;
|
|
}
|
|
|
|
1;
|