Commit 5f513c5d authored by unknown's avatar unknown

Merge bk-internal:/home/bk/mysql-4.1-maint

into  neptunus.(none):/home/msvensson/mysql/mysql-4.1-maint

parents fedfd803 9e4e7023
......@@ -124,3 +124,8 @@ test-force-pl:
cd mysql-test; \
./mysql-test-run.pl --force && \
./mysql-test-run.pl --ps-protocol --force
test-force-pl-mem:
cd mysql-test; \
./mysql-test-run.pl --force --mem && \
./mysql-test-run.pl --ps-protocol --force --mem
......@@ -30,7 +30,9 @@ mysql_SOURCES = mysql.cc readline.cc sql_string.cc completion_hash.cc
mysqladmin_SOURCES = mysqladmin.cc
mysql_LDADD = @readline_link@ @TERMCAP_LIB@ $(LDADD) $(CXXLDFLAGS)
mysqlbinlog_LDADD = $(LDADD) $(CXXLDFLAGS)
mysqltest_SOURCES= mysqltest.c $(top_srcdir)/mysys/my_getsystime.c
mysqltest_SOURCES= mysqltest.c \
$(top_srcdir)/mysys/my_getsystime.c \
$(top_srcdir)/mysys/my_copy.c
mysqltest_LDADD = $(top_builddir)/regex/libregex.a $(LDADD)
mysqlbinlog_SOURCES = mysqlbinlog.cc ../mysys/mf_tempdir.c
mysqlmanagerc_SOURCES = mysqlmanagerc.c
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -11,8 +11,8 @@ insert into t1 values('ab_def');
insert into t1 values('abc_ef');
insert into t1 values('abcd_f');
insert into t1 values('abcde_');
-- should return ab_def
# should return ab_def
select c1 as c1u from t1 where c1 like 'ab\_def';
-- should return ab_def
# should return ab_def
select c1 as c2h from t1 where c1 like 'ab#_def' escape '#';
drop table t1;
......@@ -9,8 +9,10 @@ disable_query_log;
drop table if exists t1, t2;
--enable_warnings
flush tables;
@r/have_ndb.require show variables like "have_ndbcluster";
# @r/server_id.require show variables like "server_id";
--require r/have_ndb.require
show variables like "have_ndbcluster";
#--require r/server_id.require
#show variables like "server_id";
enable_query_log;
# Check that server2 has NDB support
......@@ -20,8 +22,10 @@ disable_query_log;
drop table if exists t1, t2;
--enable_warnings
flush tables;
@r/have_ndb.require show variables like "have_ndbcluster";
# @r/server_id1.require show variables like "server_id";
--require r/have_ndb.require
show variables like "have_ndbcluster";
#--require r@r/server_id1.require
#show variables like "server_id";
enable_query_log;
# Set the default connection to 'server1'
......
......@@ -8,7 +8,8 @@ connection slave;
--disable_warnings
stop slave;
--enable_warnings
@r/slave-stopped.result show status like 'Slave_running';
--require r/slave-stopped.result
show status like 'Slave_running';
connection master;
--disable_warnings
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
......@@ -21,7 +22,8 @@ reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
--enable_warnings
start slave;
@r/slave-running.result show status like 'Slave_running';
--require r/slave-running.result
show status like 'Slave_running';
# Set the default connection to 'master'
connection master;
......@@ -52,7 +52,6 @@ execute stmt1;
##### parameter used for keyword like SELECT (must fail)
set @arg00='SELECT' ;
# mysqltest gives no output for the next statement, Why ??
--error 1064
@arg00 a from t1 where a=1;
--error 1064
......
#### include/show_msg.inc
#
# This file writes the value set in @message into the
# a protocol file as part of executing a test sequence
#
# Usage:
# Add the following to any *.test file:
# :
# let $message= <value>;
# --source include/show_msg.inc
# :
#
# Attention:
# - Please do not write any spaces between $message and the "=", because the
# assignment will not work.
# - Be careful with single quotes. They must be escaped like "''" or "\'".
#
# "include/show_msg80.inc" contains a detailed description and examples.
--disable_query_log
eval SET @utf8_message = CONVERT('$message' using utf8);
select @utf8_message as ""
union
select repeat(CONVERT('-' using utf8),char_length(@utf8_message));
--enable_query_log
#### include/show_msg80.inc
#
# This file writes the value set in @message into the a protocol file as part
# of executing a test sequence with a dash line that is fixed on 80 characters.
#
# This can be used in the case of long messages, multi line messages that
# exceed 80 or if an 80 char line is desired for short messages.
#
# Usage:
# Add the following to any *.test file:
# :
# let $message= <value>;
# --source include/show_msg80.inc
# :
#
# Attention:
# - Please do not write any spaces between $message and the "=", because the
# assignment will not work.
# - Be careful with single quotes within the value. They must be escaped like
# "''" or "\'".
# - Do not keep the value between single quotes.
#
#
# Content of "$message" and protocol output depending on the assignment:
# ----------------------------------------------------------------------
#
# I is assumed, that the value is not kept between double quotes.
#
# <x> first character after "$message=",
# where the content is not (space or tab)
# <y*> first character after beginning of the line,
# where the content is not (space or tab)
# <z> last char before ";"
# | beginning or end of line
#
# script: let $message= <x><whatever0>|
# | <y1><whatever1>|
# |................|
# | <yn><whatevern><z>;
# content: "<x><whatever0><new line><y1><whatever1><new line>
# ....<new line><yn><whatevern><z>"
# protocol output: |<x><whatever0>|
# |<y1><whatever1>|
# |.....|
# |<yn><whatevern><z>|
# |--- 80 dashes ---|
#
# Attention:
# <x> and <y*> set to characters like "-$#" which are also used
# to start comments, options and the names of mysqltest variables
# lead to syntax errors or mangled messages.
#
#
# Examples of messages:
# ---------------------
#
# Variant1 (ease of use):
# Several lines with indentation kept between double quotes
# script: |let $message=
# |" Testcase 3.1 : Ensure that Pi is not an|
# | integer number.|
# | Third line";
# protocol: |" Testcase 3.1 : Ensure that Pi is not an|
# | integer number.|
# | Third line"|
# |------ 80 dashes ----|
#
# Please mention that
# - the '"' preserves the indentation.
# - it is easy to write the script lines to get a fine indentation,
# if the value starts at the beginning of a new line
# - the '"' is printed
# - there are the least or no problems with characters like "-#$"
#
#
# Variant 2 (grep the messages from the protocol is easy):
# Several lines with indentation + auxiliary character (".")
# at the (non tab or space) beginning of every message line
# script: |let $message= . Testcase 3.1 : Ensure that Pi is not an|
# | . integer number.|
# | . Third line;
# protocol: |. Testcase 3.1 : Ensure that Pi is not an|
# |. integer number.|
# |. Third line|
# |------ 80 dashes ----|
# Please mention that
# - the auxiliary character preserves the indentation.
# - it is easy to write the script lines to get a fine indentation
# - the auxiliary character is printed
# - it is recommended to use "." as auxiliary character
# - auxiliary characters like "-'$#" cause problems
#
#
#
# Bad variant1: Several lines with lost indentation
# script: |let $message= Here is message line 1
# | message line 2;
# protocol: |Here is message line 1|
# |message line 2|
# |------ 80 dashes ----|
# Please mention, that the leading spaces of the message lines disappeared.
#
# Bad variant2: Several lines leading to a syntax error, because of "-"
# script: |let $message= - This is a message
# | - with a second and
# | - third line;
# protocol: | - third line;;
# |ERROR 42000: You have an error ... near '- third line'
# + several following errors
#
#
--disable_query_log
eval SET @utf8_message = CONVERT('$message' using utf8);
select @utf8_message as ""
union
select repeat(CONVERT('-' using utf8),80);
--enable_query_log
......@@ -5,10 +5,13 @@
# same name.
use File::Basename;
use IO::File();
use strict;
sub collect_test_cases ($);
sub collect_one_test_case ($$$$$$);
sub collect_one_test_case ($$$$$$$);
sub mtr_options_from_test_file($$);
##############################################################################
#
......@@ -37,44 +40,114 @@ sub collect_test_cases ($) {
opendir(TESTDIR, $testdir) or mtr_error("Can't open dir \"$testdir\": $!");
# ----------------------------------------------------------------------
# Disable some tests listed in disabled.def
# ----------------------------------------------------------------------
my %disabled;
if ( open(DISABLED, "$testdir/disabled.def" ) )
{
while ( <DISABLED> )
{
chomp;
if ( /^\s*(\S+)\s*:\s*(.*?)\s*$/ )
{
$disabled{$1}= $2;
}
}
close DISABLED;
}
if ( @::opt_cases )
{
foreach my $tname ( @::opt_cases ) { # Run in specified order, no sort
$tname= basename($tname, ".test");
my $elem= "$tname.test";
if ( ! -f "$testdir/$elem")
my $elem= undef;
my $component_id= undef;
# Get rid of directory part (path). Leave the extension since it is used
# to understand type of the test.
$tname = basename($tname);
# Check if the extenstion has been specified.
if ( mtr_match_extension($tname, "test") )
{
$elem= $tname;
$tname=~ s/\.test$//;
$component_id= 'mysqld';
}
elsif ( mtr_match_extension($tname, "imtest") )
{
$elem= $tname;
$tname =~ s/\.imtest$//;
$component_id= 'im';
}
# If target component is known, check that the specified test case
# exists.
#
# Otherwise, try to guess the target component.
if ( $component_id )
{
if ( ! -f "$testdir/$elem")
{
mtr_error("Test case $tname ($testdir/$elem) is not found");
}
}
else
{
mtr_error("Test case $tname ($testdir/$elem) is not found");
my $mysqld_test_exists = -f "$testdir/$tname.test";
my $im_test_exists = -f "$testdir/$tname.imtest";
if ( $mysqld_test_exists and $im_test_exists )
{
mtr_error("Ambiguous test case name ($tname)");
}
elsif ( ! $mysqld_test_exists and ! $im_test_exists )
{
mtr_error("Test case $tname is not found");
}
elsif ( $mysqld_test_exists )
{
$elem= "$tname.test";
$component_id= 'mysqld';
}
elsif ( $im_test_exists )
{
$elem= "$tname.imtest";
$component_id= 'im';
}
}
collect_one_test_case($testdir,$resdir,$tname,$elem,$cases,{});
collect_one_test_case($testdir,$resdir,$tname,$elem,$cases,\%disabled,
$component_id);
}
closedir TESTDIR;
}
else
{
# ----------------------------------------------------------------------
# Disable some tests listed in disabled.def
# ----------------------------------------------------------------------
my %disabled;
if ( open(DISABLED, "$testdir/disabled.def" ) )
{
while ( <DISABLED> )
foreach my $elem ( sort readdir(TESTDIR) ) {
my $component_id= undef;
my $tname= undef;
if ($tname= mtr_match_extension($elem, 'test'))
{
chomp;
if ( /^\s*(\S+)\s*:\s*(.*?)\s*$/ )
{
$disabled{$1}= $2;
}
$component_id = 'mysqld';
}
elsif ($tname= mtr_match_extension($elem, 'imtest'))
{
$component_id = 'im';
}
else
{
next;
}
close DISABLED;
}
foreach my $elem ( sort readdir(TESTDIR) ) {
my $tname= mtr_match_extension($elem,"test");
next if ! defined $tname;
next if $::opt_do_test and ! defined mtr_match_prefix($elem,$::opt_do_test);
collect_one_test_case($testdir,$resdir,$tname,$elem,$cases,\%disabled);
collect_one_test_case($testdir,$resdir,$tname,$elem,$cases,\%disabled,
$component_id);
}
closedir TESTDIR;
}
......@@ -84,34 +157,77 @@ sub collect_test_cases ($) {
if ( $::opt_reorder )
{
@$cases = sort {
if ( ! $a->{'master_restart'} and ! $b->{'master_restart'} )
{
return $a->{'name'} cmp $b->{'name'};
}
if ( $a->{'master_restart'} and $b->{'master_restart'} )
my %sort_criteria;
# Make a mapping of test name to a string that represents how that test
# should be sorted among the other tests. Put the most important criterion
# first, then a sub-criterion, then sub-sub-criterion, et c.
foreach my $tinfo (@$cases)
{
my @criteria = ();
# Look for tests that muct be in run in a defined order
# that is defined by test having the same name except for
# the ending digit
# Put variables into hash
my $test_name= $tinfo->{'name'};
my $depend_on_test_name;
if ( $test_name =~ /^([\D]+)([0-9]{1})$/ )
{
my $cmp= mtr_cmp_opts($a->{'master_opt'}, $b->{'master_opt'});
if ( $cmp == 0 )
{
return $a->{'name'} cmp $b->{'name'};
}
else
{
return $cmp;
}
my $base_name= $1;
my $idx= $2;
mtr_verbose("$test_name => $base_name idx=$idx");
if ( $idx > 1 )
{
$idx-= 1;
$base_name= "$base_name$idx";
mtr_verbose("New basename $base_name");
}
foreach my $tinfo2 (@$cases)
{
if ( $tinfo2->{'name'} eq $base_name )
{
mtr_verbose("found dependent test $tinfo2->{'name'}");
$depend_on_test_name=$base_name;
}
}
}
if ( $a->{'master_restart'} )
if ( defined $depend_on_test_name )
{
return 1; # Is greater
mtr_verbose("Giving $test_name same critera as $depend_on_test_name");
$sort_criteria{$test_name} = $sort_criteria{$depend_on_test_name};
}
else
{
return -1; # Is less
#
# Append the criteria for sorting, in order of importance.
#
push(@criteria, "ndb=" . ($tinfo->{'ndb_test'} ? "1" : "0"));
push(@criteria, "restart=" . ($tinfo->{'master_restart'} ? "1" : "0"));
# Group test with equal options together.
# Ending with "~" makes empty sort later than filled
push(@criteria, join("!", sort @{$tinfo->{'master_opt'}}) . "~");
$sort_criteria{$test_name} = join(" ", @criteria);
}
}
@$cases = sort {
$sort_criteria{$a->{'name'}} . $a->{'name'} cmp
$sort_criteria{$b->{'name'}} . $b->{'name'}; } @$cases;
if ( $::opt_script_debug )
{
# For debugging the sort-order
foreach my $tinfo (@$cases)
{
print("$sort_criteria{$tinfo->{'name'}} -> \t$tinfo->{'name'}\n");
}
} @$cases;
}
}
return $cases;
......@@ -125,13 +241,14 @@ sub collect_test_cases ($) {
##############################################################################
sub collect_one_test_case($$$$$$) {
sub collect_one_test_case($$$$$$$) {
my $testdir= shift;
my $resdir= shift;
my $tname= shift;
my $elem= shift;
my $cases= shift;
my $disabled=shift;
my $component_id= shift;
my $path= "$testdir/$elem";
......@@ -151,6 +268,7 @@ sub collect_one_test_case($$$$$$) {
my $tinfo= {};
$tinfo->{'name'}= $tname;
$tinfo->{'result_file'}= "$resdir/$tname.result";
$tinfo->{'component_id'} = $component_id;
push(@$cases, $tinfo);
if ( $::opt_skip_test and defined mtr_match_prefix($tname,$::opt_skip_test) )
......@@ -166,53 +284,61 @@ sub collect_one_test_case($$$$$$) {
$tinfo->{'path'}= $path;
$tinfo->{'timezone'}= "GMT-3"; # for UNIX_TIMESTAMP tests to work
$tinfo->{'slave_num'}= 0; # Default, no slave
if ( defined mtr_match_prefix($tname,"rpl") )
{
if ( $::opt_skip_rpl )
{
$tinfo->{'skip'}= 1;
$tinfo->{'comment'}= "No replication tests(--skip-rpl)";
return;
}
$tinfo->{'slave_num'}= 1; # Default, use one slave
# FIXME currently we always restart slaves
$tinfo->{'slave_restart'}= 1;
$tinfo->{'slave_num'}= 1; # Default for rpl* tests, use one slave
if ( $tname eq 'rpl_failsafe' or $tname eq 'rpl_chain_temp_table' )
{
# $tinfo->{'slave_num'}= 3; # Not 3 ? Check old code, strange
# $tinfo->{'slave_num'}= 3; # Not 3 ? Check old code, strange
}
}
if ( defined mtr_match_prefix($tname,"federated") )
{
$tinfo->{'slave_num'}= 1; # Default, use one slave
# FIXME currently we always restart slaves
$tinfo->{'slave_restart'}= 1;
# Default, federated uses the first slave as it's federated database
$tinfo->{'slave_num'}= 1;
}
# Cluster is needed by test case if testname contains ndb
if ( defined mtr_match_substring($tname,"ndb") )
if ( $::opt_with_ndbcluster or defined mtr_match_substring($tname,"ndb") )
{
# This is an ndb test or all tests should be run with ndb cluster started
$tinfo->{'ndb_test'}= 1;
if ( $::opt_skip_ndbcluster )
{
# Skip all ndb tests
# All ndb test's should be skipped
$tinfo->{'skip'}= 1;
$tinfo->{'comment'}= "No ndbcluster test(--skip-ndbcluster)";
return;
}
if ( ! $::opt_with_ndbcluster )
if ( ! $::opt_ndbcluster_supported )
{
# Ndb is not supported, skip them
$tinfo->{'skip'}= 1;
$tinfo->{'comment'}= "No ndbcluster support";
return;
}
}
else
{
# This is not a ndb test
$tinfo->{'ndb_test'}= 0;
if ( $::opt_with_ndbcluster_only )
{
# Only the ndb test should be run, all other should be skipped
$tinfo->{'skip'}= 1;
$tinfo->{'comment'}= "Only ndbcluster tests(--with-ndbcluster-only)";
return;
}
}
# FIXME what about embedded_server + ndbcluster, skip ?!
......@@ -223,6 +349,7 @@ sub collect_one_test_case($$$$$$) {
my $master_sh= "$testdir/$tname-master.sh";
my $slave_sh= "$testdir/$tname-slave.sh";
my $disabled_file= "$testdir/$tname.disabled";
my $im_opt_file= "$testdir/$tname-im.opt";
$tinfo->{'master_opt'}= [];
$tinfo->{'slave_opt'}= [];
......@@ -255,11 +382,6 @@ sub collect_one_test_case($$$$$$) {
if ( defined $value )
{
$tinfo->{'result_file'}= "r/$value.result";
if ( $::opt_result_ext and $::opt_record or
-f "$tinfo->{'result_file'}$::opt_result_ext")
{
$tinfo->{'result_file'}.= $::opt_result_ext;
}
$tinfo->{'master_restart'}= 0;
last MASTER_OPT;
}
......@@ -303,6 +425,8 @@ sub collect_one_test_case($$$$$$) {
if ( $::glob_win32_perl )
{
$tinfo->{'skip'}= 1;
$tinfo->{'comment'}= "No tests with sh scripts on Windows";
return;
}
else
{
......@@ -316,6 +440,8 @@ sub collect_one_test_case($$$$$$) {
if ( $::glob_win32_perl )
{
$tinfo->{'skip'}= 1;
$tinfo->{'comment'}= "No tests with sh scripts on Windows";
return;
}
else
{
......@@ -324,29 +450,166 @@ sub collect_one_test_case($$$$$$) {
}
}
if ( -f $im_opt_file )
{
$tinfo->{'im_opts'} = mtr_get_opts_from_file($im_opt_file);
}
else
{
$tinfo->{'im_opts'} = [];
}
# FIXME why this late?
my $marked_as_disabled= 0;
if ( $disabled->{$tname} )
{
$tinfo->{'skip'}= 1;
$tinfo->{'disable'}= 1; # Sub type of 'skip'
$tinfo->{'comment'}= $disabled->{$tname} if $disabled->{$tname};
$marked_as_disabled= 1;
$tinfo->{'comment'}= $disabled->{$tname};
}
if ( -f $disabled_file )
{
$tinfo->{'skip'}= 1;
$tinfo->{'disable'}= 1; # Sub type of 'skip'
$marked_as_disabled= 1;
$tinfo->{'comment'}= mtr_fromfile($disabled_file);
}
# If test was marked as disabled, either opt_enable_disabled is off and then
# we skip this test, or it is on and then we run this test but warn
if ( $marked_as_disabled )
{
if ( $::opt_enable_disabled )
{
$tinfo->{'dont_skip_though_disabled'}= 1;
}
else
{
$tinfo->{'skip'}= 1;
$tinfo->{'disable'}= 1; # Sub type of 'skip'
return;
}
}
if ( $component_id eq 'im' )
{
if ( $::glob_use_embedded_server )
{
$tinfo->{'skip'}= 1;
$tinfo->{'comment'}= "No IM with embedded server";
return;
}
elsif ( $::opt_ps_protocol )
{
$tinfo->{'skip'}= 1;
$tinfo->{'comment'}= "No IM with --ps-protocol";
return;
}
elsif ( $::opt_skip_im )
{
$tinfo->{'skip'}= 1;
$tinfo->{'comment'}= "No IM tests(--skip-im)";
return;
}
}
else
{
mtr_options_from_test_file($tinfo,"$testdir/${tname}.test");
if ( $tinfo->{'big_test'} and ! $::opt_big_test )
{
$tinfo->{'skip'}= 1;
$tinfo->{'comment'}= "Test need 'big-test' option";
return;
}
if ( $tinfo->{'ndb_extra'} and ! $::opt_ndb_extra_test )
{
$tinfo->{'skip'}= 1;
$tinfo->{'comment'}= "Test need 'ndb_extra' option";
return;
}
if ( $tinfo->{'require_manager'} )
{
$tinfo->{'skip'}= 1;
$tinfo->{'comment'}= "Test need the _old_ manager(to be removed)";
return;
}
if ( defined $tinfo->{'binlog_format'} and
! ( $tinfo->{'binlog_format'} eq $::used_binlog_format ) )
{
$tinfo->{'skip'}= 1;
$tinfo->{'comment'}= "Not running with binlog format '$tinfo->{'binlog_format'}'";
return;
}
if ( $tinfo->{'need_debug'} && ! $::debug_compiled_binaries )
{
$tinfo->{'skip'}= 1;
$tinfo->{'comment'}= "Test need debug binaries";
return;
}
}
# We can't restart a running server that may be in use
if ( $::glob_use_running_server and
( $tinfo->{'master_restart'} or $tinfo->{'slave_restart'} ) )
{
$tinfo->{'skip'}= 1;
$tinfo->{'comment'}= "Can't restart a running server";
return;
}
}
# List of tags in the .test files that if found should set
# the specified value in "tinfo"
our @tags=
(
["include/have_innodb.inc", "innodb_test", 1],
["include/have_binlog_format_row.inc", "binlog_format", "row"],
["include/have_binlog_format_statement.inc", "binlog_format", "stmt"],
["include/big_test.inc", "big_test", 1],
["include/have_debug.inc", "need_debug", 1],
["include/have_ndb_extra.inc", "ndb_extra", 1],
["require_manager", "require_manager", 1],
);
sub mtr_options_from_test_file($$) {
my $tinfo= shift;
my $file= shift;
#mtr_verbose("$file");
my $F= IO::File->new($file) or mtr_error("can't open file \"$file\": $!");
while ( my $line= <$F> )
{
next if ( $line !~ /^--/ );
# Match this line against tag in "tags" array
foreach my $tag (@tags)
{
if ( index($line, $tag->[0]) >= 0 )
{
# Tag matched, assign value to "tinfo"
$tinfo->{"$tag->[1]"}= $tag->[2];
}
}
# If test sources another file, open it as well
if ( $line =~ /^\-\-([[:space:]]*)source(.*)$/ )
{
my $value= $2;
$value =~ s/^\s+//; # Remove leading space
$value =~ s/[[:space:]]+$//; # Remove ending space
my $sourced_file= "$::glob_mysql_test_dir/$value";
mtr_options_from_test_file($tinfo, $sourced_file);
}
}
}
1;
# -*- 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;
# Private IM-related operations.
sub mtr_im_kill_process ($$$$);
sub mtr_im_load_pids ($);
sub mtr_im_terminate ($);
sub mtr_im_check_alive ($);
sub mtr_im_check_main_alive ($);
sub mtr_im_check_angel_alive ($);
sub mtr_im_check_mysqlds_alive ($);
sub mtr_im_check_mysqld_alive ($);
sub mtr_im_cleanup ($);
sub mtr_im_rm_file ($);
sub mtr_im_errlog ($);
sub mtr_im_kill ($);
sub mtr_im_wait_for_connection ($$$);
sub mtr_im_wait_for_mysqld($$$);
# Public IM-related operations.
sub mtr_im_start ($$);
sub mtr_im_stop ($);
##############################################################################
#
# Private operations.
#
##############################################################################
sub mtr_im_kill_process ($$$$) {
my $pid_lst= shift;
my $signal= shift;
my $total_retries= shift;
my $timeout= shift;
my %pids;
foreach my $pid ( @{$pid_lst} )
{
$pids{$pid}= 1;
}
for ( my $cur_attempt= 1; $cur_attempt <= $total_retries; ++$cur_attempt )
{
foreach my $pid ( keys %pids )
{
mtr_debug("Sending $signal to $pid...");
kill($signal, $pid);
unless ( kill (0, $pid) )
{
mtr_debug("Process $pid died.");
delete $pids{$pid};
}
}
return if scalar keys %pids == 0;
mtr_debug("Sleeping $timeout second(s) waiting for processes to die...");
sleep($timeout);
}
mtr_debug("Process(es) " .
join(' ', keys %pids) .
" is still alive after $total_retries " .
"of sending signal $signal.");
}
###########################################################################
sub mtr_im_load_pids($) {
my $im= shift;
mtr_debug("Loading PID files...");
# Obtain mysqld-process pids.
my $instances = $im->{'instances'};
for ( my $idx= 0; $idx < 2; ++$idx )
{
mtr_debug("IM-guarded mysqld[$idx] PID file: '" .
$instances->[$idx]->{'path_pid'} . "'.");
my $mysqld_pid;
if ( -r $instances->[$idx]->{'path_pid'} )
{
$mysqld_pid= mtr_get_pid_from_file($instances->[$idx]->{'path_pid'});
mtr_debug("IM-guarded mysqld[$idx] PID: $mysqld_pid.");
}
else
{
$mysqld_pid= undef;
mtr_debug("IM-guarded mysqld[$idx]: no PID file.");
}
$instances->[$idx]->{'pid'}= $mysqld_pid;
}
# Re-read Instance Manager PIDs from the file, since during tests Instance
# Manager could have been restarted, so its PIDs could have been changed.
# - IM-main
mtr_debug("IM-main PID file: '$im->{path_pid}'.");
if ( -f $im->{'path_pid'} )
{
$im->{'pid'} =
mtr_get_pid_from_file($im->{'path_pid'});
mtr_debug("IM-main PID: $im->{pid}.");
}
else
{
mtr_debug("IM-main: no PID file.");
$im->{'pid'}= undef;
}
# - IM-angel
mtr_debug("IM-angel PID file: '$im->{path_angel_pid}'.");
if ( -f $im->{'path_angel_pid'} )
{
$im->{'angel_pid'} =
mtr_get_pid_from_file($im->{'path_angel_pid'});
mtr_debug("IM-angel PID: $im->{'angel_pid'}.");
}
else
{
mtr_debug("IM-angel: no PID file.");
$im->{'angel_pid'} = undef;
}
}
###########################################################################
sub mtr_im_terminate($) {
my $im= shift;
# Load pids from pid-files. We should do it first of all, because IM deletes
# them on shutdown.
mtr_im_load_pids($im);
mtr_debug("Shutting Instance Manager down...");
# Ignoring SIGCHLD so that all children could rest in peace.
start_reap_all();
# Send SIGTERM to IM-main.
if ( defined $im->{'pid'} )
{
mtr_debug("IM-main pid: $im->{pid}.");
mtr_debug("Stopping IM-main...");
mtr_im_kill_process([ $im->{'pid'} ], 'TERM', 10, 1);
}
else
{
mtr_debug("IM-main pid: n/a.");
}
# If IM-angel was alive, wait for it to die.
if ( defined $im->{'angel_pid'} )
{
mtr_debug("IM-angel pid: $im->{'angel_pid'}.");
mtr_debug("Waiting for IM-angel to die...");
my $total_attempts= 10;
for ( my $cur_attempt=1; $cur_attempt <= $total_attempts; ++$cur_attempt )
{
unless ( kill (0, $im->{'angel_pid'}) )
{
mtr_debug("IM-angel died.");
last;
}
sleep(1);
}
}
else
{
mtr_debug("IM-angel pid: n/a.");
}
stop_reap_all();
# Re-load PIDs.
mtr_im_load_pids($im);
}
###########################################################################
sub mtr_im_check_alive($) {
my $im= shift;
mtr_debug("Checking whether IM-components are alive...");
return 1 if mtr_im_check_main_alive($im);
return 1 if mtr_im_check_angel_alive($im);
return 1 if mtr_im_check_mysqlds_alive($im);
return 0;
}
###########################################################################
sub mtr_im_check_main_alive($) {
my $im= shift;
# Check that the process, that we know to be IM's, is dead.
if ( defined $im->{'pid'} )
{
if ( kill (0, $im->{'pid'}) )
{
mtr_debug("IM-main (PID: $im->{pid}) is alive.");
return 1;
}
else
{
mtr_debug("IM-main (PID: $im->{pid}) is dead.");
}
}
else
{
mtr_debug("No PID file for IM-main.");
}
# Check that IM does not accept client connections.
if ( mtr_ping_port($im->{'port'}) )
{
mtr_debug("IM-main (port: $im->{port}) " .
"is accepting connections.");
mtr_im_errlog("IM-main is accepting connections on port " .
"$im->{port}, but there is no " .
"process information.");
return 1;
}
else
{
mtr_debug("IM-main (port: $im->{port}) " .
"does not accept connections.");
return 0;
}
}
###########################################################################
sub mtr_im_check_angel_alive($) {
my $im= shift;
# Check that the process, that we know to be the Angel, is dead.
if ( defined $im->{'angel_pid'} )
{
if ( kill (0, $im->{'angel_pid'}) )
{
mtr_debug("IM-angel (PID: $im->{angel_pid}) is alive.");
return 1;
}
else
{
mtr_debug("IM-angel (PID: $im->{angel_pid}) is dead.");
return 0;
}
}
else
{
mtr_debug("No PID file for IM-angel.");
return 0;
}
}
###########################################################################
sub mtr_im_check_mysqlds_alive($) {
my $im= shift;
mtr_debug("Checking for IM-guarded mysqld instances...");
my $instances = $im->{'instances'};
for ( my $idx= 0; $idx < 2; ++$idx )
{
mtr_debug("Checking mysqld[$idx]...");
return 1
if mtr_im_check_mysqld_alive($instances->[$idx]);
}
}
###########################################################################
sub mtr_im_check_mysqld_alive($) {
my $mysqld_instance= shift;
# Check that the process is dead.
if ( defined $mysqld_instance->{'pid'} )
{
if ( kill (0, $mysqld_instance->{'pid'}) )
{
mtr_debug("Mysqld instance (PID: $mysqld_instance->{pid}) is alive.");
return 1;
}
else
{
mtr_debug("Mysqld instance (PID: $mysqld_instance->{pid}) is dead.");
}
}
else
{
mtr_debug("No PID file for mysqld instance.");
}
# Check that mysqld does not accept client connections.
if ( mtr_ping_port($mysqld_instance->{'port'}) )
{
mtr_debug("Mysqld instance (port: $mysqld_instance->{port}) " .
"is accepting connections.");
mtr_im_errlog("Mysqld is accepting connections on port " .
"$mysqld_instance->{port}, but there is no " .
"process information.");
return 1;
}
else
{
mtr_debug("Mysqld instance (port: $mysqld_instance->{port}) " .
"does not accept connections.");
return 0;
}
}
###########################################################################
sub mtr_im_cleanup($) {
my $im= shift;
mtr_im_rm_file($im->{'path_pid'});
mtr_im_rm_file($im->{'path_sock'});
mtr_im_rm_file($im->{'path_angel_pid'});
for ( my $idx= 0; $idx < 2; ++$idx )
{
mtr_im_rm_file($im->{'instances'}->[$idx]->{'path_pid'});
mtr_im_rm_file($im->{'instances'}->[$idx]->{'path_sock'});
}
}
###########################################################################
sub mtr_im_rm_file($)
{
my $file_path= shift;
if ( -f $file_path )
{
mtr_debug("Removing '$file_path'...");
unless ( unlink($file_path) )
{
mtr_warning("Can not remove '$file_path'.")
}
}
else
{
mtr_debug("File '$file_path' does not exist already.");
}
}
###########################################################################
sub mtr_im_errlog($) {
my $msg= shift;
# Complain in error log so that a warning will be shown.
#
# TODO: unless BUG#20761 is fixed, we will print the warning to stdout, so
# that it can be seen on console and does not produce pushbuild error.
# my $errlog= "$opt_vardir/log/mysql-test-run.pl.err";
#
# open (ERRLOG, ">>$errlog") ||
# mtr_error("Can not open error log ($errlog)");
#
# my $ts= localtime();
# print ERRLOG
# "Warning: [$ts] $msg\n";
#
# close ERRLOG;
my $ts= localtime();
print "Warning: [$ts] $msg\n";
}
###########################################################################
sub mtr_im_kill($) {
my $im= shift;
# Re-load PIDs. That can be useful because some processes could have been
# restarted.
mtr_im_load_pids($im);
# Ignoring SIGCHLD so that all children could rest in peace.
start_reap_all();
# Kill IM-angel first of all.
if ( defined $im->{'angel_pid'} )
{
mtr_debug("Killing IM-angel (PID: $im->{angel_pid})...");
mtr_im_kill_process([ $im->{'angel_pid'} ], 'KILL', 10, 1)
}
else
{
mtr_debug("IM-angel is dead.");
}
# Re-load PIDs again.
mtr_im_load_pids($im);
# Kill IM-main.
if ( defined $im->{'pid'} )
{
mtr_debug("Killing IM-main (PID: $im->pid})...");
mtr_im_kill_process([ $im->{'pid'} ], 'KILL', 10, 1);
}
else
{
mtr_debug("IM-main is dead.");
}
# Re-load PIDs again.
mtr_im_load_pids($im);
# Kill guarded mysqld instances.
my @mysqld_pids;
mtr_debug("Collecting PIDs of mysqld instances to kill...");
for ( my $idx= 0; $idx < 2; ++$idx )
{
my $pid= $im->{'instances'}->[$idx]->{'pid'};
unless ( defined $pid )
{
next;
}
mtr_debug(" - IM-guarded mysqld[$idx] PID: $pid.");
push (@mysqld_pids, $pid);
}
if ( scalar @mysqld_pids > 0 )
{
mtr_debug("Killing IM-guarded mysqld instances...");
mtr_im_kill_process(\@mysqld_pids, 'KILL', 10, 1);
}
# That's all.
stop_reap_all();
}
##############################################################################
sub mtr_im_wait_for_connection($$$) {
my $im= shift;
my $total_attempts= shift;
my $connect_timeout= shift;
mtr_debug("Waiting for IM on port $im->{port} " .
"to start accepting connections...");
for ( my $cur_attempt= 1; $cur_attempt <= $total_attempts; ++$cur_attempt )
{
mtr_debug("Trying to connect to IM ($cur_attempt of $total_attempts)...");
if ( mtr_ping_port($im->{'port'}) )
{
mtr_debug("IM is accepting connections " .
"on port $im->{port}.");
return 1;
}
mtr_debug("Sleeping $connect_timeout...");
sleep($connect_timeout);
}
mtr_debug("IM does not accept connections " .
"on port $im->{port} after " .
($total_attempts * $connect_timeout) . " seconds.");
return 0;
}
##############################################################################
sub mtr_im_wait_for_mysqld($$$) {
my $mysqld= shift;
my $total_attempts= shift;
my $connect_timeout= shift;
mtr_debug("Waiting for IM-guarded mysqld on port $mysqld->{port} " .
"to start accepting connections...");
for ( my $cur_attempt= 1; $cur_attempt <= $total_attempts; ++$cur_attempt )
{
mtr_debug("Trying to connect to mysqld " .
"($cur_attempt of $total_attempts)...");
if ( mtr_ping_port($mysqld->{'port'}) )
{
mtr_debug("Mysqld is accepting connections " .
"on port $mysqld->{port}.");
return 1;
}
mtr_debug("Sleeping $connect_timeout...");
sleep($connect_timeout);
}
mtr_debug("Mysqld does not accept connections " .
"on port $mysqld->{port} after " .
($total_attempts * $connect_timeout) . " seconds.");
return 0;
}
##############################################################################
#
# Public operations.
#
##############################################################################
sub mtr_im_start($$) {
my $im = shift;
my $opts = shift;
mtr_debug("Starting Instance Manager...");
my $args;
mtr_init_args(\$args);
mtr_add_arg($args, "--defaults-file=%s", $im->{'defaults_file'});
foreach my $opt ( @{$opts} )
{
mtr_add_arg($args, $opt);
}
$im->{'pid'} =
mtr_spawn(
$::exe_im, # path to the executable
$args, # cmd-line args
'', # stdin
$im->{'path_log'}, # stdout
$im->{'path_err'}, # stderr
'', # pid file path (not used)
{ append_log_file => 1 } # append log files
);
unless ( $im->{'pid'} )
{
mtr_error('Could not start Instance Manager.')
}
# Instance Manager can be run in daemon mode. In this case, it creates
# several processes and the parent process, created by mtr_spawn(), exits just
# after start. So, we have to obtain Instance Manager PID from the PID file.
mtr_debug("Waiting for IM to create PID file (" .
"path: '$im->{path_pid}'; " .
"timeout: $im->{start_timeout})...");
unless ( sleep_until_file_created($im->{'path_pid'},
$im->{'start_timeout'},
-1) ) # real PID is still unknown
{
mtr_debug("IM has not created PID file in $im->{start_timeout} secs.");
mtr_debug("Aborting test suite...");
mtr_kill_leftovers();
mtr_report("IM has not created PID file in $im->{start_timeout} secs.");
return 0;
}
$im->{'pid'}= mtr_get_pid_from_file($im->{'path_pid'});
mtr_debug("Instance Manager started. PID: $im->{pid}.");
# Wait until we can connect to IM.
my $IM_CONNECT_TIMEOUT= 30;
unless ( mtr_im_wait_for_connection($im,
$IM_CONNECT_TIMEOUT, 1) )
{
mtr_debug("Can not connect to Instance Manager " .
"in $IM_CONNECT_TIMEOUT seconds after start.");
mtr_debug("Aborting test suite...");
mtr_kill_leftovers();
mtr_report("Can not connect to Instance Manager " .
"in $IM_CONNECT_TIMEOUT seconds after start.");
return 0;
}
# Wait for IM to start guarded instances:
# - wait for PID files;
mtr_debug("Waiting for guarded mysqlds instances to create PID files...");
for ( my $idx= 0; $idx < 2; ++$idx )
{
my $mysqld= $im->{'instances'}->[$idx];
if ( exists $mysqld->{'nonguarded'} )
{
next;
}
mtr_debug("Waiting for mysqld[$idx] to create PID file (" .
"path: '$mysqld->{path_pid}'; " .
"timeout: $mysqld->{start_timeout})...");
unless ( sleep_until_file_created($mysqld->{'path_pid'},
$mysqld->{'start_timeout'},
-1) ) # real PID is still unknown
{
mtr_debug("mysqld[$idx] has not created PID file in " .
"$mysqld->{start_timeout} secs.");
mtr_debug("Aborting test suite...");
mtr_kill_leftovers();
mtr_report("mysqld[$idx] has not created PID file in " .
"$mysqld->{start_timeout} secs.");
return 0;
}
mtr_debug("PID file for mysqld[$idx] ($mysqld->{path_pid} created.");
}
# Wait until we can connect to guarded mysqld-instances
# (in other words -- wait for IM to start guarded instances).
mtr_debug("Waiting for guarded mysqlds to start accepting connections...");
for ( my $idx= 0; $idx < 2; ++$idx )
{
my $mysqld= $im->{'instances'}->[$idx];
if ( exists $mysqld->{'nonguarded'} )
{
next;
}
mtr_debug("Waiting for mysqld[$idx] to accept connection...");
unless ( mtr_im_wait_for_mysqld($mysqld, 30, 1) )
{
mtr_debug("Can not connect to mysqld[$idx] " .
"in $IM_CONNECT_TIMEOUT seconds after start.");
mtr_debug("Aborting test suite...");
mtr_kill_leftovers();
mtr_report("Can not connect to mysqld[$idx] " .
"in $IM_CONNECT_TIMEOUT seconds after start.");
return 0;
}
mtr_debug("mysqld[$idx] started.");
}
mtr_debug("Instance Manager and its components are up and running.");
return 1;
}
##############################################################################
sub mtr_im_stop($) {
my $im= shift;
mtr_debug("Stopping Instance Manager...");
# Try graceful shutdown.
mtr_im_terminate($im);
# Check that all processes died.
unless ( mtr_im_check_alive($im) )
{
mtr_debug("Instance Manager has been stopped successfully.");
mtr_im_cleanup($im);
return 1;
}
# Instance Manager don't want to die. We should kill it.
mtr_im_errlog("Instance Manager did not shutdown gracefully.");
mtr_im_kill($im);
# Check again that all IM-related processes have been killed.
my $im_is_alive= mtr_im_check_alive($im);
mtr_im_cleanup($im);
if ( $im_is_alive )
{
mtr_debug("Can not kill Instance Manager or its children.");
return 0;
}
mtr_debug("Instance Manager has been killed successfully.");
return 1;
}
###########################################################################
1;
......@@ -11,6 +11,8 @@ sub mtr_get_opts_from_file ($);
sub mtr_fromfile ($);
sub mtr_tofile ($@);
sub mtr_tonewfile($@);
sub mtr_lastlinefromfile($);
sub mtr_appendfile_to_file ($$);
##############################################################################
#
......@@ -19,13 +21,39 @@ sub mtr_tonewfile($@);
##############################################################################
sub mtr_get_pid_from_file ($) {
my $file= shift;
my $pid_file_path= shift;
my $TOTAL_ATTEMPTS= 30;
my $timeout= 1;
open(FILE,"<",$file) or mtr_error("can't open file \"$file\": $!");
my $pid= <FILE>;
chomp($pid);
close FILE;
return $pid;
# 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 ($) {
......@@ -113,6 +141,20 @@ sub mtr_fromfile ($) {
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;
......@@ -129,5 +171,17 @@ sub mtr_tonewfile ($@) {
close FILE;
}
sub mtr_appendfile_to_file ($$) {
my $from_file= shift;
my $to_file= shift;
open(TOFILE,">>",$to_file) or mtr_error("can't open file \"$to_file\": $!");
open(FROMFILE,"<",$from_file)
or mtr_error("can't open file \"$from_file\": $!");
print TOFILE while (<FROMFILE>);
close FROMFILE;
close TOFILE;
}
1;
......@@ -9,9 +9,10 @@ use strict;
sub mtr_full_hostname ();
sub mtr_short_hostname ();
sub mtr_init_args ($);
sub mtr_add_arg ($$);
sub mtr_add_arg ($$@);
sub mtr_path_exists(@);
sub mtr_script_exists(@);
sub mtr_file_exists(@);
sub mtr_exe_exists(@);
sub mtr_copy_dir($$);
sub mtr_same_opts($$);
......@@ -54,7 +55,7 @@ sub mtr_init_args ($) {
$$args = []; # Empty list
}
sub mtr_add_arg ($$) {
sub mtr_add_arg ($$@) {
my $args= shift;
my $format= shift;
my @fargs = @_;
......@@ -101,6 +102,14 @@ sub mtr_script_exists (@) {
}
}
sub mtr_file_exists (@) {
foreach my $path ( @_ )
{
return $path if -e $path;
}
return "";
}
sub mtr_exe_exists (@) {
my @path= @_;
map {$_.= ".exe"} @path if $::glob_win32;
......@@ -125,19 +134,30 @@ sub mtr_exe_exists (@) {
}
}
sub mtr_copy_dir($$) {
my $srcdir= shift;
my $dstdir= shift;
my $from_dir= shift;
my $to_dir= shift;
# Create destination directory
mkpath($dstdir);
find(\&mtr_copy_one_file, $dstdir);
}
# mtr_verbose("Copying from $from_dir to $to_dir");
mkpath("$to_dir");
opendir(DIR, "$from_dir")
or mtr_error("Can't find $from_dir$!");
for(readdir(DIR)) {
next if "$_" eq "." or "$_" eq "..";
if ( -d "$from_dir/$_" )
{
mtr_copy_dir("$from_dir/$_", "$to_dir/$_");
next;
}
copy("$from_dir/$_", "$to_dir/$_");
}
closedir(DIR);
sub mtr_copy_one_file {
print $File::Find::name, "\n";
}
sub mtr_same_opts ($$) {
my $l1= shift;
my $l2= shift;
......
......@@ -4,7 +4,6 @@
# and is part of the translation of the Bourne shell script with the
# same name.
#use Carp qw(cluck);
use Socket;
use Errno;
use strict;
......@@ -14,12 +13,17 @@ use POSIX 'WNOHANG';
sub mtr_run ($$$$$$;$);
sub mtr_spawn ($$$$$$;$);
sub mtr_stop_mysqld_servers ($);
sub mtr_check_stop_servers ($);
sub mtr_kill_leftovers ();
sub mtr_wait_blocking ($);
sub mtr_record_dead_children ();
sub mtr_ndbmgm_start($$);
sub mtr_mysqladmin_start($$$);
sub mtr_exit ($);
sub sleep_until_file_created ($$$);
sub mtr_kill_processes ($);
sub mtr_ping_with_timeout($);
sub mtr_ping_port ($);
# static in C
sub spawn_impl ($$$$$$$$);
......@@ -31,7 +35,6 @@ sub spawn_impl ($$$$$$$$);
##############################################################################
# This function try to mimic the C version used in "netware/mysql_test_run.c"
# FIXME learn it to handle append mode as well, a "new" flag or a "append"
sub mtr_run ($$$$$$;$) {
my $path= shift;
......@@ -112,6 +115,9 @@ sub spawn_impl ($$$$$$$$) {
print STDERR "#### ", "-" x 78, "\n";
}
mtr_error("Can't spawn with empty \"path\"") unless defined $path;
FORK:
{
my $pid= fork();
......@@ -144,17 +150,6 @@ sub spawn_impl ($$$$$$$$) {
$SIG{INT}= 'DEFAULT'; # Parent do some stuff, we don't
if ( $::glob_cygwin_shell and $mode eq 'test' )
{
# Programs started from mysqltest under Cygwin, are to
# execute them within Cygwin. Else simple things in test
# files like
# --system "echo 1 > file"
# will fail.
# FIXME not working :-(
# $ENV{'COMSPEC'}= "$::glob_cygwin_shell -c";
}
my $log_file_open_mode = '>';
if ($spawn_opts and $spawn_opts->{'append_log_file'})
......@@ -164,7 +159,15 @@ sub spawn_impl ($$$$$$$$) {
if ( $output )
{
if ( ! open(STDOUT,$log_file_open_mode,$output) )
if ( $::glob_win32_perl )
{
# Don't redirect stdout on ActiveState perl since this is
# just another thread in the same process.
# Should be fixed so that the thread that is created with fork
# executes the exe in another process and wait's for it to return.
# In the meanwhile, we get all the output from mysqld's to screen
}
elsif ( ! open(STDOUT,$log_file_open_mode,$output) )
{
mtr_child_error("can't redirect STDOUT to \"$output\": $!");
}
......@@ -216,8 +219,7 @@ sub spawn_parent_impl {
{
# Simple run of command, we wait for it to return
my $ret_pid= waitpid($pid,0);
if ( $ret_pid <= 0 )
if ( $ret_pid != $pid )
{
mtr_error("$path ($pid) got lost somehow");
}
......@@ -245,7 +247,6 @@ sub spawn_parent_impl {
# Someone terminated, don't know who. Collect
# status info first before $? is lost,
# but not $exit_value, this is flagged from
#
my $timer_name= mtr_timer_timeout($::glob_timers, $ret_pid);
if ( $timer_name )
......@@ -272,45 +273,22 @@ sub spawn_parent_impl {
last;
}
# If one of the mysqld processes died, we want to
# mark this, and kill the mysqltest process.
foreach my $idx (0..1)
{
if ( $::master->[$idx]->{'pid'} eq $ret_pid )
{
mtr_debug("child $ret_pid was master[$idx], " .
"exit during mysqltest run");
$::master->[$idx]->{'pid'}= 0;
last;
}
}
foreach my $idx (0..2)
{
if ( $::slave->[$idx]->{'pid'} eq $ret_pid )
{
mtr_debug("child $ret_pid was slave[$idx], " .
"exit during mysqltest run");
$::slave->[$idx]->{'pid'}= 0;
last;
}
}
# One of the child processes died, unless this was expected
# mysqltest should be killed and test aborted
mtr_debug("waitpid() catched exit of unknown child $ret_pid, " .
"exit during mysqltest run");
check_expected_crash_and_restart($ret_pid);
}
if ( $ret_pid != $pid )
{
# We terminated the waiting because a "mysqld" process died.
# Kill the mysqltest process.
mtr_verbose("Kill mysqltest because another process died");
kill(9,$pid);
$ret_pid= waitpid($pid,0);
if ( $ret_pid == -1 )
if ( $ret_pid != $pid )
{
mtr_error("$path ($pid) got lost somehow");
}
......@@ -351,39 +329,101 @@ sub mtr_process_exit_status {
#
##############################################################################
# We just "ping" on the ports, and if we can't do a socket connect
# we assume the server is dead. So we don't *really* know a server
# is dead, we just hope that it after letting the listen port go,
# it is dead enough for us to start a new server.
# Kill all processes(mysqld, ndbd, ndb_mgmd and im) that would conflict with
# this run
# Make sure to remove the PID file, if any.
# kill IM manager first, else it will restart the servers
sub mtr_kill_leftovers () {
# First, kill all masters and slaves that would conflict with
# this run. Make sure to remove the PID file, if any.
mtr_report("Killing Possible Leftover Processes");
mtr_debug("mtr_kill_leftovers(): started.");
my @args;
mkpath("$::opt_vardir/log"); # Needed for mysqladmin log
for ( my $idx; $idx < 2; $idx++ )
# Stop or kill Instance Manager and all its children. If we failed to do
# that, we can only abort -- there is nothing left to do.
# mtr_error("Failed to stop Instance Manager.")
# unless mtr_im_stop($::instance_manager);
# Start shutdown of masters and slaves. Don't touch IM-managed mysqld
# instances -- they should be stopped by mtr_im_stop().
mtr_debug("Shutting down mysqld-instances...");
my @kill_pids;
my %admin_pids;
foreach my $srv (@{$::master}, @{$::slave})
{
push(@args,{
pid => 0, # We don't know the PID
pidfile => $::master->[$idx]->{'path_mypid'},
sockfile => $::master->[$idx]->{'path_mysock'},
port => $::master->[$idx]->{'path_myport'},
});
mtr_debug(" - mysqld " .
"(pid: $srv->{pid}; " .
"pid file: '$srv->{path_pid}'; " .
"socket: '$srv->{path_sock}'; ".
"port: $srv->{port})");
my $pid= mtr_mysqladmin_start($srv, "shutdown", 70);
# Save the pid of the mysqladmin process
$admin_pids{$pid}= 1;
push(@kill_pids,{
pid => $srv->{'pid'},
pidfile => $srv->{'path_pid'},
sockfile => $srv->{'path_sock'},
port => $srv->{'port'},
});
$srv->{'pid'}= 0; # Assume we are done with it
}
for ( my $idx; $idx < 3; $idx++ )
if ( ! $::opt_skip_ndbcluster )
{
push(@args,{
pid => 0, # We don't know the PID
pidfile => $::slave->[$idx]->{'path_mypid'},
sockfile => $::slave->[$idx]->{'path_mysock'},
port => $::slave->[$idx]->{'path_myport'},
});
# Start shutdown of clusters.
mtr_debug("Shutting down cluster...");
foreach my $cluster (@{$::clusters})
{
mtr_debug(" - cluster " .
"(pid: $cluster->{pid}; " .
"pid file: '$cluster->{path_pid})");
my $pid= mtr_ndbmgm_start($cluster, "shutdown");
# Save the pid of the ndb_mgm process
$admin_pids{$pid}= 1;
push(@kill_pids,{
pid => $cluster->{'pid'},
pidfile => $cluster->{'path_pid'}
});
$cluster->{'pid'}= 0; # Assume we are done with it
foreach my $ndbd (@{$cluster->{'ndbds'}})
{
mtr_debug(" - ndbd " .
"(pid: $ndbd->{pid}; " .
"pid file: '$ndbd->{path_pid})");
push(@kill_pids,{
pid => $ndbd->{'pid'},
pidfile => $ndbd->{'path_pid'},
});
$ndbd->{'pid'}= 0; # Assume we are done with it
}
}
}
mtr_mysqladmin_shutdown(\@args, 20);
# Wait for all the admin processes to complete
mtr_wait_blocking(\%admin_pids);
# If we trusted "mysqladmin --shutdown_timeout= ..." we could just
# terminate now, but we don't (FIXME should be debugged).
# So we try again to ping and at least wait the same amount of time
# mysqladmin would for all to die.
mtr_ping_with_timeout(\@kill_pids);
# We now have tried to terminate nice. We have waited for the listen
# port to be free, but can't really tell if the mysqld process died
......@@ -401,6 +441,8 @@ sub mtr_kill_leftovers () {
# FIXME $path_run_dir or something
my $rundir= "$::opt_vardir/run";
mtr_debug("Processing PID files in directory '$rundir'...");
if ( -d $rundir )
{
opendir(RUNDIR, $rundir)
......@@ -414,26 +456,32 @@ sub mtr_kill_leftovers () {
if ( -f $pidfile )
{
my $pid= mtr_get_pid_from_file($pidfile);
mtr_debug("Processing PID file: '$pidfile'...");
# Race, could have been removed between I tested with -f
# and the unlink() below, so I better check again with -f
my $pid= mtr_get_pid_from_file($pidfile);
if ( ! unlink($pidfile) and -f $pidfile )
{
mtr_error("can't remove $pidfile");
}
mtr_debug("Got pid: $pid from file '$pidfile'");
if ( $::glob_cygwin_perl or kill(0, $pid) )
{
mtr_debug("There is process with pid $pid -- scheduling for kill.");
push(@pids, $pid); # We know (cygwin guess) it exists
}
else
{
mtr_debug("There is no process with pid $pid -- skipping.");
}
}
}
closedir(RUNDIR);
if ( @pids )
{
mtr_debug("Killing the following processes with PID files: " .
join(' ', @pids) . "...");
start_reap_all();
if ( $::glob_cygwin_perl )
{
# We have no (easy) way of knowing the Cygwin controlling
......@@ -447,8 +495,9 @@ sub mtr_kill_leftovers () {
my $retries= 10; # 10 seconds
do
{
mtr_debug("Sending SIGKILL to pids: " . join(' ', @pids));
kill(9, @pids);
mtr_debug("Sleep 1 second waiting for processes to die");
mtr_report("Sleep 1 second waiting for processes to die");
sleep(1) # Wait one second
} while ( $retries-- and kill(0, @pids) );
......@@ -457,56 +506,74 @@ sub mtr_kill_leftovers () {
mtr_warning("can't kill process(es) " . join(" ", @pids));
}
}
stop_reap_all();
}
}
else
{
mtr_debug("Directory for PID files ($rundir) does not exist.");
}
# We may have failed everything, bug we now check again if we have
# We may have failed everything, but we now check again if we have
# the listen ports free to use, and if they are free, just go for it.
foreach my $srv ( @args )
mtr_debug("Checking known mysqld servers...");
foreach my $srv ( @kill_pids )
{
if ( mtr_ping_mysqld_server($srv->{'port'}, $srv->{'sockfile'}) )
if ( defined $srv->{'port'} and mtr_ping_port($srv->{'port'}) )
{
mtr_warning("can't kill old mysqld holding port $srv->{'port'}");
mtr_warning("can't kill old process holding port $srv->{'port'}");
}
}
}
##############################################################################
#
# Shut down mysqld servers we have started from this run of this script
#
##############################################################################
mtr_debug("mtr_kill_leftovers(): finished.");
}
# To speed things we kill servers in parallel. The argument is a list
# of 'ports', 'pids', 'pidfiles' and 'socketfiles'.
# Check that all processes in list are killed
# The argument is a list of 'ports', 'pids', 'pidfiles' and 'socketfiles'
# for which shutdown has been started. Make sure they all get killed
# in one way or the other.
#
# FIXME On Cygwin, and maybe some other platforms, $srv->{'pid'} and
# $srv->{'pidfile'} will not be the same PID. We need to try to kill
# the pid in $srv->{'pidfile'} will not be the same PID. We need to try to kill
# both I think.
sub mtr_stop_mysqld_servers ($) {
sub mtr_check_stop_servers ($) {
my $spec= shift;
# ----------------------------------------------------------------------
# First try nice normal shutdown using 'mysqladmin'
# ----------------------------------------------------------------------
# Return if no processes are defined
return if ! @$spec;
# Shutdown time must be high as slave may be in reconnect
mtr_mysqladmin_shutdown($spec, 70);
#mtr_report("mtr_check_stop_servers");
mtr_ping_with_timeout(\@$spec);
# ----------------------------------------------------------------------
# We loop with waitpid() nonblocking to see how many of the ones we
# are to kill, actually got killed by mtr_mysqladmin_shutdown().
# Note that we don't rely on this, the mysqld server might have stop
# are to kill, actually got killed by mysqladmin or ndb_mgm
#
# Note that we don't rely on this, the mysqld server might have stopped
# listening to the port, but still be alive. But it is a start.
# ----------------------------------------------------------------------
foreach my $srv ( @$spec )
{
if ( $srv->{'pid'} and (waitpid($srv->{'pid'},&WNOHANG) == $srv->{'pid'}) )
my $ret_pid;
if ( $srv->{'pid'} )
{
$srv->{'pid'}= 0;
$ret_pid= waitpid($srv->{'pid'},&WNOHANG);
if ($ret_pid == $srv->{'pid'})
{
mtr_verbose("Caught exit of process $ret_pid");
$srv->{'pid'}= 0;
}
else
{
# mtr_warning("caught exit of unknown child $ret_pid");
}
}
}
......@@ -540,13 +607,12 @@ sub mtr_stop_mysqld_servers ($) {
}
# ----------------------------------------------------------------------
# If the processes where started from this script, and we had no PIDS
# If all the processes in list already have been killed,
# then we don't have to do anything.
# ----------------------------------------------------------------------
if ( ! keys %mysqld_pids )
{
# cluck "This is how we got here!";
return;
}
......@@ -595,139 +661,288 @@ sub mtr_stop_mysqld_servers ($) {
foreach my $file ($srv->{'pidfile'}, $srv->{'sockfile'})
{
# Know it is dead so should be no race, careful anyway
if ( -f $file and ! unlink($file) and -f $file )
if ( defined $file and -f $file and ! unlink($file) and -f $file )
{
$errors++;
mtr_warning("couldn't delete $file");
}
}
$srv->{'pid'}= 0;
}
}
}
if ( $errors )
{
# We are in trouble, just die....
mtr_error("we could not kill or clean up all processes");
# There where errors killing processes
# do one last attempt to ping the servers
# and if they can't be pinged, assume they are dead
if ( ! mtr_ping_with_timeout( \@$spec ) )
{
mtr_error("we could not kill or clean up all processes");
}
else
{
mtr_verbose("All ports were free, continuing");
}
}
}
# FIXME We just assume they are all dead, for Cygwin we are not
# really sure
}
# Wait for all the process in the list to terminate
sub mtr_wait_blocking($) {
my $admin_pids= shift;
##############################################################################
#
# Shut down mysqld servers using "mysqladmin ... shutdown".
# To speed this up, we start them in parallel and use waitpid() to
# catch their termination. Note that this doesn't say the servers
# are terminated, just that 'mysqladmin' is terminated.
#
# Note that mysqladmin will ask the server about what PID file it uses,
# and mysqladmin will wait for it to be removed before it terminates
# (unless passes timeout).
#
# This function will take at most about 20 seconds, and we still are not
# sure we killed them all. If none is responding to ping, we return 1,
# else we return 0.
#
##############################################################################
sub mtr_mysqladmin_shutdown {
my $spec= shift;
# Return if no processes defined
return if ! %$admin_pids;
mtr_verbose("mtr_wait_blocking");
# Wait for all the started processes to exit
# As mysqladmin is such a simple program, we trust it to terminate itself.
# I.e. we wait blocking, and wait for them all before we go on.
foreach my $pid (keys %{$admin_pids})
{
my $ret_pid= waitpid($pid,0);
}
}
# Start "mysqladmin shutdown" for a specific mysqld
sub mtr_mysqladmin_start($$$) {
my $srv= shift;
my $command= shift;
my $adm_shutdown_tmo= shift;
my %mysql_admin_pids;
my @to_kill_specs;
my $args;
mtr_init_args(\$args);
foreach my $srv ( @$spec )
mtr_add_arg($args, "--no-defaults");
mtr_add_arg($args, "--user=%s", $::opt_user);
mtr_add_arg($args, "--password=");
mtr_add_arg($args, "--silent");
if ( -e $srv->{'path_sock'} )
{
mtr_add_arg($args, "--socket=%s", $srv->{'path_sock'});
}
if ( $srv->{'port'} )
{
if ( mtr_ping_mysqld_server($srv->{'port'}, $srv->{'sockfile'}) )
mtr_add_arg($args, "--port=%s", $srv->{'port'});
}
if ( $srv->{'port'} and ! -e $srv->{'path_sock'} )
{
mtr_add_arg($args, "--protocol=tcp"); # Needed if no --socket
}
mtr_add_arg($args, "--connect_timeout=5");
# Shutdown time must be high as slave may be in reconnect
mtr_add_arg($args, "--shutdown_timeout=$adm_shutdown_tmo");
mtr_add_arg($args, "$command");
my $path_mysqladmin_log= "$::opt_vardir/log/mysqladmin.log";
my $pid= mtr_spawn($::exe_mysqladmin, $args,
"", $path_mysqladmin_log, $path_mysqladmin_log, "",
{ append_log_file => 1 });
mtr_verbose("mtr_mysqladmin_start, pid: $pid");
return $pid;
}
# Start "ndb_mgm shutdown" for a specific cluster, it will
# shutdown all data nodes and leave the ndb_mgmd running
sub mtr_ndbmgm_start($$) {
my $cluster= shift;
my $command= shift;
my $args;
mtr_init_args(\$args);
mtr_add_arg($args, "--no-defaults");
mtr_add_arg($args, "--core");
mtr_add_arg($args, "--try-reconnect=1");
mtr_add_arg($args, "--ndb_connectstring=%s", $cluster->{'connect_string'});
mtr_add_arg($args, "-e");
mtr_add_arg($args, "$command");
my $pid= mtr_spawn($::exe_ndb_mgm, $args,
"", "/dev/null", "/dev/null", "",
{});
mtr_verbose("mtr_ndbmgm_start, pid: $pid");
return $pid;
}
# Ping all servers in list, exit when none of them answers
# or when timeout has passed
sub mtr_ping_with_timeout($) {
my $spec= shift;
my $timeout= 200; # 20 seconds max
my $res= 1; # If we just fall through, we are done
# in the sense that the servers don't
# listen to their ports any longer
mtr_debug("Waiting for mysqld servers to stop...");
TIME:
while ( $timeout-- )
{
foreach my $srv ( @$spec )
{
push(@to_kill_specs, $srv);
$res= 1; # We are optimistic
if ( $srv->{'pid'} and defined $srv->{'port'} )
{
if ( mtr_ping_port($srv->{'port'}) )
{
mtr_verbose("waiting for process $srv->{'pid'} to stop ".
"using port $srv->{'port'}");
# Millisceond sleep emulated with select
select(undef, undef, undef, (0.1));
$res= 0;
next TIME;
}
else
{
# Process was not using port
}
}
}
last; # If we got here, we are done
}
foreach my $srv ( @to_kill_specs )
if ($res)
{
mtr_debug("mtr_ping_with_timeout(): All mysqld instances are down.");
}
else
{
# FIXME wrong log.....
# FIXME, stderr.....
# Shutdown time must be high as slave may be in reconnect
my $args;
mtr_report("mtr_ping_with_timeout(): At least one server is alive.");
}
mtr_init_args(\$args);
return $res;
}
#
# Loop through our list of processes and look for and entry
# with the provided pid
# Set the pid of that process to 0 if found
#
sub mark_process_dead($)
{
my $ret_pid= shift;
mtr_add_arg($args, "--no-defaults");
mtr_add_arg($args, "--user=%s", $::opt_user);
mtr_add_arg($args, "--password=");
if ( -e $srv->{'sockfile'} )
foreach my $mysqld (@{$::master}, @{$::slave})
{
if ( $mysqld->{'pid'} eq $ret_pid )
{
mtr_add_arg($args, "--socket=%s", $srv->{'sockfile'});
mtr_verbose("$mysqld->{'type'} $mysqld->{'idx'} exited, pid: $ret_pid");
$mysqld->{'pid'}= 0;
return;
}
if ( $srv->{'port'} )
}
foreach my $cluster (@{$::clusters})
{
if ( $cluster->{'pid'} eq $ret_pid )
{
mtr_add_arg($args, "--port=%s", $srv->{'port'});
mtr_verbose("$cluster->{'name'} cluster ndb_mgmd exited, pid: $ret_pid");
$cluster->{'pid'}= 0;
return;
}
if ( $srv->{'port'} and ! -e $srv->{'sockfile'} )
foreach my $ndbd (@{$cluster->{'ndbds'}})
{
mtr_add_arg($args, "--protocol=tcp"); # Needed if no --socket
if ( $ndbd->{'pid'} eq $ret_pid )
{
mtr_verbose("$cluster->{'name'} cluster ndbd exited, pid: $ret_pid");
$ndbd->{'pid'}= 0;
return;
}
}
mtr_add_arg($args, "--connect_timeout=5");
mtr_add_arg($args, "--shutdown_timeout=$adm_shutdown_tmo");
mtr_add_arg($args, "shutdown");
# We don't wait for termination of mysqladmin
my $pid= mtr_spawn($::exe_mysqladmin, $args,
"", $::path_manager_log, $::path_manager_log, "",
{ append_log_file => 1 });
$mysql_admin_pids{$pid}= 1;
}
mtr_warning("mark_process_dead couldn't find an entry for pid: $ret_pid");
}
#
# Loop through our list of processes and look for and entry
# with the provided pid, if found check for the file indicating
# expected crash and restart it.
#
sub check_expected_crash_and_restart($)
{
my $ret_pid= shift;
# As mysqladmin is such a simple program, we trust it to terminate.
# I.e. we wait blocking, and wait wait for them all before we go on.
while (keys %mysql_admin_pids)
foreach my $mysqld (@{$::master}, @{$::slave})
{
foreach my $pid (keys %mysql_admin_pids)
if ( $mysqld->{'pid'} eq $ret_pid )
{
if ( waitpid($pid,0) > 0 )
mtr_verbose("$mysqld->{'type'} $mysqld->{'idx'} exited, pid: $ret_pid");
$mysqld->{'pid'}= 0;
# Check if crash expected and restart if it was
my $expect_file= "$::opt_vardir/tmp/" . "$mysqld->{'type'}" .
"$mysqld->{'idx'}" . ".expect";
if ( -f $expect_file )
{
delete $mysql_admin_pids{$pid};
mtr_verbose("Crash was expected, file $expect_file exists");
mysqld_start($mysqld, $mysqld->{'start_opts'},
$mysqld->{'start_slave_master_info'});
unlink($expect_file);
}
return;
}
}
# If we trusted "mysqladmin --shutdown_timeout= ..." we could just
# terminate now, but we don't (FIXME should be debugged).
# So we try again to ping and at least wait the same amount of time
# mysqladmin would for all to die.
my $timeout= 20; # 20 seconds max
my $res= 1; # If we just fall through, we are done
# in the sense that the servers don't
# listen to their ports any longer
TIME:
while ( $timeout-- )
foreach my $cluster (@{$::clusters})
{
foreach my $srv ( @to_kill_specs )
if ( $cluster->{'pid'} eq $ret_pid )
{
$res= 1; # We are optimistic
if ( mtr_ping_mysqld_server($srv->{'port'}, $srv->{'sockfile'}) )
mtr_verbose("$cluster->{'name'} cluster ndb_mgmd exited, pid: $ret_pid");
$cluster->{'pid'}= 0;
# Check if crash expected and restart if it was
my $expect_file= "$::opt_vardir/tmp/ndb_mgmd_" . "$cluster->{'type'}" .
".expect";
if ( -f $expect_file )
{
mtr_debug("Sleep 1 second waiting for processes to stop using port");
sleep(1); # One second
$res= 0;
next TIME;
mtr_verbose("Crash was expected, file $expect_file exists");
ndbmgmd_start($cluster);
unlink($expect_file);
}
return;
}
last; # If we got here, we are done
}
$timeout or mtr_debug("At least one server is still listening to its port");
sleep(5) if $::glob_win32; # FIXME next startup fails if no sleep
foreach my $ndbd (@{$cluster->{'ndbds'}})
{
if ( $ndbd->{'pid'} eq $ret_pid )
{
mtr_verbose("$cluster->{'name'} cluster ndbd exited, pid: $ret_pid");
$ndbd->{'pid'}= 0;
# Check if crash expected and restart if it was
my $expect_file= "$::opt_vardir/tmp/ndbd_" . "$cluster->{'type'}" .
"$ndbd->{'idx'}" . ".expect";
if ( -f $expect_file )
{
mtr_verbose("Crash was expected, file $expect_file exists");
ndbd_start($cluster, $ndbd->{'idx'},
$ndbd->{'start_extra_args'});
unlink($expect_file);
}
return;
}
}
}
mtr_warning("check_expected_crash_and_restart couldn't find an entry for pid: $ret_pid");
return $res;
}
##############################################################################
......@@ -740,32 +955,18 @@ sub mtr_mysqladmin_shutdown {
sub mtr_record_dead_children () {
my $process_died= 0;
my $ret_pid;
# FIXME the man page says to wait for -1 to terminate,
# but on OS X we get '0' all the time...
while ( ($ret_pid= waitpid(-1,&WNOHANG)) > 0 )
# Wait without blockinng to see if any processes had died
# -1 or 0 means there are no more procesess to wait for
while ( ($ret_pid= waitpid(-1,&WNOHANG)) != 0 and $ret_pid != -1)
{
mtr_debug("waitpid() catched exit of child $ret_pid");
foreach my $idx (0..1)
{
if ( $::master->[$idx]->{'pid'} eq $ret_pid )
{
mtr_debug("child $ret_pid was master[$idx]");
$::master->[$idx]->{'pid'}= 0;
}
}
foreach my $idx (0..2)
{
if ( $::slave->[$idx]->{'pid'} eq $ret_pid )
{
mtr_debug("child $ret_pid was slave[$idx]");
$::slave->[$idx]->{'pid'}= 0;
last;
}
}
mtr_warning("mtr_record_dead_children: $ret_pid");
mark_process_dead($ret_pid);
$process_died= 1;
}
return $process_died;
}
sub start_reap_all {
......@@ -777,16 +978,24 @@ sub start_reap_all {
# here. If a process terminated before setting $SIG{CHLD} (but after
# any attempt to waitpid() it), it will still be a zombie. So we
# have to handle any such process here.
while(waitpid(-1, &WNOHANG) > 0) { };
my $pid;
while(($pid= waitpid(-1, &WNOHANG)) != 0 and $pid != -1)
{
mtr_warning("start_reap_all pid: $pid");
mark_process_dead($pid);
};
}
sub stop_reap_all {
$SIG{CHLD}= 'DEFAULT';
}
sub mtr_ping_mysqld_server () {
sub mtr_ping_port ($) {
my $port= shift;
mtr_verbose("mtr_ping_port: $port");
my $remote= "localhost";
my $iaddr= inet_aton($remote);
if ( ! $iaddr )
......@@ -799,13 +1008,18 @@ sub mtr_ping_mysqld_server () {
{
mtr_error("can't create socket: $!");
}
mtr_debug("Pinging server (port: $port)...");
if ( connect(SOCK, $paddr) )
{
close(SOCK); # FIXME check error?
mtr_verbose("USED");
return 1;
}
else
{
mtr_verbose("FREE");
return 0;
}
}
......@@ -822,30 +1036,36 @@ sub sleep_until_file_created ($$$) {
my $pidfile= shift;
my $timeout= shift;
my $pid= shift;
my $sleeptime= 100; # Milliseconds
my $loops= ($timeout * 1000) / $sleeptime;
for ( my $loop= 1; $loop <= $timeout; $loop++ )
for ( my $loop= 1; $loop <= $loops; $loop++ )
{
if ( -r $pidfile )
{
return $pid;
}
# Check if it died after the fork() was successful
if ( waitpid($pid,&WNOHANG) == $pid )
# Check if it died after the fork() was successful
if ( $pid != 0 && waitpid($pid,&WNOHANG) == $pid )
{
mtr_warning("Process $pid died");
return 0;
}
mtr_debug("Sleep 1 second waiting for creation of $pidfile");
mtr_debug("Sleep $sleeptime milliseconds waiting for $pidfile");
if ( $loop % 60 == 0 )
# Print extra message every 60 seconds
my $seconds= ($loop * $sleeptime) / 1000;
if ( $seconds > 1 and int($seconds) % 60 == 0 )
{
my $left= $timeout - $loop;
mtr_warning("Waited $loop seconds for $pidfile to be created, " .
my $left= $timeout - $seconds;
mtr_warning("Waited $seconds seconds for $pidfile to be created, " .
"still waiting for $left seconds...");
}
sleep(1);
# Millisceond sleep emulated with select
select(undef, undef, undef, ($sleeptime/1000));
}
return 0;
......@@ -855,18 +1075,18 @@ sub sleep_until_file_created ($$$) {
sub mtr_kill_processes ($) {
my $pids = shift;
foreach my $sig (15,9)
mtr_verbose("mtr_kill_processes " . join(" ", @$pids));
foreach my $pid (@$pids)
{
my $retries= 20; # FIXME 20 seconds, this is silly!
kill($sig, @{$pids});
while ( $retries-- and kill(0, @{$pids}) )
foreach my $sig (15, 9)
{
mtr_debug("Sleep 1 second waiting for processes to die");
sleep(1) # Wait one second
last if mtr_im_kill_process([ $pid ], $sig, 10, 1);
}
}
}
##############################################################################
#
# When we exit, we kill off all children
......@@ -876,7 +1096,7 @@ sub mtr_kill_processes ($) {
# FIXME something is wrong, we sometimes terminate with "Hangup" written
# to tty, and no STDERR output telling us why.
# FIXME for some readon, setting HUP to 'IGNORE' will cause exit() to
# FIXME for some reason, setting HUP to 'IGNORE' will cause exit() to
# write out "Hangup", and maybe loose some output. We insert a sleep...
sub mtr_exit ($) {
......@@ -884,9 +1104,18 @@ sub mtr_exit ($) {
# cluck("Called mtr_exit()");
mtr_timer_stop_all($::glob_timers);
local $SIG{HUP} = 'IGNORE';
kill('HUP', -$$);
sleep 2;
# ToDo: Signalling -$$ will only work if we are the process group
# leader (in fact on QNX it will signal our session group leader,
# which might be Do-compile or Pushbuild, causing tests to be
# aborted). So we only do it if we are the group leader. We might
# set ourselves as the group leader at startup (with
# POSIX::setpgrp(0,0)), but then care must be needed to always do
# proper child process cleanup.
kill('HUP', -$$) if !$::glob_win32_perl and $$ == getpgrp();
exit($code);
}
###########################################################################
1;
......@@ -10,6 +10,7 @@ sub mtr_report_test_name($);
sub mtr_report_test_passed($);
sub mtr_report_test_failed($);
sub mtr_report_test_skipped($);
sub mtr_report_test_not_skipped_though_disabled($);
sub mtr_show_failed_diff ($);
sub mtr_report_stats ($);
......@@ -21,6 +22,7 @@ sub mtr_warning (@);
sub mtr_error (@);
sub mtr_child_error (@);
sub mtr_debug (@);
sub mtr_verbose (@);
##############################################################################
......@@ -36,6 +38,7 @@ sub mtr_show_failed_diff ($) {
my $reject_file= "r/$tname.reject";
my $result_file= "r/$tname.result";
my $log_file= "r/$tname.log";
my $eval_file= "r/$tname.eval";
if ( $::opt_suite ne "main" )
......@@ -43,18 +46,12 @@ sub mtr_show_failed_diff ($) {
$reject_file= "$::glob_mysql_test_dir/suite/$::opt_suite/$reject_file";
$result_file= "$::glob_mysql_test_dir/suite/$::opt_suite/$result_file";
$eval_file= "$::glob_mysql_test_dir/suite/$::opt_suite/$eval_file";
$log_file= "$::glob_mysql_test_dir/suite/$::opt_suite/$log_file";
}
if ( -f $eval_file )
{
$result_file= $eval_file;
}
elsif ( $::opt_result_ext and
( $::opt_record or -f "$result_file$::opt_result_ext" ))
{
# If we have an special externsion for result files we use it if we are
# recording or a result file with that extension exists.
$result_file= "$result_file$::opt_result_ext";
$result_file= $eval_file;
}
my $diffopts= $::opt_udiff ? "-u" : "-c";
......@@ -70,6 +67,12 @@ sub mtr_show_failed_diff ($) {
print "http://www.mysql.com/doc/en/Reporting_mysqltest_bugs.html\n";
print "to find the reason to this problem and how to report this.\n\n";
}
if ( -f $log_file )
{
print "Result from queries before failure can be found in $log_file\n";
# FIXME Maybe a tail -f -n 10 $log_file here
}
}
sub mtr_report_test_name ($) {
......@@ -88,7 +91,24 @@ sub mtr_report_test_skipped ($) {
}
else
{
print "[ skipped ]\n";
print "[ skipped ] $tinfo->{'comment'}\n";
}
}
sub mtr_report_tests_not_skipped_though_disabled ($) {
my $tests= shift;
if ( $::opt_enable_disabled )
{
my @disabled_tests= grep {$_->{'dont_skip_though_disabled'}} @$tests;
if ( @disabled_tests )
{
print "\nTest(s) which will be run though they are marked as disabled:\n";
foreach my $tinfo ( sort {$a->{'name'} cmp $b->{'name'}} @disabled_tests )
{
printf " %-20s : %s\n", $tinfo->{'name'}, $tinfo->{'comment'};
}
}
}
}
......@@ -99,7 +119,7 @@ sub mtr_report_test_passed ($) {
if ( $::opt_timer and -f "$::opt_vardir/log/timer" )
{
$timer= mtr_fromfile("$::opt_vardir/log/timer");
$::glob_tot_real_time += $timer;
$::glob_tot_real_time += ($timer/1000);
$timer= sprintf "%12s", $timer;
}
$tinfo->{'result'}= 'MTR_RES_PASSED';
......@@ -114,14 +134,21 @@ sub mtr_report_test_failed ($) {
{
print "[ fail ] timeout\n";
}
elsif ( $tinfo->{'ndb_test'} and $::cluster->[0]->{'installed_ok'} eq "NO")
{
print "[ fail ] ndbcluster start failure\n";
return;
}
else
{
print "[ fail ]\n";
}
# FIXME Instead of this test, and meaningless error message in 'else'
# we should write out into $::path_timefile when the error occurs.
if ( -f $::path_timefile )
if ( $tinfo->{'comment'} )
{
print "\nERROR: $tinfo->{'comment'}\n";
}
elsif ( -f $::path_timefile )
{
print "\nErrors are (from $::path_timefile) :\n";
print mtr_fromfile($::path_timefile); # FIXME print_file() instead
......@@ -144,6 +171,8 @@ sub mtr_report_stats ($) {
my $tot_passed= 0;
my $tot_failed= 0;
my $tot_tests= 0;
my $tot_restarts= 0;
my $found_problems= 0; # Some warnings are errors...
foreach my $tinfo (@$tests)
{
......@@ -161,6 +190,10 @@ sub mtr_report_stats ($) {
$tot_tests++;
$tot_failed++;
}
if ( $tinfo->{'restarted'} )
{
$tot_restarts++;
}
}
# ----------------------------------------------------------------------
......@@ -183,41 +216,69 @@ sub mtr_report_stats ($) {
"the documentation at\n",
"http://www.mysql.com/doc/en/MySQL_test_suite.html\n";
}
print
"The servers were restarted $tot_restarts times\n";
if ( $::opt_timer )
{
print
"Spent $::glob_tot_real_time seconds actually executing testcases\n"
}
# ----------------------------------------------------------------------
# If a debug run, there might be interesting information inside
# the "var/log/*.err" files. We save this info in "var/log/warnings"
# ----------------------------------------------------------------------
if ( ! $::glob_use_running_server )
{
# Save and report if there was any fatal warnings/errors in err logs
# Report if there was any fatal warnings/errors in the log files
#
unlink("$::opt_vardir/log/warnings");
unlink("$::opt_vardir/log/warnings.tmp");
# Remove some non fatal warnings from the log files
# FIXME what is going on ????? ;-)
# sed -e 's!Warning: Table:.* on delete!!g' -e 's!Warning: Setting lower_case_table_names=2!!g' -e 's!Warning: One can only use the --user.*root!!g' \
# var/log/*.err \
# | sed -e 's!Warning: Table:.* on rename!!g' \
# > var/log/warnings.tmp;
#
# found_error=0;
# # Find errors
# for i in "^Warning:" "^Error:" "^==.* at 0x"
# do
# if ( $GREP "$i" var/log/warnings.tmp >> var/log/warnings )
# {
# found_error=1
# }
# done
# unlink("$::opt_vardir/log/warnings.tmp");
# if ( $found_error= "1" )
# {
# print "WARNING: Got errors/warnings while running tests. Please examine\n"
# print "$::opt_vardir/log/warnings for details.\n"
# }
# }
my $warnlog= "$::opt_vardir/log/warnings";
unless ( open(WARN, ">$warnlog") )
{
mtr_warning("can't write to the file \"$warnlog\": $!");
}
else
{
# We report different types of problems in order
foreach my $pattern ( "^Warning:", "^Error:", "^==.* at 0x",
"InnoDB: Warning", "missing DBUG_RETURN",
"mysqld: Warning",
"Attempting backtrace", "Assertion .* failed" )
{
foreach my $errlog ( sort glob("$::opt_vardir/log/*.err") )
{
unless ( open(ERR, $errlog) )
{
mtr_warning("can't read $errlog");
next;
}
while ( <ERR> )
{
# Skip some non fatal warnings from the log files
if ( /Warning:\s+Table:.* on (delete|rename)/ or
/Warning:\s+Setting lower_case_table_names=2/ or
/Warning:\s+One can only use the --user.*root/ or
/InnoDB: Warning: we did not need to do crash recovery/)
{
next; # Skip these lines
}
if ( /$pattern/ )
{
$found_problems= 1;
print WARN $_;
}
}
}
}
if ( $found_problems )
{
mtr_warning("Got errors/warnings while running tests, please examine",
"\"$warnlog\" for details.");
}
}
}
print "\n";
......@@ -235,6 +296,9 @@ sub mtr_report_stats ($) {
}
}
print "\n";
}
if ( $tot_failed != 0 || $found_problems)
{
mtr_error("there where failing test cases");
}
}
......@@ -298,5 +362,11 @@ sub mtr_debug (@) {
print STDERR "####: ",join(" ", @_),"\n";
}
}
sub mtr_verbose (@) {
if ( $::opt_verbose )
{
print STDERR "> ",join(" ", @_),"\n";
}
}
1;
# -*- 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;
use File::Spec;
# These are not to be prefixed with "mtr_"
sub run_stress_test ();
##############################################################################
#
# Run tests in the stress mode
#
##############################################################################
sub run_stress_test ()
{
my $args;
my $stress_suitedir;
mtr_report("Starting stress testing\n");
if ( ! $::glob_use_embedded_server )
{
if ( ! mysqld_start($::master->[0],[],[]) )
{
mtr_error("Can't start the mysqld server");
}
}
my $stress_basedir=File::Spec->catdir($::opt_vardir, "stress");
#Clean up stress dir
if ( -d $stress_basedir )
{
rmtree($stress_basedir);
}
mkpath($stress_basedir);
if ($::opt_stress_suite ne 'main' && $::opt_stress_suite ne 'default' )
{
$stress_suitedir=File::Spec->catdir($::glob_mysql_test_dir, "suite",
$::opt_stress_suite);
}
else
{
$stress_suitedir=$::glob_mysql_test_dir;
}
if ( -d $stress_suitedir )
{
#$stress_suite_t_dir=File::Spec->catdir($stress_suitedir, "t");
#$stress_suite_r_dir=File::Spec->catdir($stress_suitedir, "r");
#FIXME: check dirs above for existence to ensure that test suite
# contains tests and results dirs
}
else
{
mtr_error("Specified test suite $::opt_stress_suite doesn't exist");
}
if ( @::opt_cases )
{
$::opt_stress_test_file=File::Spec->catfile($stress_basedir, "stress_tests.txt");
open(STRESS_FILE, ">$::opt_stress_test_file");
print STRESS_FILE join("\n",@::opt_cases),"\n";
close(STRESS_FILE);
}
elsif ( $::opt_stress_test_file )
{
$::opt_stress_test_file=File::Spec->catfile($stress_suitedir,
$::opt_stress_test_file);
if ( ! -f $::opt_stress_test_file )
{
mtr_error("Specified file $::opt_stress_test_file with list of tests does not exist\n",
"Please ensure that file exists and has proper permissions");
}
}
else
{
$::opt_stress_test_file=File::Spec->catfile($stress_suitedir,
"stress_tests.txt");
if ( ! -f $::opt_stress_test_file )
{
mtr_error("Default file $::opt_stress_test_file with list of tests does not exist\n",
"Please use --stress-test-file option to specify custom one or you can\n",
"just specify name of test for testing as last argument in command line");
}
}
if ( $::opt_stress_init_file )
{
$::opt_stress_init_file=File::Spec->catfile($stress_suitedir,
$::opt_stress_init_file);
if ( ! -f $::opt_stress_init_file )
{
mtr_error("Specified file $::opt_stress_init_file with list of tests does not exist\n",
"Please ensure that file exists and has proper permissions");
}
}
else
{
$::opt_stress_init_file=File::Spec->catfile($stress_suitedir,
"stress_init.txt");
if ( ! -f $::opt_stress_init_file )
{
$::opt_stress_init_file='';
}
}
if ( $::opt_stress_mode ne 'random' && $::opt_stress_mode ne 'seq' )
{
mtr_error("You specified wrong mode $::opt_stress_mode for stress test\n",
"Correct values are 'random' or 'seq'");
}
mtr_init_args(\$args);
mtr_add_arg($args, "--server-socket=%s", $::master->[0]->{'path_mysock'});
mtr_add_arg($args, "--server-user=%s", $::opt_user);
mtr_add_arg($args, "--server-database=%s", "test");
mtr_add_arg($args, "--stress-suite-basedir=%s", $::glob_mysql_test_dir);
mtr_add_arg($args, "--suite=%s", $::opt_stress_suite);
mtr_add_arg($args, "--stress-tests-file=%s", $::opt_stress_test_file);
mtr_add_arg($args, "--stress-basedir=%s", $stress_basedir);
mtr_add_arg($args, "--server-logs-dir=%s", $stress_basedir);
mtr_add_arg($args, "--stress-mode=%s", $::opt_stress_mode);
mtr_add_arg($args, "--mysqltest=%s", $::exe_mysqltest);
mtr_add_arg($args, "--threads=%s", $::opt_stress_threads);
mtr_add_arg($args, "--verbose");
mtr_add_arg($args, "--cleanup");
mtr_add_arg($args, "--log-error-details");
mtr_add_arg($args, "--abort-on-error");
if ( $::opt_stress_init_file )
{
mtr_add_arg($args, "--stress-init-file=%", $::opt_stress_init_file);
}
if ( !$::opt_stress_loop_count && !$::opt_stress_test_count &&
!$::opt_stress_test_duration )
{
#Limit stress testing with 20 loops in case when any limit parameter
#was specified
$::opt_stress_test_count=20;
}
if ( $::opt_stress_loop_count )
{
mtr_add_arg($args, "--loop-count=%s", $::opt_stress_loop_count);
}
if ( $::opt_stress_test_count )
{
mtr_add_arg($args, "--test-count=%s", $::opt_stress_test_count);
}
if ( $::opt_stress_test_duration )
{
mtr_add_arg($args, "--test-duration=%s", $::opt_stress_test_duration);
}
#Run stress test
mtr_run("$::glob_mysql_test_dir/mysql-stress-test.pl", $args, "", "", "", "");
if ( ! $::glob_use_embedded_server )
{
stop_masters();
}
}
1;
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -188,7 +188,7 @@ SYST=0
REALT=0
FAST_START=""
MYSQL_TMP_DIR=$MYSQL_TEST_DIR/var/tmp
SLAVE_LOAD_TMPDIR=../../var/tmp #needs to be same length to test logging
SLAVE_LOAD_TMPDIR=../tmp #needs to be same length to test logging
RES_SPACE=" "
MYSQLD_SRC_DIRS="strings mysys include extra regex isam merge myisam \
myisammrg heap sql"
......
drop table if exists t1;
create table t1(n int not null, key(n), key(n), key(n), key(n));
check table t1 extended;
check table t1 extended;
insert into t1 values (200000);
Table Op Msg_type Msg_text
test.t1 check status OK
......
......@@ -18,6 +18,10 @@ time_zone_transition_type
user
show tables;
Tables_in_test
connect(localhost,root,z,test2,MASTER_PORT,MASTER_SOCKET);
ERROR 28000: Access denied for user 'root'@'localhost' (using password: YES)
connect(localhost,root,z,test,MASTER_PORT,MASTER_SOCKET);
ERROR 28000: Access denied for user 'root'@'localhost' (using password: YES)
grant ALL on *.* to test@localhost identified by "gambling";
grant ALL on *.* to test@127.0.0.1 identified by "gambling";
show tables;
......@@ -39,6 +43,14 @@ time_zone_transition_type
user
show tables;
Tables_in_test
connect(localhost,test,,test2,MASTER_PORT,MASTER_SOCKET);
ERROR 28000: Access denied for user 'test'@'localhost' (using password: NO)
connect(localhost,test,,"",MASTER_PORT,MASTER_SOCKET);
ERROR 28000: Access denied for user 'test'@'localhost' (using password: NO)
connect(localhost,test,zorro,test2,MASTER_PORT,MASTER_SOCKET);
ERROR 28000: Access denied for user 'test'@'localhost' (using password: YES)
connect(localhost,test,zorro,test,MASTER_PORT,MASTER_SOCKET);
ERROR 28000: Access denied for user 'test'@'localhost' (using password: YES)
update mysql.user set password=old_password("gambling2") where user=_binary"test";
flush privileges;
set password="";
......@@ -64,6 +76,14 @@ time_zone_transition_type
user
show tables;
Tables_in_test
connect(localhost,test,,test2,MASTER_PORT,MASTER_SOCKET);
ERROR 28000: Access denied for user 'test'@'localhost' (using password: NO)
connect(localhost,test,,test,MASTER_PORT,MASTER_SOCKET);
ERROR 28000: Access denied for user 'test'@'localhost' (using password: NO)
connect(localhost,test,zorro,test2,MASTER_PORT,MASTER_SOCKET);
ERROR 28000: Access denied for user 'test'@'localhost' (using password: YES)
connect(localhost,test,zorro,test,MASTER_PORT,MASTER_SOCKET);
ERROR 28000: Access denied for user 'test'@'localhost' (using password: YES)
delete from mysql.user where user=_binary"test";
flush privileges;
create table t1 (id integer not null auto_increment primary key);
......
......@@ -9,13 +9,13 @@ n
flush tables with read lock;
drop table t2;
ERROR HY000: Table 't2' was locked with a READ lock and can't be updated
drop table t2;
drop table t2;
unlock tables;
create database mysqltest;
create table mysqltest.t1(n int);
insert into mysqltest.t1 values (23);
flush tables with read lock;
drop database mysqltest;
drop database mysqltest;
select * from mysqltest.t1;
n
23
......
......@@ -5,7 +5,7 @@ insert into t1 values(1);
flush tables with read lock;
select * from t1;
a
commit;
commit;
select * from t1;
a
unlock tables;
......@@ -14,8 +14,8 @@ select * from t1 for update;
a
1
begin;
select * from t1 for update;
flush tables with read lock;
select * from t1 for update;
flush tables with read lock;
commit;
a
1
......
......@@ -69,7 +69,7 @@ FROM t1
WHERE conn = 'default';
IS_USED_LOCK('bug16501') = connection_id
1
SELECT GET_LOCK('bug16501',600);
SELECT GET_LOCK('bug16501',600);
SELECT IS_USED_LOCK('bug16501') = CONNECTION_ID();
IS_USED_LOCK('bug16501') = CONNECTION_ID()
1
......
......@@ -123,12 +123,12 @@ drop database mysqltest_1;
set password = password("changed");
ERROR 42000: Access denied for user ''@'localhost' to database 'mysql'
lock table mysql.user write;
flush privileges;
grant all on *.* to 'mysqltest_1'@'localhost';
flush privileges;
grant all on *.* to 'mysqltest_1'@'localhost';
unlock tables;
lock table mysql.user write;
set password for 'mysqltest_1'@'localhost' = password('');
revoke all on *.* from 'mysqltest_1'@'localhost';
set password for 'mysqltest_1'@'localhost' = password('');
revoke all on *.* from 'mysqltest_1'@'localhost';
unlock tables;
drop user 'mysqltest_1'@'localhost';
insert into mysql.user (user, host) values
......
......@@ -452,7 +452,7 @@ handler t1 read first;
c1
1
send the below to another connection, do not wait for the result
optimize table t1;
optimize table t1;
proceed with the normal connection
handler t1 read next;
c1
......
......@@ -24,7 +24,7 @@ create table t2 (id int unsigned not null);
insert into t2 select id from t1;
create table t3 (kill_id int);
insert into t3 values(connection_id());
select id from t1 where id in (select distinct id from t2);
select id from t1 where id in (select distinct id from t2);
select ((@id := kill_id) - kill_id) from t3;
((@id := kill_id) - kill_id)
0
......
......@@ -2,8 +2,8 @@ drop table if exists t1,t2;
create table t1(n int);
insert into t1 values (1);
lock tables t1 write;
update low_priority t1 set n = 4;
select n from t1;
update low_priority t1 set n = 4;
select n from t1;
unlock tables;
n
4
......@@ -11,8 +11,8 @@ drop table t1;
create table t1(n int);
insert into t1 values (1);
lock tables t1 read;
update low_priority t1 set n = 4;
select n from t1;
update low_priority t1 set n = 4;
select n from t1;
unlock tables;
n
1
......@@ -23,7 +23,7 @@ insert into t1 values(1,1);
insert into t1 values(2,2);
insert into t2 values(1,2);
lock table t1 read;
update t1,t2 set c=a where b=d;
update t1,t2 set c=a where b=d;
select c from t2;
c
2
......@@ -32,7 +32,7 @@ drop table t2;
create table t1 (a int);
create table t2 (a int);
lock table t1 write, t2 write;
insert t1 select * from t2;
insert t1 select * from t2;
drop table t2;
ERROR 42S02: Table 'test.t2' doesn't exist
drop table t1;
......@@ -193,7 +193,7 @@ select (@before:=unix_timestamp())*0;
(@before:=unix_timestamp())*0
0
begin;
select * from t1 for update;
select * from t1 for update;
insert into t2 values (20);
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select (@after:=unix_timestamp())*0;
......
......@@ -16,7 +16,7 @@ otto
mysqltest: At line 1: query 'select otto from (select 1 as otto) as t1' succeeded - should have failed with sqlstate 42S22...
select friedrich from (select 1 as otto) as t1;
ERROR 42S22: Unknown column 'friedrich' in 'field list'
mysqltest: At line 1: query 'select friedrich from (select 1 as otto) as t1' failed with wrong sqlstate 42S22 instead of 00000...
mysqltest: At line 1: query 'select friedrich from (select 1 as otto) as t1' failed with wrong sqlstate 42S22: 'Unknown column 'friedrich' in 'field list'', instead of 00000...
select otto from (select 1 as otto) as t1;
otto
1
......@@ -133,8 +133,7 @@ ERROR 42S02: Table 'test.t1' doesn't exist
select 1146 as "after_!errno_masked_error" ;
after_!errno_masked_error
1146
mysqltest: At line 1: query 'select 3 from t1' failed with wrong errno 1146 instead of 1000...
mysqltest: At line 1: query 'select 3 from t1' failed with wrong errno 1146 instead of 1000...
mysqltest: At line 1: query 'select 3 from t1' failed with wrong errno 1146: 'Table 'test.t1' doesn't exist', instead of 1000...
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
select 1064 as "after_--enable_abort_on_error" ;
......@@ -142,8 +141,7 @@ after_--enable_abort_on_error
1064
select 3 from t1 ;
ERROR 42S02: Table 'test.t1' doesn't exist
mysqltest: At line 1: query 'select 3 from t1' failed with wrong errno 1146 instead of 1064...
mysqltest: At line 1: query 'select 3 from t1' failed: 1146: Table 'test.t1' doesn't exist
mysqltest: At line 1: query 'select 3 from t1' failed with wrong errno 1146: 'Table 'test.t1' doesn't exist', instead of 1064...
hello
hello
;;;;;;;;
......@@ -151,7 +149,41 @@ hello
mysqltest: At line 1: End of line junk detected: "6"
mysqltest: At line 1: End of line junk detected: "6"
mysqltest: At line 1: Missing delimiter
mysqltest: At line 1: End of line junk detected: "sleep 7
# Another comment
"
mysqltest: At line 1: Missing delimiter
mysqltest: At line 1: Missing delimiter
mysqltest: At line 1: End of line junk detected: "disconnect default
#
# comment
# comment2
# comment 3
--disable_query_log
"
mysqltest: At line 1: End of line junk detected: "disconnect default # comment
# comment part2
# comment 3
--disable_query_log
"
mysqltest: At line 1: Extra delimiter ";" found
mysqltest: At line 1: Extra delimiter ";" found
mysqltest: At line 1: Missing argument(s) to 'error'
mysqltest: At line 1: Missing argument(s) to 'error'
mysqltest: At line 1: The sqlstate definition must start with an uppercase S
mysqltest: At line 1: The error name definition must start with an uppercase E
mysqltest: At line 1: Invalid argument to error: '9eeeee' - the errno may only consist of digits[0-9]
mysqltest: At line 1: Invalid argument to error: '1sssss' - the errno may only consist of digits[0-9]
mysqltest: At line 1: The sqlstate must be exactly 5 chars long
mysqltest: At line 1: The sqlstate may only consist of digits[0-9] and _uppercase_ letters
mysqltest: At line 1: The sqlstate must be exactly 5 chars long
mysqltest: At line 1: Not available in this version of mysqltest
mysqltest: At line 1: Invalid argument to error: '999e9' - the errno may only consist of digits[0-9]
mysqltest: At line 1: Invalid argument to error: '9b' - the errno may only consist of digits[0-9]
mysqltest: At line 1: Too many errorcodes specified
MySQL
"MySQL"
MySQL: The world''s most popular open source database
......@@ -166,8 +198,8 @@ source database
- most popular open
- source database
- MySQL: The world''s
-- most popular open
-- source database
-- most popular
-- open source database
# MySQL: The
--world''s
# most popular
......@@ -193,14 +225,20 @@ source database
# source database
-- MySQL: The
-- world''s most
-- popular open
-- source database
-- popular
-- open source database
# MySQL: The
- world''s most
-- popular open
# source database
'$message'
"$message"
'# MySQL: The
- world''s most
-- popular open
# source database'
"# MySQL: The
- world''s most
-- popular open
# source database"
hej
hej
hej
......@@ -209,21 +247,32 @@ hej
a long variable content
a long variable content
a long $where variable content
a long a long variable content variable content
a long \$where variable content
banana = banana
Not a banana: ba\$cat\$cat
mysqltest: At line 1: Missing arguments to let
mysqltest: At line 1: Missing variable name in let
mysqltest: At line 1: Variable name in hi=hi does not start with '$'
mysqltest: At line 1: Missing assignment operator in let
mysqltest: At line 1: Missing assignment operator in let
mysqltest: At line 1: Missing arguments to let
mysqltest: At line 1: Missing assignment operator in let
mysqltest: At line 1: Missing variable name in let
mysqltest: At line 1: Missing variable name in let
mysqltest: At line 1: Variable name in =hi does not start with '$'
mysqltest: At line 1: Missing assignment operator in let
mysqltest: At line 1: Missing file name in source
# Execute: --echo # <whatever> success: $success
# <whatever> success: 1
# Execute: echo # <whatever> success: $success ;
# <whatever> success: 1
# The next two variants work fine and expand the content of $success
# Execute: --echo $success
1
# Execute: echo $success ;
1
mysqltest: At line 1: Missing required argument 'filename' to command 'source'
mysqltest: At line 1: Could not open file ./non_existingFile
mysqltest: In included file "./var/tmp/recursive.sql": At line 1: Source directives are nesting too deep
mysqltest: In included file "./var/tmp/error.sql": At line 1: query 'garbage ' failed: 1064: 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
mysqltest: In included file "MYSQLTEST_VARDIR/tmp/recursive.sql": At line 1: Source directives are nesting too deep
mysqltest: In included file "MYSQLTEST_VARDIR/tmp/error.sql": At line 1: query 'garbage ' failed: 1064: 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
2 = outer loop variable after while
here is the sourced script
......@@ -288,8 +337,8 @@ mysqltest: At line 1: Invalid argument to real_sleep "abc"
101
hej
1
mysqltest: At line 1: Missing arguments to inc
mysqltest: At line 1: First argument to inc must be a variable (start with $)
mysqltest: At line 1: Missing argument to inc
mysqltest: At line 1: The argument to inc must be a variable (start with $)
mysqltest: At line 1: End of line junk detected: "1000"
4
4
......@@ -298,27 +347,31 @@ mysqltest: At line 1: End of line junk detected: "1000"
99
hej
-1
mysqltest: At line 1: Missing arguments to dec
mysqltest: At line 1: First argument to dec must be a variable (start with $)
mysqltest: At line 1: Missing argument to dec
mysqltest: At line 1: The argument to dec must be a variable (start with $)
mysqltest: At line 1: End of line junk detected: "1000"
mysqltest: At line 1: Missing arguments to system, nothing to do!
mysqltest: At line 1: Missing arguments to system, nothing to do!
mysqltest: At line 1: system command 'false' failed
system command 'NonExistsinfComamdn 2> /dev/null' failed
test
test2
test3
test4
Counter is greater than 0, (counter=10)
Counter is not 0, (counter=0)
1
mysqltest: In included file "./include/mysqltest_while.inc": At line 64: Nesting too deeply
Testing while with not
mysqltest: In included file "MYSQLTEST_VARDIR/tmp/mysqltest_while.inc": At line 64: Nesting too deeply
mysqltest: At line 1: missing '(' in while
mysqltest: At line 1: missing ')' in while
mysqltest: At line 1: Missing '{' after while. Found "dec $i"
mysqltest: At line 1: Stray '}' - end of block before beginning
mysqltest: At line 1: Stray 'end' command - end of block before beginning
mysqltest: At line 1: query '' failed: 1065: Query was empty
mysqltest: At line 1: query '{' failed: 1064: 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 '{' at line 1
mysqltest: At line 1: Missing '{' after while. Found "echo hej"
mysqltest: At line 3: Missing end of block
mysqltest: At line 1: Missing newline between while and '{'
mysqltest: At line 3: Missing end of block
mysqltest: At line 1: missing '(' in if
mysqltest: At line 1: Stray 'end' command - end of block before beginning
select "b" bs col1, "c" bs col2;
......@@ -331,6 +384,7 @@ mysqltest: At line 1: Wrong number of arguments to replace_result in 'replace_re
mysqltest: At line 1: Wrong number of arguments to replace_result in 'replace_result a;'
mysqltest: At line 1: Wrong number of arguments to replace_result in 'replace_result a'
mysqltest: At line 1: Wrong number of arguments to replace_result in 'replace_result a '
OK
mysqltest: At line 1: Wrong number of arguments to replace_result in 'replace_result a b c'
mysqltest: At line 1: Wrong number of arguments to replace_result in 'replace_result a b c '
select "a" as col1, "c" as col2;
......@@ -347,6 +401,18 @@ mysqltest: At line 1: Wrong column number to replace_column in 'replace_column 1
mysqltest: At line 1: Invalid integer argument "10!"
mysqltest: At line 1: End of line junk detected: "!"
mysqltest: At line 1: Invalid integer argument "a"
mysqltest: At line 1: Missing required argument 'connection name' to command 'connect'
mysqltest: At line 1: Missing required argument 'connection name' to command 'connect'
mysqltest: At line 1: Missing required argument 'host' to command 'connect'
mysqltest: At line 1: Missing required argument 'host' to command 'connect'
mysqltest: At line 1: query 'connect con2,localhost,root,,illegal_db' failed: 1049: Unknown database 'illegal_db'
mysqltest: At line 1: Illegal argument for port: 'illegal_port'
mysqltest: At line 1: Illegal option to connect: SMTP
OK
mysqltest: In included file "MYSQLTEST_VARDIR/tmp/mysqltest.sql": At line 7: Connection limit exhausted, you can have max 128 connections
mysqltest: In included file "MYSQLTEST_VARDIR/tmp/mysqltest.sql": At line 3: connection 'test_con1' not found in connection pool
mysqltest: In included file "MYSQLTEST_VARDIR/tmp/mysqltest.sql": At line 2: Connection test_con1 already exists
connect(localhost,root,,test,MASTER_PORT,MASTER_SOCKET);
Output from mysqltest-x.inc
Output from mysqltest-x.inc
Output from mysqltest-x.inc
......@@ -358,3 +424,98 @@ ERROR 42000: You have an error in your SQL syntax; check the manual that corresp
SELECT 1 as a;
a
1
select 1 as `a'b`, 2 as `a"b`;
a'b a"b
1 2
select 'aaa\\','aa''a',"aa""a";
aaa\ aa'a aa"a
aaa\ aa'a aa"a
Here comes a message
--------------------
root@localhost
--------------
"Here comes a very very long message that
- is longer then 80 characters and
- consists of several lines"
--------------------------------------------------------------------------------
. Here comes a very very long message that
. - is longer then 80 characters and
. - consists of several lines
--------------------------------------------------------------------------------
this will be executed
this will be executed
mysqltest: Result length mismatch
mysqltest: The test didn't produce any output
Failing multi statement query
mysqltest: At line 3: query 'create table t1 (a int primary key);
insert into t1 values (1);
select 'select-me';
insertz 'error query'' failed: 1064: 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 'insertz 'error query'' at line 1
drop table t1;
mysqltest: At line 3: query 'create table t1 (a int primary key);
insert into t1 values (1);
select 'select-me';
insertz 'error query'' failed: 1064: 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 'insertz 'error query'' at line 1
drop table t1;
Multi statement using expected error
create table t1 (a int primary key);
insert into t1 values (1);
select 'select-me';
insertz error query||||
select-me
select-me
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 'insertz error query' at line 1
drop table t1;
drop table t1;
sleep;
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 'sleep' at line 1
sleep;
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 'sleep' at line 1
;
ERROR 42000: Query was empty
select "b" as col1, "c" as col2;
col1 col2
b c
select "b" as col1, "b" as col2, "c" as col3;
col1 col2 col3
b b c
seled "b" bs col1, "d" bs col2;
col1 col2
b d
select "raspberry and strawberry","blackberry","tomato";
raspberry and strawberry blackberry tomato
raspberry and strawberry blackberry tomato
mysqltest: At line 1: Error parsing replace_regex "a"
mysqltest: At line 1: Error parsing replace_regex "a;"
mysqltest: At line 1: Error parsing replace_regex "a"
mysqltest: At line 1: Error parsing replace_regex "a "
mysqltest: At line 1: Error parsing replace_regex "a b"
mysqltest: At line 1: Error parsing replace_regex "/a b c"
mysqltest: At line 1: Error parsing replace_regex "/a /b c "
create table t1 (a int, b int);
insert into t1 values (1,3);
insert into t1 values (2,4);
select * from t1;
a D
1 1
1 4
drop table t1;
mysqltest: At line 1: Missing required argument 'filename' to command 'remove_file'
mysqltest: At line 1: Missing required argument 'filename' to command 'write_file'
mysqltest: At line 1: End of file encountered before 'EOF' delimiter was found
mysqltest: At line 1: End of line junk detected: "write_file filename ";
"
mysqltest: At line 1: Missing required argument 'filename' to command 'file_exists'
mysqltest: At line 1: Missing required argument 'from_file' to command 'copy_file'
mysqltest: At line 1: Missing required argument 'to_file' to command 'copy_file'
hello
hello
hello
mysqltest: At line 1: Max delimiter length(16) exceeded
hello
hello
End of tests
......@@ -85,6 +85,8 @@ c1 c2 c3 c4 c5 c6 c7 c8 c9 c10 c11 c12 c13 c14 c15 c16 c17 c18 c19 c20 c21 c22 c
1 1 1 1 1 1 1 1 1 1 1.0000 1.0000 2004-02-29 2004-02-29 11:11:11 2004-02-29 11:11:11 11:11:11 2004 1 1 a 123456789a 123456789a123456789b123456789c tinyblob tinytext blob text mediumblob mediumtext longblob longtext one monday
9 9 9 9 9 9 9 9 9 9 9.0000 9.0000 2004-02-29 2004-02-29 11:11:11 2004-02-29 11:11:11 11:11:11 2004 1 0 a 123456789a 123456789a123456789b123456789c tinyblob tinytext blob text mediumblob mediumtext longblob longtext two tuesday
set @arg00='SELECT' ;
@arg00 a from t1 where a=1;
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 '@arg00 a from t1 where a=1' at line 1
prepare stmt1 from ' ? a from t1 where a=1 ';
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 '? a from t1 where a=1' at line 1
set @arg00=1 ;
......
......@@ -85,6 +85,8 @@ c1 c2 c3 c4 c5 c6 c7 c8 c9 c10 c11 c12 c13 c14 c15 c16 c17 c18 c19 c20 c21 c22 c
1 1 1 1 1 1 1 1 1 1 1.0000 1.0000 2004-02-29 2004-02-29 11:11:11 2004-02-29 11:11:11 11:11:11 2004 1 1 a 123456789a 123456789a123456789b123456789c tinyblob tinytext blob text mediumblob mediumtext longblob longtext one monday
9 9 9 9 9 9 9 9 9 9 9.0000 9.0000 2004-02-29 2004-02-29 11:11:11 2004-02-29 11:11:11 11:11:11 2004 1 0 a 123456789a 123456789a123456789b123456789c tinyblob tinytext blob text mediumblob mediumtext longblob longtext two tuesday
set @arg00='SELECT' ;
@arg00 a from t1 where a=1;
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 '@arg00 a from t1 where a=1' at line 1
prepare stmt1 from ' ? a from t1 where a=1 ';
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 '? a from t1 where a=1' at line 1
set @arg00=1 ;
......
......@@ -86,6 +86,8 @@ c1 c2 c3 c4 c5 c6 c7 c8 c9 c10 c11 c12 c13 c14 c15 c16 c17 c18 c19 c20 c21 c22 c
1 1 1 1 1 1 1 1 1 1 1.0000 1.0000 2004-02-29 2004-02-29 11:11:11 2004-02-29 11:11:11 11:11:11 2004 1 1 a 123456789a 123456789a123456789b123456789c tinyblob tinytext blob text mediumblob mediumtext longblob longtext one monday
9 9 9 9 9 9 9 9 9 9 9.0000 9.0000 2004-02-29 2004-02-29 11:11:11 2004-02-29 11:11:11 11:11:11 2004 1 0 a 123456789a 123456789a123456789b123456789c tinyblob tinytext blob text mediumblob mediumtext longblob longtext two tuesday
set @arg00='SELECT' ;
@arg00 a from t1 where a=1;
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 '@arg00 a from t1 where a=1' at line 1
prepare stmt1 from ' ? a from t1 where a=1 ';
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 '? a from t1 where a=1' at line 1
set @arg00=1 ;
......
......@@ -128,6 +128,8 @@ c1 c2 c3 c4 c5 c6 c7 c8 c9 c10 c11 c12 c13 c14 c15 c16 c17 c18 c19 c20 c21 c22 c
1 1 1 1 1 1 1 1 1 1 1.0000 1.0000 2004-02-29 2004-02-29 11:11:11 2004-02-29 11:11:11 11:11:11 2004 1 1 a 123456789a 123456789a123456789b123456789c tinyblob tinytext blob text mediumblob mediumtext longblob longtext one monday
9 9 9 9 9 9 9 9 9 9 9.0000 9.0000 2004-02-29 2004-02-29 11:11:11 2004-02-29 11:11:11 11:11:11 2004 1 0 a 123456789a 123456789a123456789b123456789c tinyblob tinytext blob text mediumblob mediumtext longblob longtext two tuesday
set @arg00='SELECT' ;
@arg00 a from t1 where a=1;
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 '@arg00 a from t1 where a=1' at line 1
prepare stmt1 from ' ? a from t1 where a=1 ';
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 '? a from t1 where a=1' at line 1
set @arg00=1 ;
......@@ -3142,6 +3144,8 @@ c1 c2 c3 c4 c5 c6 c7 c8 c9 c10 c11 c12 c13 c14 c15 c16 c17 c18 c19 c20 c21 c22 c
1 1 1 1 1 1 1 1 1 1 1.0000 1.0000 2004-02-29 2004-02-29 11:11:11 2004-02-29 11:11:11 11:11:11 2004 1 1 a 123456789a 123456789a123456789b123456789c tinyblob tinytext blob text mediumblob mediumtext longblob longtext one monday
9 9 9 9 9 9 9 9 9 9 9.0000 9.0000 2004-02-29 2004-02-29 11:11:11 2004-02-29 11:11:11 11:11:11 2004 1 0 a 123456789a 123456789a123456789b123456789c tinyblob tinytext blob text mediumblob mediumtext longblob longtext two tuesday
set @arg00='SELECT' ;
@arg00 a from t1 where a=1;
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 '@arg00 a from t1 where a=1' at line 1
prepare stmt1 from ' ? a from t1 where a=1 ';
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 '? a from t1 where a=1' at line 1
set @arg00=1 ;
......
......@@ -85,6 +85,8 @@ c1 c2 c3 c4 c5 c6 c7 c8 c9 c10 c11 c12 c13 c14 c15 c16 c17 c18 c19 c20 c21 c22 c
1 1 1 1 1 1 1 1 1 1 1.0000 1.0000 2004-02-29 2004-02-29 11:11:11 2004-02-29 11:11:11 11:11:11 2004 1 1 a 123456789a 123456789a123456789b123456789c tinyblob tinytext blob text mediumblob mediumtext longblob longtext one monday
9 9 9 9 9 9 9 9 9 9 9.0000 9.0000 2004-02-29 2004-02-29 11:11:11 2004-02-29 11:11:11 11:11:11 2004 1 0 a 123456789a 123456789a123456789b123456789c tinyblob tinytext blob text mediumblob mediumtext longblob longtext two tuesday
set @arg00='SELECT' ;
@arg00 a from t1 where a=1;
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 '@arg00 a from t1 where a=1' at line 1
prepare stmt1 from ' ? a from t1 where a=1 ';
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 '? a from t1 where a=1' at line 1
set @arg00=1 ;
......
......@@ -85,6 +85,8 @@ c1 c2 c3 c4 c5 c6 c7 c8 c9 c10 c11 c12 c13 c14 c15 c16 c17 c18 c19 c20 c21 c22 c
1 1 1 1 1 1 1 1 1 1 1.0000 1.0000 2004-02-29 2004-02-29 11:11:11 2004-02-29 11:11:11 11:11:11 2004 1 1 a 123456789a 123456789a123456789b123456789c tinyblob tinytext blob text mediumblob mediumtext longblob longtext one monday
9 9 9 9 9 9 9 9 9 9 9.0000 9.0000 2004-02-29 2004-02-29 11:11:11 2004-02-29 11:11:11 11:11:11 2004 1 0 a 123456789a 123456789a123456789b123456789c tinyblob tinytext blob text mediumblob mediumtext longblob longtext two tuesday
set @arg00='SELECT' ;
@arg00 a from t1 where a=1;
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 '@arg00 a from t1 where a=1' at line 1
prepare stmt1 from ' ? a from t1 where a=1 ';
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 '? a from t1 where a=1' at line 1
set @arg00=1 ;
......
......@@ -43,7 +43,7 @@ Note 1051 Unknown table 't4'
CREATE TABLE t1 (a int);
CREATE TABLE t3 (a int);
FLUSH TABLES WITH READ LOCK;
RENAME TABLE t1 TO t2, t3 to t4;
RENAME TABLE t1 TO t2, t3 to t4;
show tables;
Tables_in_test
t1
......
......@@ -59,7 +59,7 @@ create table t2(id int);
insert into t2 values(connection_id());
create temporary table t3(n int);
insert into t3 select get_lock('crash_lock%20C', 1) from t2;
update t1 set n = n + get_lock('crash_lock%20C', 2);
update t1 set n = n + get_lock('crash_lock%20C', 2);
select (@id := id) - id from t2;
(@id := id) - id
0
......
reset master;
reset slave;
start slave;
show binary logs;
Log_name
master-bin.000001
master-bin.000002
drop table if exists t1;
create table t1(n int);
insert into t1 values (3351);
select * from t1;
n
3351
drop table t1;
slave stop;
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;
slave start;
reset master;
change master to master_host='127.0.0.1',master_port=9307, master_user='root';
start slave;
create temporary table t1 (a int);
create temporary table t1 (a int);
show status like 'slave_open_temp_tables';
Variable_name Value
Slave_open_temp_tables 2
create temporary table t1 (a int);
create temporary table t1 (a int);
show status like 'slave_open_temp_tables';
Variable_name Value
Slave_open_temp_tables 4
stop slave;
insert into t1 values(1);
create table t2 as select * from t1;
start slave;
show status like 'slave_open_temp_tables';
Variable_name Value
Slave_open_temp_tables 4
select * from t2;
a
1
drop table t2;
......@@ -147,10 +147,10 @@ master-bin.000001 3577 Intvar 1 3577 INSERT_ID=4
master-bin.000001 3605 Query 1 3605 use `mysqltest2`; insert into t1 (b) values(LEAST("Müller","Muffler"))
master-bin.000001 3698 Query 1 3698 use `mysqltest2`; SET ONE_SHOT CHARACTER_SET_CLIENT=8,COLLATION_CONNECTION=31,COLLATION_DATABASE=9,COLLATION_SERVER=64
master-bin.000001 3839 Intvar 1 3839 INSERT_ID=74
master-bin.000001 3867 Create_file 1 3867 db=mysqltest2;table=t1;file_id=1;block_len=581
master-bin.000001 3867 Create_file 1 3867 db=mysqltest2;table=t1;file_id=x;block_len=581
master-bin.000001 4540 Query 1 4540 use `mysqltest2`; SET ONE_SHOT CHARACTER_SET_CLIENT=8,COLLATION_CONNECTION=31,COLLATION_DATABASE=9,COLLATION_SERVER=64
master-bin.000001 4681 Intvar 1 4681 INSERT_ID=5
master-bin.000001 4709 Exec_load 1 4709 ;file_id=1
master-bin.000001 4709 Exec_load 1 4709 ;file_id=x
master-bin.000001 4732 Query 1 4732 use `mysqltest2`; SET ONE_SHOT CHARACTER_SET_CLIENT=8,COLLATION_CONNECTION=31,COLLATION_DATABASE=9,COLLATION_SERVER=64
master-bin.000001 4873 Query 1 4873 use `mysqltest2`; truncate table t1
master-bin.000001 4931 Query 1 4931 use `mysqltest2`; SET ONE_SHOT CHARACTER_SET_CLIENT=8,COLLATION_CONNECTION=31,COLLATION_DATABASE=9,COLLATION_SERVER=64
......
......@@ -20,7 +20,7 @@ create table t2 (a int primary key);
insert into t2 values(1);
create table t3 (id int);
insert into t3 values(connection_id());
update t2 set a = a + 1 + get_lock('crash_lock%20C', 10);
update t2 set a = a + 1 + get_lock('crash_lock%20C', 10);
select (@id := id) - id from t3;
(@id := id) - id
0
......
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;
show variables like 'rpl_recovery_rank';
Variable_name Value
rpl_recovery_rank 1
show status like 'Rpl_status';
Variable_name Value
Rpl_status AUTH_MASTER
create table t1(n int);
drop table t1;
show variables like 'rpl_recovery_rank';
Variable_name Value
rpl_recovery_rank 2
show status like 'Rpl_status';
Variable_name Value
Rpl_status ACTIVE_SLAVE
start slave;
show variables like 'rpl_recovery_rank';
Variable_name Value
rpl_recovery_rank 3
show status like 'Rpl_status';
Variable_name Value
Rpl_status ACTIVE_SLAVE
start slave;
show variables like 'rpl_recovery_rank';
Variable_name Value
rpl_recovery_rank 4
show status like 'Rpl_status';
Variable_name Value
Rpl_status ACTIVE_SLAVE
reset master;
drop table if exists t1;
create table t1 type=HEAP select 10 as a;
insert into t1 values(11);
show binlog events from 79;
Log_name Pos Event_type Server_id Orig_log_pos Info
master-bin.001 79 Query 1 79 use `test`; create table t1 type=HEAP select 10 as a
master-bin.001 154 Query 1 154 use `test`; insert into t1 values(11)
reset slave;
start slave;
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` bigint(2) NOT NULL default '0'
) TYPE=HEAP
select * from t1;
a
10
11
select * from t1;
a
select * from t1 limit 10;
a
show binlog events in 'master-bin.002' from 79;
Log_name Pos Event_type Server_id Orig_log_pos Info
master-bin.002 79 Query 1 79 use `test`; DELETE FROM `test`.`t1`
select * from t1;
a
drop table t1;
......@@ -22,7 +22,7 @@ day id category name
2003-03-22 2416 a bbbbb
show master status;
File Position Binlog_Do_DB Binlog_Ignore_DB
slave-bin.000001 964
slave-bin.000001 950
drop table t1;
drop table t2;
drop table t3;
......
......@@ -5,9 +5,9 @@ reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
start slave;
create table t1(a int);
select * into outfile '../../var/master-data/rpl_loaddatalocal.select_outfile' from t1;
select * into outfile 'MYSQLTEST_VARDIR/master-data/rpl_loaddatalocal.select_outfile' from t1;
truncate table t1;
load data local infile './var/master-data/rpl_loaddatalocal.select_outfile' into table t1;
load data local infile 'MYSQLTEST_VARDIR/master-data/rpl_loaddatalocal.select_outfile' into table t1;
select a,count(*) from t1 group by a;
a count(*)
1 10000
......
......@@ -73,7 +73,7 @@ master-bin.000002 276
start slave;
show binary logs;
Log_name File_size
slave-bin.000001 1285
slave-bin.000001 1278
slave-bin.000002 170
show binlog events in 'slave-bin.000001' from 4;
Log_name Pos Event_type Server_id Orig_log_pos Info
......@@ -84,11 +84,11 @@ slave-bin.000001 200 Query 1 200 use `test`; insert into t1 values (NULL)
slave-bin.000001 263 Query 1 263 use `test`; drop table t1
slave-bin.000001 311 Query 1 311 use `test`; create table t1 (word char(20) not null)
slave-bin.000001 386 Create_file 1 386 db=test;table=t1;file_id=1;block_len=581
slave-bin.000001 1065 Exec_load 1 1065 ;file_id=1
slave-bin.000001 1088 Query 1 1088 use `test`; drop table t1
slave-bin.000001 1136 Query 1 1136 use `test`; create table t5 (a int)
slave-bin.000001 1194 Query 1 1194 use `test`; drop table t5
slave-bin.000001 1242 Rotate 2 1242 slave-bin.000002;pos=4
slave-bin.000001 1058 Exec_load 1 1058 ;file_id=1
slave-bin.000001 1081 Query 1 1081 use `test`; drop table t1
slave-bin.000001 1129 Query 1 1129 use `test`; create table t5 (a int)
slave-bin.000001 1187 Query 1 1187 use `test`; drop table t5
slave-bin.000001 1235 Rotate 2 1235 slave-bin.000002;pos=4
show binlog events in 'slave-bin.000002' from 4;
Log_name Pos Event_type Server_id Orig_log_pos Info
slave-bin.000002 4 Query 1 4 use `test`; create table t1 (n int)
......
......@@ -12,7 +12,7 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings:
Note 1003 select sql_no_cache master_pos_wait(_latin1'master-bin.999999',0,2) AS `master_pos_wait('master-bin.999999',0,2)`
select master_pos_wait('master-bin.999999',0);
select master_pos_wait('master-bin.999999',0);
stop slave sql_thread;
master_pos_wait('master-bin.999999',0)
NULL
......@@ -2697,8 +2697,7 @@ select (1,2,3) = (select * from t1);
ERROR 21000: Operand should contain 3 column(s)
select (select * from t1) = (1,2,3);
ERROR 21000: Operand should contain 2 column(s)
drop table t1
#;
drop table t1;
CREATE TABLE `t1` (
`itemid` bigint(20) unsigned NOT NULL auto_increment,
`sessionid` bigint(20) unsigned default NULL,
......
CREATE TABLE t1 (x1 int);
ALTER TABLE t1 CHANGE x1 x2 int;
ALTER TABLE t1 CHANGE x1 x2 int;
CREATE TABLE t2 LIKE t1;
SHOW CREATE TABLE t2;
Table Create Table
......@@ -7,7 +7,7 @@ t2 CREATE TABLE `t2` (
`xx` int(11) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t2;
ALTER TABLE t1 CHANGE x2 x1 int;
ALTER TABLE t1 CHANGE x2 x1 int;
CREATE TABLE t2 LIKE t1;
SHOW CREATE TABLE t2;
Table Create Table
......@@ -15,7 +15,7 @@ t2 CREATE TABLE `t2` (
`xx` int(11) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t2;
ALTER TABLE t1 CHANGE x1 x2 int;
ALTER TABLE t1 CHANGE x1 x2 int;
CREATE TABLE t2 LIKE t1;
SHOW CREATE TABLE t2;
Table Create Table
......@@ -23,7 +23,7 @@ t2 CREATE TABLE `t2` (
`xx` int(11) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t2;
ALTER TABLE t1 CHANGE x2 x1 int;
ALTER TABLE t1 CHANGE x2 x1 int;
CREATE TABLE t2 LIKE t1;
SHOW CREATE TABLE t2;
Table Create Table
......@@ -31,7 +31,7 @@ t2 CREATE TABLE `t2` (
`xx` int(11) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t2;
ALTER TABLE t1 CHANGE x1 x2 int;
ALTER TABLE t1 CHANGE x1 x2 int;
CREATE TABLE t2 LIKE t1;
SHOW CREATE TABLE t2;
Table Create Table
......@@ -39,7 +39,7 @@ t2 CREATE TABLE `t2` (
`xx` int(11) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t2;
ALTER TABLE t1 CHANGE x2 x1 int;
ALTER TABLE t1 CHANGE x2 x1 int;
CREATE TABLE t2 LIKE t1;
SHOW CREATE TABLE t2;
Table Create Table
......@@ -47,7 +47,7 @@ t2 CREATE TABLE `t2` (
`xx` int(11) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t2;
ALTER TABLE t1 CHANGE x1 x2 int;
ALTER TABLE t1 CHANGE x1 x2 int;
CREATE TABLE t2 LIKE t1;
SHOW CREATE TABLE t2;
Table Create Table
......@@ -55,7 +55,7 @@ t2 CREATE TABLE `t2` (
`xx` int(11) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t2;
ALTER TABLE t1 CHANGE x2 x1 int;
ALTER TABLE t1 CHANGE x2 x1 int;
CREATE TABLE t2 LIKE t1;
SHOW CREATE TABLE t2;
Table Create Table
......@@ -63,7 +63,7 @@ t2 CREATE TABLE `t2` (
`xx` int(11) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t2;
ALTER TABLE t1 CHANGE x1 x2 int;
ALTER TABLE t1 CHANGE x1 x2 int;
CREATE TABLE t2 LIKE t1;
SHOW CREATE TABLE t2;
Table Create Table
......@@ -71,7 +71,7 @@ t2 CREATE TABLE `t2` (
`xx` int(11) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t2;
ALTER TABLE t1 CHANGE x2 x1 int;
ALTER TABLE t1 CHANGE x2 x1 int;
CREATE TABLE t2 LIKE t1;
SHOW CREATE TABLE t2;
Table Create Table
......@@ -79,7 +79,7 @@ t2 CREATE TABLE `t2` (
`xx` int(11) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t2;
ALTER TABLE t1 CHANGE x1 x2 int;
ALTER TABLE t1 CHANGE x1 x2 int;
CREATE TABLE t2 LIKE t1;
SHOW CREATE TABLE t2;
Table Create Table
......@@ -87,7 +87,7 @@ t2 CREATE TABLE `t2` (
`xx` int(11) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t2;
ALTER TABLE t1 CHANGE x2 x1 int;
ALTER TABLE t1 CHANGE x2 x1 int;
CREATE TABLE t2 LIKE t1;
SHOW CREATE TABLE t2;
Table Create Table
......@@ -95,7 +95,7 @@ t2 CREATE TABLE `t2` (
`xx` int(11) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t2;
ALTER TABLE t1 CHANGE x1 x2 int;
ALTER TABLE t1 CHANGE x1 x2 int;
CREATE TABLE t2 LIKE t1;
SHOW CREATE TABLE t2;
Table Create Table
......@@ -103,7 +103,7 @@ t2 CREATE TABLE `t2` (
`xx` int(11) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t2;
ALTER TABLE t1 CHANGE x2 x1 int;
ALTER TABLE t1 CHANGE x2 x1 int;
CREATE TABLE t2 LIKE t1;
SHOW CREATE TABLE t2;
Table Create Table
......@@ -111,7 +111,7 @@ t2 CREATE TABLE `t2` (
`xx` int(11) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t2;
ALTER TABLE t1 CHANGE x1 x2 int;
ALTER TABLE t1 CHANGE x1 x2 int;
CREATE TABLE t2 LIKE t1;
SHOW CREATE TABLE t2;
Table Create Table
......@@ -119,7 +119,7 @@ t2 CREATE TABLE `t2` (
`xx` int(11) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t2;
ALTER TABLE t1 CHANGE x2 x1 int;
ALTER TABLE t1 CHANGE x2 x1 int;
CREATE TABLE t2 LIKE t1;
SHOW CREATE TABLE t2;
Table Create Table
......@@ -127,7 +127,7 @@ t2 CREATE TABLE `t2` (
`xx` int(11) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t2;
ALTER TABLE t1 CHANGE x1 x2 int;
ALTER TABLE t1 CHANGE x1 x2 int;
CREATE TABLE t2 LIKE t1;
SHOW CREATE TABLE t2;
Table Create Table
......@@ -135,7 +135,7 @@ t2 CREATE TABLE `t2` (
`xx` int(11) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t2;
ALTER TABLE t1 CHANGE x2 x1 int;
ALTER TABLE t1 CHANGE x2 x1 int;
CREATE TABLE t2 LIKE t1;
SHOW CREATE TABLE t2;
Table Create Table
......@@ -143,7 +143,7 @@ t2 CREATE TABLE `t2` (
`xx` int(11) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t2;
ALTER TABLE t1 CHANGE x1 x2 int;
ALTER TABLE t1 CHANGE x1 x2 int;
CREATE TABLE t2 LIKE t1;
SHOW CREATE TABLE t2;
Table Create Table
......@@ -151,7 +151,7 @@ t2 CREATE TABLE `t2` (
`xx` int(11) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t2;
ALTER TABLE t1 CHANGE x2 x1 int;
ALTER TABLE t1 CHANGE x2 x1 int;
CREATE TABLE t2 LIKE t1;
SHOW CREATE TABLE t2;
Table Create Table
......
......@@ -24,8 +24,7 @@ t3 CREATE TABLE `t3` (
`a` mediumtext,
`b` mediumblob
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1,t2,t3
#;
drop table t1,t2,t3;
CREATE TABLE t1 (a char(257) default "hello");
ERROR 42000: Column length too big for column 'a' (max = 255); use BLOB or TEXT instead
CREATE TABLE t2 (a blob default "hello");
......
# This test is to check various cases of connections
# with right and wrong password, with and without database
# Unfortunately the check is incomplete as we can't handle errors on connect
# Also we can't connect without database
# with right and wrong password, with and without database
# Unfortunately the check is incomplete as we can't connect without database
# This test makes no sense with the embedded server
--source include/not_embedded.inc
......@@ -10,69 +9,73 @@
drop table if exists t1,t2;
--enable_warnings
#connect (con1,localhost,root,,"");
#show tables;
connect (con1,localhost,root,,mysql);
show tables;
connect (con1,localhost,root,,test);
connect (con2,localhost,root,,test);
show tables;
# Re enable this one day if error handling on connect will take place
#connect (con1,localhost,root,z,test2);
#--error 1045
#connect (con1,localhost,root,z,);
#--error 1045
--replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT
--error 1045
connect (fail_con,localhost,root,z,test2);
--replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT
--error 1045
connect (fail_con,localhost,root,z,);
grant ALL on *.* to test@localhost identified by "gambling";
grant ALL on *.* to test@127.0.0.1 identified by "gambling";
# Now check this user with different databases
#connect (con1,localhost,test,gambling,"");
#show tables;
connect (con1,localhost,test,gambling,mysql);
connect (con3,localhost,test,gambling,mysql);
show tables;
connect (con1,localhost,test,gambling,test);
connect (con4,localhost,test,gambling,test);
show tables;
# Re enable this one day if error handling on connect will take place
#connect (con1,localhost,test,,test2);
#--error 1045
#connect (con1,localhost,test,,"");
#--error 1045
#connect (con1,localhost,test,zorro,test2);
#--error 1045
#connect (con1,localhost,test,zorro,);
#--error 1045
--replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT
--error 1045
connect (fail_con,localhost,test,,test2);
--replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT
--error 1045
connect (fail_con,localhost,test,,"");
--replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT
--error 1045
connect (fail_con,localhost,test,zorro,test2);
--replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT
--error 1045
connect (fail_con,localhost,test,zorro,);
# check if old password version also works
update mysql.user set password=old_password("gambling2") where user=_binary"test";
flush privileges;
#connect (con1,localhost,test,gambling2,"");
#show tables;
connect (con1,localhost,test,gambling2,mysql);
connect (con10,localhost,test,gambling2,);
connect (con5,localhost,test,gambling2,mysql);
connection con5;
set password="";
--error 1105
set password='gambling3';
set password=old_password('gambling3');
show tables;
connect (con1,localhost,test,gambling3,test);
connect (con6,localhost,test,gambling3,test);
show tables;
# Re enable this one day if error handling on connect will take place
#connect (con1,localhost,test,,test2);
#--error 1045
#connect (con1,localhost,test,,);
#--error 1045
#connect (con1,localhost,test,zorro,test2);
#--error 1045
#connect (con1,localhost,test,zorro,);
#--error 1045
--replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT
--error 1045
connect (fail_con,localhost,test,,test2);
--replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT
--error 1045
connect (fail_con,localhost,test,,);
--replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT
--error 1045
connect (fail_con,localhost,test,zorro,test2);
--replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT
--error 1045
connect (fail_con,localhost,test,zorro,);
# remove user 'test' so that other tests which may use 'test'
......@@ -84,13 +87,13 @@ flush privileges;
#
# Bug#12517: Clear user variables and replication events before
# closing temp tables in thread cleanup.
connect (con2,localhost,root,,test);
connection con2;
connect (con7,localhost,root,,test);
connection con7;
create table t1 (id integer not null auto_increment primary key);
create temporary table t2(id integer not null auto_increment primary key);
set @id := 1;
delete from t1 where id like @id;
disconnect con2;
disconnect con7;
--sleep 5
connection default;
drop table t1;
......
......@@ -4,6 +4,7 @@
#
# See mysql-test/std_data/init_file.dat and
# mysql-test/t/init_file-master.opt for the actual test
#
#
# End of 4.1 tests
--echo ok
--echo End of 4.1 tests
......@@ -8,8 +8,8 @@
# server or run mysql-test-run --debug mysql_client_test and check
# var/log/mysql_client_test.trace
--disable_result_log
--exec echo $MYSQL_CLIENT_TEST --getopt-ll-test=25600M
--exec $MYSQL_CLIENT_TEST --getopt-ll-test=25600M
--exec echo "$MYSQL_CLIENT_TEST --getopt-ll-test=25600M" > $MYSQLTEST_VARDIR/log/mysql_client_test.log 2>&1
--exec $MYSQL_CLIENT_TEST --getopt-ll-test=25600M >> $MYSQLTEST_VARDIR/log/mysql_client_test.log 2>&1
# End of 4.1 tests
echo ok;
# This test should work in embedded server after mysqltest is fixed
-- source include/not_embedded.inc
# ============================================================================
......@@ -26,7 +27,7 @@
# ----------------------------------------------------------------------------
# $mysql_errno contains the return code of the last command
# send to the server.
# sent to the server.
# ----------------------------------------------------------------------------
# get $mysql_errno before the first statement
# $mysql_errno should be -1
......@@ -49,7 +50,7 @@ select otto from (select 1 as otto) as t1;
# ----------------------------------------------------------------------------
# Negative case(statement):
# The dervied table t1 does not contain a column named 'friedrich' .
# The derived table t1 does not contain a column named 'friedrich' .
# --> ERROR 42S22: Unknown column 'friedrich' in 'field list and
# --> 1054: Unknown column 'friedrich' in 'field list'
# ----------------------------------------------------------------------------
......@@ -67,7 +68,7 @@ select friedrich from (select 1 as otto) as t1;
# The following unmasked unsuccessful statement must give
# 1. mysqltest gives a 'failed'
# 2. does not produce a r/<test case>.reject file !!!
# PLEASE uncomment it and check it's effect
# PLEASE uncomment it and check its effect
#select friedrich from (select 1 as otto) as t1;
......@@ -113,7 +114,7 @@ select friedrich from (select 1 as otto) as t1;
# test cases for $mysql_errno
#
# $mysql_errno is a builtin variable of mysqltest and contains the return code
# of the last command send to the server.
# of the last command sent to the server.
#
# The following test cases often initialize $mysql_errno to 1064 by
# a command with wrong syntax.
......@@ -216,7 +217,7 @@ garbage ;
execute stmt;
eval select $mysql_errno as "after_successful_execute" ;
# failing execute (table dropped)
# failing execute (table has been dropped)
drop table t1;
--error 1064
garbage ;
......@@ -248,8 +249,8 @@ eval select $mysql_errno as "after_failing_deallocate" ;
# ----------------------------------------------------------------------------
# test cases for "--disable_abort_on_error"
#
# "--disable_abort_on_error" switches the abort of mysqltest
# after "unmasked" failing statements off.
# "--disable_abort_on_error" switches off the abort of mysqltest
# after "unmasked" failing statements.
#
# The default is "--enable_abort_on_error".
#
......@@ -257,13 +258,13 @@ eval select $mysql_errno as "after_failing_deallocate" ;
# --error <error number> and --error <error number>
# in the line before the failing statement.
#
# There are some additional test case for $mysql_errno
# There are some additional test cases for $mysql_errno
# because "--disable_abort_on_error" enables a new situation.
# Example: "unmasked" statement fails + analysis of $mysql_errno
# ----------------------------------------------------------------------------
# ----------------------------------------------------------------------------
# Switch the abort on error off and check the effect on $mysql_errno
# Switch off the abort on error and check the effect on $mysql_errno
# ----------------------------------------------------------------------------
--error 1064
garbage ;
......@@ -316,7 +317,6 @@ select 3 from t1 ;
#
#select 3 from t1 ;
# End of 4.1 tests
--error 1
--exec echo "disable_abort_on_error; enable_abort_on_error; error 1064; select 3 from t1; select 3 from t1;" | $MYSQL_TEST 2>&1
......@@ -344,7 +344,7 @@ select 3 from t1 ;
# ----------------------------------------------------------------------------
# Test detect end of line "junk"
# Most likely causes by a missing delimiter
# Most likely caused by a missing delimiter
# ----------------------------------------------------------------------------
# Too many parameters to function
......@@ -359,23 +359,157 @@ select 3 from t1 ;
# Missing delimiter
# The comment will be "sucked into" the sleep command since
# delimiter is missing until after "show status"
--system echo "sleep 4" > var/log/mysqltest.sql
--system echo "# A comment" >> var/log/mysqltest.sql
--system echo "show status;" >> var/log/mysqltest.sql
--write_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql
sleep 4
# A comment
show status;
EOF
--error 1
--exec $MYSQL_TEST < var/log/mysqltest.sql 2>&1
--exec $MYSQL_TEST < $MYSQLTEST_VARDIR/tmp/mysqltest.sql 2>&1
#
# Missing delimiter until eof
# The comment will be "sucked into" the sleep command since
# delimiter is missing
--write_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql
sleep 7
# Another comment
EOF
--error 1
--exec $MYSQL_TEST < $MYSQLTEST_VARDIR/tmp/mysqltest.sql 2>&1
#
# Missing delimiter until "disable_query_log"
#
--write_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql
disconnect default
#
# comment
# comment 3
disable_query_log;
EOF
--error 1
--exec $MYSQL_TEST < $MYSQLTEST_VARDIR/tmp/mysqltest.sql 2>&1
#
# Missing delimiter until "disable_query_log"
#
--write_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql
disconnect default
#
# comment
# comment 3
disable_query_log;
EOF
--error 1
--exec $MYSQL_TEST < $MYSQLTEST_VARDIR/tmp/mysqltest.sql 2>&1
#
# Missing delimiter until eof
#
--write_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql
disconnect default
#
# comment
# comment2
# comment 3
--disable_query_log
EOF
--error 1
--exec $MYSQL_TEST < $MYSQLTEST_VARDIR/tmp/mysqltest.sql 2>&1
#
# Missing delimiter until eof
#
--write_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql
disconnect default # comment
# comment part2
# comment 3
--disable_query_log
EOF
--error 1
--exec $MYSQL_TEST < $MYSQLTEST_VARDIR/tmp/mysqltest.sql 2>&1
#
# Extra delimiter
#
--error 1
--exec echo "--sleep 4;" | $MYSQL_TEST 2>&1
--error 1
--exec echo "--disable_query_log;" | $MYSQL_TEST 2>&1
# Allow trailing # comment
--sleep 1 # Wait for insert delayed to be executed.
--sleep 1 # Wait for insert delayed to be executed.
# ----------------------------------------------------------------------------
# Test error
# ----------------------------------------------------------------------------
# Missing argument
--error 1
--exec echo "error;" | $MYSQL_TEST 2>&1
--error 1
--exec echo "--error" | $MYSQL_TEST 2>&1
# First char must be uppercase 'S' or 'E' or [0-9]
--error 1
--exec echo "--error s99999" | $MYSQL_TEST 2>&1
--error 1
--exec echo "--error e99999" | $MYSQL_TEST 2>&1
--error 1
--exec echo "--error 9eeeee" | $MYSQL_TEST 2>&1
--error 1
--exec echo "--error 1sssss" | $MYSQL_TEST 2>&1
# First char 'S' but too long
--error 1
--exec echo "--error S999999" | $MYSQL_TEST 2>&1
# First char 'S' but lowercase char found
--error 1
--exec echo "--error S99a99" | $MYSQL_TEST 2>&1
# First char 'S' but too short
--error 1
--exec echo "--error S9999" | $MYSQL_TEST 2>&1
# First char 'E' but not found in error array
--error 1
--exec echo "--error E9999" | $MYSQL_TEST 2>&1
# First char [0-9] but contains chars
--error 1
--exec echo "--error 999e9" | $MYSQL_TEST 2>&1
--error 1
--exec echo "--error 9b" | $MYSQL_TEST 2>&1
# Multiple errorcodes separated by ','
--error 1,1,1,1
#--error 9,ER_PARSE_ERROR
#--error ER_PARSE_ERROR
#--error 9,ER_PARSE_ERROR,9,ER_PARSE_ERROR
#--error 9, ER_PARSE_ERROR, 9, ER_PARSE_ERROR
#--error 9,S00000,9,ER_PARSE_ERROR
#--error 9,S00000,9,ER_PARSE_ERROR,ER_PARSE_ERROR,ER_PARSE_ERROR,9,10,11,12
--error 9,S00000,9
--error 9,S00000,9,9,10,11,12
--error 9 ,10
--error 9 , 10
--error 9 , 10
--error 9 , 10
# Too many errorcodes specified
--error 1
--exec echo "--error 1,2,3,4,5,6,7,8,9,10,11" | $MYSQL_TEST 2>&1
# ----------------------------------------------------------------------------
# Test echo command
......@@ -399,8 +533,8 @@ echo - MySQL: The world''s
- source database;
echo - MySQL: The world''s
-- most popular open
-- source database;
-- most popular
-- open source database;
echo # MySQL: The
--world''s
......@@ -419,7 +553,7 @@ echo ;
# Illegal use of echo
--error 1
--exec echo "echo $;" | $MYSQL_TEST 2>&1
--exec echo "echo \$;" | $MYSQL_TEST 2>&1
# ----------------------------------------------------------------------------
......@@ -457,8 +591,8 @@ echo $message;
let $message= -- MySQL: The
-- world''s most
-- popular open
-- source database;
-- popular
-- open source database;
echo $message;
let $message= # MySQL: The
......@@ -495,9 +629,21 @@ echo $where2;
let $where3=a long $where variable content;
echo $where3;
let $where3=a long \\\$where variable content;
echo $where3;
let $novar1= $novar2;
echo $novar1;
let $cat=na;
let $cat=ba$cat$cat;
echo banana = $cat;
# ba\$cat\$cat should have been sufficient.
# ba\\\$cat\\\$cat -> ba\$cat\$cat -> ba$cat$cat -> banana
# Magnus' upcoming patch will fix the missing second interpretation.
let $cat=ba\\\$cat\\\$cat;
echo Not a banana: $cat;
# Test illegal uses of let
......@@ -506,22 +652,19 @@ echo $novar1;
--exec echo "let ;" | $MYSQL_TEST 2>&1
--error 1
--exec echo "let $=hi;" | $MYSQL_TEST 2>&1
--error 1
--exec echo "let hi=hi;" | $MYSQL_TEST 2>&1
--exec echo "let \$=hi;" | $MYSQL_TEST 2>&1
--error 1
--exec echo "let $1 hi;" | $MYSQL_TEST 2>&1
--exec echo "let \$1 hi;" | $MYSQL_TEST 2>&1
--error 1
--exec echo "let $m hi;" | $MYSQL_TEST 2>&1
--exec echo "let \$m hi;" | $MYSQL_TEST 2>&1
--error 1
--exec echo "let $hi;" | $MYSQL_TEST 2>&1
--exec echo "let \$hi;" | $MYSQL_TEST 2>&1
--error 1
--exec echo "let $ hi;" | $MYSQL_TEST 2>&1
--exec echo "let \$ hi;" | $MYSQL_TEST 2>&1
--error 1
--exec echo "let =hi;" | $MYSQL_TEST 2>&1
......@@ -529,6 +672,55 @@ echo $novar1;
--error 1
--exec echo "let hi;" | $MYSQL_TEST 2>&1
# More advanced test for bug#17280
let $success= 1;
--echo # Execute: --echo # <whatever> success: \$success
--echo # <whatever> success: $success
--echo # Execute: echo # <whatever> success: \$success ;
echo # <whatever> success: $success ;
--echo # The next two variants work fine and expand the content of \$success
--echo # Execute: --echo \$success
--echo $success
--echo # Execute: echo \$success ;
echo $success ;
# ----------------------------------------------------------------------------
# Test to assign let from query
# let $<var_name>=`<query>`;
# ----------------------------------------------------------------------------
--disable_parsing
echo var1;
let $var1= `select "hi" as "Col", 1 as "Column1", "hi there" as Col3`;
echo $var1;
echo $var1_Col;
echo $var1_Column1;
echo $var1_Col3;
echo var2;
let $var2= `select 2 as "Column num 2"`;
echo $var2;
echo $var2_Column num 2;
echo $var2_Column;
echo var2 again;
let $var2= `select 2 as "Column num 2"`;
echo $var2;
echo $var2_Column num 2;
echo $var2_Column_num_2;
echo $var2_Column;
echo var3 two columns with same name;
let $var3= `select 1 as "Col", 2 as "Col", 3 as "var3"`;
echo $var3;
echo $var3_Col;
echo $var3_Col;
echo $var3_var3;
#echo failing query in let;
#--error 1
#--exec echo "let $var2= `failing query;`" | $MYSQL_TEST 2>&1
--enable_parsing
# ----------------------------------------------------------------------------
# Test source command
# ----------------------------------------------------------------------------
......@@ -538,29 +730,36 @@ echo $novar1;
--error 1
--exec echo "source ;" | $MYSQL_TEST 2>&1
# Fix win paths
--replace_result \\ /
# Source a nonexisting file
--error 1
--exec echo "source non_existingFile;" | $MYSQL_TEST 2>&1
# Too many source
--exec echo "source var/tmp/recursive.sql;" > var/tmp/recursive.sql
--exec echo "source $MYSQLTEST_VARDIR/tmp/recursive.sql;" > $MYSQLTEST_VARDIR/tmp/recursive.sql
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
--error 1
--exec echo "source var/tmp/recursive.sql;" | $MYSQL_TEST 2>&1
--exec echo "source $MYSQLTEST_VARDIR/tmp/recursive.sql;" | $MYSQL_TEST 2>&1
# Source a file with error
--exec echo "garbage ;" > var/tmp/error.sql
--exec echo "garbage ;" > $MYSQLTEST_VARDIR/tmp/error.sql
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
--error 1
--exec echo "source var/tmp/error.sql;" | $MYSQL_TEST 2>&1
--exec echo "source $MYSQLTEST_VARDIR/tmp/error.sql;" | $MYSQL_TEST 2>&1
# Test execution of source in a while loop
--exec echo "echo here is the sourced script;" > var/tmp/sourced.sql
--write_file $MYSQLTEST_VARDIR/tmp/sourced.inc
echo here is the sourced script;
EOF
--disable_query_log
let $outer= 2; # Number of outer loops
while ($outer)
{
eval SELECT '$outer = outer loop variable after while' AS "";
--source var/tmp/sourced.sql
--source $MYSQLTEST_VARDIR/tmp/sourced.inc
eval SELECT '$outer = outer loop variable before dec' AS "";
dec $outer;
......@@ -581,7 +780,6 @@ while ($outer)
# Test execution of source in a while loop
--exec echo "--source var/tmp/sourced.sql" > var/tmp/sourced1.sql
--disable_abort_on_error
# Sourcing of a file within while loop, sourced file will
# source other file
......@@ -589,11 +787,12 @@ let $num= 9;
while ($num)
{
SELECT 'In loop' AS "";
--source var/tmp/sourced1.sql
--source $MYSQLTEST_VARDIR/tmp/sourced.inc
dec $num;
}
--enable_abort_on_error
--enable_query_log
--remove_file $MYSQLTEST_VARDIR/tmp/sourced.inc
# ----------------------------------------------------------------------------
# Test sleep command
......@@ -683,7 +882,7 @@ system echo "hej" > /dev/null;
--exec echo "system false;" | $MYSQL_TEST 2>&1
--disable_abort_on_error
system NonExistsinfComamdn;
system NonExistsinfComamdn 2> /dev/null;
--enable_abort_on_error
......@@ -700,6 +899,30 @@ echo test3stop
--delimiter ;
echo test4;
# ----------------------------------------------------------------------------
# Test if
# ----------------------------------------------------------------------------
let $counter=10;
if ($counter)
{
echo Counter is greater than 0, (counter=10);
}
if (!$counter)
{
echo Counter is not 0, (counter=10);
}
let $counter=0;
if ($counter)
{
echo Counter is greater than 0, (counter=0);
}
if (!$counter)
{
echo Counter is not 0, (counter=0);
}
# ----------------------------------------------------------------------------
# Test while, { and }
# ----------------------------------------------------------------------------
......@@ -713,11 +936,158 @@ while ($i)
# One liner
#let $i=1;while ($i){echo $i;dec $i;}
let $i=0;
while (!$i)
{
echo Testing while with not;
inc $i;
}
# Exceed max nesting level
--write_file $MYSQLTEST_VARDIR/tmp/mysqltest_while.inc
let $1 = 10;
while ($1)
{
while ($1)
{
while ($1)
{
while ($1)
{
while ($1)
{
while ($1)
{
while ($1)
{
while ($1)
{
while ($1)
{
while ($1)
{
while ($1)
{
while ($1)
{
while ($1)
{
while ($1)
{
while ($1)
{
while ($1)
{
while ($1)
{
while ($1)
{
while ($1)
{
while ($1)
{
while ($1)
{
while ($1)
{
while ($1)
{
while ($1)
{
while ($1)
{
while ($1)
{
while ($1)
{
while ($1)
{
while ($1)
{
while ($1)
{
while ($1)
{
while ($1)
{
while ($1)
{
while ($1)
{
while ($1)
{
while ($1)
{
while ($1)
{
while ($1)
{
while ($1)
{
while ($1)
{
while ($1)
{
while ($1)
{
while ($1)
{
while ($1)
{
while ($1)
{
while ($1)
{
while ($1)
{
while ($1)
{
while ($1)
{
echo $1;
dec $1;
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
EOF
# Fix win path
--replace_result \\ / $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
--error 1
--exec echo "source include/mysqltest_while.inc;" | $MYSQL_TEST 2>&1
--exec echo "source $MYSQLTEST_VARDIR/tmp/mysqltest_while.inc;" | $MYSQL_TEST 2>&1
--remove_file $MYSQLTEST_VARDIR/tmp/mysqltest_while.inc
--error 1
--exec echo "while \$i;" | $MYSQL_TEST 2>&1
--error 1
......@@ -731,20 +1101,20 @@ while ($i)
--error 1
--exec echo "{;" | $MYSQL_TEST 2>&1
--system echo "while (0)" > var/log/mysqltest.sql
--system echo "echo hej;" >> var/log/mysqltest.sql
--system echo "while (0)" > $MYSQLTEST_VARDIR/tmp/mysqltest.sql
--system echo "echo hej;" >> $MYSQLTEST_VARDIR/tmp/mysqltest.sql
--error 1
--exec $MYSQL_TEST < var/log/mysqltest.sql 2>&1
--exec $MYSQL_TEST < $MYSQLTEST_VARDIR/tmp/mysqltest.sql 2>&1
--system echo "while (0)" > var/log/mysqltest.sql
--system echo "{echo hej;" >> var/log/mysqltest.sql
--system echo "while (0)" > $MYSQLTEST_VARDIR/tmp/mysqltest.sql
--system echo "{echo hej;" >> $MYSQLTEST_VARDIR/tmp/mysqltest.sql
--error 1
--exec $MYSQL_TEST < var/log/mysqltest.sql 2>&1
--exec $MYSQL_TEST < $MYSQLTEST_VARDIR/tmp/mysqltest.sql 2>&1
--system echo "while (0){" > var/log/mysqltest.sql
--system echo "echo hej;" >> var/log/mysqltest.sql
--system echo "while (0){" > $MYSQLTEST_VARDIR/tmp/mysqltest.sql
--system echo "echo hej;" >> $MYSQLTEST_VARDIR/tmp/mysqltest.sql
--error 1
--exec $MYSQL_TEST < var/log/mysqltest.sql 2>&1
--exec $MYSQL_TEST < $MYSQLTEST_VARDIR/tmp/mysqltest.sql 2>&1
# ----------------------------------------------------------------------------
# Test error messages returned from comments starting with a command
......@@ -772,7 +1142,7 @@ select "a" as col1, "c" as col2;
--exec echo "replace_result a;" | $MYSQL_TEST 2>&1
--error 1
--exec echo "replace_result a ;" | $MYSQL_TEST 2>&1
--exec echo "replace_result a b;" | $MYSQL_TEST 2>&1
--exec echo "replace_result a b; echo OK;" | $MYSQL_TEST 2>&1
--error 1
--exec echo "--replace_result a b c" | $MYSQL_TEST 2>&1
--error 1
......@@ -809,6 +1179,71 @@ select "a" as col1, "c" as col2;
--error 1
--exec echo "save_master_pos; sync_with_master a;" | $MYSQL_TEST 2>&1
# ----------------------------------------------------------------------------
# Test connect
# ----------------------------------------------------------------------------
--error 1
--exec echo "connect;" | $MYSQL_TEST 2>&1
--error 1
--exec echo "connect ();" | $MYSQL_TEST 2>&1
--error 1
--exec echo "connect (con2);" | $MYSQL_TEST 2>&1
--error 1
--exec echo "connect (con2,);" | $MYSQL_TEST 2>&1
--error 1
--exec echo "connect (con2,localhost,root,,illegal_db);" | $MYSQL_TEST 2>&1
--error 1
--exec echo "connect (con1,localhost,root,,,illegal_port,);" | $MYSQL_TEST 2>&1
--error 1
--exec echo "connect (con1,localhost,root,,,,,SMTP POP);" | $MYSQL_TEST 2>&1
# Repeat connect/disconnect
--write_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql
let $i=100;
while ($i)
{
connect (test_con1,localhost,root,,);
disconnect test_con1;
dec $i;
}
EOF
--exec echo "source $MYSQLTEST_VARDIR/tmp/mysqltest.sql; echo OK;" | $MYSQL_TEST 2>&1
# Repeat connect/disconnect, exceed max number of connections
--system echo "let \$i=200;" > $MYSQLTEST_VARDIR/tmp/mysqltest.sql
--system echo "while (\$i)" >> $MYSQLTEST_VARDIR/tmp/mysqltest.sql
--system echo "{" >> $MYSQLTEST_VARDIR/tmp/mysqltest.sql
--system echo " connect (test_con1,localhost,root,,); " >> $MYSQLTEST_VARDIR/tmp/mysqltest.sql
--system echo " disconnect test_con1; " >> $MYSQLTEST_VARDIR/tmp/mysqltest.sql
--system echo " dec \$i; " >> $MYSQLTEST_VARDIR/tmp/mysqltest.sql
--system echo "}" >> $MYSQLTEST_VARDIR/tmp/mysqltest.sql
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
--error 1
--exec echo "source $MYSQLTEST_VARDIR/tmp/mysqltest.sql;" | $MYSQL_TEST 2>&1
# Select disconnected connection
--system echo "connect (test_con1,localhost,root,,);" > $MYSQLTEST_VARDIR/tmp/mysqltest.sql
--system echo "disconnect test_con1; " >> $MYSQLTEST_VARDIR/tmp/mysqltest.sql
--system echo "connection test_con1;" >> $MYSQLTEST_VARDIR/tmp/mysqltest.sql
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
--error 1
--exec echo "source $MYSQLTEST_VARDIR/tmp/mysqltest.sql;" | $MYSQL_TEST 2>&1
# Connection name already used
--system echo "connect (test_con1,localhost,root,,);" > $MYSQLTEST_VARDIR/tmp/mysqltest.sql
--system echo "connect (test_con1,localhost,root,,);" >> $MYSQLTEST_VARDIR/tmp/mysqltest.sql
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
--error 1
--exec echo "source $MYSQLTEST_VARDIR/tmp/mysqltest.sql;" | $MYSQL_TEST 2>&1
# connect when "disable_abort_on_error" caused "connection not found"
--replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT
--disable_abort_on_error
connect (con1,localhost,root,,);
connection default;
connection con1;
--enable_abort_on_error
# ----------------------------------------------------------------------------
# Test mysqltest arguments
......@@ -818,6 +1253,8 @@ select "a" as col1, "c" as col2;
--exec $MYSQL_TEST < $MYSQL_TEST_DIR/include/mysqltest-x.inc
--exec $MYSQL_TEST -x $MYSQL_TEST_DIR/include/mysqltest-x.inc
--exec $MYSQL_TEST --test_file=$MYSQL_TEST_DIR/include/mysqltest-x.inc
# Fix Win paths
--replace_result \\ /
--error 1
--exec $MYSQL_TEST -x non_existing_file.inc 2>&1
......@@ -841,3 +1278,275 @@ while ($num)
SELECT 1 as a;
#
# Bug #10251: Identifiers containing quotes not handled correctly
#
select 1 as `a'b`, 2 as `a"b`;
# Test escaping of quotes
select 'aaa\\','aa''a',"aa""a";
#
# Check of include/show_msg.inc and include/show_msg80.inc
#
# The message contains in most cases a string with the default character set
let $message= Here comes a message;
--source include/show_msg.inc
# The message could also contain a string with character set utf8
let $message= `SELECT USER()`;
--source include/show_msg.inc
# The message contains more then 80 characters on multiple lines
# and is kept between double quotes.
let $message=
"Here comes a very very long message that
- is longer then 80 characters and
- consists of several lines";
--source include/show_msg80.inc
# The message contains more then 80 characters on multiple lines
# and uses the auxiliary character "." at the beginning of the message lines.
let $message= . Here comes a very very long message that
. - is longer then 80 characters and
. - consists of several lines;
--source include/show_msg80.inc
#
# Test --enable_parsing / disable_parsing
#
--disable_query_log
--disable_parsing
# The following will not enable query logging
--enable_query_log
select "this will not be executed";
--enable_parsing
select "this will be executed";
--enable_query_log
#
# Test zero length result file. Should not pass
#
--exec touch $MYSQLTEST_VARDIR/tmp/zero_length_file.result
--exec echo "echo ok;" > $MYSQLTEST_VARDIR/tmp/query.sql
--error 1
--exec $MYSQL_TEST -x $MYSQLTEST_VARDIR/tmp/query.sql -R $MYSQLTEST_VARDIR/tmp/zero_length_file.result 2>&1
#
# Test that a test file that does not generate any output fails.
#
--exec echo "let \$i= 1;" > $MYSQLTEST_VARDIR/tmp/query.sql
--error 1
--exec $MYSQL_TEST -x $MYSQLTEST_VARDIR/tmp/query.sql 2>&1
#
# Test that mysqltest fails when there are no queries executed
# but a result file exists
# NOTE! This will never happen as long as it's not allowed to have
# test files that produce no output
#--exec echo "something" > $MYSQLTEST_VARDIR/tmp/result_file.result
#--exec echo "let \$i= 1;" > $MYSQLTEST_VARDIR/tmp/query.sql
#--error 1
#--exec $MYSQL_TEST -x $MYSQLTEST_VARDIR/tmp/query.sql -R $MYSQLTEST_VARDIR/tmp/result_file.result 2>&1
#
# Bug #11731 mysqltest in multi-statement queries ignores errors in
# non-1st queries
#
echo Failing multi statement query;
# PS does not support multi statement
--exec echo "--disable_ps_protocol" > $MYSQLTEST_VARDIR/tmp/bug11731.sql
--exec echo "delimiter ||||;" >> $MYSQLTEST_VARDIR/tmp/bug11731.sql
--exec echo "create table t1 (a int primary key);" >> $MYSQLTEST_VARDIR/tmp/bug11731.sql
--exec echo "insert into t1 values (1);" >> $MYSQLTEST_VARDIR/tmp/bug11731.sql
--exec echo "select 'select-me';" >> $MYSQLTEST_VARDIR/tmp/bug11731.sql
--exec echo "insertz 'error query'||||" >> $MYSQLTEST_VARDIR/tmp/bug11731.sql
--exec echo "delimiter ;||||" >> $MYSQLTEST_VARDIR/tmp/bug11731.sql
--error 1
--exec $MYSQL_TEST -x $MYSQLTEST_VARDIR/tmp/bug11731.sql 2>&1
drop table t1;
--error 1
--exec $MYSQL_TEST --record -x $MYSQLTEST_VARDIR/tmp/bug11731.sql -R $MYSQLTEST_VARDIR/tmp/bug11731.out 2>&1
# The .out file should be non existent
--exec test ! -s $MYSQLTEST_VARDIR/tmp/bug11731.out
drop table t1;
echo Multi statement using expected error;
# PS does not support multi statement
--exec echo "--disable_ps_protocol" > $MYSQLTEST_VARDIR/tmp/bug11731.sql
--exec echo "delimiter ||||;" >> $MYSQLTEST_VARDIR/tmp/bug11731.sql
--exec echo "--error 1064" >> $MYSQLTEST_VARDIR/tmp/bug11731.sql
--exec echo "create table t1 (a int primary key);" >> $MYSQLTEST_VARDIR/tmp/bug11731.sql
--exec echo "insert into t1 values (1);" >> $MYSQLTEST_VARDIR/tmp/bug11731.sql
--exec echo "select 'select-me';" >> $MYSQLTEST_VARDIR/tmp/bug11731.sql
--exec echo "insertz "error query"||||" >> $MYSQLTEST_VARDIR/tmp/bug11731.sql
--exec echo "delimiter ;||||" >> $MYSQLTEST_VARDIR/tmp/bug11731.sql
# These two should work since the error is expected
--exec $MYSQL_TEST -x $MYSQLTEST_VARDIR/tmp/bug11731.sql 2>&1
drop table t1;
--exec $MYSQL_TEST --record -x $MYSQLTEST_VARDIR/tmp/bug11731.sql -R $MYSQLTEST_VARDIR/tmp/bug11731.out 2>&1
# The .out file should exist
--exec test -s $MYSQLTEST_VARDIR/tmp/bug11731.out
drop table t1;
#
# Bug#19890 mysqltest: "query" command is broken
#
# It should be possible to use the command "query" to force mysqltest to
# send the command to the server although it's a builtin mysqltest command.
--error 1064
query sleep;
--error 1064
--query sleep
# Just an empty query command
--error 1065
query ;
# test for replace_regex
--replace_regex /at/b/
select "at" as col1, "c" as col2;
--replace_regex /at/b/i
select "at" as col1, "AT" as col2, "c" as col3;
--replace_regex /a/b/ /ct/d/
select "a" as col1, "ct" as col2;
--replace_regex /(strawberry)/raspberry and \1/ /blueberry/blackberry/ /potato/tomato/;
select "strawberry","blueberry","potato";
--error 1
--exec echo "--replace_regex a" | $MYSQL_TEST 2>&1
--error 1
--exec echo "--replace_regex a;" | $MYSQL_TEST 2>&1
--error 1
--exec echo "replace_regex a;" | $MYSQL_TEST 2>&1
--error 1
--exec echo "replace_regex a ;" | $MYSQL_TEST 2>&1
--error 1
--exec echo "replace_regex a b; echo OK;" | $MYSQL_TEST 2>&1
--error 1
--exec echo "--replace_regex /a b c" | $MYSQL_TEST 2>&1
--error 1
--exec echo "replace_regex /a /b c ;" | $MYSQL_TEST 2>&1
# REQUIREMENT
# replace_regex should replace substitutions from left to right in output
create table t1 (a int, b int);
insert into t1 values (1,3);
insert into t1 values (2,4);
--replace_regex /A/C/ /B/D/i /3/2/ /2/1/
select * from t1;
drop table t1;
# ----------------------------------------------------------------------------
# test for remove_file
# ----------------------------------------------------------------------------
--error 1
--exec echo "remove_file ;" | $MYSQL_TEST 2>&1
--error 1
remove_file non_existing_file;
# ----------------------------------------------------------------------------
# test for write_file
# ----------------------------------------------------------------------------
--error 1
--exec echo "write_file ;" | $MYSQL_TEST 2>&1
--error 1
--exec echo "write_file filename ;" | $MYSQL_TEST 2>&1
--error 1
--exec echo "write_file filename \";" | $MYSQL_TEST 2>&1
write_file $MYSQLTEST_VARDIR/tmp/test_file1.tmp;
Content for test_file1
EOF
file_exists $MYSQLTEST_VARDIR/tmp/test_file1.tmp;
remove_file $MYSQLTEST_VARDIR/tmp/test_file1.tmp;
write_file $MYSQLTEST_VARDIR/tmp/test_file1.tmp END_DELIMITER;
Content for test_file1 contains EOF
END_DELIMITER
file_exists $MYSQLTEST_VARDIR/tmp/test_file1.tmp;
remove_file $MYSQLTEST_VARDIR/tmp/test_file1.tmp;
# ----------------------------------------------------------------------------
# test for file_exist
# ----------------------------------------------------------------------------
--error 1
--exec echo "file_exists ;" | $MYSQL_TEST 2>&1
--error 0,1
remove_file $MYSQLTEST_VARDIR/tmp/test_file1.tmp;
--error 1
file_exists $MYSQLTEST_VARDIR/tmp/test_file1.tmp;
write_file $MYSQLTEST_VARDIR/tmp/test_file1.tmp;
Content for test_file1
EOF
file_exists $MYSQLTEST_VARDIR/tmp/test_file1.tmp;
remove_file $MYSQLTEST_VARDIR/tmp/test_file1.tmp;
--error 1
file_exists $MYSQLTEST_VARDIR/tmp/test_file1.tmp;
# ----------------------------------------------------------------------------
# test for copy_file
# ----------------------------------------------------------------------------
--write_file $MYSQLTEST_VARDIR/tmp/file1.tmp
file1
EOF
copy_file $MYSQLTEST_VARDIR/tmp/file1.tmp $MYSQLTEST_VARDIR/tmp/file2.tmp;
file_exists $MYSQLTEST_VARDIR/tmp/file2.tmp;
remove_file $MYSQLTEST_VARDIR/tmp/file1.tmp;
remove_file $MYSQLTEST_VARDIR/tmp/file2.tmp;
--error 1
--exec echo "copy_file ;" | $MYSQL_TEST 2>&1
--error 1
--exec echo "copy_file from_file;" | $MYSQL_TEST 2>&1
# ----------------------------------------------------------------------------
# test for perl
# ----------------------------------------------------------------------------
--perl
print "hello\n";
EOF
--perl EOF
print "hello\n";
EOF
--perl DELIMITER
print "hello\n";
DELIMITER
--error 1
--exec echo "perl TOO_LONG_DELIMITER ;" | $MYSQL_TEST 2>&1
perl;
print "hello\n";
EOF
perl;
# Print "hello"
print "hello\n";
EOF
--echo End of tests
......@@ -351,14 +351,14 @@ create table t1 (a int, b int);
insert into t1 (a, b) values (1,1), (1,2), (2,1), (2,2);
prepare stmt from
"explain select * from t1 where t1.a=2 and t1.a=t1.b and t1.b > 1 + ?";
--replace_column 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 -
set @v=5;
execute stmt using @v;
--replace_column 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 -
set @v=0;
execute stmt using @v;
set @v=0;
--replace_column 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 -
execute stmt using @v;
set @v=5;
--replace_column 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 -
execute stmt using @v;
drop table t1;
deallocate prepare stmt;
......
......@@ -305,8 +305,8 @@ prepare stmt4 from ' show table status from test like ''t9%'' ';
--replace_result 2147483647 4294967295
# Bug#4288
execute stmt4;
--replace_column 2 #
prepare stmt4 from ' show status like ''Threads_running'' ';
--replace_column 2 #
execute stmt4;
prepare stmt4 from ' show variables like ''sql_mode'' ';
execute stmt4;
......
......@@ -35,7 +35,7 @@ use mysqltest;
--source include/ps_create.inc
--source include/ps_renew.inc
--enable_query_log
eval use $DB;
use test;
grant usage on mysqltest.* to second_user@localhost
identified by 'looser' ;
grant select on mysqltest.t9 to second_user@localhost
......
#
# Running test with abort-slave-event-count=1
# This will force slave to reconnect after every event
#
require_manager;
connect (master,localhost,root,,test,0,master.sock);
connect (slave,localhost,root,,test,0,slave.sock);
connection master;
reset master;
server_stop master;
server_start master;
connection slave;
reset slave;
start slave;
connection master;
show binary logs;
--disable_warnings
drop table if exists t1;
--enable_warnings
create table t1(n int);
insert into t1 values (3351);
sync_slave_with_master;
select * from t1;
connection master;
drop table t1;
sync_slave_with_master;
# End of 4.1 tests
# This test makes some assumptions about values of thread ids, which should be
# true if the servers have been restarted for this test. So we want to
# stop/restart servers. Note that if assumptions are wrong, the test will not
# fail; it will just fail to test the error-prone scenario.
# Using the manager is the only way to have more than one slave server.
# So you must run this test with --manager.
require_manager;
server_stop master;
server_start master;
server_stop slave;
server_start slave;
# no need for slave_sec (no assumptions on thread ids for this server).
source include/master-slave.inc;
connect (slave_sec,localhost,root,,test,0,slave.sock-1);
connection master;
save_master_pos;
connection slave;
sync_with_master;
reset master;
save_master_pos;
connection slave_sec;
eval change master to master_host='127.0.0.1',master_port=$SLAVE_MYPORT, master_user='root';
start slave;
sync_with_master;
# :P now we have a chain ready-to-test.
connection master;
create temporary table t1 (a int);
save_master_pos;
connection slave;
sync_with_master;
connection master1;
create temporary table t1 (a int);
save_master_pos;
connection slave;
sync_with_master;
save_master_pos;
# First test:
connection slave_sec;
# Before BUG#1686 ("If 2 master threads with same-name temp table, slave makes
# bad binlog") was fixed, sync_with_master failed
sync_with_master;
show status like 'slave_open_temp_tables';
# 'master' and 'master1' usually have thread id 2-3 or 3-4.
# 'slave' and 'slave1' usually have thread id 2-3.
connection slave;
create temporary table t1 (a int);
connection slave1;
create temporary table t1 (a int);
# So it's likely that in the binlog of slave we get
# server_id=of_master thread_id=3 create temp...
# server_id=of_slave thread_id=3 create temp...
# which would confuse slave-sec unless slave-sec uses server id to distinguish
# between temp tables (here thread id is obviously not enough to distinguish).
save_master_pos;
# Second test:
connection slave_sec;
# If we did not use the server id to distinguish between temp tables,
# sync_with_master would fail
sync_with_master;
show status like 'slave_open_temp_tables';
# Third test (BUG#1240 "slave of slave breaks when STOP SLAVE was issud on
# parent slave and temp tables").
stop slave;
connection slave;
insert into t1 values(1);
create table t2 as select * from t1;
save_master_pos;
connection slave_sec;
start slave;
sync_with_master;
show status like 'slave_open_temp_tables';
select * from t2;
# clean up
connection slave;
drop table t2;
save_master_pos;
connection slave_sec;
sync_with_master;
# On purpose, we don't delete the temporary tables explicitely.
# So temp tables remain on slave (remember they are not deleted when the slave
# SQL thread terminates). If you run this test with
# --valgrind --valgrind-options=--show-reachable=yes
# you will see if they get cleaned up at slave's shutdown (that is, if the
# memory they use is freed (it should) by mysqld before it terminates).
# If they wouldn't be cleaned up, you would see some "still reachable" blocks in
# Valgrind.
# End of 4.1 tests
......@@ -106,6 +106,8 @@ select * from mysqltest2.t1 order by a;
connection master;
drop database mysqltest2;
drop database mysqltest3;
# file_id: xx can vary depending on previous tests
--replace_regex /file_id=[0-9]/file_id=x/
show binlog events from 79;
sync_slave_with_master;
......
require_manager;
source include/master-slave.inc;
connect (slave_sec,localhost,root,,test,0,slave.sock-1);
connect (slave_ter,localhost,root,,test,0,slave.sock-2);
connection master;
show variables like 'rpl_recovery_rank';
show status like 'Rpl_status';
create table t1(n int);
drop table t1;
sync_slave_with_master;
show variables like 'rpl_recovery_rank';
show status like 'Rpl_status';
connection slave_sec;
start slave;
sync_with_master;
show variables like 'rpl_recovery_rank';
show status like 'Rpl_status';
connection slave_ter;
start slave;
sync_with_master;
show variables like 'rpl_recovery_rank';
show status like 'Rpl_status';
# End of 4.1 tests
......@@ -8,6 +8,8 @@
# merge table getting renamed.
--source include/not_windows.inc
let $SERVER_VERSION=`select version()`;
create table t1 (a int);
insert into t1 values (10);
create table t2 (a int);
......
# You must run this test with --manager.
require_manager;
# Don't know why, but using TCP/IP connections makes this test fail
# with "Lost connection to MySQL server during query" when we
# issue a query after the server restart.
# Maybe this is something awkward in mysqltest or in the manager?
# So we use sockets.
connect (master,localhost,root,,test,0,master.sock);
connect (slave,localhost,root,,test,0,slave.sock);
connection master;
reset master;
drop table if exists t1;
# we use CREATE SELECT to verify that DELETE does not get into binlog
# before CREATE SELECT
create table t1 type=HEAP select 10 as a;
insert into t1 values(11);
save_master_pos;
show binlog events from 79;
connection slave;
reset slave;
start slave;
sync_with_master;
show create table t1;
select * from t1; # should be one row
server_stop master;
server_start master;
connection master;
select * from t1;
# to check that DELETE is not written twice
# (the LIMIT is to not use the query cache)
select * from t1 limit 10;
save_master_pos;
show binlog events in 'master-bin.002' from 79;
connection slave;
sync_with_master;
select * from t1; # should be empty
# clean up
connection master;
drop table t1;
save_master_pos;
connection slave;
sync_with_master;
# End of 4.1 tests
......@@ -20,11 +20,13 @@ while ($1)
}
set SQL_LOG_BIN=1;
enable_query_log;
select * into outfile '../../var/master-data/rpl_loaddatalocal.select_outfile' from t1;
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
eval select * into outfile '$MYSQLTEST_VARDIR/master-data/rpl_loaddatalocal.select_outfile' from t1;
#This will generate a 20KB file, now test LOAD DATA LOCAL
truncate table t1;
load data local infile './var/master-data/rpl_loaddatalocal.select_outfile' into table t1;
system rm ./var/master-data/rpl_loaddatalocal.select_outfile ;
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
eval load data local infile '$MYSQLTEST_VARDIR/master-data/rpl_loaddatalocal.select_outfile' into table t1;
--remove_file $MYSQLTEST_VARDIR/master-data/rpl_loaddatalocal.select_outfile
save_master_pos;
connection slave;
sync_with_master;
......
......@@ -9,7 +9,7 @@ start slave;
connection master;
--disable_warnings
drop table if exists t1;
--enable_warning
--enable_warnings
create table t1 (n int);
insert into t1 values (1);
save_master_pos;
......
......@@ -29,7 +29,4 @@ connection slave;
show status like 'Slave_open_temp_tables';
connection master;
# End of 4.1 tests
......@@ -1721,7 +1721,7 @@ select (select a from t1) = (1,2);
select (1,2,3) = (select * from t1);
-- error 1241
select (select * from t1) = (1,2,3);
drop table t1
drop table t1;
#
# Item_int_with_ref check (BUG#10020)
......
......@@ -27,7 +27,7 @@ CREATE TABLE db (
KEY User (User)
)
type=ISAM;
--enable-warnings
--enable_warnings
INSERT INTO db VALUES ('%','test', '','Y','Y','Y','Y','Y','Y');
INSERT INTO db VALUES ('%','test\_%','','Y','Y','Y','Y','Y','Y');
......@@ -45,7 +45,7 @@ CREATE TABLE host (
PRIMARY KEY Host (Host,Db)
)
type=ISAM;
--enable-warnings
--enable_warnings
--disable_warnings
CREATE TABLE user (
......@@ -64,7 +64,7 @@ CREATE TABLE user (
PRIMARY KEY Host (Host,User)
)
type=ISAM;
--enable-warnings
--enable_warnings
INSERT INTO user VALUES ('localhost','root','','Y','Y','Y','Y','Y','Y','Y','Y','Y');
INSERT INTO user VALUES ('localhost','', '','N','N','N','N','N','N','N','N','N');
......
......@@ -23,7 +23,7 @@ CREATE TABLE t2 (a char(257), b varbinary(70000), c varchar(70000000));
show columns from t2;
create table t3 (a long, b long byte);
show create TABLE t3;
drop table t1,t2,t3
drop table t1,t2,t3;
#
# Check errors with blob
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment