diff options
106 files changed, 1895 insertions, 886 deletions
diff --git a/BUILD/compile-ia64-debug-max b/BUILD/compile-ia64-debug-max index 9cd54de428d..56c36059ea9 100755 --- a/BUILD/compile-ia64-debug-max +++ b/BUILD/compile-ia64-debug-max @@ -9,5 +9,5 @@ then (cd gemini && aclocal && autoheader && aclocal && automake && autoconf) fi -CC=ecc CFLAGS="-w1 -DEXTRA_DEBUG -DSAFEMALLOC -DSAFE_MUTEX -O2" CXX=ecc CXXFLAGS="-w1 -DEXTRA_DEBUG -DSAFEMALLOC -DSAFE_MUTEX -O2" ./configure --prefix=/usr/local/mysql --with-extra-charsets=complex --enable-thread-safe-client --with-mysqld-ldflags=-all-static --with-client-ldflags=-all-static --with-debug --with-innodb --with-embedded-server +CC=ecc CFLAGS="-w1 -DEXTRA_DEBUG -DSAFEMALLOC -DSAFE_MUTEX -O2" CXX=ecc CXXFLAGS="-w1 -DEXTRA_DEBUG -DSAFEMALLOC -DSAFE_MUTEX -O2" ./configure --prefix=/usr/local/mysql --with-extra-charsets=complex --enable-thread-safe-client --with-mysqld-ldflags=-all-static --with-client-ldflags=-all-static --with-debug --with-innodb --with-embedded-server --with-archive-storage-engine gmake diff --git a/BUILD/compile-solaris-sparc-purify b/BUILD/compile-solaris-sparc-purify index 71a60e45cb0..0e530f75b60 100755 --- a/BUILD/compile-solaris-sparc-purify +++ b/BUILD/compile-solaris-sparc-purify @@ -1,15 +1,35 @@ #! /bin/sh +mode="" +cxxfilt="" + +# For g++ 3.X, the PurifyPlus tools needs a program named "cxxfilt", +# "c++file" or similar. It is part of libtool. If not found, you can +# specify the path to it. + while test $# -gt 0 do case "$1" in - --debug) EXTRA_CONFIG_FLAGS=--with-debug; shift ;; - -h | --help ) cat <<EOF; exit 0 ;; -Usage: $0 [-h|-n] [configure-options] - --debug Compile with DBUG enabled + --debug) EXTRA_CONFIG_FLAGS=--with-debug ;; + --purify) mode=purify ;; + --purecov*) mode=purecov ;; + --quantify) mode=quantify ;; + --cxxfilt) shift ; cxxfilt=$1 ;; + -h | --help ) cat <<EOF; exit 0 ;; +Usage: $0 [ options ] + +Where the 'options' are + + --debug Compile with DBUG enabled + --purify Only prepare for Purify + --purecov Only prepare for PureCover + --quantify Only prepare for Quantify + --cxxfilt <cxxfilt> Path to cxxfilt/c++filt program + This program is needed for gcc 3.X EOF - *) echo "No such option '$1'" ; exit ;; + *) echo "No such option '$1'" ; exit 1 ;; esac + shift done gmake -k clean || true @@ -22,9 +42,70 @@ CFLAGS="-g -Wimplicit -Wreturn-type -Wswitch -Wtrigraphs -Wcomment -W -Wchar-sub gmake -j 4 -cd sql ; mv mysqld mysqld-org ; -make CXXLD="purify -best-effort g++" mysqld ; mv mysqld mysqld-purify -make CXXLD="quantify -best-effort g++" mysqld ; mv mysqld mysqld-quantify -make CXXLD="purecov -best-effort g++" mysqld ; mv mysqld mysqld-purecov -mv mysqld-org mysqld +# ---------------------------------------------------------------------- + +#set -x + +purifying_binaries () +{ + while test $1 + do + dir=$1 + shift + target=$1 + shift + binary=$1 + shift + + opts="" + if [ -n "$cxxfilt" ] ; then + opts="$opts -demangle-program=$cxxfilt" + fi + opts="$opts -best-effort g++" + + back=`pwd` + cd $dir + + # Because of libtool magic, the target and binary + # created might not be the same. To trigger rebuild, + # we need to move them both. + + mv $binary $binary-old + if [ -f $target ] ; then + mv $target $target-old + fi + + if [ -n "$mode" -a $mode = purify ] ; then + gmake CXXLD="purify $opts" $target + mv $binary $binary-purify + fi + + if [ -n "$mode" -a $mode = quantify ] ; then + gmake CXXLD="quantify $opts" $target + mv $binary $binary-quantify + fi + + if [ -n "$mode" -a $mode = purecov ] ; then + gmake CXXLD="purecov $opts" $target + mv $binary $binary-purecov + fi + + mv $binary-old $binary + if [ -f $target-old ] ; then + mv $target-old $target + fi + + cd $back + done +} + + +purifying_binaries \ + sql mysqld mysqld \ + client mysqltest .libs/mysqltest \ + tests mysql_client_test mysql_client_test \ + libmysqld/examples mysqltest_embedded mysqltest_embedded \ + libmysqld/examples mysql_client_test_embedded mysql_client_test_embedded + +# ---------------------------------------------------------------------- diff --git a/BitKeeper/etc/logging_ok b/BitKeeper/etc/logging_ok index 52b8b0584bc..cfdb004723c 100644 --- a/BitKeeper/etc/logging_ok +++ b/BitKeeper/etc/logging_ok @@ -33,6 +33,7 @@ bk@mysql.r18.ru brian@avenger.(none) brian@brian-akers-computer.local brian@private-client-ip-101.oz.net +brian@zim.(none) carsten@tsort.bitbybit.dk davida@isil.mysql.com dellis@goetia.(none) @@ -118,6 +119,7 @@ miguel@light. miguel@light.local miguel@sartre.local mikael@mc04.(none) +mikael@orca.ndb.mysql.com mikron@c-fb0ae253.1238-1-64736c10.cust.bredbandsbolaget.se mikron@mikael-ronstr-ms-dator.local mleich@mysql.com @@ -224,6 +226,7 @@ tonu@x153.internalnet tonu@x3.internalnet tsmith@build.mysql.com tulin@build.mysql.com +tulin@mysql.com ulli@morbus.(none) venu@hundin.mysql.fi venu@myvenu.com diff --git a/Build-tools/Bootstrap b/Build-tools/Bootstrap index 10ebc5c2dd1..8b769dca3c4 100755 --- a/Build-tools/Bootstrap +++ b/Build-tools/Bootstrap @@ -210,10 +210,16 @@ if (-d $target_dir) } else { - &logger("Renaming $target_dir to $target_dir.old." . $$); + # Get the time stamp of "configure.in" + @stat= stat("$target_dir/configure.in"); + my $mtime= $stat[9]; + my ($sec,$min,$hour,$mday,$mon,$year) = localtime($mtime); + my $mtime= sprintf("%04d-%02d-%02d-%02d:%02d", $year+1900, $mon+1, $mday, $hour, $min); + + &logger("Renaming $target_dir to $target_dir-$mtime"); $command= "mv "; $command.= "-v " if ($opt_verbose || defined $opt_log); - $command.= "$target_dir $target_dir.old." . $$; + $command.= "$target_dir $target_dir-$mtime"; &run_command($command, "Could not rename $target_dir!"); } } diff --git a/Build-tools/Do-compile b/Build-tools/Do-compile index 4034533f2eb..1c3ff01796f 100755 --- a/Build-tools/Do-compile +++ b/Build-tools/Do-compile @@ -7,7 +7,7 @@ use Sys::Hostname; @config_options= (); @make_options= (); -$opt_distribution=$opt_user=$opt_config_env=$opt_config_extra_env=""; +$opt_comment=$opt_distribution=$opt_user=$opt_config_env=$opt_config_extra_env=""; $opt_dbd_options=$opt_perl_options=$opt_config_options=$opt_make_options=$opt_suffix=""; $opt_tmp=$opt_version_suffix=""; $opt_bundled_zlib=$opt_help=$opt_delete=$opt_debug=$opt_stage=$opt_no_test=$opt_no_perl=$opt_one_error=$opt_with_low_memory=$opt_fast_benchmark=$opt_static_client=$opt_static_server=$opt_static_perl=$opt_sur=$opt_with_small_disk=$opt_local_perl=$opt_tcpip=$opt_build_thread=$opt_use_old_distribution=$opt_enable_shared=$opt_no_crash_me=$opt_no_strip=$opt_with_archive=$opt_with_cluster=$opt_with_csv=$opt_with_example=$opt_with_debug=$opt_no_benchmark=$opt_no_mysqltest=$opt_without_embedded=$opt_readline=0; @@ -17,6 +17,7 @@ GetOptions( "bdb", "build-thread=i", "bundled-zlib", + "comment=s", "config-env=s" => \@config_env, "config-extra-env=s" => \@config_extra_env, "config-options=s" => \@config_options, @@ -110,6 +111,7 @@ $log="$pwd/Logs/$host-$major.$minor$opt_version_suffix.log"; $opt_distribution =~ /(mysql[^\/]*)\.tar/; $ver=$1; $gcc_version=which("gcc"); +$opt_comment= "Official MySQL$opt_version_suffix binary" unless $opt_comment; if (defined($gcc_version) && ! $opt_config_env) { $tmp=`$gcc_version -v 2>&1`; @@ -303,7 +305,7 @@ if ($opt_stage <= 1) } $prefix="/usr/local/mysql"; - check_system("$opt_config_env ./configure --prefix=$prefix --localstatedir=$prefix/data --libexecdir=$prefix/bin --with-comment=\"Official MySQL$opt_version_suffix binary\" --with-extra-charsets=complex --with-server-suffix=\"$opt_version_suffix\" --enable-thread-safe-client --enable-local-infile $opt_config_options","Thank you for choosing MySQL"); + check_system("$opt_config_env ./configure --prefix=$prefix --localstatedir=$prefix/data --libexecdir=$prefix/bin --with-comment=\"$opt_comment\" --with-extra-charsets=complex --with-server-suffix=\"$opt_version_suffix\" --enable-thread-safe-client --enable-local-infile $opt_config_options","Thank you for choosing MySQL"); if (-d "$pwd/$host/include-mysql") { safe_system("cp -r $pwd/$host/include-mysql/* $pwd/$host/$ver/include"); @@ -530,6 +532,10 @@ When running several Do-compile runs in parallel, each build should have its own thread ID, so running the test suites does not cause conflicts with duplicate TCP port numbers. +--comment=<comment> +Replace the default compilation comment that is embedded into +the mysqld binary. + --config-env=<environment for configure> To set up the environment, like 'CC=cc CXX=gcc CXXFLAGS=-O3' @@ -684,16 +690,20 @@ sub abort if ($opt_user) { - $mail_header_file="$opt_tmp/do-command.$$"; - open(TMP,">$mail_header_file"); + # Take the last 40 lines of the build log + open(LOG, "$log") or die $!; + my @log= <LOG>; + close LOG; + splice @log => 0, -40; + my $mail_file="$opt_tmp/do-command.$$"; + open(TMP,">$mail_file") or die $!; print TMP "From: mysqldev\@$full_host_name\n"; print TMP "To: $email\n"; print TMP "Subject: $host($uname): $ver$opt_version_suffix compilation failed\n\n"; + print TMP @log; close TMP; - system("tail -n 40 $log > $log.mail"); - system("cat $mail_header_file $log.mail | $sendmail -t -f $email"); - unlink($mail_header_file); - unlink("$log.mail"); + system("$sendmail -t -f $email < $mail_file"); + unlink($mail_file); } exit 1; } diff --git a/acinclude.m4 b/acinclude.m4 index 4f2ad8daf91..d7e22332655 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -1624,7 +1624,12 @@ AC_DEFUN([MYSQL_CHECK_NDB_OPTIONS], [ --without-ndb-debug Disable special ndb debug features], [ndb_debug="$withval"], [ndb_debug="default"]) - + AC_ARG_WITH([ndb-ccflags], + [ + --with-ndb-ccflags Extra CC options for ndb compile], + [ndb_cxxflags_fix="$ndb_cxxflags_fix $withval"], + [ndb_cxxflags_fix=$ndb_cxxflags_fix]) + AC_MSG_CHECKING([for NDB Cluster options]) AC_MSG_RESULT([]) diff --git a/client/mysqladmin.cc b/client/mysqladmin.cc index d390a152fc7..0da7d5b3acf 100644 --- a/client/mysqladmin.cc +++ b/client/mysqladmin.cc @@ -1008,6 +1008,7 @@ static void usage(void) print_defaults("my",load_default_groups); puts("\nWhere command is a one or more of: (Commands may be shortened)\n\ create databasename Create a new database\n\ + debug Instruct server to write debug information to log\n\ drop databasename Delete a database and all its tables\n\ extended-status Gives an extended status message from the server\n\ flush-hosts Flush all cached hosts\n\ diff --git a/client/mysqldump.c b/client/mysqldump.c index 3a93adf5b36..52255ccb896 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -489,7 +489,7 @@ static void write_header(FILE *sql_file, char *db_name) "); } fprintf(sql_file, - "/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE=\"%s%s%s\" */;\n", + "/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='%s%s%s' */;\n", path?"":"NO_AUTO_VALUE_ON_ZERO",compatible_mode_normal_str[0]==0?"":",", compatible_mode_normal_str); check_io(sql_file); @@ -863,7 +863,7 @@ static int dbConnect(char *host, char *user,char *passwd) cannot reconnect. */ sock->reconnect= 0; - sprintf(buff, "/*!40100 SET @@SQL_MODE=\"%s\" */", + sprintf(buff, "/*!40100 SET @@SQL_MODE='%s' */", compatible_mode_normal_str); if (mysql_query_with_error_report(sock, 0, buff)) { @@ -2091,27 +2091,27 @@ static int dump_all_tables_in_db(char *database) RETURN void */ -static void get_actual_table_name( const char *old_table_name, - char *new_table_name, - int buf_size ) -{ - MYSQL_RES *tableRes; - MYSQL_ROW row; - char query[ NAME_LEN + 50 ]; - DBUG_ENTER("get_actual_table_name"); +static void get_actual_table_name(const char *old_table_name, + char *new_table_name, + int buf_size) +{ + MYSQL_RES *tableRes; + MYSQL_ROW row; + char query[ NAME_LEN + 50 ]; + DBUG_ENTER("get_actual_table_name"); - sprintf( query, "SHOW TABLES LIKE '%s'", old_table_name ); - if (mysql_query_with_error_report(sock, 0, query)) - { - safe_exit(EX_MYSQLERR); - } + sprintf( query, "SHOW TABLES LIKE '%s'", old_table_name); + if (mysql_query_with_error_report(sock, 0, query)) + { + safe_exit(EX_MYSQLERR); + } - tableRes = mysql_store_result( sock ); - row = mysql_fetch_row( tableRes ); - strncpy( new_table_name, row[0], buf_size ); - mysql_free_result(tableRes); -} /* get_actual_table_name */ + tableRes= mysql_store_result( sock ); + row= mysql_fetch_row( tableRes ); + strmake(new_table_name, row[0], buf_size-1); + mysql_free_result(tableRes); +} static int dump_selected_tables(char *db, char **table_names, int tables) diff --git a/configure.in b/configure.in index 98d060e660c..caa42004736 100644 --- a/configure.in +++ b/configure.in @@ -2954,6 +2954,15 @@ EOF AC_CONFIG_SUBDIRS(innobase) fi +case $SYSTEM_TYPE-$MACHINE_TYPE-$ac_cv_prog_gcc-$have_ndbcluster in + *solaris*-i?86-no-yes) + # ndb fail for whatever strange reason to link Sun Forte/x86 + # unless using incremental linker + CXXFLAGS="$CXXFLAGS -xildon" + ;; + *) ;; +esac + if test X"$have_ndbcluster" = Xyes then if test X"$mysql_cv_compress" != Xyes diff --git a/extra/perror.c b/extra/perror.c index 1bd4b203120..27027520cbe 100644 --- a/extra/perror.c +++ b/extra/perror.c @@ -184,6 +184,7 @@ int main(int argc,char *argv[]) { int error,code,found; const char *msg; + char *unknown_error = 0; MY_INIT(argv[0]); if (get_options(&argc,&argv)) @@ -212,7 +213,14 @@ int main(int argc,char *argv[]) string 'Unknown Error'. To avoid printing it we try to find the error string by asking for an impossible big error message. */ - const char *unknown_error= strerror(10000); + msg= strerror(10000); + + /* + Allocate a buffer for unknown_error since strerror always returns + the same pointer on some platforms such as Windows + */ + unknown_error= malloc(strlen(msg)+1); + strmov(unknown_error, msg); for ( ; argc-- > 0 ; argv++) { @@ -262,6 +270,11 @@ int main(int argc,char *argv[]) } } } + + /* if we allocated a buffer for unknown_error, free it now */ + if (unknown_error) + free(unknown_error); + exit(error); return error; } diff --git a/include/my_global.h b/include/my_global.h index 3263d079853..7ca3d5e1e58 100644 --- a/include/my_global.h +++ b/include/my_global.h @@ -135,7 +135,13 @@ #ifdef HAVE_UNIXWARE7_THREADS #include <thread.h> #else +#if defined(HPUX10) || defined(HPUX11) +C_MODE_START /* HPUX needs this, signal.h bug */ +#include <pthread.h> +C_MODE_END +#else #include <pthread.h> /* AIX must have this included first */ +#endif #endif /* HAVE_UNIXWARE7_THREADS */ #endif /* HAVE_mit_thread */ #if !defined(SCO) && !defined(_REENTRANT) diff --git a/innobase/buf/buf0rea.c b/innobase/buf/buf0rea.c index 58287d37387..055eede5c1a 100644 --- a/innobase/buf/buf0rea.c +++ b/innobase/buf/buf0rea.c @@ -679,7 +679,9 @@ buf_read_recv_pages( fprintf(stderr, "InnoDB: Error: InnoDB has waited for 50 seconds for pending\n" "InnoDB: reads to the buffer pool to be finished.\n" -"InnoDB: Number of pending reads %lu\n", (ulong) buf_pool->n_pend_reads); +"InnoDB: Number of pending reads %lu, pending pread calls %lu\n", + (ulong) buf_pool->n_pend_reads, + (ulong)os_file_n_pending_preads); os_aio_print_debug = TRUE; } diff --git a/innobase/fil/fil0fil.c b/innobase/fil/fil0fil.c index cc1c4a22983..a8da074cab9 100644 --- a/innobase/fil/fil0fil.c +++ b/innobase/fil/fil0fil.c @@ -3002,8 +3002,8 @@ fil_load_single_table_tablespaces(void) /* printf( " Looking at file %s\n", fileinfo.name); */ - if (fileinfo.type == OS_FILE_TYPE_DIR - || dbinfo.type == OS_FILE_TYPE_UNKNOWN) { + if (fileinfo.type == OS_FILE_TYPE_DIR) { + goto next_file_item; } diff --git a/innobase/include/univ.i b/innobase/include/univ.i index 6ae4fe1c2ce..625978ffc38 100644 --- a/innobase/include/univ.i +++ b/innobase/include/univ.i @@ -80,10 +80,6 @@ memory is read outside the allocated blocks. */ /* Make a non-inline debug version */ -#ifdef DBUG_ON -#define UNIV_DEBUG -#endif /* DBUG_ON */ - /* #define UNIV_DEBUG #define UNIV_MEM_DEBUG diff --git a/innobase/os/os0file.c b/innobase/os/os0file.c index 7090e8662f3..cc743ffad41 100644 --- a/innobase/os/os0file.c +++ b/innobase/os/os0file.c @@ -700,12 +700,12 @@ http://www.mysql.com/doc/en/Windows_symbolic_links.html */ } else if (lpFindFileData->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { info->type = OS_FILE_TYPE_DIR; - } else if (lpFindFileData->dwFileAttributes - & FILE_ATTRIBUTE_NORMAL) { -/* TODO: are FILE_ATTRIBUTE_NORMAL files really all normal files? */ - info->type = OS_FILE_TYPE_FILE; } else { - info->type = OS_FILE_TYPE_UNKNOWN; + /* It is probably safest to assume that all other + file types are normal. Better to check them rather + than blindly skip them. */ + + info->type = OS_FILE_TYPE_FILE; } } @@ -823,7 +823,7 @@ os_file_create_directory( rcode = CreateDirectory(pathname, NULL); if (!(rcode != 0 || - (GetLastError() == ERROR_FILE_EXISTS && !fail_if_exists))) { + (GetLastError() == ERROR_ALREADY_EXISTS && !fail_if_exists))) { /* failure */ os_file_handle_error(pathname, "CreateDirectory"); @@ -907,8 +907,9 @@ try_again: file = CreateFile(name, access, - FILE_SHARE_READ,/* file can be read also by other - processes */ + FILE_SHARE_READ | FILE_SHARE_WRITE, + /* file can be read ansd written also + by other processes */ NULL, /* default security attributes */ create_flag, attributes, @@ -1013,7 +1014,7 @@ os_file_create_simple_no_error_handling( DWORD create_flag; DWORD access; DWORD attributes = 0; - DWORD share_mode = FILE_SHARE_READ; + DWORD share_mode = FILE_SHARE_READ | FILE_SHARE_WRITE; ut_a(name); @@ -1336,7 +1337,7 @@ loop: return(TRUE); } - if (GetLastError() == ERROR_PATH_NOT_FOUND) { + if (GetLastError() == ERROR_FILE_NOT_FOUND) { /* the file does not exist, this not an error */ return(TRUE); @@ -1397,7 +1398,7 @@ loop: return(TRUE); } - if (GetLastError() == ERROR_PATH_NOT_FOUND) { + if (GetLastError() == ERROR_FILE_NOT_FOUND) { /* If the file does not exist, we classify this as a 'mild' error and return */ diff --git a/innobase/ut/ut0ut.c b/innobase/ut/ut0ut.c index 732380bcb1f..18722149a8f 100644 --- a/innobase/ut/ut0ut.c +++ b/innobase/ut/ut0ut.c @@ -44,13 +44,13 @@ ut_get_high32( /* out: a >> 32 */ ulint a) /* in: ulint */ { -#if SIZEOF_LONG == 4 - UT_NOT_USED(a); + ib_longlong i; - return 0; -#else - return(a >> 32); -#endif + i = (ib_longlong)a; + + i = i >> 32; + + return((ulint)i); } /************************************************************ diff --git a/mysql-test/lib/mtr_io.pl b/mysql-test/lib/mtr_io.pl index 017ba11645b..b3da6d97664 100644 --- a/mysql-test/lib/mtr_io.pl +++ b/mysql-test/lib/mtr_io.pl @@ -8,6 +8,7 @@ use strict; sub mtr_get_pid_from_file ($); sub mtr_get_opts_from_file ($); +sub mtr_fromfile ($); sub mtr_tofile ($@); sub mtr_tonewfile($@); @@ -107,6 +108,8 @@ sub mtr_fromfile ($) { open(FILE,"<",$file) or mtr_error("can't open file \"$file\": $!"); my $text= join('', <FILE>); close FILE; + $text =~ s/^\s+//; # Remove starting space, incl newlines + $text =~ s/\s+$//; # Remove ending space, incl newlines return $text; } diff --git a/mysql-test/lib/mtr_process.pl b/mysql-test/lib/mtr_process.pl index e832468d0cb..e1461a9730c 100644 --- a/mysql-test/lib/mtr_process.pl +++ b/mysql-test/lib/mtr_process.pl @@ -5,14 +5,19 @@ # same name. #use Carp qw(cluck); +use Socket; +use Errno; use strict; -use POSIX ":sys_wait_h"; +#use POSIX ":sys_wait_h"; +use POSIX 'WNOHANG'; sub mtr_run ($$$$$$); sub mtr_spawn ($$$$$$); -sub mtr_stop_mysqld_servers ($$); +sub mtr_stop_mysqld_servers ($); sub mtr_kill_leftovers (); +sub mtr_record_dead_children (); +sub sleep_until_file_created ($$$); # static in C sub spawn_impl ($$$$$$$); @@ -34,7 +39,18 @@ sub mtr_run ($$$$$$) { my $error= shift; my $pid_file= shift; - return spawn_impl($path,$arg_list_t,1,$input,$output,$error,$pid_file); + return spawn_impl($path,$arg_list_t,'run',$input,$output,$error,$pid_file); +} + +sub mtr_run_test ($$$$$$) { + my $path= shift; + my $arg_list_t= shift; + my $input= shift; + my $output= shift; + my $error= shift; + my $pid_file= shift; + + return spawn_impl($path,$arg_list_t,'test',$input,$output,$error,$pid_file); } sub mtr_spawn ($$$$$$) { @@ -45,7 +61,7 @@ sub mtr_spawn ($$$$$$) { my $error= shift; my $pid_file= shift; - return spawn_impl($path,$arg_list_t,0,$input,$output,$error,$pid_file); + return spawn_impl($path,$arg_list_t,'spawn',$input,$output,$error,$pid_file); } @@ -58,7 +74,7 @@ sub mtr_spawn ($$$$$$) { sub spawn_impl ($$$$$$$) { my $path= shift; my $arg_list_t= shift; - my $join= shift; + my $mode= shift; my $input= shift; my $output= shift; my $error= shift; @@ -71,107 +87,203 @@ sub spawn_impl ($$$$$$$) { print STDERR "#### ", "STDIN $input\n" if $input; print STDERR "#### ", "STDOUT $output\n" if $output; print STDERR "#### ", "STDERR $error\n" if $error; - if ( $join ) - { - print STDERR "#### ", "RUN "; - } - else - { - print STDERR "#### ", "SPAWN "; - } - print STDERR "$path ", join(" ",@$arg_list_t), "\n"; + print STDERR "#### ", "$mode : $path ", join(" ",@$arg_list_t), "\n"; print STDERR "#### ", "-" x 78, "\n"; } - my $pid= fork(); - if ( ! defined $pid ) + FORK: { - mtr_error("$path ($pid) can't be forked"); - } + my $pid= fork(); - if ( $pid ) - { - # Parent, i.e. the main script - if ( $join ) + if ( ! defined $pid ) { - # We run a command and wait for the result - # FIXME this need to be improved - my $res= waitpid($pid,0); - - if ( $res == -1 ) + if ( $! == $!{EAGAIN} ) # See "perldoc Errno" { - mtr_error("$path ($pid) got lost somehow"); + mtr_debug("Got EAGAIN from fork(), sleep 1 second and redo"); + sleep(1); + redo FORK; } - my $exit_value= $? >> 8; - my $signal_num= $? & 127; - my $dumped_core= $? & 128; - if ( $signal_num ) - { - mtr_error("$path ($pid) got signal $signal_num"); - } - if ( $dumped_core ) + else { - mtr_error("$path ($pid) dumped core"); + mtr_error("$path ($pid) can't be forked"); } - return $exit_value; + } + + if ( $pid ) + { + spawn_parent_impl($pid,$mode,$path); } else { - # We spawned a process we don't wait for - return $pid; + # Child, redirect output and exec + # FIXME I tried POSIX::setsid() here to detach and, I hoped, + # avoid zombies. But everything went wild, somehow the parent + # became a deamon as well, and was hard to kill ;-) + # Need to catch SIGCHLD and do waitpid or something instead...... + + $SIG{INT}= 'DEFAULT'; # Parent do some stuff, we don't + + if ( $output ) + { + if ( ! open(STDOUT,">",$output) ) + { + mtr_error("can't redirect STDOUT to \"$output\": $!"); + } + } + if ( $error ) + { + if ( $output eq $error ) + { + if ( ! open(STDERR,">&STDOUT") ) + { + mtr_error("can't dup STDOUT: $!"); + } + } + else + { + if ( ! open(STDERR,">",$error) ) + { + mtr_error("can't redirect STDERR to \"$output\": $!"); + } + } + } + if ( $input ) + { + if ( ! open(STDIN,"<",$input) ) + { + mtr_error("can't redirect STDIN to \"$input\": $!"); + } + } + exec($path,@$arg_list_t); } } - else - { - # Child, redirect output and exec - # FIXME I tried POSIX::setsid() here to detach and, I hoped, - # avoid zombies. But everything went wild, somehow the parent - # became a deamon as well, and was hard to kill ;-) - # Need to catch SIGCHLD and do waitpid or something instead...... +} + + +sub spawn_parent_impl { + my $pid= shift; + my $mode= shift; + my $path= shift; - $SIG{INT}= 'DEFAULT'; # Parent do some stuff, we don't + if ( $mode eq 'run' or $mode eq 'test' ) + { + my $exit_value= -1; + my $signal_num= 0; + my $dumped_core= 0; - if ( $output ) + if ( $mode eq 'run' ) { - if ( ! open(STDOUT,">",$output) ) + # Simple run of command, we wait for it to return + my $ret_pid= waitpid($pid,0); + + if ( $ret_pid <= 0 ) { - mtr_error("can't redirect STDOUT to \"$output\": $!"); + mtr_error("$path ($pid) got lost somehow"); } + + $exit_value= $? >> 8; + $signal_num= $? & 127; + $dumped_core= $? & 128; + + return $exit_value; } - if ( $error ) + else { - if ( $output eq $error ) + # We run mysqltest and wait for it to return. But we try to + # catch dying mysqld processes as well. + # + # We do blocking waitpid() until we get the return from the + # "mysqltest" call. But if a mysqld process dies that we + # started, we take this as an error, and kill mysqltest. + # + # FIXME is this as it should be? Can't mysqld terminate + # normally from running a test case? + + my $ret_pid; # What waitpid() returns + + while ( ($ret_pid= waitpid(-1,0)) != -1 ) { - if ( ! open(STDERR,">&STDOUT") ) + # Someone terminated, don't know who. Collect + # status info first before $? is lost, + # but not $exit_value, this is flagged from + # + + if ( $ret_pid == $pid ) { - mtr_error("can't dup STDOUT: $!"); + # We got termination of mysqltest, we are done + $exit_value= $? >> 8; + $signal_num= $? & 127; + $dumped_core= $? & 128; + last; } - } - else - { - if ( ! open(STDERR,">",$error) ) + + # If one of the mysqld processes died, we want to + # mark this, and kill the mysqltest process. + + foreach my $idx (0..1) { - mtr_error("can't redirect STDERR to \"$output\": $!"); + 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; + } + } + + mtr_debug("waitpid() catched exit of unknown child $ret_pid, " . + "exit during mysqltest run"); } - } - if ( $input ) - { - if ( ! open(STDIN,"<",$input) ) + + if ( $ret_pid != $pid ) { - mtr_error("can't redirect STDIN to \"$input\": $!"); + # We terminated the waiting because a "mysqld" process died. + # Kill the mysqltest process. + + kill(9,$pid); + + $ret_pid= waitpid($pid,0); + + if ( $ret_pid == -1 ) + { + mtr_error("$path ($pid) got lost somehow"); + } } + + return $exit_value; } - exec($path,@$arg_list_t); + } + else + { + # We spawned a process we don't wait for + return $pid; } } + + ############################################################################## # # Kill processes left from previous runs # ############################################################################## +# 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. + sub mtr_kill_leftovers () { # First, kill all masters and slaves that would conflict with @@ -199,10 +311,23 @@ sub mtr_kill_leftovers () { }); } - mtr_stop_mysqld_servers(\@args, 1); + mtr_mysqladmin_shutdown(\@args); + + # 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 + # or not. We now try to find the process PID from the PID file, and + # send a kill to that process. Note that Perl let kill(0,@pids) be + # a way to just return the numer of processes the kernel can send + # signals to. So this can be used (except on Cygwin) to determine + # if there are processes left running that we cound out might exists. + # + # But still after all this work, all we know is that we have + # the ports free. # We scan the "var/run/" directory for other process id's to kill - my $rundir= "$::glob_mysql_test_dir/var/run"; # FIXME $path_run_dir or something + + # FIXME $path_run_dir or something + my $rundir= "$::glob_mysql_test_dir/var/run"; if ( -d $rundir ) { @@ -218,193 +343,157 @@ sub mtr_kill_leftovers () { if ( -f $pidfile ) { my $pid= mtr_get_pid_from_file($pidfile); - if ( ! unlink($pidfile) ) + + # Race, could have been removed between I tested with -f + # and the unlink() below, so I better check again with -f + + if ( ! unlink($pidfile) and -f $pidfile ) { mtr_error("can't remove $pidfile"); } - push(@pids, $pid); + + if ( $::glob_cygwin_perl or kill(0, $pid) ) + { + push(@pids, $pid); # We know (cygwin guess) it exists + } } } closedir(RUNDIR); - start_reap_all(); - - if ( $::glob_cygwin_perl ) + if ( @pids ) { - # We have no (easy) way of knowing the Cygwin controlling - # process, in the PID file we only have the Windows process id. - system("kill -f " . join(" ",@pids)); # Hope for the best.... - } - else - { - my $retries= 10; # 10 seconds - do + if ( $::glob_cygwin_perl ) { - kill(9, @pids); - } while ( $retries-- and kill(0, @pids) ); - - if ( kill(0, @pids) ) + # We have no (easy) way of knowing the Cygwin controlling + # process, in the PID file we only have the Windows process id. + system("kill -f " . join(" ",@pids)); # Hope for the best.... + mtr_debug("Sleep 5 seconds waiting for processes to die"); + sleep(5); + } + else { - mtr_error("can't kill processes " . join(" ", @pids)); + my $retries= 10; # 10 seconds + do + { + kill(9, @pids); + mtr_debug("Sleep 1 second waiting for processes to die"); + sleep(1) # Wait one second + } while ( $retries-- and kill(0, @pids) ); + + if ( kill(0, @pids) ) # Check if some left + { + # FIXME maybe just mtr_warning() ? + mtr_error("can't kill process(es) " . join(" ", @pids)); + } } } + } + + # We may have failed everything, bug we now check again if we have + # the listen ports free to use, and if they are free, just go for it. - stop_reap_all(); + foreach my $srv ( @args ) + { + if ( mtr_ping_mysqld_server($srv->{'port'}, $srv->{'sockfile'}) ) + { + mtr_error("can't kill old mysqld holding port $srv->{'port'}"); + } } } ############################################################################## # -# Shut down mysqld servers +# Shut down mysqld servers we have started from this run of this script # ############################################################################## -# To speed things we kill servers in parallel. -# The argument is a list of 'pidfiles' and 'socketfiles'. -# We use the pidfiles and socketfiles to try to terminate the servers. -# This is not perfect, there could still be other server processes -# left. - -# Force flag is to be set only for killing mysqld servers this script -# didn't create in this run, i.e. initial cleanup before we start working. -# If force flag is set, we try to kill all with mysqladmin, and -# give up if we have no PIDs. +# To speed things we kill servers in parallel. The argument is a list +# of 'ports', 'pids', 'pidfiles' and 'socketfiles'. -# FIXME On some operating systems, $srv->{'pid'} and $srv->{'pidfile'} -# will not be the same PID. We need to try to kill both I think. +# 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 +# both I think. -sub mtr_stop_mysqld_servers ($$) { +sub mtr_stop_mysqld_servers ($) { my $spec= shift; - my $force= shift; # ---------------------------------------------------------------------- - # If the process was not started from this file, we got no PID, - # we try to find it in the PID file. + # First try nice normal shutdown using 'mysqladmin' # ---------------------------------------------------------------------- - my $any_pid= 0; # If we have any PIDs + mtr_mysqladmin_shutdown($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 + # listening to the port, but still be alive. But it is a start. + # ---------------------------------------------------------------------- foreach my $srv ( @$spec ) { - if ( ! $srv->{'pid'} and -f $srv->{'pidfile'} ) - { - $srv->{'pid'}= mtr_get_pid_from_file($srv->{'pidfile'}); - } - if ( $srv->{'pid'} ) + if ( $srv->{'pid'} and (waitpid($srv->{'pid'},&WNOHANG) == $srv->{'pid'}) ) { - $any_pid= 1; + $srv->{'pid'}= 0; } } - # If the processes where started from this script, and we know - # no PIDs, then we don't have to do anything. - - if ( ! $any_pid and ! $force ) - { - # cluck "This is how we got here!"; - return; - } - # ---------------------------------------------------------------------- - # First try nice normal shutdown using 'mysqladmin' + # We know the process was started from this file, so there is a PID + # saved, or else we have nothing to do. + # Might be that is is recorded to be missing, but we failed to + # take away the PID file earlier, then we do it now. # ---------------------------------------------------------------------- - start_reap_all(); # Don't require waitpid() of children + my %mysqld_pids; foreach my $srv ( @$spec ) { - if ( -e $srv->{'sockfile'} or $srv->{'port'} ) + if ( $srv->{'pid'} ) { - # FIXME wrong log..... - # FIXME, stderr..... - # Shutdown time must be high as slave may be in reconnect - my $args; - - mtr_init_args(\$args); - - mtr_add_arg($args, "--no-defaults"); - mtr_add_arg($args, "--user=%s", $::opt_user); - mtr_add_arg($args, "--password="); - if ( -e $srv->{'sockfile'} ) - { - mtr_add_arg($args, "--socket=%s", $srv->{'sockfile'}); - } - if ( $srv->{'port'} ) - { - mtr_add_arg($args, "--port=%s", $srv->{'port'}); - } - mtr_add_arg($args, "--connect_timeout=5"); - mtr_add_arg($args, "--shutdown_timeout=20"); - mtr_add_arg($args, "--protocol=tcp"); # FIXME new thing, will it help?! - mtr_add_arg($args, "shutdown"); - # We don't wait for termination of mysqladmin - mtr_spawn($::exe_mysqladmin, $args, - "", $::path_manager_log, $::path_manager_log, ""); + $mysqld_pids{$srv->{'pid'}}= 1; } - } - - # Wait for them all to remove their pid and socket file - - PIDSOCKFILEREMOVED: - for (my $loop= $::opt_sleep_time_for_delete; $loop; $loop--) - { - my $pidsockfiles_left= 0; - foreach my $srv ( @$spec ) + else { - if ( -e $srv->{'sockfile'} or -f $srv->{'pidfile'} ) + # Race, could have been removed between I tested with -f + # and the unlink() below, so I better check again with -f + + if ( -f $srv->{'pidfile'} and ! unlink($srv->{'pidfile'}) and + -f $srv->{'pidfile'} ) { - $pidsockfiles_left++; # Could be that pidfile is left + mtr_error("can't remove $srv->{'pidfile'}"); } } - if ( ! $pidsockfiles_left ) - { - last PIDSOCKFILEREMOVED; - } - if ( $loop % 20 == 1 ) - { - mtr_warning("Still processes alive after 10 seconds, retrying for $loop seconds..."); - } - mtr_debug("Sleep for 1 second waiting for pid and socket file removal"); - sleep(1); # One second } # ---------------------------------------------------------------------- - # If no known PIDs, we have nothing more to try + # If the processes where started from this script, and we had no PIDS + # then we don't have to do anything. # ---------------------------------------------------------------------- - if ( ! $any_pid ) + if ( ! keys %mysqld_pids ) { - stop_reap_all(); + # cluck "This is how we got here!"; return; } # ---------------------------------------------------------------------- - # We may have killed all that left a socket, but we are not sure we got - # them all killed. If we suspect it lives, try nice kill with SIG_TERM. - # Note that for true Win32 processes, kill(0,$pid) will not return 1. + # In mtr_mysqladmin_shutdown() we only waited for the mysqld servers + # not to listen to the port. But we are not sure we got them all + # killed. If we suspect it lives, try nice kill with SIG_TERM. Note + # that for true Win32 processes, kill(0,$pid) will not return 1. # ---------------------------------------------------------------------- SIGNAL: foreach my $sig (15,9) { - my $process_left= 0; - foreach my $srv ( @$spec ) + my $retries= 10; # 10 seconds + kill($sig, keys %mysqld_pids); + while ( $retries-- and kill(0, keys %mysqld_pids) ) { - if ( $srv->{'pid'} and - ( -f $srv->{'pidfile'} or kill(0,$srv->{'pid'}) ) ) - { - $process_left++; - mtr_warning("process $srv->{'pid'} not cooperating, " . - "will send signal $sig to process"); - kill($sig,$srv->{'pid'}); # SIG_TERM - } - if ( ! $process_left ) - { - last SIGNAL; - } + mtr_debug("Sleep 1 second waiting for processes to die"); + sleep(1) # Wait one second } - mtr_debug("Sleep for 5 seconds waiting for processes to die"); - sleep(5); # We wait longer than usual } # ---------------------------------------------------------------------- @@ -437,8 +526,8 @@ sub mtr_stop_mysqld_servers ($$) { foreach my $file ($srv->{'pidfile'}, $srv->{'sockfile'}) { - unlink($file); - if ( -e $file ) + # Know it is dead so should be no race, careful anyway + if ( -f $file and ! unlink($file) and -f $file ) { $errors++; mtr_warning("couldn't delete $file"); @@ -454,9 +543,147 @@ sub mtr_stop_mysqld_servers ($$) { } } - stop_reap_all(); + # FIXME We just assume they are all dead, for Cygwin we are not + # really sure + +} + + +############################################################################## +# +# 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; + + my @mysql_admin_pids; + my @to_kill_specs; + + foreach my $srv ( @$spec ) + { + if ( mtr_ping_mysqld_server($srv->{'port'}, $srv->{'sockfile'}) ) + { + push(@to_kill_specs, $srv); + } + } + + + foreach my $srv ( @to_kill_specs ) + { + # FIXME wrong log..... + # FIXME, stderr..... + # Shutdown time must be high as slave may be in reconnect + my $args; + + mtr_init_args(\$args); + + mtr_add_arg($args, "--no-defaults"); + mtr_add_arg($args, "--user=%s", $::opt_user); + mtr_add_arg($args, "--password="); + if ( -e $srv->{'sockfile'} ) + { + mtr_add_arg($args, "--socket=%s", $srv->{'sockfile'}); + } + if ( $srv->{'port'} ) + { + mtr_add_arg($args, "--port=%s", $srv->{'port'}); + } + if ( $srv->{'port'} and ! -e $srv->{'sockfile'} ) + { + mtr_add_arg($args, "--protocol=tcp"); # Needed if no --socket + } + mtr_add_arg($args, "--connect_timeout=5"); + mtr_add_arg($args, "--shutdown_timeout=20"); + 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, ""); + push(@mysql_admin_pids, $pid); + } + + # We wait blocking, we wait for the last one anyway + foreach my $pid (@mysql_admin_pids) + { + waitpid($pid,0); # FIXME no need to check -1 or 0? + } - # FIXME We just assume they are all dead, we don't know.... + # 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 + + TIME: + while ( $timeout-- ) + { + foreach my $srv ( @to_kill_specs ) + { + $res= 1; # We are optimistic + if ( mtr_ping_mysqld_server($srv->{'port'}, $srv->{'sockfile'}) ) + { + mtr_debug("Sleep 1 second waiting for processes to stop using port"); + sleep(1); # One second + $res= 0; + next TIME; + } + } + last; # If we got here, we are done + } + + return $res; +} + +############################################################################## +# +# The operating system will keep information about dead children, +# we read this information here, and if we have records the process +# is alive, we mark it as dead. +# +############################################################################## + +sub mtr_record_dead_children () { + + 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 ) + { + 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; + } + } + } } sub start_reap_all { @@ -467,6 +694,32 @@ sub stop_reap_all { $SIG{CHLD}= 'DEFAULT'; } +sub mtr_ping_mysqld_server () { + my $port= shift; + + my $remote= "localhost"; + my $iaddr= inet_aton($remote); + if ( ! $iaddr ) + { + mtr_error("can't find IP number for $remote"); + } + my $paddr= sockaddr_in($port, $iaddr); + my $proto= getprotobyname('tcp'); + if ( ! socket(SOCK, PF_INET, SOCK_STREAM, $proto) ) + { + mtr_error("can't create socket: $!"); + } + if ( connect(SOCK, $paddr) ) + { + close(SOCK); # FIXME check error? + return 1; + } + else + { + return 0; + } +} + ############################################################################## # # Wait for a file to be created @@ -474,33 +727,38 @@ sub stop_reap_all { ############################################################################## -sub sleep_until_file_created ($$) { +sub sleep_until_file_created ($$$) { my $pidfile= shift; my $timeout= shift; + my $pid= shift; - my $loop= $timeout; - while ( $loop-- ) + for ( my $loop= 1; $loop <= $timeout; $loop++ ) { if ( -r $pidfile ) { - return; + return 1; } - mtr_debug("Sleep for 1 second waiting for creation of $pidfile"); - if ( $loop % 20 == 1 ) + # Check if it died after the fork() was successful + if ( waitpid($pid,&WNOHANG) == $pid ) { - mtr_warning("Waiting for $pidfile to be created, still trying for $loop seconds..."); + return 0; + } + + mtr_debug("Sleep 1 second waiting for creation of $pidfile"); + + if ( $loop % 60 == 0 ) + { + my $left= $timeout - $loop; + mtr_warning("Waited $loop seconds for $pidfile to be created, " . + "still waiting for $left seconds..."); } sleep(1); } - if ( ! -r $pidfile ) - { - mtr_error("No $pidfile was created"); - } + return 0; } - 1; diff --git a/mysql-test/lib/mtr_report.pl b/mysql-test/lib/mtr_report.pl index 0f75fc1341a..c45bb1601ce 100644 --- a/mysql-test/lib/mtr_report.pl +++ b/mysql-test/lib/mtr_report.pl @@ -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_disabled($); sub mtr_show_failed_diff ($); sub mtr_report_stats ($); @@ -72,7 +73,14 @@ sub mtr_report_test_skipped ($) { my $tinfo= shift; $tinfo->{'result'}= 'MTR_RES_SKIPPED'; - print "[ skipped ]\n"; + if ( $tinfo->{'disable'} ) + { + print "[ disabled ] $tinfo->{'comment'}\n"; + } + else + { + print "[ skipped ]\n"; + } } sub mtr_report_test_passed ($) { @@ -95,9 +103,18 @@ sub mtr_report_test_failed ($) { $tinfo->{'result'}= 'MTR_RES_FAILED'; print "[ fail ]\n"; - print "Errors are (from $::path_timefile) :\n"; - print mtr_fromfile($::path_timefile); # FIXME print_file() instead - print "\n(the last lines may be the most important ones)\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 ) + { + print "Errors are (from $::path_timefile) :\n"; + print mtr_fromfile($::path_timefile); # FIXME print_file() instead + print "\n(the last lines may be the most important ones)\n"; + } + else + { + print "Unexpected termination, probably when starting mysqld\n"; + } } sub mtr_report_stats ($) { diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index 3bbdb48d98a..3dd6f5803d7 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -84,10 +84,11 @@ use Sys::Hostname; #use Carp; use IO::Socket; use IO::Socket::INET; -use Data::Dumper; +#use Data::Dumper; use strict; #use diagnostics; +require "lib/mtr_cases.pl"; require "lib/mtr_process.pl"; require "lib/mtr_io.pl"; require "lib/mtr_gcov.pl"; @@ -165,14 +166,12 @@ our $glob_user= 'test'; our $glob_use_embedded_server= 0; our $glob_basedir; -our $glob_do_test; # The total result our $path_charsetsdir; our $path_client_bindir; our $path_language; -our $path_tests_bindir; our $path_timefile; our $path_manager_log; # Used by mysqldadmin our $path_slave_load_tmpdir; # What is this?! @@ -192,8 +191,10 @@ our $exe_master_mysqld; our $exe_mysql; our $exe_mysqladmin; our $exe_mysqlbinlog; +our $exe_mysql_client_test; our $exe_mysqld; our $exe_mysqldump; # Called from test case +our $exe_mysql_fix_system_tables; our $exe_mysqltest; our $exe_slave_mysqld; @@ -208,6 +209,7 @@ our $opt_current_test; our $opt_ddd; our $opt_debug; our $opt_do_test; +our @opt_cases; # The test cases names in argv our $opt_embedded_server; our $opt_extern; our $opt_fast; @@ -232,8 +234,6 @@ our $opt_local_master; our $master; # Will be struct in C our $slave; -our $opt_master_myport; -our $opt_slave_myport; our $opt_ndbcluster_port; our $opt_ndbconnectstring; @@ -297,8 +297,6 @@ sub command_line_setup (); sub executable_setup (); sub environment_setup (); sub kill_and_cleanup (); -sub collect_test_cases ($); -sub sleep_until_file_created ($$); sub ndbcluster_start (); sub ndbcluster_stop (); sub run_benchmarks ($); @@ -306,6 +304,7 @@ sub run_tests (); sub mysql_install_db (); sub install_db ($$); sub run_testcase ($); +sub report_failure_and_restart ($); sub do_before_start_master ($$); sub do_before_start_slave ($$); sub mysqld_start ($$$$); @@ -358,7 +357,15 @@ sub main () { if ( $opt_start_and_exit ) { - mtr_report("Servers started, exiting"); + # FIXME what about ndb? + if ( mysqld_start('master',0,[],[]) ) + { + mtr_report("Servers started, exiting"); + } + else + { + mtr_error("Can't start the mysqld server"); + } } else { @@ -447,8 +454,8 @@ sub command_line_setup () { $path_manager_log= "$glob_mysql_test_dir/var/log/manager.log"; $opt_current_test= "$glob_mysql_test_dir/var/log/current_test"; - $opt_master_myport= 9306; - $opt_slave_myport= 9308; + my $opt_master_myport= 9306; + my $opt_slave_myport= 9308; $opt_ndbcluster_port= 9350; # Read the command line @@ -532,6 +539,8 @@ sub command_line_setup () { usage(""); } + @opt_cases= @ARGV; + # Put this into a hash, will be a C struct $master->[0]->{'path_myddir'}= "$glob_mysql_test_dir/var/master-data"; @@ -598,7 +607,7 @@ sub command_line_setup () { # Look at the command line options and set script flags # -------------------------------------------------------------------------- - if ( $opt_record and ! @ARGV) + if ( $opt_record and ! @opt_cases ) { mtr_error("Will not run in record mode without a specific test case"); } @@ -733,7 +742,8 @@ sub executable_setup () { { mtr_error("Can't find embedded server 'mysqltest'"); } - $path_tests_bindir= "$glob_basedir/libmysqld/examples"; + $exe_mysql_client_test= + "$glob_basedir/libmysqld/examples/mysql_client_test_embedded"; } else { @@ -749,7 +759,8 @@ sub executable_setup () { { $exe_mysqltest= "$glob_basedir/client/mysqltest"; } - $path_tests_bindir= "$glob_basedir/tests"; + $exe_mysql_client_test= + "$glob_basedir/tests/mysql_client_test"; } if ( -f "$glob_basedir/client/.libs/mysqldump" ) { @@ -768,22 +779,26 @@ sub executable_setup () { $exe_mysqlbinlog= "$glob_basedir/client/mysqlbinlog"; } - $exe_mysqld= "$glob_basedir/sql/mysqld"; - $path_client_bindir= "$glob_basedir/client"; - $exe_mysqladmin= "$path_client_bindir/mysqladmin"; - $exe_mysql= "$path_client_bindir/mysql"; - $path_language= "$glob_basedir/sql/share/english/"; - $path_charsetsdir= "$glob_basedir/sql/share/charsets"; + $path_client_bindir= "$glob_basedir/client"; + $exe_mysqld= "$glob_basedir/sql/mysqld"; + $exe_mysqladmin= "$path_client_bindir/mysqladmin"; + $exe_mysql= "$path_client_bindir/mysql"; + $exe_mysql_fix_system_tables= "$glob_basedir/scripts/mysql_fix_privilege_tables"; + $path_language= "$glob_basedir/sql/share/english/"; + $path_charsetsdir= "$glob_basedir/sql/share/charsets"; } else { - $path_client_bindir= "$glob_basedir/bin"; - $path_tests_bindir= "$glob_basedir/tests"; - $exe_mysqltest= "$path_client_bindir/mysqltest"; - $exe_mysqldump= "$path_client_bindir/mysqldump"; - $exe_mysqlbinlog= "$path_client_bindir/mysqlbinlog"; - $exe_mysqladmin= "$path_client_bindir/mysqladmin"; - $exe_mysql= "$path_client_bindir/mysql"; + my $path_tests_bindir= "$glob_basedir/tests"; + + $path_client_bindir= "$glob_basedir/bin"; + $exe_mysqltest= "$path_client_bindir/mysqltest"; + $exe_mysqldump= "$path_client_bindir/mysqldump"; + $exe_mysqlbinlog= "$path_client_bindir/mysqlbinlog"; + $exe_mysqladmin= "$path_client_bindir/mysqladmin"; + $exe_mysql= "$path_client_bindir/mysql"; + $exe_mysql_fix_system_tables= "$path_client_bindir/scripts/mysql_fix_privilege_tables"; + if ( -d "$glob_basedir/share/mysql/english" ) { $path_language ="$glob_basedir/share/mysql/english/"; @@ -804,6 +819,33 @@ sub executable_setup () { $exe_mysqld= "$glob_basedir/bin/mysqld"; } + if ( $glob_use_embedded_server ) + { + if ( -f "$path_client_bindir/mysqltest_embedded" ) + { + # FIXME valgrind? + $exe_mysqltest="$path_client_bindir/mysqltest_embedded"; + } + else + { + error("Cannot find embedded server 'mysqltest_embedded'"); + } + if ( -d "$path_tests_bindir/mysql_client_test_embedded" ) + { + $exe_mysql_client_test= + "$path_tests_bindir/mysql_client_test_embedded"; + } + else + { + $exe_mysql_client_test= + "$path_client_bindir/mysql_client_test_embedded"; + } + } + else + { + $exe_mysqltest="$path_client_bindir/mysqltest"; + $exe_mysql_client_test="$path_client_bindir/mysql_client_test"; + } } # FIXME special $exe_master_mysqld and $exe_slave_mysqld @@ -846,13 +888,18 @@ sub environment_setup () { # Also command lines in .opt files may contain env vars # -------------------------------------------------------------------------- - $ENV{'LC_COLLATE'}= "C"; - $ENV{'MYSQL_TEST_DIR'}= $glob_mysql_test_dir; - $ENV{'MASTER_MYPORT'}= $opt_master_myport; - $ENV{'SLAVE_MYPORT'}= $opt_slave_myport; -# $ENV{'MYSQL_TCP_PORT'}= '@MYSQL_TCP_PORT@'; # FIXME - $ENV{'MYSQL_TCP_PORT'}= 3306; - $ENV{'MASTER_MYSOCK'}= $master->[0]->{'path_mysock'}; + $ENV{'UMASK'}= "0660"; # The octal *string* + $ENV{'UMASK_DIR'}= "0770"; # The octal *string* + $ENV{'LC_COLLATE'}= "C"; + $ENV{'USE_RUNNING_SERVER'}= $glob_use_running_server; + $ENV{'MYSQL_TEST_DIR'}= $glob_mysql_test_dir; + $ENV{'MASTER_MYSOCK'}= $master->[0]->{'path_mysock'}; + $ENV{'MASTER_MYSOCK1'}= $master->[1]->{'path_mysock'}; + $ENV{'MASTER_MYPORT'}= $master->[0]->{'path_myport'}; + $ENV{'MASTER_MYPORT1'}= $master->[1]->{'path_myport'}; + $ENV{'SLAVE_MYPORT'}= $slave->[0]->{'path_myport'}; +# $ENV{'MYSQL_TCP_PORT'}= '@MYSQL_TCP_PORT@'; # FIXME + $ENV{'MYSQL_TCP_PORT'}= 3306; } @@ -877,203 +924,6 @@ sub handle_int_signal () { ############################################################################## # -# Collect information about test cases we are to run -# -############################################################################## - -sub collect_test_cases ($) { - my $suite= shift; # Test suite name - - my $testdir; - my $resdir; - - if ( $suite eq "main" ) - { - $testdir= "$glob_mysql_test_dir/t"; - $resdir= "$glob_mysql_test_dir/r"; - } - else - { - $testdir= "$glob_mysql_test_dir/suite/$suite/t"; - $resdir= "$glob_mysql_test_dir/suite/$suite/r"; - } - - my @tests; # Array of hash, will be array of C struct - - opendir(TESTDIR, $testdir) or mtr_error("Can't open dir \"$testdir\": $!"); - - 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); - my $path= "$testdir/$elem"; - - # ---------------------------------------------------------------------- - # Skip some tests silently - # ---------------------------------------------------------------------- - - if ( $opt_start_from and $tname lt $opt_start_from ) - { - next; - } - - # ---------------------------------------------------------------------- - # Skip some tests but include in list, just mark them to skip - # ---------------------------------------------------------------------- - - my $tinfo= {}; - $tinfo->{'name'}= $tname; - $tinfo->{'result_file'}= "$resdir/$tname.result"; - push(@tests, $tinfo); - - if ( $opt_skip_test and defined mtr_match_prefix($tname,$opt_skip_test) ) - { - $tinfo->{'skip'}= 1; - next; - } - - # FIXME temporary solution, we have a hard coded list of test cases to - # skip if we are using the embedded server - - if ( $glob_use_embedded_server and - mtr_match_any_exact($tname,\@skip_if_embedded_server) ) - { - $tinfo->{'skip'}= 1; - next; - } - - # ---------------------------------------------------------------------- - # Collect information about test case - # ---------------------------------------------------------------------- - - $tinfo->{'path'}= $path; - $tinfo->{'timezone'}= "GMT-3"; # for UNIX_TIMESTAMP tests to work - - if ( defined mtr_match_prefix($tname,"rpl") ) - { - if ( $opt_skip_rpl ) - { - $tinfo->{'skip'}= 1; - next; - } - - # FIXME currently we always restart slaves - $tinfo->{'slave_restart'}= 1; - - if ( $tname eq 'rpl_failsafe' or $tname eq 'rpl_chain_temp_table' ) - { - $tinfo->{'slave_num'}= 3; - } - else - { - $tinfo->{'slave_num'}= 1; - } - } - - # FIXME what about embedded_server + ndbcluster, skip ?! - - my $master_opt_file= "$testdir/$tname-master.opt"; - my $slave_opt_file= "$testdir/$tname-slave.opt"; - my $slave_mi_file= "$testdir/$tname.slave-mi"; - my $master_sh= "$testdir/$tname-master.sh"; - my $slave_sh= "$testdir/$tname-slave.sh"; - - if ( -f $master_opt_file ) - { - $tinfo->{'master_restart'}= 1; # We think so for now - # This is a dirty hack from old mysql-test-run, we use the opt file - # to flag other things as well, it is not a opt list at all - my $extra_master_opt= mtr_get_opts_from_file($master_opt_file); - - foreach my $opt (@$extra_master_opt) - { - my $value; - - $value= mtr_match_prefix($opt, "--timezone="); - - if ( defined $value ) - { - $tinfo->{'timezone'}= $value; - $extra_master_opt= []; - $tinfo->{'master_restart'}= 0; - last; - } - - $value= mtr_match_prefix($opt, "--result-file="); - - 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; - } - $extra_master_opt= []; - $tinfo->{'master_restart'}= 0; - last; - } - } - - $tinfo->{'master_opt'}= $extra_master_opt; - } - - if ( -f $slave_opt_file ) - { - $tinfo->{'slave_opt'}= mtr_get_opts_from_file($slave_opt_file); - $tinfo->{'slave_restart'}= 1; - } - - if ( -f $slave_mi_file ) - { - $tinfo->{'slave_mi'}= mtr_get_opts_from_file($slave_mi_file); - $tinfo->{'slave_restart'}= 1; - } - - if ( -f $master_sh ) - { - if ( $glob_win32_perl ) - { - $tinfo->{'skip'}= 1; - } - else - { - $tinfo->{'master_sh'}= $master_sh; - $tinfo->{'master_restart'}= 1; - } - } - - if ( -f $slave_sh ) - { - if ( $glob_win32_perl ) - { - $tinfo->{'skip'}= 1; - } - else - { - $tinfo->{'slave_sh'}= $slave_sh; - $tinfo->{'slave_restart'}= 1; - } - } - - # 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; - } - - } - - closedir TESTDIR; - - return \@tests; -} - - -############################################################################## -# # Handle left overs from previous runs # ############################################################################## @@ -1189,6 +1039,10 @@ sub run_benchmarks ($) { if ( ! $glob_use_embedded_server and ! $opt_local_master ) { $master->[0]->{'pid'}= mysqld_start('master',0,[],[]); + if ( ! $master->[0]->{'pid'} ) + { + mtr_error("Can't start the mysqld server"); + } } mtr_init_args(\$args); @@ -1254,7 +1108,7 @@ sub run_suite () { mtr_print_thick_line(); - mtr_report("Finding Tests in the '$suite' suite"); + mtr_report("Finding Tests in the '$suite' suite"); my $tests= collect_test_cases($suite); @@ -1301,10 +1155,12 @@ sub run_suite () { sub mysql_install_db () { - mtr_report("Installing Test Databases"); - + # FIXME not exactly true I think, needs improvements install_db('master', $master->[0]->{'path_myddir'}); + install_db('master', $master->[1]->{'path_myddir'}); install_db('slave', $slave->[0]->{'path_myddir'}); + install_db('slave', $slave->[1]->{'path_myddir'}); + install_db('slave', $slave->[2]->{'path_myddir'}); return 0; } @@ -1423,6 +1279,12 @@ sub run_testcase ($) { do_before_start_master($tname,$tinfo->{'master_sh'}); # ---------------------------------------------------------------------- + # If any mysqld servers running died, we have to know + # ---------------------------------------------------------------------- + + mtr_record_dead_children(); + + # ---------------------------------------------------------------------- # Start masters # ---------------------------------------------------------------------- @@ -1439,14 +1301,24 @@ sub run_testcase ($) { { $master->[0]->{'pid'}= mysqld_start('master',0,$tinfo->{'master_opt'},[]); + if ( ! $master->[0]->{'pid'} ) + { + report_failure_and_restart($tinfo); + return; + } } if ( $opt_with_ndbcluster and ! $master->[1]->{'pid'} ) { $master->[1]->{'pid'}= mysqld_start('master',1,$tinfo->{'master_opt'},[]); + if ( ! $master->[1]->{'pid'} ) + { + report_failure_and_restart($tinfo); + return; + } } - if ( $tinfo->{'master_opt'} ) + if ( @{$tinfo->{'master_opt'}} ) { $master->[0]->{'uses_special_flags'}= 1; } @@ -1469,6 +1341,11 @@ sub run_testcase ($) { $slave->[$idx]->{'pid'}= mysqld_start('slave',$idx, $tinfo->{'slave_opt'}, $tinfo->{'slave_mi'}); + if ( ! $slave->[$idx]->{'pid'} ) + { + report_failure_and_restart($tinfo); + return; + } } } } @@ -1502,30 +1379,37 @@ sub run_testcase ($) { "mysqltest returned unexpected code $res, " . "it has probably crashed"); } - mtr_report_test_failed($tinfo); - mtr_show_failed_diff($tname); - print "\n"; - if ( ! $opt_force ) - { - print "Aborting: $tname failed. To continue, re-run with '--force'."; - print "\n"; - if ( ! $opt_gdb and ! $glob_use_running_server and - ! $opt_ddd and ! $glob_use_embedded_server ) - { - stop_masters_slaves(); - } - exit(1); - } + report_failure_and_restart($tinfo); + } + } +} - # FIXME always terminate on failure?! - if ( ! $opt_gdb and ! $glob_use_running_server and - ! $opt_ddd and ! $glob_use_embedded_server ) - { - stop_masters_slaves(); - } - print "Resuming Tests\n\n"; + +sub report_failure_and_restart ($) { + my $tinfo= shift; + + mtr_report_test_failed($tinfo); + mtr_show_failed_diff($tinfo->{'name'}); + print "\n"; + if ( ! $opt_force ) + { + print "Aborting: $tinfo->{'name'} failed. To continue, re-run with '--force'."; + print "\n"; + if ( ! $opt_gdb and ! $glob_use_running_server and + ! $opt_ddd and ! $glob_use_embedded_server ) + { + stop_masters_slaves(); } + exit(1); + } + + # FIXME always terminate on failure?! + if ( ! $opt_gdb and ! $glob_use_running_server and + ! $opt_ddd and ! $glob_use_embedded_server ) + { + stop_masters_slaves(); } + print "Resuming Tests\n\n"; } @@ -1603,11 +1487,13 @@ sub do_before_start_slave ($$) { } sub mysqld_arguments ($$$$$) { - my $args= shift; - my $type= shift; # master/slave/bootstrap - my $idx= shift; - my $extra_opt= shift; - my $slave_master_info= shift; + my $args= shift; + my $type= shift; # master/slave/bootstrap + my $idx= shift; + my $extra_opt= shift; + my $slave_master_info= shift; + +# print STDERR Dumper($extra_opt); my $sidx= ""; # Index as string, 0 is empty string if ( $idx > 0 ) @@ -1835,10 +1721,10 @@ sub mysqld_arguments ($$$$$) { ############################################################################## sub mysqld_start ($$$$) { - my $type= shift; # master/slave/bootstrap - my $idx= shift; - my $extra_opt= shift; - my $slave_master_info= shift; + my $type= shift; # master/slave/bootstrap + my $idx= shift; + my $extra_opt= shift; + my $slave_master_info= shift; my $args; # Arg vector my $exe; @@ -1893,9 +1779,8 @@ sub mysqld_start ($$$$) { $master->[$idx]->{'path_myerr'}, $master->[$idx]->{'path_myerr'}, "") ) { - sleep_until_file_created($master->[$idx]->{'path_mypid'}, - $master->[$idx]->{'start_timeout'}); - return $pid; + return sleep_until_file_created($master->[$idx]->{'path_mypid'}, + $master->[$idx]->{'start_timeout'}, $pid); } } @@ -1905,13 +1790,12 @@ sub mysqld_start ($$$$) { $slave->[$idx]->{'path_myerr'}, $slave->[$idx]->{'path_myerr'}, "") ) { - sleep_until_file_created($slave->[$idx]->{'path_mypid'}, - $master->[$idx]->{'start_timeout'}); - return $pid; + return sleep_until_file_created($slave->[$idx]->{'path_mypid'}, + $master->[$idx]->{'start_timeout'}, $pid); } } - mtr_error("Can't start mysqld FIXME"); + return 0; } sub stop_masters_slaves () { @@ -1944,7 +1828,7 @@ sub stop_masters () { } } - mtr_stop_mysqld_servers(\@args, 0); + mtr_stop_mysqld_servers(\@args); } sub stop_slaves () { @@ -1966,7 +1850,7 @@ sub stop_slaves () { } } - mtr_stop_mysqld_servers(\@args, 0); + mtr_stop_mysqld_servers(\@args); } @@ -1992,17 +1876,32 @@ sub run_mysqltest ($$) { } my $cmdline_mysql= - "$exe_mysql --host=localhost --port=$master->[0]->{'path_myport'} " . - "--socket=$master->[0]->{'path_mysock'} --user=root --password="; + "$exe_mysql --host=localhost --user=root --password= " . + "--port=$master->[0]->{'path_myport'} " . + "--socket=$master->[0]->{'path_mysock'}"; + + my $cmdline_mysql_client_test= + "$exe_mysql_client_test --no-defaults --testcase --user=root --silent " . + "--port=$master->[0]->{'path_myport'} " . + "--socket=$master->[0]->{'path_mysock'}"; + + my $cmdline_mysql_fix_system_tables= + "$exe_mysql_fix_system_tables --no-defaults --host=localhost --user=root --password= " . + "--basedir=$glob_basedir --bindir=$path_client_bindir --verbose " . + "--port=$master->[0]->{'path_myport'} " . + "--socket=$master->[0]->{'path_mysock'}"; + + # FIXME really needing a PATH??? # $ENV{'PATH'}= "/bin:/usr/bin:/usr/local/bin:/usr/bsd:/usr/X11R6/bin:/usr/openwin/bin:/usr/bin/X11:$ENV{'PATH'}"; - $ENV{'MYSQL'}= $exe_mysql; + $ENV{'MYSQL'}= $cmdline_mysql; $ENV{'MYSQL_DUMP'}= $cmdline_mysqldump; - $ENV{'MYSQL_BINLOG'}= $exe_mysqlbinlog; - $ENV{'CLIENT_BINDIR'}= $path_client_bindir; - $ENV{'TESTS_BINDIR'}= $path_tests_bindir; + $ENV{'MYSQL_BINLOG'}= $cmdline_mysqlbinlog; + $ENV{'MYSQL_FIX_SYSTEM_TABLES'}= $cmdline_mysql_fix_system_tables; + $ENV{'MYSQL_CLIENT_TEST'}= $cmdline_mysql_client_test; + $ENV{'CHARSETSDIR'}= $path_charsetsdir; my $exe= $exe_mysqltest; my $args; diff --git a/mysql-test/mysql-test-run.sh b/mysql-test/mysql-test-run.sh index c2ac26217b9..c2f1cebbe17 100644 --- a/mysql-test/mysql-test-run.sh +++ b/mysql-test/mysql-test-run.sh @@ -220,6 +220,8 @@ EXTRA_MYSQLBINLOG_OPT="" USE_RUNNING_SERVER="" USE_NDBCLUSTER="" USE_RUNNING_NDBCLUSTER="" +USE_PURIFY="" +PURIFY_LOGS="" DO_GCOV="" DO_GDB="" MANUAL_GDB="" @@ -239,7 +241,7 @@ MYSQL_TEST_SSL_OPTS="" USE_TIMER="" USE_EMBEDDED_SERVER="" RESULT_EXT="" -TEST_MODE="default" +TEST_MODE="" NDB_MGM_EXTRA_OPTS= NDB_MGMD_EXTRA_OPTS= @@ -247,8 +249,17 @@ NDBD_EXTRA_OPTS= while test $# -gt 0; do case "$1" in - --embedded-server) USE_EMBEDDED_SERVER=1 USE_MANAGER=0 NO_SLAVE=1 ; \ - USE_RUNNING_SERVER="" RESULT_EXT=".es" TEST_MODE="embedded" ;; + --embedded-server) + USE_EMBEDDED_SERVER=1 + USE_MANAGER=0 NO_SLAVE=1 + USE_RUNNING_SERVER="" + RESULT_EXT=".es" + TEST_MODE="$TEST_MODE embedded" ;; + --purify) + USE_PURIFY=1 + USE_MANAGER=0 + USE_RUNNING_SERVER="" + TEST_MODE="$TEST_MODE purify" ;; --user=*) DBUSER=`$ECHO "$1" | $SED -e "s;--user=;;"` ;; --force) FORCE=1 ;; --timer) USE_TIMER=1 ;; @@ -334,7 +345,7 @@ while test $# -gt 0; do SLEEP_TIME_AFTER_RESTART=`$ECHO "$1" | $SED -e "s;--sleep=;;"` ;; --ps-protocol) - TEST_MODE="ps-protocol" EXTRA_MYSQL_TEST_OPT="$EXTRA_MYSQL_TEST_OPT $1" ;; + TEST_MODE="$TEST_MODE ps-protocol" EXTRA_MYSQL_TEST_OPT="$EXTRA_MYSQL_TEST_OPT $1" ;; --user-test=*) USER_TEST=`$ECHO "$1" | $SED -e "s;--user-test=;;"` ;; @@ -444,6 +455,13 @@ while test $# -gt 0; do shift done +if [ -z "$TEST_MODE" ] ; then + TEST_MODE="default" +else + # Remove the leading space if any + TEST_MODE=`echo $TEST_MODE | sed 's/^ *//'` +fi + #++ # mysqld Environment Parameters #-- @@ -505,7 +523,10 @@ if [ x$SOURCE_DIST = x1 ] ; then fi MYSQL_CLIENT_TEST="$BASEDIR/libmysqld/examples/mysql_client_test_embedded" else - MYSQLD="$VALGRIND $BASEDIR/sql/mysqld" + MYSQLD="$BASEDIR/sql/mysqld" + if [ -n "$VALGRIND" ] ; then + MYSQLD="$VALGRIND $MYSQLD" + fi if [ -f "$BASEDIR/client/.libs/lt-mysqltest" ] ; then MYSQL_TEST="$BASEDIR/client/.libs/lt-mysqltest" elif [ -f "$BASEDIR/client/.libs/mysqltest" ] ; then @@ -542,6 +563,31 @@ if [ x$SOURCE_DIST = x1 ] ; then MYSQL_FIX_SYSTEM_TABLES="$BASEDIR/scripts/mysql_fix_privilege_tables" NDB_TOOLS_DIR="$BASEDIR/ndb/tools" NDB_MGM="$BASEDIR/ndb/src/mgmclient/ndb_mgm" + + if [ -n "$USE_PURIFY" ] ; then + PSUP="$MYSQL_TEST_DIR/purify.suppress" + echo "suppress UMR rw_read_held; mi_open; ha_myisam::open64; handler::ha_open; openfrm" > $PSUP + echo "suppress UMR my_end; main" >> $PSUP + echo "suppress UMR _doprnt; fprintf; my_end; main" >> $PSUP + PURIFYOPTIONS="-windows=no -log-file=%v.purifylog -append-logfile -add-suppression-files=$PSUP" + if [ -f "${MYSQL_TEST}-purify" ] ; then + MYSQL_TEST="${MYSQL_TEST}-purify" + PLOG="$MYSQL_TEST.purifylog" + if [ -f $PLOG ]; then + mv $PLOG $PLOG.$$ + fi + PURIFY_LOGS="$PLOG" + fi + if [ -f "${MYSQLD}-purify" ] ; then + MYSQLD="${MYSQLD}-purify" + PLOG="$MYSQLD.purifylog" + if [ -f $PLOG ]; then + mv $PLOG $PLOG.$$ + fi + PURIFY_LOGS="$PURIFY_LOGS $PLOG" + fi + fi + else # We have a binary installation. Note that this can be both from @@ -558,6 +604,13 @@ else MYSQLD="$VALGRIND $BASEDIR/bin/mysqld" fi CLIENT_BINDIR="$BASEDIR/bin" + if test -d "$BASEDIR/tests" + then + TESTS_BINDIR="$BASEDIR/tests" + else + TESTS_BINDIR="$BASEDIR/bin" + fi + MYSQL_TEST="$CLIENT_BINDIR/mysqltest" MYSQL_DUMP="$CLIENT_BINDIR/mysqldump" MYSQL_BINLOG="$CLIENT_BINDIR/mysqlbinlog" MYSQLADMIN="$CLIENT_BINDIR/mysqladmin" @@ -637,6 +690,7 @@ export CLIENT_BINDIR MYSQL_CLIENT_TEST CHARSETSDIR export NDB_TOOLS_DIR export NDB_MGM export NDB_BACKUP_DIR +export PURIFYOPTIONS MYSQL_TEST_ARGS="--no-defaults --socket=$MASTER_MYSOCK --database=$DB \ --user=$DBUSER --password=$DBPASSWD --silent -v --skip-safemalloc \ @@ -753,6 +807,17 @@ skip_test() { $ECHO "$RES$RES_SPACE [ skipped ]" } +report_current_test () { + tname=$1 + echo "CURRENT_TEST: $tname" >> $MASTER_MYERR + if [ -n "$PURIFY_LOGS" ] ; then + for log in $PURIFY_LOGS + do + echo "CURRENT_TEST: $tname" >> $log + done + fi +} + report_stats () { if [ $TOT_FAIL = 0 ]; then $ECHO "All $TOT_TEST tests were successful." @@ -1487,7 +1552,7 @@ run_testcase () esac stop_master stop_master 1 - echo "CURRENT_TEST: $tname" >> $MASTER_MYERR + report_current_test $tname start_master if [ -n "$USE_NDBCLUSTER" -a -z "$DO_BENCH" ] ; then start_master 1 @@ -1503,13 +1568,13 @@ run_testcase () EXTRA_MASTER_OPT="" stop_master stop_master 1 - echo "CURRENT_TEST: $tname" >> $MASTER_MYERR + report_current_test $tname start_master if [ -n "$USE_NDBCLUSTER" -a -z "$DO_BENCH" ] ; then start_master 1 fi else - echo "CURRENT_TEST: $tname" >> $MASTER_MYERR + report_current_test $tname fi fi diff --git a/mysql-test/r/compare.result b/mysql-test/r/compare.result index bf8a5106044..6f667aabac0 100644 --- a/mysql-test/r/compare.result +++ b/mysql-test/r/compare.result @@ -36,3 +36,9 @@ hex(a) STRCMP(a,'a') STRCMP(a,'a ') 6109 -1 -1 61 0 0 DROP TABLE t1; +SELECT CHAR(31) = '', '' = CHAR(31); +CHAR(31) = '' '' = CHAR(31) +0 0 +SELECT CHAR(30) = '', '' = CHAR(30); +CHAR(30) = '' '' = CHAR(30) +0 0 diff --git a/mysql-test/r/derived.result b/mysql-test/r/derived.result index 7e6b9b44566..61d745d0236 100644 --- a/mysql-test/r/derived.result +++ b/mysql-test/r/derived.result @@ -330,3 +330,12 @@ SELECT MIN(price) min, MAX(price) max, AVG(price) avg FROM (SELECT SUBSTRING( MA min max avg 10.00 10.00 10 DROP TABLE t1; +create table t1 (a integer, b integer); +insert into t1 values (1,4), (2,2),(2,2), (4,1),(4,1),(4,1),(4,1); +select distinct sum(b) from t1 group by a; +sum(b) +4 +select distinct sum(b) from (select a,b from t1) y group by a; +sum(b) +4 +drop table t1; diff --git a/mysql-test/r/func_str.result b/mysql-test/r/func_str.result index 0db62b133e7..88b1a5ea743 100644 --- a/mysql-test/r/func_str.result +++ b/mysql-test/r/func_str.result @@ -325,6 +325,19 @@ trim(trailing 'foo' from 'foo') select trim(leading 'foo' from 'foo'); trim(leading 'foo' from 'foo') +select quote(ltrim(concat(' ', 'a'))); +quote(ltrim(concat(' ', 'a'))) +'a' +select quote(trim(concat(' ', 'a'))); +quote(trim(concat(' ', 'a'))) +'a' +CREATE TABLE t1 SELECT 1 UNION SELECT 2 UNION SELECT 3; +SELECT QUOTE('A') FROM t1; +QUOTE('A') +'A' +'A' +'A' +DROP TABLE t1; select 1=_latin1'1'; 1=_latin1'1' 1 @@ -691,15 +704,32 @@ select count(*) as total, left(c,10) as reg from t1 group by reg order by reg de total reg 10 2004-12-10 drop table t1; -select quote(ltrim(concat(' ', 'a'))); -quote(ltrim(concat(' ', 'a'))) -'a' -select quote(trim(concat(' ', 'a'))); -quote(trim(concat(' ', 'a'))) -'a' select trim(null from 'kate') as "must_be_null"; must_be_null NULL select trim('xyz' from null) as "must_be_null"; must_be_null NULL +CREATE TABLE t1 ( +id int(11) NOT NULL auto_increment, +a bigint(20) unsigned default NULL, +PRIMARY KEY (id) +) ENGINE=MyISAM; +INSERT INTO t1 VALUES +('0','16307858876001849059'); +SELECT CONV('e251273eb74a8ee3', 16, 10); +CONV('e251273eb74a8ee3', 16, 10) +16307858876001849059 +EXPLAIN +SELECT id +FROM t1 +WHERE a = 16307858876001849059; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 system NULL NULL NULL NULL 1 +EXPLAIN +SELECT id +FROM t1 +WHERE a = CONV('e251273eb74a8ee3', 16, 10); +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 system NULL NULL NULL NULL 1 +DROP TABLE t1; diff --git a/mysql-test/r/mysqldump.result b/mysql-test/r/mysqldump.result index 623bd2a0f3c..8f2294caa48 100644 --- a/mysql-test/r/mysqldump.result +++ b/mysql-test/r/mysqldump.result @@ -60,7 +60,7 @@ INSERT INTO `t1` VALUES ('1.23450',2.3456),('1.23450',2.3456),('1.23450',2.3456) /*!40101 SET NAMES utf8 */; /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; -/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE="NO_AUTO_VALUE_ON_ZERO" */; +/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; DROP TABLE IF EXISTS `t1`; CREATE TABLE `t1` ( `a` decimal(10,5) default NULL, @@ -83,7 +83,7 @@ UNLOCK TABLES; /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; -/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE="NO_AUTO_VALUE_ON_ZERO" */; +/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; CREATE TABLE `t1` ( `a` decimal(10,5) default NULL, `b` float default NULL @@ -149,7 +149,7 @@ INSERT INTO t1 VALUES (_koi8r x'C1C2C3C4C5'), (NULL); /*!40101 SET NAMES utf8 */; /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; -/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE="NO_AUTO_VALUE_ON_ZERO" */; +/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; DROP TABLE IF EXISTS `t1`; CREATE TABLE `t1` ( `a` varchar(255) default NULL @@ -175,7 +175,7 @@ CREATE TABLE t1 (a int) ENGINE=MYISAM; INSERT INTO t1 VALUES (1), (2); /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; -/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE="NO_AUTO_VALUE_ON_ZERO,MYSQL40" */; +/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO,MYSQL40' */; DROP TABLE IF EXISTS `t1`; CREATE TABLE `t1` ( `a` int(11) default NULL @@ -194,7 +194,7 @@ UNLOCK TABLES; /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; -/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE="NO_AUTO_VALUE_ON_ZERO,MYSQL323" */; +/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO,MYSQL323' */; DROP TABLE IF EXISTS `t1`; CREATE TABLE `t1` ( `a` int(11) default NULL @@ -225,7 +225,7 @@ create table t1(a int); /*!40101 SET NAMES utf8 */; /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; -/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE="NO_AUTO_VALUE_ON_ZERO" */; +/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; DROP TABLE IF EXISTS `t1`; CREATE TABLE `t1` ( `a` int(11) default NULL @@ -246,7 +246,7 @@ UNLOCK TABLES; /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; -/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE="NO_AUTO_VALUE_ON_ZERO,ANSI" */; +/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO,ANSI' */; DROP TABLE IF EXISTS "t1"; CREATE TABLE "t1" ( "a" int(11) default NULL @@ -270,7 +270,7 @@ set global sql_mode='ANSI_QUOTES'; /*!40101 SET NAMES utf8 */; /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; -/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE="NO_AUTO_VALUE_ON_ZERO" */; +/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; DROP TABLE IF EXISTS `t1`; CREATE TABLE `t1` ( `a` int(11) default NULL @@ -291,7 +291,7 @@ UNLOCK TABLES; /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; -/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE="NO_AUTO_VALUE_ON_ZERO,ANSI" */; +/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO,ANSI' */; DROP TABLE IF EXISTS "t1"; CREATE TABLE "t1" ( "a" int(11) default NULL @@ -316,7 +316,7 @@ insert into t1 values (1),(2),(3); /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; /*!40101 SET NAMES utf8 */; -/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE="" */; +/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='' */; DROP TABLE IF EXISTS `t1`; CREATE TABLE `t1` ( `a` int(11) default NULL @@ -339,7 +339,7 @@ drop table t1; /*!40101 SET NAMES utf8 */; /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; -/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE="NO_AUTO_VALUE_ON_ZERO" */; +/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; CREATE DATABASE /*!32312 IF NOT EXISTS*/ `test` /*!40100 DEFAULT CHARACTER SET latin1 */; @@ -360,7 +360,7 @@ create database mysqldump_test_db character set latin2 collate latin2_bin; /*!40101 SET NAMES utf8 */; /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; -/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE="NO_AUTO_VALUE_ON_ZERO" */; +/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; CREATE DATABASE /*!32312 IF NOT EXISTS*/ `mysqldump_test_db` /*!40100 DEFAULT CHARACTER SET latin2 COLLATE latin2_bin */; @@ -383,7 +383,7 @@ INSERT INTO t1 VALUES (_latin1 'ÄÖÜß'); /*!40101 SET NAMES utf8 */; /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; -/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE="NO_AUTO_VALUE_ON_ZERO" */; +/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; DROP TABLE IF EXISTS `t1`; CREATE TABLE `t1` ( `a` char(10) default NULL @@ -405,7 +405,7 @@ UNLOCK TABLES; /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; -/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE="NO_AUTO_VALUE_ON_ZERO,MYSQL323" */; +/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO,MYSQL323' */; DROP TABLE IF EXISTS `t1`; CREATE TABLE `t1` ( `a` char(10) default NULL @@ -424,7 +424,7 @@ UNLOCK TABLES; /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; -/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE="NO_AUTO_VALUE_ON_ZERO,MYSQL323" */; +/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO,MYSQL323' */; DROP TABLE IF EXISTS `t1`; CREATE TABLE `t1` ( `a` char(10) default NULL @@ -443,7 +443,7 @@ UNLOCK TABLES; /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; -/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE="NO_AUTO_VALUE_ON_ZERO,MYSQL323" */; +/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO,MYSQL323' */; DROP TABLE IF EXISTS `t1`; CREATE TABLE `t1` ( `a` char(10) default NULL @@ -462,7 +462,7 @@ UNLOCK TABLES; /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; -/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE="NO_AUTO_VALUE_ON_ZERO,MYSQL323" */; +/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO,MYSQL323' */; DROP TABLE IF EXISTS `t1`; CREATE TABLE `t1` ( `a` char(10) default NULL @@ -491,7 +491,7 @@ INSERT INTO t2 VALUES (4),(5),(6); /*!40101 SET NAMES utf8 */; /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; -/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE="NO_AUTO_VALUE_ON_ZERO" */; +/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; DROP TABLE IF EXISTS `t2`; CREATE TABLE `t2` ( `a` int(11) default NULL diff --git a/mysql-test/r/rpl_multi_update2.result b/mysql-test/r/rpl_multi_update2.result new file mode 100644 index 00000000000..99356ebf970 --- /dev/null +++ b/mysql-test/r/rpl_multi_update2.result @@ -0,0 +1,42 @@ +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; +CREATE TABLE t1 ( +a int unsigned not null auto_increment primary key, +b int unsigned +) ENGINE=MyISAM; +CREATE TABLE t2 ( +a int unsigned not null auto_increment primary key, +b int unsigned +) ENGINE=MyISAM; +INSERT INTO t1 VALUES (NULL, 0); +INSERT INTO t1 SELECT NULL, 0 FROM t1; +INSERT INTO t2 VALUES (NULL, 0), (NULL,1); +SELECT * FROM t1 ORDER BY a; +a b +1 0 +2 0 +SELECT * FROM t2 ORDER BY a; +a b +1 0 +2 1 +UPDATE t1, t2 SET t1.b = (t2.b+4) WHERE t1.a = t2.a; +SELECT * FROM t1 ORDER BY a; +a b +1 4 +2 5 +SELECT * FROM t2 ORDER BY a; +a b +1 0 +2 1 +SELECT * FROM t1 ORDER BY a; +a b +1 4 +2 5 +SELECT * FROM t2 ORDER BY a; +a b +1 0 +2 1 diff --git a/mysql-test/r/subselect.result b/mysql-test/r/subselect.result index 02662f9900a..437fd624ae1 100644 --- a/mysql-test/r/subselect.result +++ b/mysql-test/r/subselect.result @@ -2160,3 +2160,51 @@ ERROR 42S22: Unknown column 'a2' in 'scalar IN/ALL/ANY subquery' select * from t1 where a1 > any(select b1 from t2); a1 drop table t1,t2; +create table t1 (a integer, b integer); +select (select * from t1) = (select 1,2); +(select * from t1) = (select 1,2) +NULL +select (select 1,2) = (select * from t1); +(select 1,2) = (select * from t1) +NULL +select row(1,2) = ANY (select * from t1); +row(1,2) = ANY (select * from t1) +0 +select row(1,2) != ALL (select * from t1); +row(1,2) != ALL (select * from t1) +1 +drop table t1; +create table t1 (a integer, b integer); +select row(1,(2,2)) in (select * from t1 ); +ERROR 21000: Operand should contain 2 column(s) +select row(1,(2,2)) = (select * from t1 ); +ERROR 21000: Operand should contain 2 column(s) +select (select * from t1) = row(1,(2,2)); +ERROR 21000: Operand should contain 1 column(s) +drop table t1; +create table t1 (a integer); +insert into t1 values (1); +select 1 = ALL (select 1 from t1 where 1 = xx ), 1 as xx ; +ERROR 42S22: Reference 'xx' not supported (forward reference in item list) +select 1 = ALL (select 1 from t1 where 1 = xx ), 1 as xx; +ERROR 42S22: Reference 'xx' not supported (forward reference in item list) +select 1 as xx, 1 = ALL ( select 1 from t1 where 1 = xx ); +xx 1 = ALL ( select 1 from t1 where 1 = xx ) +1 1 +select 1 = ALL (select 1 from t1 where 1 = xx ), 1 as xx; +ERROR 42S22: Reference 'xx' not supported (forward reference in item list) +select 1 = ALL (select 1 from t1 where 1 = xx ), 1 as xx from DUAL; +ERROR 42S22: Reference 'xx' not supported (forward reference in item list) +drop table t1; +CREATE TABLE `t1` ( `a` char(3) NOT NULL default '', `b` char(3) NOT NULL default '', `c` char(3) NOT NULL default '', PRIMARY KEY (`a`,`b`,`c`)) ENGINE=InnoDB; +CREATE TABLE t2 LIKE t1; +INSERT INTO t1 VALUES (1,1,1); +INSERT INTO t2 VALUES (1,1,1); +PREPARE my_stmt FROM "SELECT t1.b, count(*) FROM t1 group by t1.b having +count(*) > ALL (SELECT COUNT(*) FROM t2 WHERE t2.a=1 GROUP By t2.b)"; +EXECUTE my_stmt; +b count(*) +EXECUTE my_stmt; +b count(*) +deallocate prepare my_stmt; +drop table t1,t2; diff --git a/mysql-test/r/timezone2.result b/mysql-test/r/timezone2.result index a1a2fec739f..206ff79e7ba 100644 --- a/mysql-test/r/timezone2.result +++ b/mysql-test/r/timezone2.result @@ -303,3 +303,11 @@ delete from mysql.db where user like 'mysqltest\_%'; delete from mysql.tables_priv where user like 'mysqltest\_%'; flush privileges; drop table t1, t2; +select convert_tz('2005-01-14 17:00:00', 'UTC', custTimeZone) from (select 'UTC' as custTimeZone) as tmp; +convert_tz('2005-01-14 17:00:00', 'UTC', custTimeZone) +2005-01-14 17:00:00 +create table t1 select convert_tz(NULL, NULL, NULL); +select * from t1; +convert_tz(NULL, NULL, NULL) +NULL +drop table t1; diff --git a/mysql-test/t/compare.test b/mysql-test/t/compare.test index b0cef48dd3f..bc20786227b 100644 --- a/mysql-test/t/compare.test +++ b/mysql-test/t/compare.test @@ -30,3 +30,8 @@ CREATE TABLE t1 (a char(10) not null); INSERT INTO t1 VALUES ('a'),('a\0'),('a\t'),('a '); SELECT hex(a),STRCMP(a,'a'), STRCMP(a,'a ') FROM t1; DROP TABLE t1; + +# Bug #8134: Comparison against CHAR(31) at end of string +SELECT CHAR(31) = '', '' = CHAR(31); +# Extra test +SELECT CHAR(30) = '', '' = CHAR(30); diff --git a/mysql-test/t/derived.test b/mysql-test/t/derived.test index 64e3fe8929b..8b322746ed6 100644 --- a/mysql-test/t/derived.test +++ b/mysql-test/t/derived.test @@ -214,3 +214,13 @@ CREATE TABLE `t1` ( `itemid` int(11) NOT NULL default '0', `grpid` varchar(15) N insert into t1 values (128, 'rozn', 2, now(), 10),(128, 'rozn', 1, now(), 10); SELECT MIN(price) min, MAX(price) max, AVG(price) avg FROM (SELECT SUBSTRING( MAX(concat(date_,";",price)), 12) price FROM t1 WHERE itemid=128 AND grpid='rozn' GROUP BY itemid, grpid, vendor) lastprices; DROP TABLE t1; + +# +# DISTINCT over grouped select on subquery in the FROM clause +# +create table t1 (a integer, b integer); +insert into t1 values (1,4), (2,2),(2,2), (4,1),(4,1),(4,1),(4,1); +select distinct sum(b) from t1 group by a; +select distinct sum(b) from (select a,b from t1) y group by a; +drop table t1; + diff --git a/mysql-test/t/func_str.test b/mysql-test/t/func_str.test index a5d95332caa..6d5974ca5ed 100644 --- a/mysql-test/t/func_str.test +++ b/mysql-test/t/func_str.test @@ -195,6 +195,18 @@ select trim(trailing 'foo' from 'foo'); select trim(leading 'foo' from 'foo'); # +# crashing bug with QUOTE() and LTRIM() or TRIM() fixed +# Bug #7495 +# + +select quote(ltrim(concat(' ', 'a'))); +select quote(trim(concat(' ', 'a'))); + +# Bad results from QUOTE(). Bug #8248 +CREATE TABLE t1 SELECT 1 UNION SELECT 2 UNION SELECT 3; +SELECT QUOTE('A') FROM t1; +DROP TABLE t1; + # Test collation and coercibility # @@ -429,12 +441,6 @@ create table t1 (a int not null primary key, b varchar(40), c datetime); insert into t1 (a,b,c) values (1,'Tom','2004-12-10 12:13:14'),(2,'ball games','2004-12-10 12:13:14'), (3,'Basil','2004-12-10 12:13:14'), (4,'Dean','2004-12-10 12:13:14'),(5,'Ellis','2004-12-10 12:13:14'), (6,'Serg','2004-12-10 12:13:14'), (7,'Sergei','2004-12-10 12:13:14'),(8,'Georg','2004-12-10 12:13:14'),(9,'Salle','2004-12-10 12:13:14'),(10,'Sinisa','2004-12-10 12:13:14'); select count(*) as total, left(c,10) as reg from t1 group by reg order by reg desc limit 0,12; drop table t1; -# crashing bug with QUOTE() and LTRIM() or TRIM() fixed -# Bug #7495 -# - -select quote(ltrim(concat(' ', 'a'))); -select quote(trim(concat(' ', 'a'))); # # Bug#7455 unexpected result: TRIM(<NULL> FROM <whatever>) gives NOT NULL @@ -443,3 +449,30 @@ select quote(trim(concat(' ', 'a'))); # select trim(null from 'kate') as "must_be_null"; select trim('xyz' from null) as "must_be_null"; + +# +# Bug #7751 - conversion for a bigint unsigned constant +# + +CREATE TABLE t1 ( + id int(11) NOT NULL auto_increment, + a bigint(20) unsigned default NULL, + PRIMARY KEY (id) +) ENGINE=MyISAM; + +INSERT INTO t1 VALUES +('0','16307858876001849059'); + +SELECT CONV('e251273eb74a8ee3', 16, 10); + +EXPLAIN +SELECT id + FROM t1 + WHERE a = 16307858876001849059; + +EXPLAIN + SELECT id + FROM t1 + WHERE a = CONV('e251273eb74a8ee3', 16, 10); + +DROP TABLE t1; diff --git a/mysql-test/t/rpl_multi_update2-slave.opt b/mysql-test/t/rpl_multi_update2-slave.opt new file mode 100644 index 00000000000..17d4171af0e --- /dev/null +++ b/mysql-test/t/rpl_multi_update2-slave.opt @@ -0,0 +1 @@ +--replicate-ignore-table=nothing.sensible diff --git a/mysql-test/t/rpl_multi_update2.test b/mysql-test/t/rpl_multi_update2.test new file mode 100644 index 00000000000..bba7700a88e --- /dev/null +++ b/mysql-test/t/rpl_multi_update2.test @@ -0,0 +1,33 @@ +# Let's verify that multi-update is not always skipped by slave if +# some replicate-* rules exist. +# (BUG#7011) + +source include/master-slave.inc; + +CREATE TABLE t1 ( + a int unsigned not null auto_increment primary key, + b int unsigned +) ENGINE=MyISAM; + +CREATE TABLE t2 ( + a int unsigned not null auto_increment primary key, + b int unsigned +) ENGINE=MyISAM; + +INSERT INTO t1 VALUES (NULL, 0); +INSERT INTO t1 SELECT NULL, 0 FROM t1; + +INSERT INTO t2 VALUES (NULL, 0), (NULL,1); + +SELECT * FROM t1 ORDER BY a; +SELECT * FROM t2 ORDER BY a; + +UPDATE t1, t2 SET t1.b = (t2.b+4) WHERE t1.a = t2.a; +SELECT * FROM t1 ORDER BY a; +SELECT * FROM t2 ORDER BY a; + +save_master_pos; +connection slave; +sync_with_master; +SELECT * FROM t1 ORDER BY a; +SELECT * FROM t2 ORDER BY a; diff --git a/mysql-test/t/subselect.test b/mysql-test/t/subselect.test index 3ee498ee380..cdec080611d 100644 --- a/mysql-test/t/subselect.test +++ b/mysql-test/t/subselect.test @@ -1414,8 +1414,11 @@ SELECT f1 FROM t1 WHERE f1 <> ALL ( SELECT SUM(f1) AS sf1 FROM t2 HAVING sf1 > 10000); drop table t1,t2; + +# # Test for BUG#7885: Server crash when 'any' subselect compared to # non-existant field. +# create table t1 (a1 int); create table t2 (b1 int); --error 1054 @@ -1423,3 +1426,56 @@ select * from t1 where a2 > any(select b1 from t2); select * from t1 where a1 > any(select b1 from t2); drop table t1,t2; + +# +# Comparison subquery with * and row +# +create table t1 (a integer, b integer); +select (select * from t1) = (select 1,2); +select (select 1,2) = (select * from t1); +# queries whih can be converted to IN +select row(1,2) = ANY (select * from t1); +select row(1,2) != ALL (select * from t1); +drop table t1; + +# +# Comparison subquery and row with nested rows +# +create table t1 (a integer, b integer); +-- error 1241 +select row(1,(2,2)) in (select * from t1 ); +-- error 1241 +select row(1,(2,2)) = (select * from t1 ); +-- error 1241 +select (select * from t1) = row(1,(2,2)); +drop table t1; + +# +# Forward reference detection +# +create table t1 (a integer); +insert into t1 values (1); +-- error 1247 +select 1 = ALL (select 1 from t1 where 1 = xx ), 1 as xx ; +-- error 1247 +select 1 = ALL (select 1 from t1 where 1 = xx ), 1 as xx; +select 1 as xx, 1 = ALL ( select 1 from t1 where 1 = xx ); +-- error 1247 +select 1 = ALL (select 1 from t1 where 1 = xx ), 1 as xx; +-- error 1247 +select 1 = ALL (select 1 from t1 where 1 = xx ), 1 as xx from DUAL; +drop table t1; + +# +# cleaning up of results of subselects (BUG#8125) +# +CREATE TABLE `t1` ( `a` char(3) NOT NULL default '', `b` char(3) NOT NULL default '', `c` char(3) NOT NULL default '', PRIMARY KEY (`a`,`b`,`c`)) ENGINE=InnoDB; +CREATE TABLE t2 LIKE t1; +INSERT INTO t1 VALUES (1,1,1); +INSERT INTO t2 VALUES (1,1,1); +PREPARE my_stmt FROM "SELECT t1.b, count(*) FROM t1 group by t1.b having +count(*) > ALL (SELECT COUNT(*) FROM t2 WHERE t2.a=1 GROUP By t2.b)"; +EXECUTE my_stmt; +EXECUTE my_stmt; +deallocate prepare my_stmt; +drop table t1,t2; diff --git a/mysql-test/t/timezone2.test b/mysql-test/t/timezone2.test index d185a647921..32ed359a2db 100644 --- a/mysql-test/t/timezone2.test +++ b/mysql-test/t/timezone2.test @@ -266,3 +266,20 @@ delete from mysql.db where user like 'mysqltest\_%'; delete from mysql.tables_priv where user like 'mysqltest\_%'; flush privileges; drop table t1, t2; + +# +# Test for bug #7705 "CONVERT_TZ() crashes with subquery/WHERE on index +# column". Queries in which one of time zone arguments of CONVERT_TZ() is +# determined as constant only at val() stage (not at fix_fields() stage), +# should not crash server. +# +select convert_tz('2005-01-14 17:00:00', 'UTC', custTimeZone) from (select 'UTC' as custTimeZone) as tmp; + +# +# Test for bug #7899 "CREATE TABLE .. SELECT .. and CONVERT_TZ() function +# does not work well together". The following statement should return only +# one NULL row and not result of full join. +# +create table t1 select convert_tz(NULL, NULL, NULL); +select * from t1; +drop table t1; diff --git a/mysys/my_handler.c b/mysys/my_handler.c index 00f25924e69..5ee181ca78e 100644 --- a/mysys/my_handler.c +++ b/mysys/my_handler.c @@ -43,7 +43,7 @@ static int compare_bin(uchar *a, uint a_length, uchar *b, uint b_length, return 0; if (skip_end_space && a_length != b_length) { - int swap= 0; + int swap= 1; /* We are using space compression. We have to check if longer key has next character < ' ', in which case it's less than the shorter @@ -62,7 +62,7 @@ static int compare_bin(uchar *a, uint a_length, uchar *b, uint b_length, for (end= a + a_length-length; a < end ; a++) { if (*a != ' ') - return ((int) *a - (int) ' ') ^ swap; + return (*a < ' ') ? -swap : swap; } return 0; } diff --git a/ndb/include/portlib/NdbThread.h b/ndb/include/portlib/NdbThread.h index 212f7de9384..e86deee4354 100644 --- a/ndb/include/portlib/NdbThread.h +++ b/ndb/include/portlib/NdbThread.h @@ -76,7 +76,7 @@ int NdbThread_WaitFor(struct NdbThread* p_wait_thread, void** status); * * * status: exit code */ -void NdbThread_Exit(int status); +void NdbThread_Exit(void *status); /** * Set thread concurrency level diff --git a/ndb/src/common/portlib/NdbPortLibTest.cpp b/ndb/src/common/portlib/NdbPortLibTest.cpp index 55b9ccec5f2..d7892411851 100644 --- a/ndb/src/common/portlib/NdbPortLibTest.cpp +++ b/ndb/src/common/portlib/NdbPortLibTest.cpp @@ -54,10 +54,7 @@ extern "C" void* thread1func(void* arg) if (arg1 != 7) fail("TEST1", "Wrong arg"); - NdbThread_Exit(returnvalue); - - return NULL; - + return returnvalue; } // test 2 variables and funcs @@ -80,10 +77,7 @@ extern "C" void* test2func(void* arg) fail("TEST2", "Failed to unlock mutex"); int returnvalue = arg1; - NdbThread_Exit(returnvalue); - - return NULL; - + return returnvalue; } @@ -129,8 +123,7 @@ extern "C" void* testfunc(void* arg) } while(tmpVar<100); - NdbThread_Exit(0); - return NULL; + return 0; } extern "C" void* testTryLockfunc(void* arg) @@ -169,8 +162,7 @@ extern "C" void* testTryLockfunc(void* arg) } while(tmpVar<100); - NdbThread_Exit(0); - return NULL; + return 0; } diff --git a/ndb/src/common/portlib/NdbThread.c b/ndb/src/common/portlib/NdbThread.c index 5f2e6021c43..aaee9b45069 100644 --- a/ndb/src/common/portlib/NdbThread.c +++ b/ndb/src/common/portlib/NdbThread.c @@ -17,7 +17,7 @@ #include <ndb_global.h> #include <NdbThread.h> -#include <pthread.h> +#include <my_pthread.h> #include <NdbMem.h> #define MAX_THREAD_NAME 16 @@ -39,21 +39,28 @@ struct NdbThread static void* ndb_thread_wrapper(void* _ss){ - void * ret; - struct NdbThread * ss = (struct NdbThread *)_ss; - DBUG_ENTER("ndb_thread_wrapper"); -#ifdef NDB_SHM_TRANSPORTER - if (g_ndb_shm_signum) + my_thread_init(); { - sigset_t mask; - DBUG_PRINT("info",("Block signum %d",g_ndb_shm_signum)); - sigemptyset(&mask); - sigaddset(&mask, g_ndb_shm_signum); - pthread_sigmask(SIG_BLOCK, &mask, 0); - } + DBUG_ENTER("ndb_thread_wrapper"); +#ifdef NDB_SHM_TRANSPORTER + if (g_ndb_shm_signum) + { + sigset_t mask; + DBUG_PRINT("info",("Block signum %d",g_ndb_shm_signum)); + sigemptyset(&mask); + sigaddset(&mask, g_ndb_shm_signum); + pthread_sigmask(SIG_BLOCK, &mask, 0); + } #endif - ret= (* ss->func)(ss->object); - DBUG_RETURN(ret); + { + void *ret; + struct NdbThread * ss = (struct NdbThread *)_ss; + ret= (* ss->func)(ss->object); + NdbThread_Exit(ret); + } + /* will never be reached */ + DBUG_RETURN(0); + } } @@ -130,9 +137,10 @@ int NdbThread_WaitFor(struct NdbThread* p_wait_thread, void** status) } -void NdbThread_Exit(int status) +void NdbThread_Exit(void *status) { - pthread_exit(&status); + my_thread_end(); + pthread_exit(status); } diff --git a/ndb/src/common/transporter/TransporterRegistry.cpp b/ndb/src/common/transporter/TransporterRegistry.cpp index 462cde76740..439730435ec 100644 --- a/ndb/src/common/transporter/TransporterRegistry.cpp +++ b/ndb/src/common/transporter/TransporterRegistry.cpp @@ -1104,11 +1104,8 @@ TransporterRegistry::setIOState(NodeId nodeId, IOState state) { static void * run_start_clients_C(void * me) { - my_thread_init(); ((TransporterRegistry*) me)->start_clients_thread(); - my_thread_end(); - NdbThread_Exit(0); - return me; + return 0; } // Run by kernel thread diff --git a/ndb/src/common/util/SocketServer.cpp b/ndb/src/common/util/SocketServer.cpp index 8bee256684d..da06389b5df 100644 --- a/ndb/src/common/util/SocketServer.cpp +++ b/ndb/src/common/util/SocketServer.cpp @@ -186,11 +186,7 @@ extern "C" void* socketServerThread_C(void* _ss){ SocketServer * ss = (SocketServer *)_ss; - - my_thread_init(); ss->doRun(); - my_thread_end(); - NdbThread_Exit(0); return 0; } @@ -309,11 +305,8 @@ void* sessionThread_C(void* _sc){ SocketServer::Session * si = (SocketServer::Session *)_sc; - my_thread_init(); if(!transfer(si->m_socket)){ si->m_stopped = true; - my_thread_end(); - NdbThread_Exit(0); return 0; } @@ -325,8 +318,6 @@ sessionThread_C(void* _sc){ } si->m_stopped = true; - my_thread_end(); - NdbThread_Exit(0); return 0; } diff --git a/ndb/src/kernel/blocks/backup/Backup.cpp b/ndb/src/kernel/blocks/backup/Backup.cpp index d72efdd0a52..2e62979ce8e 100644 --- a/ndb/src/kernel/blocks/backup/Backup.cpp +++ b/ndb/src/kernel/blocks/backup/Backup.cpp @@ -3201,7 +3201,7 @@ Backup::execSTART_BACKUP_REQ(Signal* signal) return; }//if - tabPtr.p->triggerAllocated[i] = true; + tabPtr.p->triggerAllocated[j] = true; trigPtr.p->backupPtr = ptr.i; trigPtr.p->tableId = tabPtr.p->tableId; trigPtr.p->tab_ptr_i = tabPtr.i; diff --git a/ndb/src/kernel/blocks/ndbfs/AsyncFile.cpp b/ndb/src/kernel/blocks/ndbfs/AsyncFile.cpp index ddf1681479c..f76440a462a 100644 --- a/ndb/src/kernel/blocks/ndbfs/AsyncFile.cpp +++ b/ndb/src/kernel/blocks/ndbfs/AsyncFile.cpp @@ -82,7 +82,6 @@ static int numAsyncFiles = 0; extern "C" void * runAsyncFile(void* arg) { - my_thread_init(); ((AsyncFile*)arg)->run(); return (NULL); } @@ -219,7 +218,8 @@ AsyncFile::run() rmrfReq(request, (char*)theFileName.c_str(), request->par.rmrf.own_directory); break; case Request:: end: - closeReq(request); + if (theFd > 0) + closeReq(request); endReq(); return; default: @@ -239,6 +239,7 @@ void AsyncFile::openReq(Request* request) { m_openedWithSync = false; m_syncFrequency = 0; + m_syncCount= 0; // for open.flags, see signal FSOPENREQ #ifdef NDB_WIN32 @@ -329,7 +330,6 @@ void AsyncFile::openReq(Request* request) } else { #endif m_openedWithSync = false; - m_syncCount = 0; m_syncFrequency = Global_syncFreq; #if 0 } @@ -656,6 +656,7 @@ AsyncFile::writeBuffer(const char * buf, size_t size, off_t offset, } #endif + m_syncCount+= bytes_written; buf += bytes_written; size -= bytes_written; offset += bytes_written; @@ -682,6 +683,10 @@ AsyncFile::closeReq(Request * request) hFile = INVALID_HANDLE_VALUE; #else if (-1 == ::close(theFd)) { +#ifndef DBUG_OFF + if (theFd == -1) + abort(); +#endif request->error = errno; } theFd = -1; @@ -700,7 +705,8 @@ bool AsyncFile::isOpen(){ void AsyncFile::syncReq(Request * request) { - if(m_openedWithSync){ + if(m_openedWithSync || + m_syncCount == 0){ return; } #ifdef NDB_WIN32 @@ -756,7 +762,6 @@ AsyncFile::appendReq(Request * request){ if(m_syncFrequency != 0 && m_syncCount > m_syncFrequency){ syncReq(request); - request->error = 0; } } @@ -870,8 +875,6 @@ void AsyncFile::endReq() { // Thread is ended with return if (theWriteBuffer) NdbMem_Free(theWriteBuffer); - my_thread_end(); - NdbThread_Exit(0); } diff --git a/ndb/src/kernel/blocks/ndbfs/MemoryChannelTest/MemoryChannelTest.cpp b/ndb/src/kernel/blocks/ndbfs/MemoryChannelTest/MemoryChannelTest.cpp index aeab9f7828d..b98c60693f4 100644 --- a/ndb/src/kernel/blocks/ndbfs/MemoryChannelTest/MemoryChannelTest.cpp +++ b/ndb/src/kernel/blocks/ndbfs/MemoryChannelTest/MemoryChannelTest.cpp @@ -40,7 +40,6 @@ extern "C" void* runProducer(void*arg) NdbSleep_MilliSleep(i); i++; } - NdbThread_Exit(0); return NULL; } @@ -58,7 +57,6 @@ extern "C" void* runConsumer(void* arg) delete p; } - NdbThread_Exit(0); return NULL; } @@ -92,7 +90,6 @@ extern "C" void* runProducer2(void*arg) NdbSleep_MilliSleep(i); i++; } - NdbThread_Exit(0); return NULL; } @@ -111,7 +108,6 @@ extern "C" void* runConsumer2(void* arg) delete p; } ndbout << "Consumer2: " << count << " received" << endl; - NdbThread_Exit(0); return NULL; } diff --git a/ndb/src/kernel/vm/FastScheduler.cpp b/ndb/src/kernel/vm/FastScheduler.cpp index eca456d26dd..d05c02360a7 100644 --- a/ndb/src/kernel/vm/FastScheduler.cpp +++ b/ndb/src/kernel/vm/FastScheduler.cpp @@ -76,19 +76,26 @@ FastScheduler::activateSendPacked() globalData.loopMax = 2048; }//FastScheduler::activateSendPacked() +//------------------------------------------------------------------------ +// sendPacked is executed at the end of the loop. +// To ensure that we don't send any messages before executing all local +// packed signals we do another turn in the loop (unless we have already +// executed too many signals in the loop). +//------------------------------------------------------------------------ void FastScheduler::doJob() { + Uint32 init_loopCount = 0; + Uint32 TminLoops = getBOccupancy() + EXTRA_SIGNALS_PER_DO_JOB; + Uint32 TloopMax = (Uint32)globalData.loopMax; + if (TminLoops < TloopMax) { + TloopMax = TminLoops; + }//if + if (TloopMax < MIN_NUMBER_OF_SIG_PER_DO_JOB) { + TloopMax = MIN_NUMBER_OF_SIG_PER_DO_JOB; + }//if do{ - Uint32 loopCount = 0; - Uint32 TminLoops = getBOccupancy() + EXTRA_SIGNALS_PER_DO_JOB; - Uint32 TloopMax = (Uint32)globalData.loopMax; - if (TminLoops < TloopMax) { - TloopMax = TminLoops; - }//if - if (TloopMax < MIN_NUMBER_OF_SIG_PER_DO_JOB) { - TloopMax = MIN_NUMBER_OF_SIG_PER_DO_JOB; - }//if + Uint32 loopCount = init_loopCount; register Uint32 tHighPrio = globalData.highestAvailablePrio; register Signal* signal = getVMSignals(); while ((tHighPrio < LEVEL_IDLE) && (loopCount < TloopMax)) { @@ -151,7 +158,7 @@ FastScheduler::doJob() if (globalData.sendPackedActivated == 1) { Uint32 t1 = theDoJobTotalCounter; Uint32 t2 = theDoJobCallCounter; - t1 += loopCount; + t1 += (loopCount - init_loopCount); t2++; theDoJobTotalCounter = t1; theDoJobCallCounter = t2; @@ -161,7 +168,11 @@ FastScheduler::doJob() theDoJobTotalCounter = 0; }//if }//if - } while (getBOccupancy() > MAX_OCCUPANCY); + init_loopCount = loopCount; + sendPacked(); + } while ((getBOccupancy() > MAX_OCCUPANCY) || + ((init_loopCount < TloopMax) && + (globalData.highestAvailablePrio < LEVEL_IDLE))); }//FastScheduler::doJob() void FastScheduler::sendPacked() diff --git a/ndb/src/kernel/vm/ThreadConfig.cpp b/ndb/src/kernel/vm/ThreadConfig.cpp index 4844bb9a477..76fcc4ba84f 100644 --- a/ndb/src/kernel/vm/ThreadConfig.cpp +++ b/ndb/src/kernel/vm/ThreadConfig.cpp @@ -173,9 +173,6 @@ void ThreadConfig::ipControlLoop() // until all buffers are empty or until we have executed 2048 signals. //-------------------------------------------------------------------- globalScheduler.doJob(); - - globalScheduler.sendPacked(); - }//while globalData.incrementWatchDogCounter(6); diff --git a/ndb/src/kernel/vm/WatchDog.cpp b/ndb/src/kernel/vm/WatchDog.cpp index 4e07dc1df90..23475a478d3 100644 --- a/ndb/src/kernel/vm/WatchDog.cpp +++ b/ndb/src/kernel/vm/WatchDog.cpp @@ -27,10 +27,7 @@ extern "C" void* runWatchDog(void* w){ - my_thread_init(); ((WatchDog*)w)->run(); - my_thread_end(); - NdbThread_Exit(0); return NULL; } diff --git a/ndb/src/mgmclient/CommandInterpreter.cpp b/ndb/src/mgmclient/CommandInterpreter.cpp index cbf7776fe06..025bed2bc09 100644 --- a/ndb/src/mgmclient/CommandInterpreter.cpp +++ b/ndb/src/mgmclient/CommandInterpreter.cpp @@ -457,8 +457,6 @@ event_thread_run(void* m) { NdbMgmHandle handle= *(NdbMgmHandle*)m; - my_thread_init(); - int filter[] = { 15, NDB_MGM_EVENT_CATEGORY_BACKUP, 0 }; int fd = ndb_mgm_listen_event(handle, filter); if (fd > 0) @@ -478,9 +476,7 @@ event_thread_run(void* m) do_event_thread= -1; } - my_thread_end(); - NdbThread_Exit(0); - return 0; + return NULL; } bool diff --git a/ndb/src/mgmsrv/ConfigInfo.cpp b/ndb/src/mgmsrv/ConfigInfo.cpp index 9be4af1b9b5..07310e3a8b8 100644 --- a/ndb/src/mgmsrv/ConfigInfo.cpp +++ b/ndb/src/mgmsrv/ConfigInfo.cpp @@ -3192,13 +3192,27 @@ fixShmKey(InitConfigFileParser::Context & ctx, const char *) { DBUG_ENTER("fixShmKey"); { + static int last_signum= -1; Uint32 signum; if(!ctx.m_currentSection->get("Signum", &signum)) { signum= OPT_NDB_SHM_SIGNUM_DEFAULT; + if (signum <= 0) + { + ctx.reportError("Unable to set default parameter for [SHM]Signum" + " please specify [SHM DEFAULT]Signum"); + return false; + } ctx.m_currentSection->put("Signum", signum); DBUG_PRINT("info",("Added Signum=%u", signum)); } + if ( last_signum != (int)signum && last_signum >= 0 ) + { + ctx.reportError("All shared memory transporters must have same [SHM]Signum defined." + " Use [SHM DEFAULT]Signum"); + return false; + } + last_signum= (int)signum; } { Uint32 id1= 0, id2= 0, key= 0; diff --git a/ndb/src/mgmsrv/MgmtSrvr.cpp b/ndb/src/mgmsrv/MgmtSrvr.cpp index f698099141a..66c9a6448aa 100644 --- a/ndb/src/mgmsrv/MgmtSrvr.cpp +++ b/ndb/src/mgmsrv/MgmtSrvr.cpp @@ -70,12 +70,7 @@ void * MgmtSrvr::logLevelThread_C(void* m) { MgmtSrvr *mgm = (MgmtSrvr*)m; - my_thread_init(); mgm->logLevelThreadRun(); - - my_thread_end(); - NdbThread_Exit(0); - /* NOTREACHED */ return 0; } @@ -83,12 +78,7 @@ void * MgmtSrvr::signalRecvThread_C(void *m) { MgmtSrvr *mgm = (MgmtSrvr*)m; - my_thread_init(); mgm->signalRecvThreadRun(); - - my_thread_end(); - NdbThread_Exit(0); - /* NOTREACHED */ return 0; } diff --git a/ndb/src/ndbapi/ClusterMgr.cpp b/ndb/src/ndbapi/ClusterMgr.cpp index e10b2e1d82c..1fe0cedbd6c 100644 --- a/ndb/src/ndbapi/ClusterMgr.cpp +++ b/ndb/src/ndbapi/ClusterMgr.cpp @@ -54,7 +54,6 @@ runClusterMgr_C(void * me) #ifdef NDB_OSE NdbSleep_MilliSleep(50); #endif - NdbThread_Exit(0); return NULL; } @@ -560,10 +559,7 @@ extern "C" void* runArbitMgr_C(void* me) { - my_thread_init(); ((ArbitMgr*) me)->threadMain(); - my_thread_end(); - NdbThread_Exit(0); return NULL; } diff --git a/ndb/src/ndbapi/TransporterFacade.cpp b/ndb/src/ndbapi/TransporterFacade.cpp index 031ee6315e8..5582143be44 100644 --- a/ndb/src/ndbapi/TransporterFacade.cpp +++ b/ndb/src/ndbapi/TransporterFacade.cpp @@ -405,11 +405,8 @@ extern "C" void* runSendRequest_C(void * me) { - my_thread_init(); ((TransporterFacade*) me)->threadMainSend(); - my_thread_end(); - NdbThread_Exit(0); - return me; + return 0; } void TransporterFacade::threadMainSend(void) @@ -443,11 +440,8 @@ extern "C" void* runReceiveResponse_C(void * me) { - my_thread_init(); ((TransporterFacade*) me)->threadMainReceive(); - my_thread_end(); - NdbThread_Exit(0); - return me; + return 0; } void TransporterFacade::threadMainReceive(void) diff --git a/ndb/src/ndbapi/ndb_cluster_connection.cpp b/ndb/src/ndbapi/ndb_cluster_connection.cpp index 5df707e211d..ab32d6abb8e 100644 --- a/ndb/src/ndbapi/ndb_cluster_connection.cpp +++ b/ndb/src/ndbapi/ndb_cluster_connection.cpp @@ -87,11 +87,8 @@ const char *Ndb_cluster_connection::get_connectstring(char *buf, extern "C" pthread_handler_decl(run_ndb_cluster_connection_connect_thread, me) { - my_thread_init(); g_run_connect_thread= 1; ((Ndb_cluster_connection_impl*) me)->connect_thread(); - my_thread_end(); - NdbThread_Exit(0); return me; } diff --git a/ndb/test/ndbapi/benchronja.cpp b/ndb/test/ndbapi/benchronja.cpp index 91b2a041186..a7523e8e416 100644 --- a/ndb/test/ndbapi/benchronja.cpp +++ b/ndb/test/ndbapi/benchronja.cpp @@ -984,7 +984,6 @@ void* ThreadExec(void* ThreadData){ delete pMyNdb; pMyNdb = NULL ; ThreadReady[thread_no] = 1; - NdbThread_Exit(0) ; return 0 ; }//if @@ -1197,7 +1196,6 @@ void* ThreadExec(void* ThreadData){ } // for(;;) delete pMyNdb ; - NdbThread_Exit(0) ; - return 0 ; // Compiler is happy now + return 0 ; } diff --git a/ndb/test/ndbapi/flexAsynch.cpp b/ndb/test/ndbapi/flexAsynch.cpp index 1953444d640..4b87b2c70ed 100644 --- a/ndb/test/ndbapi/flexAsynch.cpp +++ b/ndb/test/ndbapi/flexAsynch.cpp @@ -494,8 +494,7 @@ threadLoop(void* ThreadData) delete localNdb; ThreadReady[threadNo] = 1; - NdbThread_Exit(0); - return NULL; // Just to keep compiler happy + return NULL; }//threadLoop() static diff --git a/ndb/test/ndbapi/flexBench.cpp b/ndb/test/ndbapi/flexBench.cpp index 2a2388109a1..cc2bfb391da 100644 --- a/ndb/test/ndbapi/flexBench.cpp +++ b/ndb/test/ndbapi/flexBench.cpp @@ -617,7 +617,7 @@ static void* flexBenchThread(void* pArg) free(attrRefValue) ; free(pOps) ; delete pNdb ; - NdbThread_Exit(0) ; + return 0; // thread exits } pNdb->init(); @@ -934,8 +934,7 @@ static void* flexBenchThread(void* pArg) free(longKeyAttrValue); } // if - NdbThread_Exit(0); - return NULL; // Just to keep compiler happy + return NULL; // Thread exits } diff --git a/ndb/test/ndbapi/flexHammer.cpp b/ndb/test/ndbapi/flexHammer.cpp index 688e70d501a..13cd2d5e561 100644 --- a/ndb/test/ndbapi/flexHammer.cpp +++ b/ndb/test/ndbapi/flexHammer.cpp @@ -612,10 +612,7 @@ flexHammerThread(void* pArg) flexHammerErrorData->resetErrorCounters(); - // And exit using NDBT - NdbThread_Exit(0); - - return NULL; + return NULL; // thread exits } // flexHammerThread diff --git a/ndb/test/ndbapi/flexScan.cpp b/ndb/test/ndbapi/flexScan.cpp index c7f4041a525..4d2c85d6955 100644 --- a/ndb/test/ndbapi/flexScan.cpp +++ b/ndb/test/ndbapi/flexScan.cpp @@ -701,8 +701,7 @@ flexScanThread(void* ThreadData) free(pkValue); } // if - NdbThread_Exit(0); - return NULL; + return NULL; // thread exits } // flexScanThread diff --git a/ndb/test/ndbapi/flexTT.cpp b/ndb/test/ndbapi/flexTT.cpp index 3b976f9f87e..8d5be2bb399 100644 --- a/ndb/test/ndbapi/flexTT.cpp +++ b/ndb/test/ndbapi/flexTT.cpp @@ -389,8 +389,7 @@ threadLoop(void* ThreadData) delete localNdb; ThreadReady[loc_threadNo] = 1; - NdbThread_Exit(0); - return NULL; // Just to keep compiler happy + return NULL; // Thread exits }//threadLoop() static diff --git a/ndb/test/ndbapi/flexTimedAsynch.cpp b/ndb/test/ndbapi/flexTimedAsynch.cpp index 27380cc79fd..2b8c0bdd5f8 100644 --- a/ndb/test/ndbapi/flexTimedAsynch.cpp +++ b/ndb/test/ndbapi/flexTimedAsynch.cpp @@ -406,9 +406,8 @@ threadLoop(void* ThreadData) delete localNdb; ThreadReady[threadNo] = 1; - NdbThread_Exit(0); - return NULL; + return NULL; // thread exits } void executeThread(StartType aType, Ndb* aNdbObject, ThreadNdb* threadInfo) diff --git a/ndb/test/ndbapi/flex_bench_mysql.cpp b/ndb/test/ndbapi/flex_bench_mysql.cpp index c8d4d85bedf..c15175bfb00 100644 --- a/ndb/test/ndbapi/flex_bench_mysql.cpp +++ b/ndb/test/ndbapi/flex_bench_mysql.cpp @@ -710,7 +710,7 @@ static void* flexBenchThread(void* pArg) the_socket_name, 0) == NULL ) { ndbout << "failed" << endl; - NdbThread_Exit(0) ; + return 0; } ndbout << "ok" << endl; @@ -722,7 +722,7 @@ static void* flexBenchThread(void* pArg) if (r) { ndbout << "autocommit on/off failed" << endl; - NdbThread_Exit(0) ; + return 0; } } #endif @@ -741,7 +741,7 @@ static void* flexBenchThread(void* pArg) ndbout << threadNo << endl ; ndbout << "Thread #" << threadNo << " will now exit" << endl ; tResult = 13 ; - NdbThread_Exit(0) ; + return 0; } if (use_ndb) { @@ -750,7 +750,7 @@ static void* flexBenchThread(void* pArg) ndbout << "Failed to get an NDB object" << endl; ndbout << "Thread #" << threadNo << " will now exit" << endl ; tResult = 13; - NdbThread_Exit(0) ; + return 0; } pNdb->waitUntilReady(); return_ndb_object(pNdb, ndb_id); @@ -900,11 +900,11 @@ static void* flexBenchThread(void* pArg) prep_insert[i] = mysql_prepare(&mysql, buf, pos); if (prep_insert[i] == 0) { ndbout << "mysql_prepare: " << mysql_error(&mysql) << endl; - NdbThread_Exit(0) ; + return 0; } if (mysql_bind_param(prep_insert[i], bind_insert)) { ndbout << "mysql_bind_param: " << mysql_error(&mysql) << endl; - NdbThread_Exit(0) ; + return 0; } } @@ -926,11 +926,11 @@ static void* flexBenchThread(void* pArg) prep_update[i] = mysql_prepare(&mysql, buf, pos); if (prep_update[i] == 0) { ndbout << "mysql_prepare: " << mysql_error(&mysql) << endl; - NdbThread_Exit(0) ; + return 0; } if (mysql_bind_param(prep_update[i], bind_update)) { ndbout << "mysql_bind_param: " << mysql_error(&mysql) << endl; - NdbThread_Exit(0) ; + return 0; } } @@ -953,15 +953,15 @@ static void* flexBenchThread(void* pArg) prep_read[i] = mysql_prepare(&mysql, buf, pos); if (prep_read[i] == 0) { ndbout << "mysql_prepare: " << mysql_error(&mysql) << endl; - NdbThread_Exit(0) ; + return 0; } if (mysql_bind_param(prep_read[i], bind_read)) { ndbout << "mysql_bind_param: " << mysql_error(&mysql) << endl; - NdbThread_Exit(0) ; + return 0; } if (mysql_bind_result(prep_read[i], &bind_read[1])) { ndbout << "mysql_bind_result: " << mysql_error(&mysql) << endl; - NdbThread_Exit(0) ; + return 0; } } @@ -978,11 +978,11 @@ static void* flexBenchThread(void* pArg) prep_delete[i] = mysql_prepare(&mysql, buf, pos); if (prep_delete[i] == 0) { ndbout << "mysql_prepare: " << mysql_error(&mysql) << endl; - NdbThread_Exit(0) ; + return 0; } if (mysql_bind_param(prep_delete[i], bind_delete)) { ndbout << "mysql_bind_param: " << mysql_error(&mysql) << endl; - NdbThread_Exit(0) ; + return 0; } } } @@ -1431,8 +1431,7 @@ static void* flexBenchThread(void* pArg) ndbout << "I got here " << endl; return_ndb_object(pNdb, ndb_id); } - NdbThread_Exit(0); - return NULL; // Just to keep compiler happy + return NULL; } diff --git a/ndb/test/ndbapi/mainAsyncGenerator.cpp b/ndb/test/ndbapi/mainAsyncGenerator.cpp index 16cb50e160f..73a8b98ab57 100644 --- a/ndb/test/ndbapi/mainAsyncGenerator.cpp +++ b/ndb/test/ndbapi/mainAsyncGenerator.cpp @@ -274,8 +274,6 @@ threadRoutine(void *arg) asyncDbDisconnect(pNDB); - NdbThread_Exit(0); - return NULL; } diff --git a/ndb/test/src/NDBT_Test.cpp b/ndb/test/src/NDBT_Test.cpp index bbbde008938..17e46bf33e5 100644 --- a/ndb/test/src/NDBT_Test.cpp +++ b/ndb/test/src/NDBT_Test.cpp @@ -475,7 +475,6 @@ void * runStep_C(void * s) { runStep(s); - NdbThread_Exit(0); return NULL; } diff --git a/ndb/test/tools/transproxy.cpp b/ndb/test/tools/transproxy.cpp index 88267801172..28a621fa584 100644 --- a/ndb/test/tools/transproxy.cpp +++ b/ndb/test/tools/transproxy.cpp @@ -291,7 +291,6 @@ extern "C" void* copyrun_C(void* copy) { ((Copy*) copy)->run(); - NdbThread_Exit(0); return 0; } @@ -322,7 +321,6 @@ extern "C" void* connrun_C(void* conn) { ((Conn*) conn)->run(); - NdbThread_Exit(0); return 0; } diff --git a/scripts/make_binary_distribution.sh b/scripts/make_binary_distribution.sh index 22b51168c23..33d4794e4f7 100644 --- a/scripts/make_binary_distribution.sh +++ b/scripts/make_binary_distribution.sh @@ -107,8 +107,11 @@ BIN_FILES="extra/comp_err$BS extra/replace$BS extra/perror$BS \ client/mysql$BS client/mysqlshow$BS client/mysqladmin$BS \ client/mysqldump$BS client/mysqlimport$BS \ client/mysqltest$BS client/mysqlcheck$BS \ - client/mysqlbinlog$BS -"; + client/mysqlbinlog$BS \ + tests/mysql_client_test$BS \ + libmysqld/examples/mysql_client_test_embedded$BS \ + libmysqld/examples/mysqltest_embedded$BS \ + "; # Platform-specific bin dir files: if [ $BASE_SYSTEM = "netware" ] ; then @@ -127,8 +130,9 @@ else client/.libs/mysqltest client/.libs/mysqlcheck \ client/.libs/mysqlbinlog client/.libs/mysqlmanagerc \ client/.libs/mysqlmanager-pwgen tools/.libs/mysqlmanager \ - tests/.libs/mysql_client_test libmysqld/examples/mysql_client_test_embedded \ - libmysqld/examples/mysqltest_embedded \ + tests/.libs/mysql_client_test \ + libmysqld/examples/.libs/mysql_client_test_embedded \ + libmysqld/examples/.libs/mysqltest_embedded \ "; fi diff --git a/sql/examples/ha_archive.cc b/sql/examples/ha_archive.cc index e8d07a99048..491056d0e59 100644 --- a/sql/examples/ha_archive.cc +++ b/sql/examples/ha_archive.cc @@ -42,18 +42,20 @@ handle bulk inserts as well (that is if someone was trying to read at the same time since we would want to flush). - A "meta" file is kept. All this file does is contain information on - the number of rows. + A "meta" file is kept alongside the data file. This file serves two purpose. + The first purpose is to track the number of rows in the table. The second + purpose is to determine if the table was closed properly or not. When the + meta file is first opened it is marked as dirty. It is opened when the table + itself is opened for writing. When the table is closed the new count for rows + is written to the meta file and the file is marked as clean. If the meta file + is opened and it is marked as dirty, it is assumed that a crash occured. At + this point an error occurs and the user is told to rebuild the file. + A rebuild scans the rows and rewrites the meta file. If corruption is found + in the data file then the meta file is not repaired. - No attempts at durability are made. You can corrupt your data. A repair - method was added to repair the meta file that stores row information, - but if your data file gets corrupted I haven't solved that. I could - create a repair that would solve this, but do you want to take a - chance of loosing your data? + At some point a recovery method for such a drastic case needs to be divised. - Locks are row level, and you will get a consistant read. Transactions - will be added later (they are not that hard to add at this - stage). + Locks are row level, and you will get a consistant read. For performance as far as table scans go it is quite fast. I don't have good numbers but locally it has out performed both Innodb and MyISAM. For @@ -88,7 +90,6 @@ compression but may speed up ordered searches). Checkpoint the meta file to allow for faster rebuilds. Dirty open (right now the meta file is repaired if a crash occured). - Transactions. Option to allow for dirty reads, this would lower the sync calls, which would make inserts a lot faster, but would mean highly arbitrary reads. @@ -355,6 +356,7 @@ ARCHIVE_SHARE *ha_archive::get_share(const char *table_name, TABLE *table) opposite. */ (void)write_meta_file(share->meta_file, share->rows_recorded, TRUE); + /* It is expensive to open and close the data files and since you can't have a gzip file that can be both read and written we keep a writer open @@ -401,7 +403,8 @@ int ha_archive::free_share(ARCHIVE_SHARE *share) (void)write_meta_file(share->meta_file, share->rows_recorded, FALSE); if (gzclose(share->archive_write) == Z_ERRNO) rc= 1; - my_close(share->meta_file,MYF(0)); + if (my_close(share->meta_file, MYF(0))) + rc= 1; my_free((gptr) share, MYF(0)); } pthread_mutex_unlock(&archive_mutex); diff --git a/sql/ha_innodb.cc b/sql/ha_innodb.cc index 502f8eb92f3..1d75ce99aee 100644 --- a/sql/ha_innodb.cc +++ b/sql/ha_innodb.cc @@ -4672,12 +4672,12 @@ ha_innobase::update_table_comment( dict_print_info_on_foreign_keys(FALSE, file, prebuilt->trx, prebuilt->table); flen = ftell(file); - if(length + flen + 3 > 64000) { + if (flen < 0) { + flen = 0; + } else if (length + flen + 3 > 64000) { flen = 64000 - 3 - length; } - ut_ad(flen > 0); - /* allocate buffer for the full string, and read the contents of the temporary file */ @@ -4741,12 +4741,12 @@ ha_innobase::get_foreign_key_create_info(void) prebuilt->trx->op_info = (char*)""; flen = ftell(file); - if(flen > 64000 - 1) { + if (flen < 0) { + flen = 0; + } else if(flen > 64000 - 1) { flen = 64000 - 1; } - ut_ad(flen >= 0); - /* allocate buffer for the string, and read the contents of the temporary file */ @@ -5142,12 +5142,12 @@ innodb_show_status( srv_printf_innodb_monitor(srv_monitor_file); flen = ftell(srv_monitor_file); os_file_set_eof(srv_monitor_file); - if(flen > 64000 - 1) { + if (flen < 0) { + flen = 0; + } else if (flen > 64000 - 1) { flen = 64000 - 1; } - ut_ad(flen > 0); - /* allocate buffer for the string, and read the contents of the temporary file */ diff --git a/sql/item.cc b/sql/item.cc index 8c45dffce75..ab29c147dfb 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -1482,12 +1482,13 @@ bool Item_field::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref) } else if (refer != (Item **)not_found_item) { - if (!(*refer)->fixed) + if (!last->ref_pointer_array[counter]) { my_error(ER_ILLEGAL_REFERENCE, MYF(0), name, "forward reference in item list"); return -1; } + DBUG_ASSERT((*refer)->fixed); /* Here, a subset of actions performed by Item_ref::set_properties is not enough. So we pass ptr to NULL into Item_[direct]_ref @@ -2161,12 +2162,13 @@ bool Item_ref::fix_fields(THD *thd,TABLE_LIST *tables, Item **reference) mark_as_dependent(thd, last, thd->lex->current_select, fld); return 0; } - if (!(*ref)->fixed) + if (!last->ref_pointer_array[counter]) { my_error(ER_ILLEGAL_REFERENCE, MYF(0), name, "forward reference in item list"); return -1; } + DBUG_ASSERT((*ref)->fixed); mark_as_dependent(thd, last, thd->lex->current_select, this); if (place == IN_HAVING) diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h index 6834799688d..061ed468b78 100644 --- a/sql/item_cmpfunc.h +++ b/sql/item_cmpfunc.h @@ -213,7 +213,7 @@ class Item_bool_rowready_func2 :public Item_bool_func2 public: Item_bool_rowready_func2(Item *a, Item *b) :Item_bool_func2(a, b) { - allowed_arg_cols= a->cols(); + allowed_arg_cols= 0; // Fetch this value from first argument } Item *neg_transformer(THD *thd); virtual Item *negated_item(); @@ -390,7 +390,10 @@ class Item_func_interval :public Item_int_func double *intervals; public: Item_func_interval(Item_row *a) - :Item_int_func(a),row(a),intervals(0) { allowed_arg_cols= a->cols(); } + :Item_int_func(a),row(a),intervals(0) + { + allowed_arg_cols= 0; // Fetch this value from first argument + } longlong val_int(); void fix_length_and_dec(); const char *func_name() const { return "interval"; } @@ -743,7 +746,7 @@ class Item_func_in :public Item_int_func Item_func_in(List<Item> &list) :Item_int_func(list), array(0), in_item(0), have_null(0) { - allowed_arg_cols= args[0]->cols(); + allowed_arg_cols= 0; // Fetch this value from first argument } longlong val_int(); void fix_length_and_dec(); diff --git a/sql/item_func.cc b/sql/item_func.cc index 03b5688efc2..7d38c44bab3 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -303,10 +303,24 @@ Item_func::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref) We can't yet set item to *arg as fix_fields may change *arg We shouldn't call fix_fields() twice, so check 'fixed' field first */ - if ((!(*arg)->fixed && (*arg)->fix_fields(thd, tables, arg)) || - (*arg)->check_cols(allowed_arg_cols)) + if ((!(*arg)->fixed && (*arg)->fix_fields(thd, tables, arg))) return 1; /* purecov: inspected */ + item= *arg; + + if (allowed_arg_cols) + { + if (item->check_cols(allowed_arg_cols)) + return 1; + } + else + { + /* we have to fetch allowed_arg_cols from first argument */ + DBUG_ASSERT(arg == args); // it is first argument + allowed_arg_cols= item->cols(); + DBUG_ASSERT(allowed_arg_cols); // Can't be 0 any more + } + if (item->maybe_null) maybe_null=1; diff --git a/sql/item_func.h b/sql/item_func.h index ce2b34499d6..8a5347d675e 100644 --- a/sql/item_func.h +++ b/sql/item_func.h @@ -32,6 +32,10 @@ class Item_func :public Item_result_field { protected: Item **args, *tmp_arg[2]; + /* + Allowed numbers of columns in result (usually 1, which means scalar value) + 0 means get this number from first argument + */ uint allowed_arg_cols; public: uint arg_count; diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index cd98fb62818..1fb68561374 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -2171,6 +2171,7 @@ String *Item_func_conv::val_str(String *str) return 0; } null_value=0; + unsigned_flag= !(from_base < 0); if (from_base < 0) dec= my_strntoll(res->charset(),res->ptr(),res->length(),-from_base,&endptr,&err); else @@ -2613,18 +2614,13 @@ String *Item_func_quote::val_str(String *str) for (from= (char*) arg->ptr(), end= from + arg_length; from < end; from++) new_length+= get_esc_bit(escmask, (uchar) *from); - /* - We have to use realloc() instead of alloc() as we want to keep the - old result in arg - */ - if (arg->realloc(new_length)) + if (tmp_value.alloc(new_length)) goto null; /* - As 'arg' and 'str' may be the same string, we must replace characters - from the end to the beginning + We replace characters from the end to the beginning */ - to= (char*) arg->ptr() + new_length - 1; + to= (char*) tmp_value.ptr() + new_length - 1; *to--= '\''; for (start= (char*) arg->ptr(),end= start + arg_length; end-- != start; to--) { @@ -2652,10 +2648,10 @@ String *Item_func_quote::val_str(String *str) } } *to= '\''; - arg->length(new_length); - str->set_charset(collation.collation); + tmp_value.length(new_length); + tmp_value.set_charset(collation.collation); null_value= 0; - return arg; + return &tmp_value; null: null_value= 1; diff --git a/sql/item_strfunc.h b/sql/item_strfunc.h index 698536a61c7..c1c0969672c 100644 --- a/sql/item_strfunc.h +++ b/sql/item_strfunc.h @@ -588,6 +588,7 @@ public: class Item_func_quote :public Item_str_func { + String tmp_value; public: Item_func_quote(Item *a) :Item_str_func(a) {} const char *func_name() const { return "quote"; } diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc index 8516ea76a7e..16186b1a6d3 100644 --- a/sql/item_subselect.cc +++ b/sql/item_subselect.cc @@ -995,6 +995,10 @@ Item_in_subselect::row_value_transformer(JOIN *join) List_iterator_fast<Item> li(select_lex->item_list); for (uint i= 0; i < n; i++) { + DBUG_ASSERT(left_expr->fixed && select_lex->ref_pointer_array[i]->fixed); + if (select_lex->ref_pointer_array[i]-> + check_cols(left_expr->el(i)->cols())) + goto err; Item *func= new Item_ref_null_helper(this, select_lex->ref_pointer_array+i, (char *) "<no matter>", @@ -1123,6 +1127,7 @@ void subselect_single_select_engine::cleanup() DBUG_ENTER("subselect_single_select_engine::cleanup"); prepared= optimized= executed= 0; join= 0; + result->cleanup(); DBUG_VOID_RETURN; } @@ -1131,6 +1136,7 @@ void subselect_union_engine::cleanup() { DBUG_ENTER("subselect_union_engine::cleanup"); unit->reinit_exec_mechanism(); + result->cleanup(); DBUG_VOID_RETURN; } @@ -1138,6 +1144,10 @@ void subselect_union_engine::cleanup() void subselect_uniquesubquery_engine::cleanup() { DBUG_ENTER("subselect_uniquesubquery_engine::cleanup"); + /* + subselect_uniquesubquery_engine have not 'result' assigbed, so we do not + cleanup() it + */ DBUG_VOID_RETURN; } @@ -1421,13 +1431,15 @@ int subselect_indexsubquery_engine::exec() uint subselect_single_select_engine::cols() { - return select_lex->item_list.elements; + DBUG_ASSERT(select_lex->join); // should be called after fix_fields() + return select_lex->join->fields_list.elements; } uint subselect_union_engine::cols() { - return unit->first_select()->item_list.elements; + DBUG_ASSERT(unit->is_prepared()); // should be called after fix_fields() + return unit->types.elements; } diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc index bc80131e4ad..2c500f16bf3 100644 --- a/sql/item_timefunc.cc +++ b/sql/item_timefunc.cc @@ -1656,6 +1656,7 @@ void Item_func_convert_tz::fix_length_and_dec() collation.set(&my_charset_bin); decimals= 0; max_length= MAX_DATETIME_WIDTH*MY_CHARSET_BIN_MB_MAXLEN; + maybe_null= 1; } @@ -1668,12 +1669,6 @@ Item_func_convert_tz::fix_fields(THD *thd_arg, TABLE_LIST *tables_arg, Item **re tz_tables= thd_arg->lex->time_zone_tables_used; - if (args[1]->const_item()) - from_tz= my_tz_find(args[1]->val_str(&str), tz_tables); - - if (args[2]->const_item()) - to_tz= my_tz_find(args[2]->val_str(&str), tz_tables); - return 0; } @@ -1713,13 +1708,19 @@ bool Item_func_convert_tz::get_date(TIME *ltime, my_time_t my_time_tmp; bool not_used; String str; - - if (!args[1]->const_item()) + + if (!from_tz_cached) + { from_tz= my_tz_find(args[1]->val_str(&str), tz_tables); - - if (!args[2]->const_item()) + from_tz_cached= args[1]->const_item(); + } + + if (!to_tz_cached) + { to_tz= my_tz_find(args[2]->val_str(&str), tz_tables); - + to_tz_cached= args[2]->const_item(); + } + if (from_tz==0 || to_tz==0 || get_arg0_date(ltime, 0)) { null_value= 1; @@ -1741,6 +1742,13 @@ bool Item_func_convert_tz::get_date(TIME *ltime, } +void Item_func_convert_tz::cleanup() +{ + from_tz_cached= to_tz_cached= 0; + Item_date_func::cleanup(); +} + + void Item_date_add_interval::fix_length_and_dec() { enum_field_types arg0_field_type; diff --git a/sql/item_timefunc.h b/sql/item_timefunc.h index df0b05d6d42..cc2709bf555 100644 --- a/sql/item_timefunc.h +++ b/sql/item_timefunc.h @@ -545,12 +545,15 @@ class Item_func_convert_tz :public Item_date_func TABLE_LIST *tz_tables; /* If time zone parameters are constants we are caching objects that - represent them. + represent them (we use separate from_tz_cached/to_tz_cached members + to indicate this fact, since NULL is legal value for from_tz/to_tz + members. */ + bool from_tz_cached, to_tz_cached; Time_zone *from_tz, *to_tz; public: Item_func_convert_tz(Item *a, Item *b, Item *c): - Item_date_func(a, b, c) {} + Item_date_func(a, b, c), from_tz_cached(0), to_tz_cached(0) {} longlong val_int(); double val() { return (double) val_int(); } String *val_str(String *str); @@ -558,6 +561,7 @@ class Item_func_convert_tz :public Item_date_func bool fix_fields(THD *, struct st_table_list *, Item **); void fix_length_and_dec(); bool get_date(TIME *res, uint fuzzy_date); + void cleanup(); }; diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index e71833e6af6..6218bc49f53 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -377,6 +377,7 @@ Item *negate_expression(THD *thd, Item *expr); struct Query_cache_query_flags { unsigned int client_long_flag:1; + unsigned int client_protocol_41:1; uint character_set_client_num; uint character_set_results_num; uint collation_connection_num; @@ -564,6 +565,10 @@ int mysql_multi_update(THD *thd, TABLE_LIST *table_list, COND *conds, ulong options, enum enum_duplicates handle_duplicates, bool ignore, SELECT_LEX_UNIT *unit, SELECT_LEX *select_lex); +int mysql_multi_update_lock(THD *thd, + TABLE_LIST *table_list, + List<Item> *fields, + SELECT_LEX *select_lex); int mysql_prepare_insert(THD *thd, TABLE_LIST *table_list, TABLE_LIST *insert_table_list, TABLE *table, List<Item> &fields, List_item *values, diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 5367e67c32a..503fb5bfb99 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -4098,7 +4098,11 @@ enum options_mysqld OPT_RANGE_ALLOC_BLOCK_SIZE, OPT_QUERY_ALLOC_BLOCK_SIZE, OPT_QUERY_PREALLOC_SIZE, OPT_TRANS_ALLOC_BLOCK_SIZE, OPT_TRANS_PREALLOC_SIZE, - OPT_SYNC_FRM, OPT_SYNC_BINLOG, OPT_BDB_NOSYNC, + OPT_SYNC_FRM, OPT_SYNC_BINLOG, + OPT_SYNC_REPLICATION, + OPT_SYNC_REPLICATION_SLAVE_ID, + OPT_SYNC_REPLICATION_TIMEOUT, + OPT_BDB_NOSYNC, OPT_ENABLE_SHARED_MEMORY, OPT_SHARED_MEMORY_BASE_NAME, OPT_OLD_PASSWORDS, @@ -5211,6 +5215,23 @@ The minimum value for this variable is 4096.", (gptr*) &sync_binlog_period, (gptr*) &sync_binlog_period, 0, GET_ULONG, REQUIRED_ARG, 0, 0, ~0L, 0, 1, 0}, +#ifdef DOES_NOTHING_YET + {"sync-replication", OPT_SYNC_REPLICATION, + "Enable synchronous replication", + (gptr*) &global_system_variables.sync_replication, + (gptr*) &global_system_variables.sync_replication, + 0, GET_ULONG, REQUIRED_ARG, 0, 0, 1, 0, 1, 0}, + {"sync-replication-slave-id", OPT_SYNC_REPLICATION_SLAVE_ID, + "Synchronous replication is wished for this slave", + (gptr*) &global_system_variables.sync_replication_slave_id, + (gptr*) &global_system_variables.sync_replication_slave_id, + 0, GET_ULONG, REQUIRED_ARG, 0, 0, ~0L, 0, 1, 0}, + {"sync-replication-timeout", OPT_SYNC_REPLICATION_TIMEOUT, + "Synchronous replication timeout", + (gptr*) &global_system_variables.sync_replication_timeout, + (gptr*) &global_system_variables.sync_replication_timeout, + 0, GET_ULONG, REQUIRED_ARG, 10, 0, ~0L, 0, 1, 0}, +#endif {"sync-frm", OPT_SYNC_FRM, "Sync .frm to disk on create. Enabled by default", (gptr*) &opt_sync_frm, (gptr*) &opt_sync_frm, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0}, diff --git a/sql/set_var.cc b/sql/set_var.cc index e8c066cc883..ca7987d2636 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -333,6 +333,14 @@ sys_var_thd_storage_engine sys_storage_engine("storage_engine", &SV::table_type); #ifdef HAVE_REPLICATION sys_var_sync_binlog_period sys_sync_binlog_period("sync_binlog", &sync_binlog_period); +sys_var_thd_ulong sys_sync_replication("sync_replication", + &SV::sync_replication); +sys_var_thd_ulong sys_sync_replication_slave_id( + "sync_replication_slave_id", + &SV::sync_replication_slave_id); +sys_var_thd_ulong sys_sync_replication_timeout( + "sync_replication_timeout", + &SV::sync_replication_timeout); #endif sys_var_bool_ptr sys_sync_frm("sync_frm", &opt_sync_frm); sys_var_long_ptr sys_table_cache_size("table_cache", @@ -605,6 +613,9 @@ sys_var *sys_variables[]= &sys_storage_engine, #ifdef HAVE_REPLICATION &sys_sync_binlog_period, + &sys_sync_replication, + &sys_sync_replication_slave_id, + &sys_sync_replication_timeout, #endif &sys_sync_frm, &sys_table_cache_size, @@ -850,6 +861,9 @@ struct show_var_st init_vars[]= { {sys_storage_engine.name, (char*) &sys_storage_engine, SHOW_SYS}, #ifdef HAVE_REPLICATION {sys_sync_binlog_period.name,(char*) &sys_sync_binlog_period, SHOW_SYS}, + {sys_sync_replication.name, (char*) &sys_sync_replication, SHOW_SYS}, + {sys_sync_replication_slave_id.name, (char*) &sys_sync_replication_slave_id,SHOW_SYS}, + {sys_sync_replication_timeout.name, (char*) &sys_sync_replication_timeout,SHOW_SYS}, #endif {sys_sync_frm.name, (char*) &sys_sync_frm, SHOW_SYS}, #ifdef HAVE_TZNAME @@ -2438,8 +2452,15 @@ bool sys_var_thd_time_zone::check(THD *thd, set_var *var) bool sys_var_thd_time_zone::update(THD *thd, set_var *var) { - /* We are using Time_zone object found during check() phase */ - *get_tz_ptr(thd,var->type)= var->save_result.time_zone; + /* We are using Time_zone object found during check() phase. */ + if (var->type == OPT_GLOBAL) + { + pthread_mutex_lock(&LOCK_global_system_variables); + global_system_variables.time_zone= var->save_result.time_zone; + pthread_mutex_unlock(&LOCK_global_system_variables); + } + else + thd->variables.time_zone= var->save_result.time_zone; return 0; } @@ -2451,27 +2472,25 @@ byte *sys_var_thd_time_zone::value_ptr(THD *thd, enum_var_type type, We can use ptr() instead of c_ptr() here because String contaning time zone name is guaranteed to be zero ended. */ - return (byte *)((*get_tz_ptr(thd,type))->get_name()->ptr()); -} - - -Time_zone** sys_var_thd_time_zone::get_tz_ptr(THD *thd, - enum_var_type type) -{ if (type == OPT_GLOBAL) - return &global_system_variables.time_zone; + return (byte *)(global_system_variables.time_zone->get_name()->ptr()); else - return &thd->variables.time_zone; + return (byte *)(thd->variables.time_zone->get_name()->ptr()); } void sys_var_thd_time_zone::set_default(THD *thd, enum_var_type type) { + pthread_mutex_lock(&LOCK_global_system_variables); if (type == OPT_GLOBAL) { if (default_tz_name) { String str(default_tz_name, &my_charset_latin1); + /* + We are guaranteed to find this time zone since its existence + is checked during start-up. + */ global_system_variables.time_zone= my_tz_find(&str, thd->lex->time_zone_tables_used); } @@ -2480,6 +2499,7 @@ void sys_var_thd_time_zone::set_default(THD *thd, enum_var_type type) } else thd->variables.time_zone= global_system_variables.time_zone; + pthread_mutex_unlock(&LOCK_global_system_variables); } /* diff --git a/sql/set_var.h b/sql/set_var.h index 4a4e631d88c..df2fd41c7bd 100644 --- a/sql/set_var.h +++ b/sql/set_var.h @@ -736,7 +736,6 @@ public: bool update(THD *thd, set_var *var); byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base); virtual void set_default(THD *thd, enum_var_type type); - Time_zone **get_tz_ptr(THD *thd, enum_var_type type); }; /**************************************************************************** diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 7d26996856d..7434897ab90 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -2405,6 +2405,20 @@ int setup_fields(THD *thd, Item **ref_pointer_array, TABLE_LIST *tables, thd->allow_sum_func= allow_sum_func; thd->where="field list"; + /* + To prevent fail on forward lookup we fill it with zerows, + then if we got pointer on zero after find_item_in_list we will know + that it is forward lookup. + + There is other way to solve problem: fill array with pointers to list, + but it will be slower. + + TODO: remove it when (if) we made one list for allfields and + ref_pointer_array + */ + if (ref_pointer_array) + bzero(ref_pointer_array, sizeof(Item *) * fields.elements); + Item **ref= ref_pointer_array; while ((item= it++)) { diff --git a/sql/sql_cache.cc b/sql/sql_cache.cc index 55e96ec0c6d..e1367412601 100644 --- a/sql/sql_cache.cc +++ b/sql/sql_cache.cc @@ -776,6 +776,8 @@ void Query_cache::store_query(THD *thd, TABLE_LIST *tables_used) bzero(&flags, QUERY_CACHE_FLAGS_SIZE); flags.client_long_flag= (thd->client_capabilities & CLIENT_LONG_FLAG ? 1 : 0); + flags.client_protocol_41= (thd->client_capabilities & CLIENT_PROTOCOL_41 ? + 1 : 0); flags.character_set_client_num= thd->variables.character_set_client->number; flags.character_set_results_num= @@ -968,6 +970,8 @@ Query_cache::send_result_to_client(THD *thd, char *sql, uint query_length) bzero(&flags, QUERY_CACHE_FLAGS_SIZE); flags.client_long_flag= (thd->client_capabilities & CLIENT_LONG_FLAG ? 1 : 0); + flags.client_protocol_41= (thd->client_capabilities & CLIENT_PROTOCOL_41 ? + 1 : 0); flags.character_set_client_num= thd->variables.character_set_client->number; flags.character_set_results_num= (thd->variables.character_set_results ? diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 596097d9dc2..e11d8369f57 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -1240,6 +1240,14 @@ bool select_singlerow_subselect::send_data(List<Item> &items) } +void select_max_min_finder_subselect::cleanup() +{ + DBUG_ENTER("select_max_min_finder_subselect::cleanup"); + cache= 0; + DBUG_VOID_RETURN; +} + + bool select_max_min_finder_subselect::send_data(List<Item> &items) { DBUG_ENTER("select_max_min_finder_subselect::send_data"); diff --git a/sql/sql_class.h b/sql/sql_class.h index ce60ed06cfd..657a92b394c 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -397,6 +397,11 @@ struct system_variables my_bool low_priority_updates; my_bool new_mode; my_bool query_cache_wlock_invalidate; +#ifdef HAVE_REPLICATION + ulong sync_replication; + ulong sync_replication_slave_id; + ulong sync_replication_timeout; +#endif /* HAVE_REPLICATION */ #ifdef HAVE_INNOBASE_DB my_bool innodb_table_locks; #endif /* HAVE_INNOBASE_DB */ @@ -1381,6 +1386,7 @@ public: select_max_min_finder_subselect(Item_subselect *item, bool mx) :select_subselect(item), cache(0), fmax(mx) {} + void cleanup(); bool send_data(List<Item> &items); bool cmp_real(); bool cmp_int(); diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index e0cb43e093e..ed974a48ad3 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -164,7 +164,10 @@ void lex_start(THD *thd, uchar *buf,uint length) void lex_end(LEX *lex) { - lex->select_lex.expr_list.delete_elements(); // If error when parsing sql-varargs + for (SELECT_LEX *sl= lex->all_selects_list; + sl; + sl= sl->next_select_in_list()) + sl->expr_list.delete_elements(); // If error when parsing sql-varargs x_free(lex->yacc_yyss); x_free(lex->yacc_yyvs); } @@ -1718,8 +1721,8 @@ st_lex::st_lex() global_first Save first global table here local_first Save first local table here - NORES - global_first & local_first are used to save result for link_first_table_back + NOTES + This function assumes that outer select list is non-empty. RETURN global list without first table @@ -1729,25 +1732,25 @@ TABLE_LIST *st_lex::unlink_first_table(TABLE_LIST *tables, TABLE_LIST **global_first, TABLE_LIST **local_first) { - *global_first= tables; - *local_first= (TABLE_LIST*)select_lex.table_list.first; + DBUG_ASSERT(select_lex.table_list.first != 0); /* - Exclude from global table list + Save pointers to first elements of global table list and list + of tables used in outer select. It does not harm if these lists + are the same. */ + *global_first= tables; + *local_first= (TABLE_LIST*)select_lex.table_list.first; + + /* Exclude first elements from these lists */ + select_lex.table_list.first= (byte*) (*local_first)->next; tables= tables->next; - /* - and from local list if it is not the same - */ - select_lex.table_list.first= ((&select_lex != all_selects_list) ? - (byte*) (*local_first)->next : - (byte*) tables); (*global_first)->next= 0; return tables; } /* - Link table back that was unlinked with unlink_first_table() + Link table which was unlinked with unlink_first_table() back. SYNOPSIS link_first_table_back() @@ -1763,16 +1766,7 @@ TABLE_LIST *st_lex::link_first_table_back(TABLE_LIST *tables, TABLE_LIST *local_first) { global_first->next= tables; - if (&select_lex != all_selects_list) - { - /* - we do not touch local table 'next' field => we need just - put the table in the list - */ - select_lex.table_list.first= (byte*) local_first; - } - else - select_lex.table_list.first= (byte*) global_first; + select_lex.table_list.first= (byte*) local_first; return global_first; } diff --git a/sql/sql_lex.h b/sql/sql_lex.h index e2e0bc61c23..7cb71607edf 100644 --- a/sql/sql_lex.h +++ b/sql/sql_lex.h @@ -371,6 +371,7 @@ public: ulong init_prepare_fake_select_lex(THD *thd); int change_result(select_subselect *result, select_subselect *old_result); + inline bool is_prepared() { return prepared; } friend void lex_start(THD *thd, uchar *buf, uint length); friend int subselect_union_engine::exec(); diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index d3a5617d01e..e66eeb279d2 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -52,6 +52,8 @@ static int check_for_max_user_connections(THD *thd, USER_CONN *uc); #endif static void decrease_user_connections(USER_CONN *uc); static bool check_db_used(THD *thd,TABLE_LIST *tables); +static bool check_multi_update_lock(THD *thd, TABLE_LIST *tables, + List<Item> *fields, SELECT_LEX *select_lex); static void remove_escape(char *name); static void refresh_status(void); static bool append_file_to_dir(THD *thd, const char **filename_ptr, @@ -658,6 +660,8 @@ static int check_connection(THD *thd) DBUG_PRINT("info", ("New connection received on %s", vio_description(net->vio))); + vio_in_addr(net->vio,&thd->remote.sin_addr); + if (!thd->host) // If TCP/IP connection { char ip[30]; @@ -702,7 +706,6 @@ static int check_connection(THD *thd) DBUG_PRINT("info",("Host: %s",thd->host)); thd->host_or_ip= thd->host; thd->ip= 0; - bzero((char*) &thd->remote, sizeof(struct sockaddr)); } vio_keepalive(net->vio, TRUE); ulong pkt_len= 0; @@ -1883,6 +1886,8 @@ mysql_execute_command(THD *thd) { int res= 0; LEX *lex= thd->lex; + bool slave_fake_lock= 0; + MYSQL_LOCK *fake_prev_lock= 0; SELECT_LEX *select_lex= &lex->select_lex; TABLE_LIST *tables= (TABLE_LIST*) select_lex->table_list.first; SELECT_LEX_UNIT *unit= &lex->unit; @@ -1900,6 +1905,23 @@ mysql_execute_command(THD *thd) #ifdef HAVE_REPLICATION if (thd->slave_thread) { + if (lex->sql_command == SQLCOM_UPDATE_MULTI) + { + DBUG_PRINT("info",("need faked locked tables")); + + if (check_multi_update_lock(thd, tables, &select_lex->item_list, + select_lex)) + goto error; + + /* Fix for replication, the tables are opened and locked, + now we pretend that we have performed a LOCK TABLES action */ + + fake_prev_lock= thd->locked_tables; + if (thd->lock) + thd->locked_tables= thd->lock; + thd->lock= 0; + slave_fake_lock= 1; + } /* Skip if we are in the slave thread, some table rules have been given and the table list says the query should not be replicated @@ -3582,6 +3604,14 @@ purposes internal to the MySQL server", MYF(0)); send_error(thd,thd->killed ? ER_SERVER_SHUTDOWN : 0); error: + if (unlikely(slave_fake_lock)) + { + DBUG_PRINT("info",("undoing faked lock")); + thd->lock= thd->locked_tables; + thd->locked_tables= fake_prev_lock; + if (thd->lock == thd->locked_tables) + thd->lock= 0; + } DBUG_VOID_RETURN; } @@ -5012,6 +5042,58 @@ bool check_simple_select() return 0; } +/* + Setup locking for multi-table updates. Used by the replication slave. + Replication slave SQL thread examines (all_tables_not_ok()) the + locking state of referenced tables to determine if the query has to + be executed or ignored. Since in multi-table update, the + 'default' lock is read-only, this lock is corrected early enough by + calling this function, before the slave decides to execute/ignore. + + SYNOPSIS + check_multi_update_lock() + thd Current thread + tables List of user-supplied tables + fields List of fields requiring update + + RETURN VALUES + 0 ok + 1 error +*/ +static bool check_multi_update_lock(THD *thd, TABLE_LIST *tables, + List<Item> *fields, SELECT_LEX *select_lex) +{ + bool res= 1; + TABLE_LIST *table; + DBUG_ENTER("check_multi_update_lock"); + + if (check_db_used(thd, tables)) + goto error; + + /* + Ensure that we have UPDATE or SELECT privilege for each table + The exact privilege is checked in mysql_multi_update() + */ + for (table= tables ; table ; table= table->next) + { + TABLE_LIST *save= table->next; + table->next= 0; + if ((check_access(thd, UPDATE_ACL, table->db, &table->grant.privilege,0,1) || + (grant_option && check_grant(thd, UPDATE_ACL, table,0,1,1))) && + check_one_table_access(thd, SELECT_ACL, table)) + goto error; + table->next= save; + } + + if (mysql_multi_update_lock(thd, tables, fields, select_lex)) + goto error; + + res= 0; + +error: + DBUG_RETURN(res); +} + Comp_creator *comp_eq_creator(bool invert) { diff --git a/sql/sql_select.cc b/sql/sql_select.cc index ccfcb213068..8353ca9333d 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -1320,7 +1320,7 @@ JOIN::exec() curr_join->select_distinct=0; /* Each row is unique */ curr_join->join_free(0); /* Free quick selects */ - if (select_distinct && ! group_list) + if (curr_join->select_distinct && ! curr_join->group_list) { thd->proc_info="Removing duplicates"; if (curr_join->tmp_having) diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 423a309767b..5f3875ba934 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -2274,6 +2274,8 @@ int mysql_create_like_table(THD* thd, TABLE_LIST* table, { strxmov(src_path, mysql_data_home, "/", src_db, "/", src_table, reg_ext, NullS); + /* Resolve symlinks (for windows) */ + fn_format(src_path, src_path, "", "", MYF(MY_UNPACK_FILENAME)); if (access(src_path, F_OK)) { my_error(ER_BAD_TABLE_ERROR, MYF(0), src_table); @@ -2302,6 +2304,7 @@ int mysql_create_like_table(THD* thd, TABLE_LIST* table, { strxmov(dst_path, mysql_data_home, "/", db, "/", table_name, reg_ext, NullS); + fn_format(dst_path, dst_path, "", "", MYF(MY_UNPACK_FILENAME)); if (!access(dst_path, F_OK)) goto table_exists; } diff --git a/sql/sql_update.cc b/sql/sql_update.cc index c2894a0c86b..663f2d2be34 100644 --- a/sql/sql_update.cc +++ b/sql/sql_update.cc @@ -57,11 +57,11 @@ int mysql_update(THD *thd, enum enum_duplicates handle_duplicates, bool ignore) { - bool using_limit=limit != HA_POS_ERROR; + bool using_limit=limit != HA_POS_ERROR; bool safe_update= thd->options & OPTION_SAFE_UPDATES; bool used_key_is_modified, transactional_table, log_delayed; int error=0; - uint used_index= MAX_KEY; + uint used_index; #ifndef NO_EMBEDDED_ACCESS_CHECKS uint want_privilege; #endif @@ -71,7 +71,7 @@ int mysql_update(THD *thd, TABLE *table; SQL_SELECT *select; READ_RECORD info; - TABLE_LIST *update_table_list= ((TABLE_LIST*) + TABLE_LIST *update_table_list= ((TABLE_LIST*) thd->lex->select_lex.table_list.first); DBUG_ENTER("mysql_update"); @@ -159,14 +159,18 @@ int mysql_update(THD *thd, init_ftfuncs(thd, &thd->lex->select_lex, 1); /* Check if we are modifying a key that we are used to search with */ if (select && select->quick) + { + used_index=select->quick->index; used_key_is_modified= (!select->quick->unique_key_range() && - check_if_key_used(table, - (used_index=select->quick->index), - fields)); + check_if_key_used(table, used_index, fields)); + } else if ((used_index=table->file->key_used_on_scan) < MAX_KEY) used_key_is_modified=check_if_key_used(table, used_index, fields); else + { used_key_is_modified=0; + used_index= MAX_KEY; + } if (used_key_is_modified || order) { /* @@ -464,30 +468,23 @@ static table_map get_table_map(List<Item> *items) } - /* - Setup multi-update handling and call SELECT to do the join + Prepare tables for multi-update + Analyse which tables need specific privileges and perform locking + as required */ -int mysql_multi_update(THD *thd, - TABLE_LIST *table_list, - List<Item> *fields, - List<Item> *values, - COND *conds, - ulong options, - enum enum_duplicates handle_duplicates, bool ignore, - SELECT_LEX_UNIT *unit, SELECT_LEX *select_lex) +int mysql_multi_update_lock(THD *thd, + TABLE_LIST *table_list, + List<Item> *fields, + SELECT_LEX *select_lex) { int res; - multi_update *result; TABLE_LIST *tl; TABLE_LIST *update_list= (TABLE_LIST*) thd->lex->select_lex.table_list.first; - List<Item> total_list; const bool using_lock_tables= thd->locked_tables != 0; bool initialized_dervied= 0; - DBUG_ENTER("mysql_multi_update"); - - select_lex->select_limit= HA_POS_ERROR; + DBUG_ENTER("mysql_multi_update_lock"); /* The following loop is here to to ensure that we only lock tables @@ -593,7 +590,7 @@ int mysql_multi_update(THD *thd, (grant_option && check_grant(thd, wants, tl, 0, 0, 0))) { tl->next= save; - DBUG_RETURN(0); + DBUG_RETURN(1); } tl->next= save; } @@ -616,11 +613,7 @@ int mysql_multi_update(THD *thd, /* Relock the tables with the correct modes */ res= lock_tables(thd, table_list, table_count); if (using_lock_tables) - { - if (res) - DBUG_RETURN(res); break; // Don't have to do setup_field() - } /* We must setup fields again as the file may have been reopened @@ -651,6 +644,32 @@ int mysql_multi_update(THD *thd, */ close_thread_tables(thd); } + + DBUG_RETURN(res); +} + +/* + Setup multi-update handling and call SELECT to do the join +*/ + +int mysql_multi_update(THD *thd, + TABLE_LIST *table_list, + List<Item> *fields, + List<Item> *values, + COND *conds, + ulong options, + enum enum_duplicates handle_duplicates, bool ignore, + SELECT_LEX_UNIT *unit, SELECT_LEX *select_lex) +{ + int res; + TABLE_LIST *tl; + TABLE_LIST *update_list= (TABLE_LIST*) thd->lex->select_lex.table_list.first; + List<Item> total_list; + multi_update *result; + DBUG_ENTER("mysql_multi_update"); + + if ((res= mysql_multi_update_lock(thd, table_list, fields, select_lex))) + DBUG_RETURN(res); /* Setup timestamp handling */ for (tl= update_list; tl; tl= tl->next) diff --git a/sql/tztime.cc b/sql/tztime.cc index 597389220f7..c45271966f9 100644 --- a/sql/tztime.cc +++ b/sql/tztime.cc @@ -1773,7 +1773,13 @@ tz_load_from_open_tables(const String *tz_name, TABLE_LIST *tz_tables) if (table->file->index_read(table->record[0], (byte*)table->field[0]->ptr, 0, HA_READ_KEY_EXACT)) { - sql_print_error("Can't find description of time zone."); +#ifdef EXTRA_DEBUG + /* + Most probably user has mistyped time zone name, so no need to bark here + unless we need it for debugging. + */ + sql_print_error("Can't find description of time zone '%s'", tz_name_buff); +#endif goto end; } @@ -1794,7 +1800,7 @@ tz_load_from_open_tables(const String *tz_name, TABLE_LIST *tz_tables) if (table->file->index_read(table->record[0], (byte*)table->field[0]->ptr, 0, HA_READ_KEY_EXACT)) { - sql_print_error("Can't find description of time zone."); + sql_print_error("Can't find description of time zone '%u'", tzid); goto end; } diff --git a/strings/ctype-big5.c b/strings/ctype-big5.c index 997b8ce93d6..270b02212af 100644 --- a/strings/ctype-big5.c +++ b/strings/ctype-big5.c @@ -271,7 +271,7 @@ static int my_strnncollsp_big5(CHARSET_INFO * cs __attribute__((unused)), if (!res && a_length != b_length) { const uchar *end; - int swap= 0; + int swap= 1; /* Check the next not space character of the longer key. If it's < ' ', then it's smaller than the other key. @@ -286,7 +286,7 @@ static int my_strnncollsp_big5(CHARSET_INFO * cs __attribute__((unused)), for (end= a + a_length-length; a < end ; a++) { if (*a != ' ') - return ((int) *a - (int) ' ') ^ swap; + return (*a < ' ') ? -swap : swap; } } return res; diff --git a/strings/ctype-bin.c b/strings/ctype-bin.c index 95c52512243..618879607ec 100644 --- a/strings/ctype-bin.c +++ b/strings/ctype-bin.c @@ -157,7 +157,7 @@ static int my_strnncollsp_8bit_bin(CHARSET_INFO * cs __attribute__((unused)), } if (a_length != b_length) { - int swap= 0; + int swap= 1; /* Check the next not space character of the longer key. If it's < ' ', then it's smaller than the other key. @@ -172,7 +172,7 @@ static int my_strnncollsp_8bit_bin(CHARSET_INFO * cs __attribute__((unused)), for (end= a + a_length-length; a < end ; a++) { if (*a != ' ') - return ((int) *a - (int) ' ') ^ swap; + return (*a < ' ') ? -swap : swap; } } return 0; diff --git a/strings/ctype-gbk.c b/strings/ctype-gbk.c index 731ad58a2fb..9daa9f90f3c 100644 --- a/strings/ctype-gbk.c +++ b/strings/ctype-gbk.c @@ -2632,7 +2632,7 @@ static int my_strnncollsp_gbk(CHARSET_INFO * cs __attribute__((unused)), if (!res && a_length != b_length) { const uchar *end; - int swap= 0; + int swap= 1; /* Check the next not space character of the longer key. If it's < ' ', then it's smaller than the other key. @@ -2647,7 +2647,7 @@ static int my_strnncollsp_gbk(CHARSET_INFO * cs __attribute__((unused)), for (end= a + a_length-length; a < end ; a++) { if (*a != ' ') - return ((int) *a - (int) ' ') ^ swap; + return (*a < ' ') ? -swap : swap; } } return res; diff --git a/strings/ctype-latin1.c b/strings/ctype-latin1.c index 32d9a227c2f..4ab101add5b 100644 --- a/strings/ctype-latin1.c +++ b/strings/ctype-latin1.c @@ -611,7 +611,7 @@ static int my_strnncollsp_latin1_de(CHARSET_INFO *cs __attribute__((unused)), if (a != a_end || b != b_end) { - int swap= 0; + int swap= 1; /* Check the next not space character of the longer key. If it's < ' ', then it's smaller than the other key. @@ -626,7 +626,7 @@ static int my_strnncollsp_latin1_de(CHARSET_INFO *cs __attribute__((unused)), for ( ; a < a_end ; a++) { if (*a != ' ') - return ((int) *a - (int) ' ') ^ swap; + return (*a < ' ') ? -swap : swap; } } return 0; diff --git a/strings/ctype-mb.c b/strings/ctype-mb.c index 731fc460cef..6cf48291c91 100644 --- a/strings/ctype-mb.c +++ b/strings/ctype-mb.c @@ -389,7 +389,7 @@ static int my_strnncollsp_mb_bin(CHARSET_INFO * cs __attribute__((unused)), } if (a_length != b_length) { - int swap= 0; + int swap= 1; /* Check the next not space character of the longer key. If it's < ' ', then it's smaller than the other key. @@ -404,7 +404,7 @@ static int my_strnncollsp_mb_bin(CHARSET_INFO * cs __attribute__((unused)), for (end= a + a_length-length; a < end ; a++) { if (*a != ' ') - return ((int) *a - (int) ' ') ^ swap; + return (*a < ' ') ? -swap : swap; } } return 0; diff --git a/strings/ctype-simple.c b/strings/ctype-simple.c index 5bfa9e52595..1a09b16a264 100644 --- a/strings/ctype-simple.c +++ b/strings/ctype-simple.c @@ -143,7 +143,7 @@ int my_strnncollsp_simple(CHARSET_INFO * cs, const uchar *a, uint a_length, } if (a_length != b_length) { - int swap= 0; + int swap= 1; /* Check the next not space character of the longer key. If it's < ' ', then it's smaller than the other key. @@ -153,12 +153,12 @@ int my_strnncollsp_simple(CHARSET_INFO * cs, const uchar *a, uint a_length, /* put shorter key in s */ a_length= b_length; a= b; - swap= -1; /* swap sign of result */ + swap= -1; /* swap sign of result */ } for (end= a + a_length-length; a < end ; a++) { if (*a != ' ') - return ((int) *a - (int) ' ') ^ swap; + return (*a < ' ') ? -swap : swap; } } return 0; diff --git a/strings/ctype-sjis.c b/strings/ctype-sjis.c index c0b33a13cdd..0cb30a9b6ee 100644 --- a/strings/ctype-sjis.c +++ b/strings/ctype-sjis.c @@ -251,7 +251,7 @@ static int my_strnncollsp_sjis(CHARSET_INFO *cs __attribute__((unused)), int res= my_strnncoll_sjis_internal(cs, &a, a_length, &b, b_length); if (!res && (a != a_end || b != b_end)) { - int swap= 0; + int swap= 1; /* Check the next not space character of the longer key. If it's < ' ', then it's smaller than the other key. @@ -266,7 +266,7 @@ static int my_strnncollsp_sjis(CHARSET_INFO *cs __attribute__((unused)), for (; a < a_end ; a++) { if (*a != ' ') - return ((int) *a - (int) ' ') ^ swap; + return (*a < ' ') ? -swap : swap; } } return res; diff --git a/strings/ctype-tis620.c b/strings/ctype-tis620.c index 3a43c556ac8..6a6c55d214e 100644 --- a/strings/ctype-tis620.c +++ b/strings/ctype-tis620.c @@ -589,7 +589,7 @@ int my_strnncollsp_tis620(CHARSET_INFO * cs __attribute__((unused)), } if (a_length != b_length) { - int swap= 0; + int swap= 1; /* Check the next not space character of the longer key. If it's < ' ', then it's smaller than the other key. @@ -605,7 +605,7 @@ int my_strnncollsp_tis620(CHARSET_INFO * cs __attribute__((unused)), { if (*a != ' ') { - res= ((int) *a - (int) ' ') ^ swap; + res= (*a < ' ') ? -swap : swap; goto ret; } } diff --git a/strings/ctype-ucs2.c b/strings/ctype-ucs2.c index 936e2b6fdce..ea11f8816a5 100644 --- a/strings/ctype-ucs2.c +++ b/strings/ctype-ucs2.c @@ -275,7 +275,7 @@ static int my_strnncollsp_ucs2(CHARSET_INFO *cs __attribute__((unused)), if (slen != tlen) { - int swap= 0; + int swap= 1; if (slen < tlen) { s= t; @@ -286,7 +286,7 @@ static int my_strnncollsp_ucs2(CHARSET_INFO *cs __attribute__((unused)), for ( ; s < se ; s+= 2) { if (s[0] || s[1] != ' ') - return (((int)s[0] << 8) + (int) s[1] - (int) ' ') ^ swap; + return (s[0] == 0 && s[1] < ' ') ? -swap : swap; } } return 0; diff --git a/strings/ctype-utf8.c b/strings/ctype-utf8.c index 502d0ec285e..486d428bf1d 100644 --- a/strings/ctype-utf8.c +++ b/strings/ctype-utf8.c @@ -2077,7 +2077,7 @@ static int my_strnncollsp_utf8(CHARSET_INFO *cs, if (slen != tlen) { - int swap= 0; + int swap= 1; if (slen < tlen) { slen= tlen; @@ -2098,7 +2098,7 @@ static int my_strnncollsp_utf8(CHARSET_INFO *cs, for ( ; s < se; s++) { if (*s != ' ') - return ((int)*s - (int) ' ') ^ swap; + return (*s < ' ') ? -swap : swap; } } return 0; diff --git a/support-files/Makefile.am b/support-files/Makefile.am index 7ae1071f9ec..0a6077f0efc 100644 --- a/support-files/Makefile.am +++ b/support-files/Makefile.am @@ -27,7 +27,8 @@ EXTRA_DIST = mysql.spec.sh \ mysql.server.sh \ binary-configure.sh \ magic \ - MySQL-shared-compat.spec.sh + MySQL-shared-compat.spec.sh \ + ndb-config-2-node.ini.sh SUBDIRS = MacOSX @@ -38,7 +39,8 @@ pkgdata_DATA = my-small.cnf \ my-innodb-heavy-4G.cnf \ mysql-log-rotate \ mysql-@VERSION@.spec \ - MySQL-shared-compat.spec + MySQL-shared-compat.spec \ + ndb-config-2-node.ini pkgdata_SCRIPTS = mysql.server @@ -52,7 +54,8 @@ CLEANFILES = my-small.cnf \ mysql-log-rotate \ mysql.server \ binary-configure \ - MySQL-shared-compat.spec + MySQL-shared-compat.spec \ + ndb-config-2-node.ini mysql-@VERSION@.spec: mysql.spec rm -f $@ diff --git a/support-files/mysql.spec.sh b/support-files/mysql.spec.sh index 99280385965..0d72356731c 100644 --- a/support-files/mysql.spec.sh +++ b/support-files/mysql.spec.sh @@ -104,6 +104,53 @@ This package contains the standard MySQL clients and administration tools. %description client -l pt_BR Este pacote contém os clientes padrão para o MySQL. +%package ndb-storage +Release: %{release} +Summary: MySQL - ndbcluster storage engine +Group: Applications/Databases + +%description ndb-storage +This package contains the ndbcluster storage engine. +It is necessary to have this package installed on all +computers that should store ndbcluster table data. +Note that this storage engine can only be used in conjunction +with the MySQL Max server. + +%{see_base} + +%package ndb-management +Release: %{release} +Summary: MySQL - ndbcluster storage engine management +Group: Applications/Databases + +%description ndb-management +This package contains ndbcluster storage engine management. +It is necessary to have this package installed on at least +one computer in the cluster. + +%{see_base} + +%package ndb-tools +Release: %{release} +Summary: MySQL - ndbcluster storage engine basic tools +Group: Applications/Databases + +%description ndb-tools +This package contains ndbcluster storage engine basic tools. + +%{see_base} + +%package ndb-extra +Release: %{release} +Summary: MySQL - ndbcluster storage engine extra tools +Group: Applications/Databases + +%description ndb-extra +This package contains some extra ndbcluster storage engine tools for the advanced user. +They should be used with caution. + +%{see_base} + %package bench Release: %{release} Requires: %{name}-client perl-DBI perl @@ -162,6 +209,7 @@ Requires: MySQL-server >= 4.0 Optional MySQL server binary that supports additional features like: - Berkeley DB Storage Engine + - Ndbcluster Storage Engine interface - Archive Storage Engine - CSV Storage Engine - Example Storage Engine @@ -279,6 +327,7 @@ BuildMySQL "--enable-shared \ --without-openssl \ --with-berkeley-db \ --with-innodb \ + --with-ndbcluster \ --with-raid \ --with-archive \ --with-csv-storage-engine \ @@ -293,6 +342,9 @@ BuildMySQL "--enable-shared \ mv sql/mysqld sql/mysqld-max nm --numeric-sort sql/mysqld-max > sql/mysqld-max.sym +# Install the ndb binaries +(cd ndb; make install DESTDIR=$RBR) + # Install embedded server library in the build root install -m 644 libmysqld/libmysqld.a $RBR%{_libdir}/mysql/ @@ -435,6 +487,21 @@ chmod -R og-rw $mysql_datadir/mysql # Allow safe_mysqld to start mysqld and print a message before we exit sleep 2 + +%pre ndb-storage +mysql_clusterdir=/var/lib/mysql-cluster + +# Create cluster directory if needed +if test ! -d $mysql_clusterdir; then mkdir -m755 $mysql_clusterdir; fi + + +%pre ndb-storage +mysql_clusterdir=/var/lib/mysql-cluster + +# Create cluster directory if needed +if test ! -d $mysql_clusterdir; then mkdir -m755 $mysql_clusterdir; fi + + %post Max # Restart mysqld, to use the new binary. echo "Restarting mysqld." @@ -475,6 +542,7 @@ fi %doc Docs/manual.{html,ps,texi,txt} %doc Docs/manual_toc.html %doc support-files/my-*.cnf +%doc support-files/ndb-*.ini %doc %attr(644, root, root) %{_infodir}/mysql.info* @@ -556,6 +624,32 @@ fi %postun shared /sbin/ldconfig +%files ndb-storage +%defattr(-,root,root,0755) +%attr(755, root, root) %{_sbindir}/ndbd + +%files ndb-management +%defattr(-,root,root,0755) +%attr(755, root, root) %{_sbindir}/ndb_mgmd +%attr(755, root, root) %{_bindir}/ndb_mgm + +%files ndb-tools +%defattr(-,root,root,0755) +%attr(755, root, root) %{_bindir}/ndb_mgm +%attr(755, root, root) %{_bindir}/ndb_restore +%attr(755, root, root) %{_bindir}/ndb_waiter +%attr(755, root, root) %{_bindir}/ndb_select_all +%attr(755, root, root) %{_bindir}/ndb_select_count +%attr(755, root, root) %{_bindir}/ndb_desc +%attr(755, root, root) %{_bindir}/ndb_show_tables +%attr(755, root, root) %{_bindir}/ndb_test_platform + +%files ndb-extra +%defattr(-,root,root,0755) +%attr(755, root, root) %{_bindir}/ndb_drop_index +%attr(755, root, root) %{_bindir}/ndb_drop_table +%attr(755, root, root) %{_bindir}/ndb_delete_all + %files devel %defattr(-, root, root, 0755) %doc EXCEPTIONS-CLIENT diff --git a/support-files/ndb-config-2-node.ini.sh b/support-files/ndb-config-2-node.ini.sh new file mode 100644 index 00000000000..be80f1dd0b3 --- /dev/null +++ b/support-files/ndb-config-2-node.ini.sh @@ -0,0 +1,43 @@ +# Example Ndbcluster storage engine config file. +# +[ndbd default] +NoOfReplicas= 2 +MaxNoOfConcurrentOperations= 10000 +DataMemory= 80M +IndexMemory= 24M +TimeBetweenWatchDogCheck= 30000 +DataDir= /var/lib/mysql-cluster +MaxNoOfOrderedIndexes= 512 + +[ndb_mgmd default] +DataDir= /var/lib/mysql-cluster + +[ndb_mgmd] +Id=1 +HostName= localhost + +[ndbd] +Id= 2 +HostName= localhost + +[ndbd] +Id= 3 +HostName= localhost + +[mysqld] +Id= 4 + +[mysqld] +Id= 5 + +[mysqld] +Id= 6 + +[mysqld] +Id= 7 + +# choose an unused port number +# in this configuration 63132, 63133, and 63134 +# will be used +[tcp default] +PortNumber= 63132 diff --git a/vio/viosocket.c b/vio/viosocket.c index 202d70b6c26..fee97daa943 100644 --- a/vio/viosocket.c +++ b/vio/viosocket.c @@ -276,7 +276,7 @@ void vio_in_addr(Vio *vio, struct in_addr *in) { DBUG_ENTER("vio_in_addr"); if (vio->localhost) - bzero((char*) in, sizeof(*in)); /* This should never be executed */ + bzero((char*) in, sizeof(*in)); else *in=vio->remote.sin_addr; DBUG_VOID_RETURN; diff --git a/vio/viossl.c b/vio/viossl.c index a489cb98f98..07713c83763 100644 --- a/vio/viossl.c +++ b/vio/viossl.c @@ -259,7 +259,7 @@ void vio_ssl_in_addr(Vio *vio, struct in_addr *in) { DBUG_ENTER("vio_ssl_in_addr"); if (vio->localhost) - bzero((char*) in, sizeof(*in)); /* This should never be executed */ + bzero((char*) in, sizeof(*in)); else *in=vio->remote.sin_addr; DBUG_VOID_RETURN; |