summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <monty@mashka.mysql.fi>2003-01-07 16:53:10 +0200
committerunknown <monty@mashka.mysql.fi>2003-01-07 16:53:10 +0200
commitb3b66f640841e459e18a3d4300766b56f0cf3bc8 (patch)
tree568a37c17ae407938ff1ec3cae7005605d52e7c6
parente3c7f4d85ec4caf59fc408cf5643e5dc64e9a3d4 (diff)
downloadmariadb-git-b3b66f640841e459e18a3d4300766b56f0cf3bc8.tar.gz
Portability fixes
Fixed test suite for HPUX 10.20 and MacOSX Build-tools/Do-compile: Added timeout to mysqladmin shutdown commands Kill old running mysqld started by earlier runs Removed run time warning from LD_LIBRARY_PATH client/mysqladmin.c: Return 1 if pid file isn't deleted on shutdown. Fix error message if pid file is not deleted client/mysqltest.c: Always allow --debug flag (Makes it easier to run mysql-test-run) mysql-test/mysql-test-run.sh: A lot of safety fixes. This fixes some problems with test suite for HPUX 10.20 and MacOSX sql-bench/bench-init.pl.sh: Allow tests to change time limit. sql-bench/crash-me.sh: Indentation cleanups Added DROP for a created table sql-bench/test-alter-table.sh: Added default time limit Changed test to be estimated to get down run time. Fixed that add_multi_col is detected sql-bench/test-insert.sh: Comment cleanup sql/mysql_priv.h: Removed not needed prototype. sql/mysqld.cc: Removed DBUG warnings Removed default argument for clean_up() and made it static. More comments. Ignore SIGHUP during shutdown sql/net_pkg.cc: More comments sql/slave.cc: Added DBUG_PRINT messages
-rwxr-xr-xBuild-tools/Do-compile27
-rw-r--r--client/mysqladmin.c62
-rw-r--r--client/mysqltest.c8
-rw-r--r--mysql-test/mysql-test-run.sh33
-rw-r--r--sql-bench/bench-init.pl.sh5
-rw-r--r--sql-bench/crash-me.sh126
-rw-r--r--sql-bench/test-alter-table.sh43
-rw-r--r--sql-bench/test-insert.sh7
-rw-r--r--sql/mysql_priv.h1
-rw-r--r--sql/mysqld.cc43
-rw-r--r--sql/net_pkg.cc5
-rw-r--r--sql/slave.cc2
12 files changed, 233 insertions, 129 deletions
diff --git a/Build-tools/Do-compile b/Build-tools/Do-compile
index 4351a4f69f4..8695c72b913 100755
--- a/Build-tools/Do-compile
+++ b/Build-tools/Do-compile
@@ -135,6 +135,7 @@ $ENV{'MYSQL_UNIX_PORT'}=$mysql_unix_port="$opt_tmp/mysql$opt_suffix.build";
$ENV{"PERL5LIB"}="$pwd/$host/perl5:$pwd/$host/perl5/site_perl";
$slave_port=$mysql_tcp_port+16;
$manager_port=$mysql_tcp_port+1;
+$mysqladmin_args="--no-defaults -u root --connect_timeout=5 --shutdown_timeout=20";
if ($opt_stage == 0)
{
@@ -154,13 +155,18 @@ log_timestamp();
if (-x "$host/bin/mysqladmin")
{
- log_system("$host/bin/mysqladmin --no-defaults -u root -S $mysql_unix_port -s shutdown");
- log_system("$host/bin/mysqladmin --no-defaults -u root -P $mysql_tcp_port -h $host -s shutdown");
- log_system("$host/bin/mysqladmin --no-defaults -u root -P $slave_port -h $host -s shutdown");
- log_system("$host/bin/mysqladmin --no-defaults -u root -P 9306 -h $host -s shutdown");
- log_system("$host/bin/mysqladmin --no-defaults -u root -P 9307 -h $host -s shutdown");
+ log_system("$host/bin/mysqladmin $mysqladmin_args -S $mysql_unix_port -s shutdown");
+ log_system("$host/bin/mysqladmin $mysqladmin_args -P $mysql_tcp_port -h $host -s shutdown");
+ log_system("$host/bin/mysqladmin $mysqladmin_args -P $slave_port -h $host -s shutdown");
+ log_system("$host/bin/mysqladmin $mysqladmin_args -P 9306 -h $host -s shutdown");
+ log_system("$host/bin/mysqladmin $mysqladmin_args -P 9307 -h $host -s shutdown");
}
kill_all("mysqlmanager");
+#
+# Kill all old processes that are in the build directories
+# This is to find any old mysqld servers left from previous builds
+kill_all("$pwd/host/mysql");
+kill_all("$pwd/host/test");
if ($opt_stage == 0)
{
@@ -308,8 +314,9 @@ if ($opt_stage <= 4 && !$opt_no_test)
$tar_file =~ /(mysql[^\/]*)\.tar/;
$ver=$1;
$test_dir="$pwd/$host/test/$ver";
-$ENV{"LD_LIBRARY_PATH"}= "$test_dir/lib:" . $ENV{"LD_LIBRARY_PATH"};
-
+$ENV{"LD_LIBRARY_PATH"}= ("$test_dir/lib" .
+ (defined($ENV{"LD_LIBRARY_PATH"}) ?
+ ":" . $ENV{"LD_LIBRARY_PATH"} : ""));
#
# Run the test suite
#
@@ -328,7 +335,7 @@ if (!$opt_no_test && !$opt_no_benchmark)
{
my $extra;
safe_cd($test_dir);
- log_system("./bin/mysqladmin --no-defaults -u root -S $mysql_unix_port -s shutdown") || info("There was no mysqld running\n");
+ log_system("./bin/mysqladmin $mysqladmin_args -S $mysql_unix_port -s shutdown") || info("There was no mysqld running\n");
sleep(2);
log_system("rm -f ./data/mysql/*");
check_system("scripts/mysql_install_db --no-defaults --skip-locking","https://order");
@@ -418,7 +425,7 @@ if ($opt_stage <= 9 && !$opt_no_test && !$opt_no_benchmark)
rm_all($bench_tmpdir);
rm_all("$opt_tmp") if ($new_opt_tmp);
-log_system("$pwd/$host/bin/mysqladmin --no-defaults -S $mysql_unix_port -u root shutdown");
+log_system("$pwd/$host/bin/mysqladmin $mysqladmin_args -S $mysql_unix_port -u root shutdown");
print LOG "ok\n";
close LOG;
print "$host: ok\n";
@@ -429,7 +436,7 @@ exit 0;
sub usage
{
print <<EOF;
-$0 version 1.4
+$0 version 1.5
$0 takes the following options:
diff --git a/client/mysqladmin.c b/client/mysqladmin.c
index 00af8c592ec..5446718dea6 100644
--- a/client/mysqladmin.c
+++ b/client/mysqladmin.c
@@ -24,7 +24,7 @@
#endif
#include <sys/stat.h>
-#define ADMIN_VERSION "8.38"
+#define ADMIN_VERSION "8.39"
#define MAX_MYSQL_VAR 128
#define SHUTDOWN_DEF_TIMEOUT 3600 /* Wait for shutdown */
#define MAX_TRUNC_LENGTH 3
@@ -70,8 +70,8 @@ static void print_relative_header();
static void print_relative_line();
static void truncate_names();
static my_bool get_pidfile(MYSQL *mysql, char *pidfile);
-static void wait_pidfile(char *pidfile, time_t last_modified,
- struct stat *pidfile_status);
+static my_bool wait_pidfile(char *pidfile, time_t last_modified,
+ struct stat *pidfile_status);
static void store_values(MYSQL_RES *result);
/*
@@ -481,7 +481,8 @@ static int execute_commands(MYSQL *mysql,int argc, char **argv)
printf("Shutdown signal sent to server; Waiting for pid file to disappear\n");
/* Wait until pid file is gone */
- wait_pidfile(pidfile, last_modified, &pidfile_status);
+ if (wait_pidfile(pidfile, last_modified, &pidfile_status))
+ return -1;
}
break;
}
@@ -1110,34 +1111,51 @@ static my_bool get_pidfile(MYSQL *mysql, char *pidfile)
return 1; /* Error */
}
+/*
+ Return 1 if pid file didn't disappear or change
+*/
-static void wait_pidfile(char *pidfile, time_t last_modified,
- struct stat *pidfile_status)
+static my_bool wait_pidfile(char *pidfile, time_t last_modified,
+ struct stat *pidfile_status)
{
char buff[FN_REFLEN];
- int fd = -1;
- uint count=0;
+ int error= 1;
+ uint count= 0;
+ DBUG_ENTER("wait_pidfile");
system_filename(buff, pidfile);
- while (count++ <= opt_shutdown_timeout && !interrupted &&
- (!last_modified || (last_modified == pidfile_status->st_mtime)) &&
- (fd= my_open(buff, O_RDONLY, MYF(0))) >= 0)
+ do
{
- if (!my_close(fd,MYF(0)))
- fd= -1;
+ int fd;
+ if ((fd= my_open(buff, O_RDONLY, MYF(0))) < 0)
+ {
+ error= 0;
+ break;
+ }
+ (void) my_close(fd,MYF(0));
+ if (last_modified && !stat(pidfile, pidfile_status))
+ {
+ if (last_modified != pidfile_status->st_mtime)
+ {
+ /* File changed; Let's assume that mysqld did restart */
+ if (opt_verbose)
+ printf("pid file '%s' changed while waiting for it to disappear!\nmysqld did probably restart\n",
+ buff);
+ error= 0;
+ break;
+ }
+ }
+ if (count++ == opt_shutdown_timeout)
+ break;
sleep(1);
- if (last_modified && stat(pidfile, pidfile_status))
- last_modified= 0;
- }
- if (opt_verbose && last_modified &&
- last_modified != pidfile_status->st_mtime)
- printf("Warning; pid file '%s' changed while waiting for it to disappear!\n",
- buff);
- if (fd >= 0)
+ } while (!interrupted);
+
+ if (error)
{
- my_close(fd,MYF(0));
+ DBUG_PRINT("warning",("Pid file didn't disappear"));
fprintf(stderr,
"Warning; Aborted waiting on pid file: '%s' after %d seconds\n",
buff, count-1);
}
+ DBUG_RETURN(error);
}
diff --git a/client/mysqltest.c b/client/mysqltest.c
index 20d277ca969..fe99dda1ac3 100644
--- a/client/mysqltest.c
+++ b/client/mysqltest.c
@@ -42,7 +42,7 @@
**********************************************************************/
-#define MTEST_VERSION "1.25"
+#define MTEST_VERSION "1.26"
#include <my_global.h>
#include <mysql_embed.h>
@@ -1797,10 +1797,8 @@ int read_query(struct st_query** q_ptr)
static struct my_option my_long_options[] =
{
-#ifndef DBUG_OFF
{"debug", '#', "Output debug log. Often this is 'd:t:o,filename'",
0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
-#endif
{"database", 'D', "Database to use.", (gptr*) &db, (gptr*) &db, 0,
GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"basedir", 'b', "Basedir for tests", (gptr*) &opt_basedir,
@@ -1893,7 +1891,9 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
{
switch(optid) {
case '#':
+#ifndef DBUG_OFF
DBUG_PUSH(argument ? argument : "d:t:S:i:O,/tmp/mysqltest.trace");
+#endif
break;
case 'r':
record = 1;
@@ -1971,7 +1971,7 @@ int parse_args(int argc, char **argv)
default_argv= argv;
if ((ho_error=handle_options(&argc, &argv, my_long_options, get_one_option)))
- exit(ho_error);
+ exit(1);
if (argc > 1)
{
diff --git a/mysql-test/mysql-test-run.sh b/mysql-test/mysql-test-run.sh
index 5c80e7d538a..408c76d8602 100644
--- a/mysql-test/mysql-test-run.sh
+++ b/mysql-test/mysql-test-run.sh
@@ -88,6 +88,7 @@ sleep_until_file_created ()
wait_for_pid()
{
pid=$1
+ #$WAIT_PID pid $SLEEP_TIME_FOR_DELETE
}
# No paths below as we can't be sure where the program is!
@@ -343,9 +344,9 @@ while test $# -gt 0; do
;;
--debug)
EXTRA_MASTER_MYSQLD_OPT="$EXTRA_MASTER_MYSQLD_OPT \
- --debug=d:t:i:O,$MYSQL_TEST_DIR/var/log/master.trace"
+ --debug=d:t:i:A,$MYSQL_TEST_DIR/var/log/master.trace"
EXTRA_SLAVE_MYSQLD_OPT="$EXTRA_SLAVE_MYSQLD_OPT \
- --debug=d:t:i:O,$MYSQL_TEST_DIR/var/log/slave.trace"
+ --debug=d:t:i:A,$MYSQL_TEST_DIR/var/log/slave.trace"
EXTRA_MYSQL_TEST_OPT="$EXTRA_MYSQL_TEST_OPT --debug"
;;
--fast)
@@ -419,6 +420,7 @@ if [ x$SOURCE_DIST = x1 ] ; then
fi
MYSQLADMIN="$BASEDIR/client/mysqladmin"
+ WAIT_PID="$BASEDIR/extra/mysql_waitpid"
MYSQL_MANAGER_CLIENT="$BASEDIR/client/mysqlmanagerc"
MYSQL_MANAGER="$BASEDIR/tools/mysqlmanager"
MYSQL_MANAGER_PWGEN="$BASEDIR/client/mysqlmanager-pwgen"
@@ -435,6 +437,7 @@ else
fi
MYSQL_TEST="$BASEDIR/bin/mysqltest"
MYSQLADMIN="$BASEDIR/bin/mysqladmin"
+ WAIT_PID="$BASEDIR/bin/mysql_waitpid"
MYSQL_MANAGER="$BASEDIR/bin/mysqlmanager"
MYSQL_MANAGER_CLIENT="$BASEDIR/bin/mysqlmanagerc"
MYSQL_MANAGER_PWGEN="$BASEDIR/bin/mysqlmanager-pwgen"
@@ -749,9 +752,9 @@ manager_term()
{
pid=$1
ident=$2
- shift
if [ $USE_MANAGER = 0 ] ; then
- $MYSQLADMIN --no-defaults -uroot --socket=$MYSQL_TMP_DIR/$ident.sock --connect_timeout=5 --shutdown_timeout=20 shutdown >> $MYSQL_MANAGER_LOG 2>&1
+ # Shutdown time must be high as slave may be in reconnect
+ $MYSQLADMIN --no-defaults -uroot --socket=$MYSQL_TMP_DIR/$ident.sock --connect_timeout=5 --shutdown_timeout=70 shutdown >> $MYSQL_MANAGER_LOG 2>&1
res=$?
# Some systems require an extra connect
$MYSQLADMIN --no-defaults -uroot --socket=$MYSQL_TMP_DIR/$ident.sock --connect_timeout=1 ping >> $MYSQL_MANAGER_LOG 2>&1
@@ -873,8 +876,8 @@ start_slave()
[ x$SKIP_SLAVE = x1 ] && return
eval "this_slave_running=\$SLAVE$1_RUNNING"
[ x$this_slave_running = 1 ] && return
- #when testing fail-safe replication, we will have more than one slave
- #in this case, we start secondary slaves with an argument
+ # When testing fail-safe replication, we will have more than one slave
+ # in this case, we start secondary slaves with an argument
slave_ident="slave$1"
if [ -n "$1" ] ;
then
@@ -982,9 +985,12 @@ EOF
mysql_start ()
{
- $ECHO "Starting MySQL daemon"
- start_master
- start_slave
+# We should not start the deamon here as we don't know the argumens
+# for the test. Better to let the test start the deamon
+
+# $ECHO "Starting MySQL daemon"
+# start_master
+# start_slave
cd $MYSQL_TEST_DIR
return 1
}
@@ -1085,8 +1091,6 @@ run_testcase ()
slave_init_script=$TESTDIR/$tname-slave.sh
slave_master_info_file=$TESTDIR/$tname-slave-master-info.opt
echo $tname > $CURRENT_TEST
- echo "CURRENT_TEST: $tname" >> $SLAVE_MYERR
- echo "CURRENT_TEST: $tname" >> $MASTER_MYERR
SKIP_SLAVE=`$EXPR \( $tname : rpl \) = 0`
if [ $USE_MANAGER = 1 ] ; then
many_slaves=`$EXPR \( $tname : rpl_failsafe \) != 0`
@@ -1123,13 +1127,17 @@ run_testcase ()
then
EXTRA_MASTER_OPT=`$CAT $master_opt_file | $SED -e "s;\\$MYSQL_TEST_DIR;$MYSQL_TEST_DIR;"`
stop_master
+ echo "CURRENT_TEST: $tname" >> $MASTER_MYERR
start_master
else
if [ ! -z "$EXTRA_MASTER_OPT" ] || [ x$MASTER_RUNNING != x1 ] ;
then
EXTRA_MASTER_OPT=""
stop_master
+ echo "CURRENT_TEST: $tname" >> $MASTER_MYERR
start_master
+ else
+ echo "CURRENT_TEST: $tname" >> $MASTER_MYERR
fi
fi
@@ -1159,7 +1167,10 @@ run_testcase ()
if [ x$do_slave_restart = x1 ] ; then
stop_slave
+ echo "CURRENT_TEST: $tname" >> $SLAVE_MYERR
start_slave
+ else
+ echo "CURRENT_TEST: $tname" >> $SLAVE_MYERR
fi
if [ x$many_slaves = x1 ]; then
start_slave 1
diff --git a/sql-bench/bench-init.pl.sh b/sql-bench/bench-init.pl.sh
index 9b999ee7f95..b7d2b962e13 100644
--- a/sql-bench/bench-init.pl.sh
+++ b/sql-bench/bench-init.pl.sh
@@ -48,7 +48,10 @@ $opt_optimization="None";
$opt_hw="";
$opt_threads=5;
-$opt_time_limit=10*60; # Don't wait more than 10 min for some tests
+if (!defined($opt_time_limit))
+{
+ $opt_time_limit=10*60; # Don't wait more than 10 min for some tests
+}
$log_prog_args=join(" ", skip_arguments(\@ARGV,"comments","cmp","server",
"user", "host", "database", "password",
diff --git a/sql-bench/crash-me.sh b/sql-bench/crash-me.sh
index ea18431f8da..130816de0be 100644
--- a/sql-bench/crash-me.sh
+++ b/sql-bench/crash-me.sh
@@ -39,7 +39,7 @@
# as such, and clarify ones such as "mediumint" with comments such as
# "3-byte int" or "same as xxx".
-$version="1.59";
+$version="1.60";
use DBI;
use Getopt::Long;
@@ -50,7 +50,7 @@ $opt_server="mysql"; $opt_host="localhost"; $opt_database="test";
$opt_dir="limits";
$opt_user=$opt_password="";$opt_verbose="";
$opt_debug=$opt_help=$opt_Information=$opt_restart=$opt_force=$opt_quick=0;
-$opt_log_all_queries=$opt_fix_limit_file=$opt_batch_mode=0;
+$opt_log_all_queries=$opt_fix_limit_file=$opt_batch_mode=$opt_version=0;
$opt_db_start_cmd=""; # the db server start command
$opt_check_server=0; # Check if server is alive before each query
$opt_sleep=10; # time to sleep while starting the db server
@@ -68,8 +68,10 @@ GetOptions("Information","help","server=s","debug","user=s","password=s",
"database=s","restart","force","quick","log-all-queries","comment=s",
"host=s","fix-limit-file","dir=s","db-start-cmd=s","sleep=s","suffix=s",
"batch-mode","config-file=s","log-queries-to-file=s","check-server",
+"version",
"verbose!" => \$opt_verbose) || usage();
usage() if ($opt_help || $opt_Information);
+version() && exit(0) if ($opt_version);
$opt_suffix = '-'.$opt_suffix if (length($opt_suffix) != 0);
$opt_config_file = "$pwd/$opt_dir/$opt_server$opt_suffix.cfg"
@@ -1190,7 +1192,7 @@ else
# Test: NOROUND
{
- my $resultat = 'undefined';
+ my $result = 'undefined';
my $error;
print "NOROUND: ";
save_incomplete('func_extra_noround','Function NOROUND');
@@ -1199,21 +1201,25 @@ else
$error = safe_query_l('func_extra_noround',"select noround(22.6) $end_query");
if ($error ne 1) # syntax error -- noround is not supported
{
- $resultat = 'no'
- } else # Ok, now check if it really works
- {
+ $result = 'no'
+ }
+ else # Ok, now check if it really works
+ {
$error=safe_query_l('func_extra_noround',
["create table crash_me_nr (a int)",
"insert into crash_me_nr values(noround(10.2))",
"drop table crash_me_nr $drop_attr"]);
- if ($error eq 1) {
- $resultat = "syntax only";
- } else {
- $resultat = 'yes';
- }
- }
- print "$resultat\n";
- save_config_data('func_extra_noround',$resultat,"Function NOROUND");
+ if ($error == 1)
+ {
+ $result= "syntax only";
+ }
+ else
+ {
+ $result= 'yes';
+ }
+ }
+ print "$result\n";
+ save_config_data('func_extra_noround',$result,"Function NOROUND");
}
check_parenthesis("func_sql_","CURRENT_USER");
@@ -1377,7 +1383,7 @@ if ($limits{'type_sql_date'} eq 'yes')
# Test: WEEK()
{
- my $resultat="no";
+ my $result="no";
my $error;
print "WEEK:";
save_incomplete('func_odbc_week','WEEK');
@@ -1388,17 +1394,17 @@ if ($limits{'type_sql_date'} eq 'yes')
# and 0 - EURO weeks
if ($error == -1) {
if ($last_result == 4) {
- $resultat = 'USA';
+ $result = 'USA';
} else {
- $resultat='error';
+ $result='error';
add_log('func_odbc_week',
" must return 4 or 5, but $last_result");
}
} elsif ($error == 0) {
- $resultat = 'EURO';
+ $result = 'EURO';
}
- print " $resultat\n";
- save_config_data('func_odbc_week',$resultat,"WEEK");
+ print " $result\n";
+ save_config_data('func_odbc_week',$result,"WEEK");
}
my $insert_query ='insert into crash_me_d values('.
@@ -1498,7 +1504,7 @@ if ($limits{'type_sql_date'} eq 'yes')
# NOT id BETWEEN a and b
if ($limits{'func_where_not_between'} eq 'yes')
{
- my $resultat = 'error';
+ my $result = 'error';
my $err;
my $key='not_id_between';
my $prompt='NOT ID BETWEEN interprets as ID NOT BETWEEN';
@@ -1512,15 +1518,15 @@ if ($limits{'func_where_not_between'} eq 'yes')
5,0);
if ($err eq 1) {
if (not defined($last_result)) {
- $resultat='no';
+ $result='no';
};
};
if ( $err eq 0) {
- $resultat = 'yes';
+ $result = 'yes';
};
safe_query_l($key,["drop table crash_me_b"]);
- save_config_data($key,$resultat,$prompt);
- print "$resultat\n";
+ save_config_data($key,$result,$prompt);
+ print "$result\n";
};
@@ -2018,37 +2024,44 @@ report("views","views",
# Test: foreign key
{
- my $resultat = 'undefined';
+ my $result = 'undefined';
my $error;
print "foreign keys: ";
save_incomplete('foreign_key','foreign keys');
# 1) check if foreign keys are supported
- safe_query_l('foreign_key',create_table("crash_me_qf",["a integer not null"],
- ["primary key (a)"]));
- $error = safe_query_l('foreign_key',
- create_table("crash_me_qf2",["a integer not null",
- "foreign key (a) references crash_me_qf (a)"], []));
-
- if ($error eq 1) # OK -- syntax is supported
+ safe_query_l('foreign_key',
+ create_table("crash_me_qf",
+ ["a integer not null"],
+ ["primary key (a)"]));
+ $error= safe_query_l('foreign_key',
+ create_table("crash_me_qf2",
+ ["a integer not null",
+ "foreign key (a) references crash_me_qf (a)"],
+ []));
+
+ if ($error == 1) # OK -- syntax is supported
{
- $resultat = 'error';
+ $result = 'error';
# now check if foreign key really works
safe_query_l('foreign_key', "insert into crash_me_qf values (1)");
- if (safe_query_l('foreign_key', "insert into crash_me_qf2 values (2)") eq 1)
+ if (safe_query_l('foreign_key', "insert into crash_me_qf2 values (2)") eq 1)
{
- $resultat = 'syntax only';
- } else {
- $resultat = 'yes';
- }
-
- } else {
- $resultat = "no";
- }
- safe_query_l('foreign_key',
- "drop table crash_me_qf2 $drop_attr","drop table crash_me_qf $drop_attr");
- print "$resultat\n";
- save_config_data('foreign_key',$resultat,"foreign keys");
+ $result = 'syntax only';
+ }
+ else
+ {
+ $result = 'yes';
+ }
+ }
+ else
+ {
+ $result = "no";
+ }
+ safe_query_l('foreign_key', "drop table crash_me_qf2 $drop_attr");
+ safe_query_l('foreign_key', "drop table crash_me_qf $drop_attr");
+ print "$result\n";
+ save_config_data('foreign_key',$result,"foreign keys");
}
report("Create SCHEMA","create_schema",
@@ -2607,7 +2620,7 @@ sub detect_null_position
sub check_parenthesis {
my $prefix=shift;
my $fn=shift;
- my $resultat='no';
+ my $result='no';
my $param_name=$prefix.lc($fn);
my $r;
@@ -2616,18 +2629,18 @@ sub check_parenthesis {
add_log($param_name,$safe_query_log);
if ($r == 1)
{
- $resultat="yes";
+ $result="yes";
}
else{
$r = safe_query("select $fn() $end_query");
add_log($param_name,$safe_query_log);
if ( $r == 1)
{
- $resultat="with_parenthesis";
+ $result="with_parenthesis";
}
}
- save_config_data($param_name,$resultat,$fn);
+ save_config_data($param_name,$result,$fn);
}
sub check_constraint {
@@ -2699,10 +2712,16 @@ sub make_date {
}
+sub version
+{
+ print "$0 Ver $version\n";
+}
+
+
sub usage
{
+ version();
print <<EOF;
-$0 Ver $version
This program tries to find all limits and capabilities for a SQL
server. As it will use the server in some 'unexpected' ways, one
@@ -3048,7 +3067,7 @@ sub safe_query_l {
my $r = safe_query($q);
add_log($key,$safe_query_log);
return $r;
-}
+}
sub safe_query
{
@@ -3110,7 +3129,6 @@ sub safe_query
$retry = $retry_limit;
$retry_ok = 1;
$safe_query_log .= "> OK\n";
-
}
$sth->finish;
}
diff --git a/sql-bench/test-alter-table.sh b/sql-bench/test-alter-table.sh
index cc6453188de..f338792e9ef 100644
--- a/sql-bench/test-alter-table.sh
+++ b/sql-bench/test-alter-table.sh
@@ -27,6 +27,7 @@ $opt_start_field_count=8; # start with this many fields
$opt_loop_count=20; # How many tests to do
$opt_row_count=1000; # Rows in the table
$opt_field_count=1000; # Add until this many fields.
+$opt_time_limit=10*60; # Don't wait more than 10 min for some tests
chomp($pwd = `pwd`); $pwd = "." if ($pwd eq '');
require "$pwd/bench-init.pl" || die "Can't read Configuration file: $!\n";
@@ -113,10 +114,9 @@ if ($opt_fast)
}
else
{
- $add=1 if (!$limits{'alter_add_multi_col'});
+ $add=1 if (!$limits->{'alter_add_multi_col'});
}
-
$count=0;
while ($field_count < $opt_field_count)
{
@@ -131,19 +131,43 @@ while ($field_count < $opt_field_count)
$tmp="" if (!$multi_add); # Adabas
}
do_query($dbh,"ALTER TABLE bench " . substr($fields,1));
+ $end_time=new Benchmark;
+ last if ($estimated=predict_query_time($loop_time,$end_time,\$count,$count,
+ $opt_field_count/$add+1));
}
$end_time=new Benchmark;
-print "Time for alter_table_add ($count): " .
+if ($estimated)
+{ print "Estimated time"; }
+else
+{ print "Time"; }
+print " for alter_table_add ($count): " .
timestr(timediff($end_time, $loop_time),"all") . "\n\n";
+#
+# If estimated, fix table to have known number of fields
+#
+if ($estimated && $field_count < $opt_field_count)
+{
+ $fields="";
+ $tmp="ADD ";
+ while ($field_count < $opt_field_count)
+ {
+ $field_count++;
+ $fields.=",$tmp i${field_count} integer";
+ $tmp="" if (!$multi_add); # Adabas
+ }
+ do_query($dbh,"ALTER TABLE bench " . substr($fields,1));
+}
+
####
#### Test adding and deleting index on the first $opt_start_fields
####
$loop_time=new Benchmark;
-for ($i=1; $i < $opt_start_field_count ; $i++)
+$count= 0;
+for ($i=1; $i <= $opt_start_field_count ; $i++)
{
$dbh->do("CREATE INDEX bench_ind$i ON bench (i${i})") || die $DBI::errstr;
}
@@ -153,7 +177,7 @@ print "Time for create_index ($opt_start_field_count): " .
timestr(timediff($end_time, $loop_time),"all") . "\n\n";
$loop_time=new Benchmark;
-for ($i=1; $i < $opt_start_field_count ; $i++)
+for ($i=1; $i <= $opt_start_field_count ; $i++)
{
$dbh->do($server->drop_index("bench","bench_ind$i")) || die $DBI::errstr;
}
@@ -182,10 +206,17 @@ while ($field_count > $opt_start_field_count)
}
$dbh->do("ALTER TABLE bench " . substr($fields,1) . $server->{'drop_attr'})
|| die $DBI::errstr;
+ $end_time=new Benchmark;
+ last if ($estimated=predict_query_time($loop_time,$end_time,\$count,$count,
+ $opt_field_count/$add+1));
}
$end_time=new Benchmark;
-print "Time for alter_table_drop ($count): " .
+if ($estimated)
+{ print "Estimated time"; }
+else
+{ print "Time"; }
+print " for alter_table_drop ($count): " .
timestr(timediff($end_time, $loop_time),"all") . "\n\n";
skip_dropcol:
diff --git a/sql-bench/test-insert.sh b/sql-bench/test-insert.sh
index 085d7cce7f3..38014f7cddf 100644
--- a/sql-bench/test-insert.sh
+++ b/sql-bench/test-insert.sh
@@ -21,10 +21,11 @@
# $opt_loop_count rows in random order
#
# changes made for Oracle compatibility
-# - $limits{'func_odbc_mod'} is OK from crash-me, but it fails here so set we
+# - $limits->{'func_odbc_mod'} is OK from crash-me, but it fails here so set we
# set it to 0 in server-cfg
-# - the default server config runs out of rollback segments, so I added a couple
-# of disconnect/connects to reset
+# - the default server config runs out of rollback segments, so we added a
+# couple of disconnect/connects to reset
+#
##################### Standard benchmark inits ##############################
use DBI;
diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h
index 3cf6bb2c1a5..2a8b263bf28 100644
--- a/sql/mysql_priv.h
+++ b/sql/mysql_priv.h
@@ -772,7 +772,6 @@ uint calc_week(TIME *ltime, bool with_year, bool sunday_first_day_of_week,
void find_date(char *pos,uint *vek,uint flag);
TYPELIB *convert_strings_to_array_type(my_string *typelibs, my_string *end);
TYPELIB *typelib(List<String> &strings);
-void clean_up(bool print_message=1);
ulong get_form_pos(File file, uchar *head, TYPELIB *save_names);
ulong make_new_entry(File file,uchar *fileinfo,TYPELIB *formnames,
const char *newname);
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index 61ae07c01e7..e7190f575db 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -470,6 +470,7 @@ extern "C" pthread_handler_decl(handle_slave,arg);
static uint set_maximum_open_files(uint max_file_limit);
#endif
static ulong find_bit_type(const char *x, TYPELIB *bit_lib);
+static void clean_up(bool print_message);
/****************************************************************************
** Code to end mysqld
@@ -742,13 +743,13 @@ void kill_mysql(void)
#if defined(OS2)
extern "C" void kill_server(int sig_ptr)
-#define RETURN_FROM_KILL_SERVER return
+#define RETURN_FROM_KILL_SERVER DBUG_RETURN
#elif !defined(__WIN__)
static void *kill_server(void *sig_ptr)
-#define RETURN_FROM_KILL_SERVER return 0
+#define RETURN_FROM_KILL_SERVER DBUG_RETURN(0)
#else
static void __cdecl kill_server(int sig_ptr)
-#define RETURN_FROM_KILL_SERVER return
+#define RETURN_FROM_KILL_SERVER DBUG_RETURN
#endif
{
int sig=(int) (long) sig_ptr; // This is passed a int
@@ -827,7 +828,7 @@ extern "C" sig_handler print_signal_warning(int sig)
void unireg_end(void)
{
- clean_up();
+ clean_up(1);
my_thread_end();
#ifdef SIGNALS_DONT_BREAK_READ
exit(0);
@@ -842,7 +843,7 @@ extern "C" void unireg_abort(int exit_code)
DBUG_ENTER("unireg_abort");
if (exit_code)
sql_print_error("Aborting\n");
- clean_up(); /* purecov: inspected */
+ clean_up(1); /* purecov: inspected */
DBUG_PRINT("quit",("done with cleanup in unireg_abort"));
my_thread_end();
exit(exit_code); /* purecov: inspected */
@@ -887,12 +888,12 @@ void clean_up(bool print_message)
regex_end();
#endif
+ if (print_message && errmesg)
+ sql_print_error(ER(ER_SHUTDOWN_COMPLETE),my_progname);
#if !defined(__WIN__) && !defined(EMBEDDED_LIBRARY)
if (!opt_bootstrap)
(void) my_delete(pidfile_name,MYF(0)); // This may not always exist
#endif
- if (print_message && errmesg)
- sql_print_error(ER(ER_SHUTDOWN_COMPLETE),my_progname);
x_free((gptr) my_errmsg[ERRMAPP]); /* Free messages */
DBUG_PRINT("quit", ("Error messages freed"));
/* Tell main we are ready */
@@ -902,6 +903,10 @@ void clean_up(bool print_message)
/* do the broadcast inside the lock to ensure that my_end() is not called */
(void) pthread_cond_broadcast(&COND_thread_count);
(void) pthread_mutex_unlock(&LOCK_thread_count);
+ /*
+ The following lines may never be executed as the main thread may have
+ killed us
+ */
DBUG_PRINT("quit", ("done with cleanup"));
} /* clean_up */
@@ -1481,7 +1486,7 @@ static void init_signals(void)
/* Change limits so that we will get a core file */
struct rlimit rl;
rl.rlim_cur = rl.rlim_max = RLIM_INFINITY;
- if (setrlimit(RLIMIT_CORE, &rl))
+ if (setrlimit(RLIMIT_CORE, &rl) && global_system_variables.log_warnings)
sql_print_error("Warning: setrlimit could not change the size of core files to 'infinity'; We may not be able to generate a core file on signals");
}
#endif
@@ -1550,8 +1555,11 @@ extern "C" void *signal_hand(void *arg __attribute__((unused)))
my_thread_init(); // Init new thread
DBUG_ENTER("signal_hand");
SIGNAL_THD;
- /* Setup alarm handler */
- init_thr_alarm(max_connections+max_insert_delayed_threads);
+ /*
+ Setup alarm handler
+ The two extra handlers are for slave threads
+ */
+ init_thr_alarm(max_connections+max_insert_delayed_threads+2);
#if SIGINT != THR_KILL_SIGNAL
(void) sigemptyset(&set); // Setup up SIGINT for debug
(void) sigaddset(&set,SIGINT); // For debugging
@@ -1639,12 +1647,15 @@ extern "C" void *signal_hand(void *arg __attribute__((unused)))
}
break;
case SIGHUP:
- reload_acl_and_cache((THD*) 0,
- (REFRESH_LOG | REFRESH_TABLES | REFRESH_FAST |
- REFRESH_STATUS | REFRESH_GRANT | REFRESH_THREADS |
- REFRESH_HOSTS),
- (TABLE_LIST*) 0); // Flush logs
- mysql_print_status((THD*) 0); // Send debug some info
+ if (!abort_loop)
+ {
+ reload_acl_and_cache((THD*) 0,
+ (REFRESH_LOG | REFRESH_TABLES | REFRESH_FAST |
+ REFRESH_STATUS | REFRESH_GRANT |
+ REFRESH_THREADS | REFRESH_HOSTS),
+ (TABLE_LIST*) 0); // Flush logs
+ mysql_print_status((THD*) 0); // Send debug some info
+ }
break;
#ifdef USE_ONE_SIGNAL_HAND
case THR_SERVER_ALARM:
diff --git a/sql/net_pkg.cc b/sql/net_pkg.cc
index afedba6a259..30cad3a4177 100644
--- a/sql/net_pkg.cc
+++ b/sql/net_pkg.cc
@@ -134,7 +134,10 @@ net_printf(NET *net, uint errcode, ...)
{
if (thd && thd->bootstrap)
{
- /* In bootstrap it's ok to print on stderr */
+ /*
+ In bootstrap it's ok to print on stderr
+ This may also happen when we get an error from a slave thread
+ */
fprintf(stderr,"ERROR: %d %s\n",errcode,text_pos);
thd->fatal_error=1;
}
diff --git a/sql/slave.cc b/sql/slave.cc
index d254221e726..455b574b355 100644
--- a/sql/slave.cc
+++ b/sql/slave.cc
@@ -376,6 +376,7 @@ int terminate_slave_threads(MASTER_INFO* mi,int thread_mask,bool skip_lock)
}
if ((thread_mask & (SLAVE_IO|SLAVE_FORCE_ALL)) && mi->slave_running)
{
+ DBUG_PRINT("info",("Terminating IO thread"));
mi->abort_slave=1;
if ((error=terminate_slave_thread(mi->io_thd,io_lock,
io_cond_lock,
@@ -386,6 +387,7 @@ int terminate_slave_threads(MASTER_INFO* mi,int thread_mask,bool skip_lock)
}
if ((thread_mask & (SLAVE_SQL|SLAVE_FORCE_ALL)) && mi->rli.slave_running)
{
+ DBUG_PRINT("info",("Terminating SQL thread"));
DBUG_ASSERT(mi->rli.sql_thd != 0) ;
mi->rli.abort_slave=1;
if ((error=terminate_slave_thread(mi->rli.sql_thd,sql_lock,