diff options
author | Chad MILLER <chad@mysql.com> | 2009-03-12 11:57:47 -0400 |
---|---|---|
committer | Chad MILLER <chad@mysql.com> | 2009-03-12 11:57:47 -0400 |
commit | 955fb852498158ad72ec2ec7bc39f4f4e8741edd (patch) | |
tree | 0e7e82e23b316da322dc810c4d1f920dffbde783 | |
parent | 5139538c9cf16336ab495c4a51fd5421329a6d22 (diff) | |
parent | 8cbd34f0d7a08f112ca4fb900bda31aeaf0703f1 (diff) | |
download | mariadb-git-955fb852498158ad72ec2ec7bc39f4f4e8741edd.tar.gz |
Merge fix and upstream.
39 files changed, 1058 insertions, 498 deletions
diff --git a/include/my_md5.h b/include/my_md5.h index f92976b3beb..6458f27c5cc 100644 --- a/include/my_md5.h +++ b/include/my_md5.h @@ -13,80 +13,42 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +/* See md5.c for explanation and copyright information. */ -/* MD5.H - header file for MD5C.C +/* + * $FreeBSD: src/contrib/cvs/lib/md5.h,v 1.2 1999/12/11 15:10:02 peter Exp $ */ -/* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All -rights reserved. +/* Unlike previous versions of this code, uint32 need not be exactly + 32 bits, merely 32 bits or more. Choosing a data type which is 32 + bits instead of 64 is not important; speed is considerably more + important. ANSI guarantees that "unsigned long" will be big enough, + and always using it seems to have few disadvantages. */ +typedef uint32 cvs_uint32; -License to copy and use this software is granted provided that it -is identified as the "RSA Data Security, Inc. MD5 Message-Digest -Algorithm" in all material mentioning or referencing this software -or this function. - -License is also granted to make and use derivative works provided -that such works are identified as "derived from the RSA Data -Security, Inc. MD5 Message-Digest Algorithm" in all material -mentioning or referencing the derived work. - -RSA Data Security, Inc. makes no representations concerning either -the merchantability of this software or the suitability of this -software for any particular purpose. It is provided "as is" -without express or implied warranty of any kind. - -These notices must be retained in any copies of any part of this -documentation and/or software. - */ - -/* GLOBAL.H - RSAREF types and constants - */ - -/* PROTOTYPES should be set to one if and only if the compiler supports - function argument prototyping. -The following makes PROTOTYPES default to 0 if it has not already - been defined with C compiler flags. - */ - -/* egcs 1.1.2 under linux didn't defined it.... :( */ - -#ifndef PROTOTYPES -#define PROTOTYPES 1 /* Assume prototypes */ -#endif - -/* POINTER defines a generic pointer type */ -typedef unsigned char *POINTER; - -/* UINT2 defines a two byte word */ -typedef uint16 UINT2; /* Fix for MySQL / Alpha */ - -/* UINT4 defines a four byte word */ -typedef uint32 UINT4; /* Fix for MySQL / Alpha */ - -/* PROTO_LIST is defined depending on how PROTOTYPES is defined above. -If using PROTOTYPES, then PROTO_LIST returns the list, otherwise it - returns an empty list. - */ -#if PROTOTYPES -#define PROTO_LIST(list) list -#else -#define PROTO_LIST(list) () -#endif -/* MD5 context. */ typedef struct { - UINT4 state[4]; /* state (ABCD) */ - UINT4 count[2]; /* number of bits, modulo 2^64 (lsb first) */ - unsigned char buffer[64]; /* input buffer */ -} my_MD5_CTX; + cvs_uint32 buf[4]; + cvs_uint32 bits[2]; + unsigned char in[64]; +} my_MD5Context; #ifdef __cplusplus extern "C" { #endif - void my_MD5Init PROTO_LIST ((my_MD5_CTX *)); - void my_MD5Update PROTO_LIST - ((my_MD5_CTX *, unsigned char *, unsigned int)); - void my_MD5Final PROTO_LIST ((unsigned char [16], my_MD5_CTX *)); +void my_MD5Init (my_MD5Context *context); +void my_MD5Update (my_MD5Context *context, + unsigned char const *buf, unsigned len); +void my_MD5Final (unsigned char digest[16], + my_MD5Context *context); #ifdef __cplusplus } #endif + +#define MY_MD5_HASH(digest,buf,len) \ +do { \ + my_MD5Context ctx; \ + my_MD5Init (&ctx); \ + my_MD5Update (&ctx, buf, len); \ + my_MD5Final (digest, &ctx); \ +} while (0) diff --git a/mysql-test/Makefile.am b/mysql-test/Makefile.am index 60679e5b06d..5e3582d5e16 100644 --- a/mysql-test/Makefile.am +++ b/mysql-test/Makefile.am @@ -71,11 +71,11 @@ SUBDIRS = lib/My/SafeProcess EXTRA_DIST = README \ valgrind.supp \ $(test_SCRIPTS) \ - $(nobase_test_DATA) + $(nobase_test_DATA) # List of directories containing test + result files and the # related test data files that should be copied -TEST_DIRS = t r include std_data std_data/parts \ +TEST_DIRS = t r include std_data std_data/parts collections \ std_data/ndb_backup50 std_data/ndb_backup51 \ std_data/ndb_backup51_data_be std_data/ndb_backup51_data_le \ std_data/funcs_1 \ diff --git a/mysql-test/collections/README b/mysql-test/collections/README new file mode 100644 index 00000000000..9af84646a40 --- /dev/null +++ b/mysql-test/collections/README @@ -0,0 +1,30 @@ +This directory contains collections of test runs that we run during our +integration and release testing. Each file contains zero or more lines, +with one invocation of mysql-test-run.pl on each. These invocations are +written so that, with the assumption that perl is in your search path, +any collection can run as a shell script or a batch file, with the parent +mysql-test directory being the current working directory. + +During integration testing, we choose the collection to run by following +these steps: + +1) We choose the extension to look for, based on these rules: + - If we're running a per-push test, we choose ".push" as the extension. + - If we're running a daily test, we choose ".daily" as the extension. + - If we're running a weekly test, we choose ".weekly" as the extension. + +2) If there is a collection that has the same name as the branch we're + testing plus the extension as determined in step 1, we choose that + collection. + +3) If the branch is unknown or we have removed all characters from it + and still not found a matching collection, we choose the name "default" + plus the extension determined in step 1. If there is no such file, + we give up and don't test anything at all. + +4) If we haven't found a collection yet, we remove the last character from + the branch name and go back to step 2. + +5) The commands from the collection are run line by line via execv() or + similar system calls. They are not run as a shell script. Shell + expansions are not guaranteed to work and most likely won't. diff --git a/mysql-test/collections/README.experimental b/mysql-test/collections/README.experimental new file mode 100644 index 00000000000..9eee2394423 --- /dev/null +++ b/mysql-test/collections/README.experimental @@ -0,0 +1,25 @@ +The .experimental files in this directory contain names of test cases that +are still in development and whose failures should be considered expected, +instead of regressions. + +These files are to be used with the --experimental option of +mysql-test-run.pl. Please look at its help screen for usage information. + +The syntax is as follows: + +1) One line per test case. + +2) Empty lines and lines starting with a hash (#) are ignored. + +3) If any other line contains a blank followed by a hash (#), the hash + and any subsequent characters are ignored. + +4) The full test case name including the suite and execution mode + must be specified, for example: + main.alias 'row' # bug#00000 + +5) As an exception to item 4, the last character of the test case + specification may be an asterisk (*). In that case, all test cases that + start with the same characters up to the last letter before the asterisk + are considered experimental: + main.a* # get rid of main.alias, main.alibaba and main.agliolio diff --git a/mysql-test/collections/default.daily b/mysql-test/collections/default.daily new file mode 100644 index 00000000000..194cc2aad59 --- /dev/null +++ b/mysql-test/collections/default.daily @@ -0,0 +1 @@ +perl mysql-test-run.pl --timer --force --comment=rpl_ndb_row --suite=rpl_ndb,ndb --mysqld=--binlog-format=row --experimental=collections/default.experimental diff --git a/mysql-test/collections/default.experimental b/mysql-test/collections/default.experimental new file mode 100644 index 00000000000..103069f79cf --- /dev/null +++ b/mysql-test/collections/default.experimental @@ -0,0 +1 @@ +funcs_1.charset_collation_1 # depends on compile-time decisions diff --git a/mysql-test/collections/default.push b/mysql-test/collections/default.push new file mode 100644 index 00000000000..0879b6fde2c --- /dev/null +++ b/mysql-test/collections/default.push @@ -0,0 +1,5 @@ +perl mysql-test-run.pl --timer --force --comment=n_mix --mysqld=--binlog-format=mixed --experimental=collections/default.experimental +perl mysql-test-run.pl --timer --force --comment=ps_row --ps-protocol --mysqld=--binlog-format=row --experimental=collections/default.experimental +perl mysql-test-run.pl --timer --force --comment=embedded --embedded --experimental=collections/default.experimental +perl mysql-test-run.pl --timer --force --comment=rpl_binlog_row --suite=rpl,binlog --mysqld=--binlog-format=row --experimental=collections/default.experimental +perl mysql-test-run.pl --timer --force --comment=funcs_1 --suite=funcs_1 --experimental=collections/default.experimental diff --git a/mysql-test/collections/default.weekly b/mysql-test/collections/default.weekly new file mode 100644 index 00000000000..e69de29bb2d --- /dev/null +++ b/mysql-test/collections/default.weekly diff --git a/mysql-test/include/check-warnings.test b/mysql-test/include/check-warnings.test index 2144957f742..5295dd51a85 100644 --- a/mysql-test/include/check-warnings.test +++ b/mysql-test/include/check-warnings.test @@ -26,7 +26,7 @@ create temporary table error_log ( ) engine=myisam; # Get the name of servers error log -let $log_error= query_get_value(show variables like 'log_error', Value, 1); +let $log_error= $MTR_LOG_ERROR; let $log_warning= $log_error.warnings; # Try tload the warnings into a temporary table, diff --git a/mysql-test/lib/My/ConfigFactory.pm b/mysql-test/lib/My/ConfigFactory.pm index 567a05ac7a1..852f706c858 100644 --- a/mysql-test/lib/My/ConfigFactory.pm +++ b/mysql-test/lib/My/ConfigFactory.pm @@ -116,8 +116,8 @@ sub fix_tmpdir { sub fix_log_error { my ($self, $config, $group_name, $group)= @_; - my $dir= dirname($group->value('datadir')); - return "$dir/mysqld.err"; + my $dir= $self->{ARGS}->{vardir}; + return "$dir/log/$group_name.err"; } sub fix_log { @@ -203,7 +203,7 @@ my @mysqld_rules= { '#host' => \&fix_host }, { 'port' => \&fix_port }, { 'socket' => \&fix_socket }, - { 'log-error' => \&fix_log_error }, + { '#log-error' => \&fix_log_error }, { 'log' => \&fix_log }, { 'log-slow-queries' => \&fix_log_slow_queries }, { '#user' => sub { return shift->{ARGS}->{user} || ""; } }, @@ -389,7 +389,7 @@ sub post_check_embedded_group { my @no_copy = ( - 'log-error', # Embedded server writes stderr to mysqltest's log file + '#log-error', # Embedded server writes stderr to mysqltest's log file 'slave-net-timeout', # Embedded server are not build with replication ); diff --git a/mysql-test/lib/My/Platform.pm b/mysql-test/lib/My/Platform.pm index 3dd5c552b10..69ffdfbb4ce 100644 --- a/mysql-test/lib/My/Platform.pm +++ b/mysql-test/lib/My/Platform.pm @@ -113,8 +113,8 @@ sub check_socket_path_length { # Create a tempfile name with same length as "path" my $tmpdir = tempdir( CLEANUP => 0); - my $len = length($path) - length($tmpdir); - my $testfile = $tmpdir . "x" x ($len > 0 ? $len : 1); + my $len = length($path) - length($tmpdir) - 1; + my $testfile = $tmpdir . "/" . "x" x ($len > 0 ? $len : 1); my $sock; eval { $sock= new IO::Socket::UNIX @@ -126,17 +126,15 @@ sub check_socket_path_length { die "Could not create UNIX domain socket: $!" unless defined $sock; - die "UNIX domain socket patch was truncated" + die "UNIX domain socket path was truncated" unless ($testfile eq $sock->hostpath()); $truncated= 0; # Yes, it worked! }; - #print "check_socket_path_length, failed: ", $@, '\n' if ($@); $sock= undef; # Close socket - unlink($testfile); # Remove the physical file - rmdir($tmpdir); # Remove the tempdir + rmtree($tmpdir); # Remove the tempdir and any socket file created return $truncated; } diff --git a/mysql-test/lib/My/SafeProcess.pm b/mysql-test/lib/My/SafeProcess.pm index 0e3aa968052..5ef3286ad8e 100644 --- a/mysql-test/lib/My/SafeProcess.pm +++ b/mysql-test/lib/My/SafeProcess.pm @@ -117,6 +117,7 @@ sub new { my $output = delete($opts{'output'}); my $error = delete($opts{'error'}); my $verbose = delete($opts{'verbose'}); + my $nocore = delete($opts{'nocore'}); my $host = delete($opts{'host'}); my $shutdown = delete($opts{'shutdown'}); my $user_data= delete($opts{'user_data'}); @@ -137,6 +138,7 @@ sub new { push(@safe_args, $safe_script) if defined $safe_script; push(@safe_args, "--verbose") if $verbose > 0; + push(@safe_args, "--nocore") if $nocore; # Point the safe_process at the right parent if running on cygwin push(@safe_args, "--parent-pid=".Cygwin::pid_to_winpid($$)) if IS_CYGWIN; diff --git a/mysql-test/lib/My/SafeProcess/safe_process.cc b/mysql-test/lib/My/SafeProcess/safe_process.cc index 7932f3fd2d6..6ad45a3226e 100644 --- a/mysql-test/lib/My/SafeProcess/safe_process.cc +++ b/mysql-test/lib/My/SafeProcess/safe_process.cc @@ -45,6 +45,7 @@ #include <sys/types.h> #include <sys/wait.h> +#include <sys/resource.h> #include <unistd.h> #include <stdarg.h> #include <stdio.h> @@ -149,7 +150,8 @@ int main(int argc, char* const argv[] ) char* const* child_argv= 0; pid_t own_pid= getpid(); pid_t parent_pid= getppid(); - + bool nocore = false; + /* Install signal handlers */ signal(SIGTERM, handle_signal); signal(SIGINT, handle_signal); @@ -181,6 +183,9 @@ int main(int argc, char* const argv[] ) start++; /* Step past = */ if ((parent_pid= atoi(start)) == 0) die("Invalid value '%s' passed to --parent-id", start); + } else if ( strcmp(arg, "--nocore") == 0 ) + { + nocore = true; // Don't allow the process to dump core } else die("Unknown option: %s", arg); @@ -218,6 +223,15 @@ int main(int argc, char* const argv[] ) // it and any childs(that hasn't changed group themself) setpgid(0, 0); + if (nocore) + { + struct rlimit corelim = { 0, 0 }; + if (setrlimit (RLIMIT_CORE, &corelim) < 0) + { + message("setrlimit failed, errno=%d", errno); + } + } + // Signal that child is ready buf= 37; write(pfd[1], &buf, 1); diff --git a/mysql-test/lib/mtr_report.pm b/mysql-test/lib/mtr_report.pm index ce3fba87385..9c6ab35ee5e 100644 --- a/mysql-test/lib/mtr_report.pm +++ b/mysql-test/lib/mtr_report.pm @@ -69,6 +69,8 @@ sub _mtr_report_test_name ($) { print _name(), _timestamp(); printf "%-40s ", $tname; + + return $tname; } @@ -105,20 +107,48 @@ sub mtr_report_test_passed ($) { sub mtr_report_test ($) { my ($tinfo)= @_; - _mtr_report_test_name($tinfo); + my $test_name = _mtr_report_test_name($tinfo); my $comment= $tinfo->{'comment'}; my $logfile= $tinfo->{'logfile'}; my $warnings= $tinfo->{'warnings'}; my $result= $tinfo->{'result'}; + my $retry= $tinfo->{'retries'} ? "retry-" : ""; if ($result eq 'MTR_RES_FAILED'){ my $timest = format_time(); + my $fail = "fail"; + + if ( $::opt_experimental ) + { + # Find out if this test case is an experimental one, so we can treat + # the failure as an expected failure instead of a regression. + for my $exp ( @$::experimental_test_cases ) { + if ( $exp ne $test_name ) { + # if the expression is not the name of this test case, but has + # an asterisk at the end, determine if the characters up to + # but excluding the asterisk are the same + if ( $exp ne "" && substr($exp, -1, 1) eq "*" ) { + $exp = substr($exp, 0, length($exp) - 1); + if ( substr($test_name, 0, length($exp)) ne $exp ) { + # no match, try next entry + next; + } + # if yes, fall through to set the exp-fail status + } else { + # no match, try next entry + next; + } + } + $fail = "exp-fail"; + last; + } + } if ( $warnings ) { - mtr_report("[ fail ] Found warnings/errors in server log file!"); + mtr_report("[ $retry$fail ] Found warnings/errors in server log file!"); mtr_report(" Test ended at $timest"); mtr_report($warnings); return; @@ -126,14 +156,14 @@ sub mtr_report_test ($) { my $timeout= $tinfo->{'timeout'}; if ( $timeout ) { - mtr_report("[ fail ] timeout after $timeout seconds"); + mtr_report("[ $retry$fail ] timeout after $timeout seconds"); mtr_report(" Test ended at $timest"); mtr_report("\n$tinfo->{'comment'}"); return; } else { - mtr_report("[ fail ]\n Test ended at $timest"); + mtr_report("[ $retry$fail ]\n Test ended at $timest"); } if ( $logfile ) @@ -176,7 +206,7 @@ sub mtr_report_test ($) { { my $timer_str= $tinfo->{timer} || ""; $tot_real_time += ($timer_str/1000); - mtr_report("[ pass ] ", sprintf("%5s", $timer_str)); + mtr_report("[ ${retry}pass ] ", sprintf("%5s", $timer_str)); # Show any problems check-testcase found if ( defined $tinfo->{'check'} ) diff --git a/mysql-test/lib/mtr_unique.pm b/mysql-test/lib/mtr_unique.pm index 2ac172883a2..294a5d7b4d6 100644 --- a/mysql-test/lib/mtr_unique.pm +++ b/mysql-test/lib/mtr_unique.pm @@ -188,6 +188,8 @@ sub mtr_release_unique_id($) { flock SEM, LOCK_UN or warn "can't unlock $file.sem"; close SEM; + + delete $mtr_unique_ids{$$}; } diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index b07d1539844..c5a68662d5b 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -181,12 +181,18 @@ our $opt_client_debugger; my $config; # The currently running config my $current_config_name; # The currently running config file template +our $opt_experimental; +our $experimental_test_cases; + my $baseport; my $opt_build_thread= $ENV{'MTR_BUILD_THREAD'} || "auto"; +my $build_thread= 0; my $opt_record; my $opt_report_features; +my $opt_skip_core; + our $opt_check_testcases= 1; my $opt_mark_progress; @@ -677,14 +683,9 @@ sub run_worker ($) { report_option('name',"worker[$thread_num]"); # -------------------------------------------------------------------------- - # Use auto build thread in all but first worker + # Set different ports per thread # -------------------------------------------------------------------------- - set_build_thread_ports($thread_num > 1 ? 'auto' : $opt_build_thread); - - if (check_ports_free()){ - # Some port was not free(which one has already been printed) - mtr_error("Some port(s) was not free") - } + set_build_thread_ports($thread_num); # -------------------------------------------------------------------------- # Turn off verbosity in workers, unless explicitly specified @@ -804,7 +805,7 @@ sub command_line_setup { 'big-test' => \$opt_big_test, 'combination=s' => \@opt_combinations, 'skip-combinations' => \&collect_option, - + 'experimental=s' => \$opt_experimental, 'skip-im' => \&ignore_option, # Specify ports @@ -944,12 +945,12 @@ sub command_line_setup { } # Look for language files and charsetsdir, use same share - my $path_share= mtr_path_exists("$basedir/share/mysql", - "$basedir/sql/share", - "$basedir/share"); + $path_language= mtr_path_exists("$basedir/share/mysql/english", + "$basedir/sql/share/english", + "$basedir/share/english"); - - $path_language= mtr_path_exists("$path_share/english"); + + my $path_share= dirname($path_language); $path_charsetsdir= mtr_path_exists("$path_share/charsets"); if (using_extern()) @@ -971,6 +972,33 @@ sub command_line_setup { mtr_print_thick_line('#'); } + if ( $opt_experimental ) + { + # read the list of experimental test cases from the file specified on + # the command line + open(FILE, "<", $opt_experimental) or mtr_error("Can't read experimental file: $opt_experimental"); + mtr_report("Using experimental file: $opt_experimental"); + $experimental_test_cases = []; + while(<FILE>) { + chomp; + # remove comments (# foo) at the beginning of the line, or after a + # blank at the end of the line + s/( +|^)#.*$//; + # remove whitespace + s/^ +//; + s/ +$//; + # if nothing left, don't need to remember this line + if ( $_ eq "" ) { + next; + } + # remember what is left as the name of another test case that should be + # treated as experimental + print " - $_\n"; + push @$experimental_test_cases, $_; + } + close FILE; + } + foreach my $arg ( @ARGV ) { if ( $arg =~ /^--skip-/ ) @@ -1095,6 +1123,14 @@ sub command_line_setup { } # -------------------------------------------------------------------------- + # Check parallel value + # -------------------------------------------------------------------------- + if ($opt_parallel < 1) + { + mtr_error("0 or negative parallel value makes no sense, use positive number"); + } + + # -------------------------------------------------------------------------- # Record flag # -------------------------------------------------------------------------- if ( $opt_record and ! @opt_cases ) @@ -1283,18 +1319,32 @@ sub command_line_setup { # But a fairly safe range seems to be 5001 - 32767 # sub set_build_thread_ports($) { - my $build_thread= shift || 0; + my $thread= shift || 0; - if ( lc($build_thread) eq 'auto' ) { - #mtr_report("Requesting build thread... "); - $build_thread= mtr_get_unique_id(250, 299); - if ( !defined $build_thread ) { - mtr_error("Could not get a unique build thread id"); + if ( lc($opt_build_thread) eq 'auto' ) { + my $found_free = 0; + $build_thread = 250; # Start attempts from here + while (! $found_free) + { + $build_thread= mtr_get_unique_id($build_thread, 299); + if ( !defined $build_thread ) { + mtr_error("Could not get a unique build thread id"); + } + $found_free= check_ports_free($build_thread); + # If not free, release and try from next number + mtr_release_unique_id($build_thread++) unless $found_free; } - #mtr_report(" - got $build_thread"); + } + else + { + $build_thread = $opt_build_thread + $thread - 1; } $ENV{MTR_BUILD_THREAD}= $build_thread; - $opt_build_thread= $build_thread; + + if (! check_ports_free($build_thread)) { + # Some port was not free(which one has already been printed) + mtr_error("Some port(s) was not free") + } # Calculate baseport $baseport= $build_thread * 10 + 10000; @@ -2448,22 +2498,18 @@ sub kill_leftovers ($) { # Check that all the ports that are going to # be used are free # -sub check_ports_free +sub check_ports_free ($) { - my @ports_to_check; - for ($baseport..$baseport+9){ - push(@ports_to_check, $_); - } - #mtr_report("Checking ports..."); - # print "@ports_to_check\n"; - foreach my $port (@ports_to_check){ - if (mtr_ping_port($port)){ - mtr_report(" - 'localhost:$port' was not free"); - return 1; # One port was not free + my $bthread= shift; + my $portbase = $bthread * 10 + 10000; + for ($portbase..$portbase+9){ + if (mtr_ping_port($_)){ + mtr_report(" - 'localhost:$_' was not free"); + return 0; # One port was not free } } - return 0; # All ports free + return 1; # All ports free } @@ -3482,7 +3528,10 @@ sub start_check_warnings ($$) { my $name= "warnings-".$mysqld->name(); - extract_warning_lines($mysqld->value('log-error')); + my $log_error= $mysqld->value('#log-error'); + # To be communicated to the test + $ENV{MTR_LOG_ERROR}= $log_error; + extract_warning_lines($log_error); my $args; mtr_init_args(\$args); @@ -3957,6 +4006,7 @@ sub mysqld_arguments ($$$) { mtr_add_arg($args, "%s", $arg); } } + $opt_skip_core = $found_skip_core; if ( !$found_skip_core ) { mtr_add_arg($args, "%s", "--core-file"); @@ -3996,6 +4046,12 @@ sub mysqld_start ($$) { $path_vardir_trace, $mysqld->name()); } + if (IS_WINDOWS) + { + # Trick the server to send output to stderr, with --console + mtr_add_arg($args, "--console"); + } + if ( $opt_gdb || $opt_manual_gdb ) { gdb_arguments(\$args, \$exe, $mysqld->name()); @@ -4028,7 +4084,7 @@ sub mysqld_start ($$) { # Remove the old pidfile if any unlink($mysqld->value('pid-file')); - my $output= $mysqld->value('log-error'); + my $output= $mysqld->value('#log-error'); if ( $opt_valgrind and $opt_debug ) { # When both --valgrind and --debug is selected, send @@ -4048,6 +4104,7 @@ sub mysqld_start ($$) { error => $output, append => 1, verbose => $opt_verbose, + nocore => $opt_skip_core, host => undef, shutdown => sub { mysqld_stop($mysqld) }, ); @@ -4100,12 +4157,6 @@ sub server_need_restart { return 0; } - if ( $opt_embedded_server ) - { - mtr_verbose_restart($server, "no start or restart for embedded server"); - return 0; - } - if ( $tinfo->{'force_restart'} ) { mtr_verbose_restart($server, "forced in .opt file"); return 1; @@ -4335,7 +4386,7 @@ sub start_servers($) { # Already started # Write start of testcase to log file - mark_log($mysqld->value('log-error'), $tinfo); + mark_log($mysqld->value('#log-error'), $tinfo); next; } @@ -4394,7 +4445,7 @@ sub start_servers($) { mkpath($tmpdir) unless -d $tmpdir; # Write start of testcase to log file - mark_log($mysqld->value('log-error'), $tinfo); + mark_log($mysqld->value('#log-error'), $tinfo); # Run <tname>-master.sh if ($mysqld->option('#!run-master-sh') and @@ -4445,7 +4496,7 @@ sub start_servers($) { $tinfo->{comment}= "Failed to start ".$mysqld->name(); - my $logfile= $mysqld->value('log-error'); + my $logfile= $mysqld->value('#log-error'); if ( defined $logfile and -f $logfile ) { $tinfo->{logfile}= mtr_fromfile($logfile); diff --git a/mysql-test/r/events_bugs.result b/mysql-test/r/events_bugs.result index 83030a00179..50bfa97c59f 100644 --- a/mysql-test/r/events_bugs.result +++ b/mysql-test/r/events_bugs.result @@ -736,6 +736,17 @@ select replace(@full_mode, 'ALLOW_INVALID_DATES', 'INVALID_DATES') into @full_mo select name from mysql.event where name = 'p' and sql_mode = @full_mode; name drop event e1; +SET @old_server_id = @@GLOBAL.server_id; +SET GLOBAL server_id = (1 << 32) - 1; +SELECT @@GLOBAL.server_id; +@@GLOBAL.server_id +4294967295 +CREATE EVENT ev1 ON SCHEDULE EVERY 1 DAY DO SELECT 1; +SELECT event_name, originator FROM INFORMATION_SCHEMA.EVENTS; +event_name originator +ev1 4294967295 +DROP EVENT ev1; +SET GLOBAL server_id = @old_server_id; DROP DATABASE events_test; SET GLOBAL event_scheduler= 'ON'; SET @@global.concurrent_insert= @concurrent_insert; diff --git a/mysql-test/r/explain.result b/mysql-test/r/explain.result index 3de741b5efb..a81ff554ca2 100644 --- a/mysql-test/r/explain.result +++ b/mysql-test/r/explain.result @@ -155,6 +155,10 @@ id select_type table type possible_keys key key_len ref rows filtered Extra Warnings: Note 1003 select 1 AS `1` from (select count(distinct `test`.`t1`.`a`) AS `COUNT(DISTINCT t1.a)` from `test`.`t1` join `test`.`t2` group by `test`.`t1`.`a`) `s1` DROP TABLE t1,t2; +CREATE TABLE t1 (a INT PRIMARY KEY); +EXPLAIN EXTENDED SELECT COUNT(a) FROM t1 USE KEY(a); +ERROR 42000: Key 'a' doesn't exist in table 't1' +DROP TABLE t1; # # Bug#37870: Usage of uninitialized value caused failed assertion. # @@ -182,3 +186,4 @@ dt 2001-01-01 01:01:01 2001-01-01 01:01:01 drop tables t1, t2; +End of 5.1 tests. diff --git a/mysql-test/r/innodb-autoinc.result b/mysql-test/r/innodb-autoinc.result index 1e4b088c6cd..ade4db35ce6 100644 --- a/mysql-test/r/innodb-autoinc.result +++ b/mysql-test/r/innodb-autoinc.result @@ -579,3 +579,291 @@ c1 18446744073709551610 18446744073709551615 DROP TABLE t1; +SET @@SESSION.AUTO_INCREMENT_INCREMENT=1, @@SESSION.AUTO_INCREMENT_OFFSET=1; +SET @@INSERT_ID=1; +SHOW VARIABLES LIKE "%auto_inc%"; +Variable_name Value +auto_increment_increment 1 +auto_increment_offset 1 +CREATE TABLE t1 (c1 DOUBLE NOT NULL AUTO_INCREMENT, c2 INT, PRIMARY KEY (c1)) ENGINE=InnoDB; +INSERT INTO t1 VALUES(NULL, 1); +INSERT INTO t1 VALUES(NULL, 2); +SELECT * FROM t1; +c1 c2 +1 1 +2 2 +ALTER TABLE t1 CHANGE c1 c1 SERIAL; +SELECT * FROM t1; +c1 c2 +1 1 +2 2 +INSERT INTO t1 VALUES(NULL, 3); +INSERT INTO t1 VALUES(NULL, 4); +SELECT * FROM t1; +c1 c2 +1 1 +2 2 +3 3 +4 4 +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 (c1 FLOAT NOT NULL AUTO_INCREMENT, c2 INT, PRIMARY KEY (c1)) ENGINE=InnoDB; +INSERT INTO t1 VALUES(NULL, 1); +INSERT INTO t1 VALUES(NULL, 2); +SELECT * FROM t1; +c1 c2 +1 1 +2 2 +ALTER TABLE t1 CHANGE c1 c1 SERIAL; +SELECT * FROM t1; +c1 c2 +1 1 +2 2 +INSERT INTO t1 VALUES(NULL, 3); +INSERT INTO t1 VALUES(NULL, 4); +SELECT * FROM t1; +c1 c2 +1 1 +2 2 +3 3 +4 4 +DROP TABLE t1; +SET @@SESSION.AUTO_INCREMENT_INCREMENT=1, @@SESSION.AUTO_INCREMENT_OFFSET=5; +DROP TABLE IF EXISTS t1; +Warnings: +Note 1051 Unknown table 't1' +DROP TABLE IF EXISTS t2; +Warnings: +Note 1051 Unknown table 't2' +CREATE TABLE t1 ( +a INT(11) UNSIGNED NOT NULL AUTO_INCREMENT, +b INT(10) UNSIGNED NOT NULL, +c ENUM('FALSE','TRUE') DEFAULT NULL, +PRIMARY KEY (a)) ENGINE = InnoDB; +CREATE TABLE t2 ( +m INT(11) UNSIGNED NOT NULL AUTO_INCREMENT, +n INT(10) UNSIGNED NOT NULL, +o enum('FALSE','TRUE') DEFAULT NULL, +PRIMARY KEY (m)) ENGINE = InnoDB; +INSERT INTO t2 (n,o) VALUES +(1 , 'true'), (1 , 'false'), (2 , 'true'), (2 , 'false'), (3 , 'true'), +(3 , 'false'), (4 , 'true'), (4 , 'false'), (5 , 'true'), (5 , 'false'); +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `m` int(11) unsigned NOT NULL AUTO_INCREMENT, + `n` int(10) unsigned NOT NULL, + `o` enum('FALSE','TRUE') DEFAULT NULL, + PRIMARY KEY (`m`) +) ENGINE=InnoDB AUTO_INCREMENT=15 DEFAULT CHARSET=latin1 +INSERT INTO t1 (b,c) SELECT n,o FROM t2 ; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) unsigned NOT NULL AUTO_INCREMENT, + `b` int(10) unsigned NOT NULL, + `c` enum('FALSE','TRUE') DEFAULT NULL, + PRIMARY KEY (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=13 DEFAULT CHARSET=latin1 +INSERT INTO t1 (b,c) SELECT n,o FROM t2 ; +SELECT * FROM t1; +a b c +1 1 TRUE +2 1 FALSE +3 2 TRUE +4 2 FALSE +5 3 TRUE +6 3 FALSE +7 4 TRUE +8 4 FALSE +9 5 TRUE +10 5 FALSE +13 1 TRUE +14 1 FALSE +15 2 TRUE +16 2 FALSE +17 3 TRUE +18 3 FALSE +19 4 TRUE +20 4 FALSE +21 5 TRUE +22 5 FALSE +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) unsigned NOT NULL AUTO_INCREMENT, + `b` int(10) unsigned NOT NULL, + `c` enum('FALSE','TRUE') DEFAULT NULL, + PRIMARY KEY (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=23 DEFAULT CHARSET=latin1 +INSERT INTO t1 (b,c) SELECT n,o FROM t2 WHERE o = 'false'; +SELECT * FROM t1; +a b c +1 1 TRUE +2 1 FALSE +3 2 TRUE +4 2 FALSE +5 3 TRUE +6 3 FALSE +7 4 TRUE +8 4 FALSE +9 5 TRUE +10 5 FALSE +13 1 TRUE +14 1 FALSE +15 2 TRUE +16 2 FALSE +17 3 TRUE +18 3 FALSE +19 4 TRUE +20 4 FALSE +21 5 TRUE +22 5 FALSE +23 1 FALSE +24 2 FALSE +25 3 FALSE +26 4 FALSE +27 5 FALSE +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) unsigned NOT NULL AUTO_INCREMENT, + `b` int(10) unsigned NOT NULL, + `c` enum('FALSE','TRUE') DEFAULT NULL, + PRIMARY KEY (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=30 DEFAULT CHARSET=latin1 +INSERT INTO t1 (b,c) SELECT n,o FROM t2 WHERE o = 'false'; +SELECT * FROM t1; +a b c +1 1 TRUE +2 1 FALSE +3 2 TRUE +4 2 FALSE +5 3 TRUE +6 3 FALSE +7 4 TRUE +8 4 FALSE +9 5 TRUE +10 5 FALSE +13 1 TRUE +14 1 FALSE +15 2 TRUE +16 2 FALSE +17 3 TRUE +18 3 FALSE +19 4 TRUE +20 4 FALSE +21 5 TRUE +22 5 FALSE +23 1 FALSE +24 2 FALSE +25 3 FALSE +26 4 FALSE +27 5 FALSE +30 1 FALSE +31 2 FALSE +32 3 FALSE +33 4 FALSE +34 5 FALSE +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) unsigned NOT NULL AUTO_INCREMENT, + `b` int(10) unsigned NOT NULL, + `c` enum('FALSE','TRUE') DEFAULT NULL, + PRIMARY KEY (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=37 DEFAULT CHARSET=latin1 +INSERT INTO t1 (b,c) SELECT n,o FROM t2 WHERE o = 'false'; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) unsigned NOT NULL AUTO_INCREMENT, + `b` int(10) unsigned NOT NULL, + `c` enum('FALSE','TRUE') DEFAULT NULL, + PRIMARY KEY (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=44 DEFAULT CHARSET=latin1 +INSERT INTO t1 (b,c) SELECT n,o FROM t2 WHERE o = 'false'; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) unsigned NOT NULL AUTO_INCREMENT, + `b` int(10) unsigned NOT NULL, + `c` enum('FALSE','TRUE') DEFAULT NULL, + PRIMARY KEY (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=51 DEFAULT CHARSET=latin1 +INSERT INTO t1 (b,c) SELECT n,o FROM t2 WHERE o = 'false'; +SELECT * FROM t1; +a b c +1 1 TRUE +2 1 FALSE +3 2 TRUE +4 2 FALSE +5 3 TRUE +6 3 FALSE +7 4 TRUE +8 4 FALSE +9 5 TRUE +10 5 FALSE +13 1 TRUE +14 1 FALSE +15 2 TRUE +16 2 FALSE +17 3 TRUE +18 3 FALSE +19 4 TRUE +20 4 FALSE +21 5 TRUE +22 5 FALSE +23 1 FALSE +24 2 FALSE +25 3 FALSE +26 4 FALSE +27 5 FALSE +30 1 FALSE +31 2 FALSE +32 3 FALSE +33 4 FALSE +34 5 FALSE +37 1 FALSE +38 2 FALSE +39 3 FALSE +40 4 FALSE +41 5 FALSE +44 1 FALSE +45 2 FALSE +46 3 FALSE +47 4 FALSE +48 5 FALSE +51 1 FALSE +52 2 FALSE +53 3 FALSE +54 4 FALSE +55 5 FALSE +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) unsigned NOT NULL AUTO_INCREMENT, + `b` int(10) unsigned NOT NULL, + `c` enum('FALSE','TRUE') DEFAULT NULL, + PRIMARY KEY (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=58 DEFAULT CHARSET=latin1 +DROP TABLE t1; +DROP TABLE t2; +DROP TABLE IF EXISTS t1; +Warnings: +Note 1051 Unknown table 't1' +DROP TABLE IF EXISTS t2; +Warnings: +Note 1051 Unknown table 't2' +CREATE TABLE t1( +c1 INT(10) UNSIGNED NOT NULL AUTO_INCREMENT +PRIMARY KEY) ENGINE=InnoDB; +INSERT INTO t1 VALUES (NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL); +CREATE TABLE t2( +c1 TINYINT(3) UNSIGNED NOT NULL AUTO_INCREMENT +PRIMARY KEY) ENGINE=InnoDB; +INSERT INTO t2 SELECT c1 FROM t1; +Got one of the listed errors +INSERT INTO t2 SELECT NULL FROM t1; +Got one of the listed errors +DROP TABLE t1; +DROP TABLE t2; diff --git a/mysql-test/r/log_tables.result b/mysql-test/r/log_tables.result index 376120abcda..f8321520880 100644 --- a/mysql-test/r/log_tables.result +++ b/mysql-test/r/log_tables.result @@ -56,7 +56,7 @@ general_log CREATE TABLE `general_log` ( `event_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, `user_host` mediumtext NOT NULL, `thread_id` int(11) NOT NULL, - `server_id` int(11) NOT NULL, + `server_id` int(10) unsigned NOT NULL, `command_type` varchar(64) NOT NULL, `argument` mediumtext NOT NULL ) ENGINE=CSV DEFAULT CHARSET=utf8 COMMENT='General log' @@ -65,7 +65,7 @@ Field Type Null Key Default Extra event_time timestamp NO CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP user_host mediumtext NO NULL thread_id int(11) NO NULL -server_id int(11) NO NULL +server_id int(10) unsigned NO NULL command_type varchar(64) NO NULL argument mediumtext NO NULL show create table mysql.slow_log; @@ -80,7 +80,7 @@ slow_log CREATE TABLE `slow_log` ( `db` varchar(512) NOT NULL, `last_insert_id` int(11) NOT NULL, `insert_id` int(11) NOT NULL, - `server_id` int(11) NOT NULL, + `server_id` int(10) unsigned NOT NULL, `sql_text` mediumtext NOT NULL ) ENGINE=CSV DEFAULT CHARSET=utf8 COMMENT='Slow log' show fields from mysql.slow_log; @@ -94,7 +94,7 @@ rows_examined int(11) NO NULL db varchar(512) NO NULL last_insert_id int(11) NO NULL insert_id int(11) NO NULL -server_id int(11) NO NULL +server_id int(10) unsigned NO NULL sql_text mediumtext NO NULL flush logs; flush tables; @@ -167,7 +167,7 @@ general_log CREATE TABLE `general_log` ( `event_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, `user_host` mediumtext NOT NULL, `thread_id` int(11) NOT NULL, - `server_id` int(11) NOT NULL, + `server_id` int(10) unsigned NOT NULL, `command_type` varchar(64) NOT NULL, `argument` mediumtext NOT NULL ) ENGINE=CSV DEFAULT CHARSET=utf8 COMMENT='General log' @@ -183,7 +183,7 @@ slow_log CREATE TABLE `slow_log` ( `db` varchar(512) NOT NULL, `last_insert_id` int(11) NOT NULL, `insert_id` int(11) NOT NULL, - `server_id` int(11) NOT NULL, + `server_id` int(10) unsigned NOT NULL, `sql_text` mediumtext NOT NULL ) ENGINE=CSV DEFAULT CHARSET=utf8 COMMENT='Slow log' alter table mysql.general_log engine=myisam; @@ -194,7 +194,7 @@ general_log CREATE TABLE `general_log` ( `event_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, `user_host` mediumtext NOT NULL, `thread_id` int(11) NOT NULL, - `server_id` int(11) NOT NULL, + `server_id` int(10) unsigned NOT NULL, `command_type` varchar(64) NOT NULL, `argument` mediumtext NOT NULL ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='General log' @@ -210,7 +210,7 @@ slow_log CREATE TABLE `slow_log` ( `db` varchar(512) NOT NULL, `last_insert_id` int(11) NOT NULL, `insert_id` int(11) NOT NULL, - `server_id` int(11) NOT NULL, + `server_id` int(10) unsigned NOT NULL, `sql_text` mediumtext NOT NULL ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='Slow log' set global general_log='ON'; @@ -268,7 +268,7 @@ CREATE TABLE `general_log` ( ON UPDATE CURRENT_TIMESTAMP, `user_host` mediumtext NOT NULL, `thread_id` int(11) NOT NULL, -`server_id` int(11) NOT NULL, +`server_id` int(10) unsigned NOT NULL, `command_type` varchar(64) NOT NULL, `argument` mediumtext NOT NULL ) ENGINE=CSV DEFAULT CHARSET=utf8 COMMENT='General log'; @@ -283,7 +283,7 @@ ON UPDATE CURRENT_TIMESTAMP, `db` varchar(512) NOT NULL, `last_insert_id` int(11) NOT NULL, `insert_id` int(11) NOT NULL, -`server_id` int(11) NOT NULL, +`server_id` int(10) unsigned NOT NULL, `sql_text` mediumtext NOT NULL ) ENGINE=CSV DEFAULT CHARSET=utf8 COMMENT='Slow log'; set global general_log='ON'; diff --git a/mysql-test/r/system_mysql_db.result b/mysql-test/r/system_mysql_db.result index 0106c9459e7..e252331cd1a 100644 --- a/mysql-test/r/system_mysql_db.result +++ b/mysql-test/r/system_mysql_db.result @@ -227,7 +227,7 @@ event CREATE TABLE `event` ( `on_completion` enum('DROP','PRESERVE') NOT NULL DEFAULT 'DROP', `sql_mode` set('REAL_AS_FLOAT','PIPES_AS_CONCAT','ANSI_QUOTES','IGNORE_SPACE','NOT_USED','ONLY_FULL_GROUP_BY','NO_UNSIGNED_SUBTRACTION','NO_DIR_IN_CREATE','POSTGRESQL','ORACLE','MSSQL','DB2','MAXDB','NO_KEY_OPTIONS','NO_TABLE_OPTIONS','NO_FIELD_OPTIONS','MYSQL323','MYSQL40','ANSI','NO_AUTO_VALUE_ON_ZERO','NO_BACKSLASH_ESCAPES','STRICT_TRANS_TABLES','STRICT_ALL_TABLES','NO_ZERO_IN_DATE','NO_ZERO_DATE','INVALID_DATES','ERROR_FOR_DIVISION_BY_ZERO','TRADITIONAL','NO_AUTO_CREATE_USER','HIGH_NOT_PRECEDENCE','NO_ENGINE_SUBSTITUTION','PAD_CHAR_TO_FULL_LENGTH') NOT NULL DEFAULT '', `comment` char(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '', - `originator` int(10) NOT NULL, + `originator` int(10) unsigned NOT NULL, `time_zone` char(64) CHARACTER SET latin1 NOT NULL DEFAULT 'SYSTEM', `character_set_client` char(32) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, `collation_connection` char(32) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, @@ -241,7 +241,7 @@ general_log CREATE TABLE `general_log` ( `event_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, `user_host` mediumtext NOT NULL, `thread_id` int(11) NOT NULL, - `server_id` int(11) NOT NULL, + `server_id` int(10) unsigned NOT NULL, `command_type` varchar(64) NOT NULL, `argument` mediumtext NOT NULL ) ENGINE=CSV DEFAULT CHARSET=utf8 COMMENT='General log' @@ -257,7 +257,7 @@ slow_log CREATE TABLE `slow_log` ( `db` varchar(512) NOT NULL, `last_insert_id` int(11) NOT NULL, `insert_id` int(11) NOT NULL, - `server_id` int(11) NOT NULL, + `server_id` int(10) unsigned NOT NULL, `sql_text` mediumtext NOT NULL ) ENGINE=CSV DEFAULT CHARSET=utf8 COMMENT='Slow log' show tables; diff --git a/mysql-test/r/variables.result b/mysql-test/r/variables.result index 28b35c1461d..80fa0c88b82 100644 --- a/mysql-test/r/variables.result +++ b/mysql-test/r/variables.result @@ -1426,4 +1426,32 @@ Catalog Database Table Table_alias Column Column_alias Type Length Max length Is def @@storage_engine 253 6 6 N 1 31 8 @@storage_engine MyISAM +SET @old_server_id = @@GLOBAL.server_id; +SET GLOBAL server_id = (1 << 32) - 1; +SELECT @@GLOBAL.server_id; +@@GLOBAL.server_id +4294967295 +SET GLOBAL server_id = (1 << 32); +Warnings: +Warning 1292 Truncated incorrect server-id value: '4294967296' +SELECT @@GLOBAL.server_id; +@@GLOBAL.server_id +4294967295 +SET GLOBAL server_id = (1 << 60); +Warnings: +Warning 1292 Truncated incorrect server-id value: '1152921504606846976' +SELECT @@GLOBAL.server_id; +@@GLOBAL.server_id +4294967295 +SET GLOBAL server_id = 0; +SELECT @@GLOBAL.server_id; +@@GLOBAL.server_id +0 +SET GLOBAL server_id = -1; +Warnings: +Warning 1292 Truncated incorrect server_id value: '-1' +SELECT @@GLOBAL.server_id; +@@GLOBAL.server_id +0 +SET GLOBAL server_id = @old_server_id; End of 5.1 tests diff --git a/mysql-test/suite/sys_vars/r/server_id_basic_64.result b/mysql-test/suite/sys_vars/r/server_id_basic_64.result index b6f3095ccfe..6f801fc627b 100644 --- a/mysql-test/suite/sys_vars/r/server_id_basic_64.result +++ b/mysql-test/suite/sys_vars/r/server_id_basic_64.result @@ -60,9 +60,11 @@ SELECT @@global.server_id; @@global.server_id 0 SET @@global.server_id = 2147483649*2; +Warnings: +Warning 1292 Truncated incorrect server-id value: '4294967298' SELECT @@global.server_id; @@global.server_id -4294967298 +4294967295 SET @@global.server_id = 65530.34.; ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '.' at line 1 SET @@global.server_id = '125'; diff --git a/mysql-test/t/events_bugs.test b/mysql-test/t/events_bugs.test index 69e2f681aa2..81397b333f9 100644 --- a/mysql-test/t/events_bugs.test +++ b/mysql-test/t/events_bugs.test @@ -1209,6 +1209,18 @@ select replace(@full_mode, 'ALLOW_INVALID_DATES', 'INVALID_DATES') into @full_mo select name from mysql.event where name = 'p' and sql_mode = @full_mode; drop event e1; +# +# Bug#36540: CREATE EVENT and ALTER EVENT statements fail with large server_id +# + +SET @old_server_id = @@GLOBAL.server_id; +SET GLOBAL server_id = (1 << 32) - 1; +SELECT @@GLOBAL.server_id; +CREATE EVENT ev1 ON SCHEDULE EVERY 1 DAY DO SELECT 1; +SELECT event_name, originator FROM INFORMATION_SCHEMA.EVENTS; +DROP EVENT ev1; +SET GLOBAL server_id = @old_server_id; + ########################################################################### # # End of tests diff --git a/mysql-test/t/explain.test b/mysql-test/t/explain.test index 3a71fde4421..755e126baf2 100644 --- a/mysql-test/t/explain.test +++ b/mysql-test/t/explain.test @@ -123,6 +123,21 @@ execute s1; DROP TABLE t1,t2; + +# +# Bug #43354: Use key hint can crash server in explain extended query +# + +CREATE TABLE t1 (a INT PRIMARY KEY); + +--error ER_KEY_DOES_NOT_EXITS +EXPLAIN EXTENDED SELECT COUNT(a) FROM t1 USE KEY(a); + +DROP TABLE t1; + + +# End of 5.0 tests. + --echo # --echo # Bug#37870: Usage of uninitialized value caused failed assertion. --echo # @@ -141,4 +156,4 @@ flush tables; SELECT OUTR.dt FROM t1 AS OUTR WHERE OUTR.dt IN ( SELECT INNR.dt FROM t2 AS INNR WHERE OUTR.t < '2005-11-13 7:41:31' ); drop tables t1, t2; -# End of 5.0 tests. +--echo End of 5.1 tests. diff --git a/mysql-test/t/innodb-autoinc.test b/mysql-test/t/innodb-autoinc.test index e6b804c4fff..d76b29a7dc8 100644 --- a/mysql-test/t/innodb-autoinc.test +++ b/mysql-test/t/innodb-autoinc.test @@ -390,3 +390,91 @@ INSERT INTO t1 VALUES (NULL); #endif SELECT * FROM t1; DROP TABLE t1; + +# +# Check for floating point autoinc column handling +# +SET @@SESSION.AUTO_INCREMENT_INCREMENT=1, @@SESSION.AUTO_INCREMENT_OFFSET=1; +SET @@INSERT_ID=1; +SHOW VARIABLES LIKE "%auto_inc%"; +CREATE TABLE t1 (c1 DOUBLE NOT NULL AUTO_INCREMENT, c2 INT, PRIMARY KEY (c1)) ENGINE=InnoDB; +INSERT INTO t1 VALUES(NULL, 1); +INSERT INTO t1 VALUES(NULL, 2); +SELECT * FROM t1; +ALTER TABLE t1 CHANGE c1 c1 SERIAL; +SELECT * FROM t1; +INSERT INTO t1 VALUES(NULL, 3); +INSERT INTO t1 VALUES(NULL, 4); +SELECT * FROM t1; +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 (c1 FLOAT NOT NULL AUTO_INCREMENT, c2 INT, PRIMARY KEY (c1)) ENGINE=InnoDB; +INSERT INTO t1 VALUES(NULL, 1); +INSERT INTO t1 VALUES(NULL, 2); +SELECT * FROM t1; +ALTER TABLE t1 CHANGE c1 c1 SERIAL; +SELECT * FROM t1; +INSERT INTO t1 VALUES(NULL, 3); +INSERT INTO t1 VALUES(NULL, 4); +SELECT * FROM t1; +DROP TABLE t1; + +# +# Bug# 42714: AUTOINC column calculated next value not greater than highest +# value stored in table. +# +SET @@SESSION.AUTO_INCREMENT_INCREMENT=1, @@SESSION.AUTO_INCREMENT_OFFSET=5; +DROP TABLE IF EXISTS t1; +DROP TABLE IF EXISTS t2; +CREATE TABLE t1 ( + a INT(11) UNSIGNED NOT NULL AUTO_INCREMENT, + b INT(10) UNSIGNED NOT NULL, + c ENUM('FALSE','TRUE') DEFAULT NULL, + PRIMARY KEY (a)) ENGINE = InnoDB; +CREATE TABLE t2 ( + m INT(11) UNSIGNED NOT NULL AUTO_INCREMENT, + n INT(10) UNSIGNED NOT NULL, + o enum('FALSE','TRUE') DEFAULT NULL, + PRIMARY KEY (m)) ENGINE = InnoDB; +INSERT INTO t2 (n,o) VALUES + (1 , 'true'), (1 , 'false'), (2 , 'true'), (2 , 'false'), (3 , 'true'), + (3 , 'false'), (4 , 'true'), (4 , 'false'), (5 , 'true'), (5 , 'false'); +SHOW CREATE TABLE t2; +INSERT INTO t1 (b,c) SELECT n,o FROM t2 ; +SHOW CREATE TABLE t1; +INSERT INTO t1 (b,c) SELECT n,o FROM t2 ; +SELECT * FROM t1; +SHOW CREATE TABLE t1; +INSERT INTO t1 (b,c) SELECT n,o FROM t2 WHERE o = 'false'; +SELECT * FROM t1; +SHOW CREATE TABLE t1; +INSERT INTO t1 (b,c) SELECT n,o FROM t2 WHERE o = 'false'; +SELECT * FROM t1; +SHOW CREATE TABLE t1; +INSERT INTO t1 (b,c) SELECT n,o FROM t2 WHERE o = 'false'; +SHOW CREATE TABLE t1; +INSERT INTO t1 (b,c) SELECT n,o FROM t2 WHERE o = 'false'; +SHOW CREATE TABLE t1; +INSERT INTO t1 (b,c) SELECT n,o FROM t2 WHERE o = 'false'; +SELECT * FROM t1; +SHOW CREATE TABLE t1; +DROP TABLE t1; +DROP TABLE t2; +# +# 43203: Overflow from auto incrementing causes server segv +# + +DROP TABLE IF EXISTS t1; +DROP TABLE IF EXISTS t2; +CREATE TABLE t1( + c1 INT(10) UNSIGNED NOT NULL AUTO_INCREMENT + PRIMARY KEY) ENGINE=InnoDB; +INSERT INTO t1 VALUES (NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL); +CREATE TABLE t2( + c1 TINYINT(3) UNSIGNED NOT NULL AUTO_INCREMENT + PRIMARY KEY) ENGINE=InnoDB; +-- error ER_DUP_ENTRY,1062 +INSERT INTO t2 SELECT c1 FROM t1; +-- error ER_DUP_ENTRY,1467 +INSERT INTO t2 SELECT NULL FROM t1; +DROP TABLE t1; +DROP TABLE t2; diff --git a/mysql-test/t/log_tables.test b/mysql-test/t/log_tables.test index 326914f09d9..076f2e8bc3b 100644 --- a/mysql-test/t/log_tables.test +++ b/mysql-test/t/log_tables.test @@ -287,7 +287,7 @@ CREATE TABLE `general_log` ( ON UPDATE CURRENT_TIMESTAMP, `user_host` mediumtext NOT NULL, `thread_id` int(11) NOT NULL, - `server_id` int(11) NOT NULL, + `server_id` int(10) unsigned NOT NULL, `command_type` varchar(64) NOT NULL, `argument` mediumtext NOT NULL ) ENGINE=CSV DEFAULT CHARSET=utf8 COMMENT='General log'; @@ -303,7 +303,7 @@ CREATE TABLE `slow_log` ( `db` varchar(512) NOT NULL, `last_insert_id` int(11) NOT NULL, `insert_id` int(11) NOT NULL, - `server_id` int(11) NOT NULL, + `server_id` int(10) unsigned NOT NULL, `sql_text` mediumtext NOT NULL ) ENGINE=CSV DEFAULT CHARSET=utf8 COMMENT='Slow log'; diff --git a/mysql-test/t/type_bit_innodb.test b/mysql-test/t/type_bit_innodb.test index 85c9127b2f6..e7e66da8927 100644 --- a/mysql-test/t/type_bit_innodb.test +++ b/mysql-test/t/type_bit_innodb.test @@ -40,6 +40,8 @@ drop table t1; create table t1 (a bit) engine=innodb; insert into t1 values (b'0'), (b'1'), (b'000'), (b'100'), (b'001'); select hex(a) from t1; +# It is not deterministic which duplicate will be seen first +--replace_regex /(.*Duplicate entry )'.*'( for key.*)/\1''\2/ --error ER_DUP_ENTRY alter table t1 add unique (a); drop table t1; diff --git a/mysql-test/t/variables.test b/mysql-test/t/variables.test index 95f4d6e97c5..7865a9d7b8e 100644 --- a/mysql-test/t/variables.test +++ b/mysql-test/t/variables.test @@ -1164,5 +1164,21 @@ SET GLOBAL expire_logs_days = @old_eld; select @@storage_engine; --disable_metadata +# +# Bug#36540: CREATE EVENT and ALTER EVENT statements fail with large server_id +# + +SET @old_server_id = @@GLOBAL.server_id; +SET GLOBAL server_id = (1 << 32) - 1; +SELECT @@GLOBAL.server_id; +SET GLOBAL server_id = (1 << 32); +SELECT @@GLOBAL.server_id; +SET GLOBAL server_id = (1 << 60); +SELECT @@GLOBAL.server_id; +SET GLOBAL server_id = 0; +SELECT @@GLOBAL.server_id; +SET GLOBAL server_id = -1; +SELECT @@GLOBAL.server_id; +SET GLOBAL server_id = @old_server_id; --echo End of 5.1 tests diff --git a/mysys/md5.c b/mysys/md5.c index 0945f9ce5f4..2388cebedc4 100644 --- a/mysys/md5.c +++ b/mysys/md5.c @@ -13,356 +13,313 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* MD5C.C - RSA Data Security, Inc., MD5 message-digest algorithm +/* + * This code implements the MD5 message-digest algorithm. + * The algorithm is due to Ron Rivest. This code was + * written by Colin Plumb in 1993, no copyright is claimed. + * This code is in the public domain; do with it what you wish. + * + * Equivalent code is available from RSA Data Security, Inc. + * This code has been tested against that, and is equivalent, + * except that you don't need to include two pages of legalese + * with every copy. + * + * To compute the message digest of a chunk of bytes, declare an + * MD5Context structure, pass it to MD5Init, call MD5Update as + * needed on buffers full of bytes, and then call MD5Final, which + * will fill a supplied 16-byte array with the digest. */ -/* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All -rights reserved. - -License to copy and use this software is granted provided that it -is identified as the "RSA Data Security, Inc. MD5 Message-Digest -Algorithm" in all material mentioning or referencing this software -or this function. - -License is also granted to make and use derivative works provided -that such works are identified as "derived from the RSA Data -Security, Inc. MD5 Message-Digest Algorithm" in all material -mentioning or referencing the derived work. - -RSA Data Security, Inc. makes no representations concerning either -the merchantability of this software or the suitability of this -software for any particular purpose. It is provided "as is" -without express or implied warranty of any kind. - -These notices must be retained in any copies of any part of this -documentation and/or software. -*/ - -/* - Changes by Monty: - Replace of MD5_memset and MD5_memcpy with memset & memcpy -*/ +/* This code was modified in 1997 by Jim Kingdon of Cyclic Software to + not require an integer type which is exactly 32 bits. This work + draws on the changes for the same purpose by Tatu Ylonen + <ylo@cs.hut.fi> as part of SSH, but since I didn't actually use + that code, there is no copyright issue. I hereby disclaim + copyright in any changes I have made; this code remains in the + public domain. */ #include <my_global.h> #include <m_string.h> #include "my_md5.h" -/* Constants for MD5Transform routine. */ - -#define S11 7 -#define S12 12 -#define S13 17 -#define S14 22 -#define S21 5 -#define S22 9 -#define S23 14 -#define S24 20 -#define S31 4 -#define S32 11 -#define S33 16 -#define S34 23 -#define S41 6 -#define S42 10 -#define S43 15 -#define S44 21 - - -static void MD5Transform PROTO_LIST ((UINT4 [4], unsigned char [64])); -static void Encode PROTO_LIST - ((unsigned char *, UINT4 *, unsigned int)); -static void Decode PROTO_LIST - ((UINT4 *, unsigned char *, unsigned int)); -#ifdef OLD_CODE -static void MD5_memcpy PROTO_LIST ((POINTER, POINTER, unsigned int)); -static void MD5_memset PROTO_LIST ((POINTER, int, unsigned int)); -#else -#define MD5_memcpy(A,B,C) memcpy((char*) (A),(char*) (B), (C)) -#define MD5_memset(A,B,C) memset((char*) (A),(B), (C)) -#endif +#include <string.h> /* for memcpy() and memset() */ -static unsigned char PADDING[64] = { - 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 -}; -/* F, G, H and I are basic MD5 functions. - */ -#define F(x, y, z) (((x) & (y)) | ((~x) & (z))) -#define G(x, y, z) (((x) & (z)) | ((y) & (~z))) -#define H(x, y, z) ((x) ^ (y) ^ (z)) -#define I(x, y, z) ((y) ^ ((x) | (~z))) +static void +my_MD5Transform (cvs_uint32 buf[4], const unsigned char in[64]); -/* ROTATE_LEFT rotates x left n bits. - */ -#define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32-(n)))) +/* Little-endian byte-swapping routines. Note that these do not + depend on the size of datatypes such as uint32, nor do they require + us to detect the endianness of the machine we are running on. It + is possible they should be macros for speed, but I would be + surprised if they were a performance bottleneck for MD5. */ -/* FF, GG, HH, and II transformations for rounds 1, 2, 3, and 4. -Rotation is separate from addition to prevent recomputation. - */ -#define FF(a, b, c, d, x, s, ac) { \ - (a) += F ((b), (c), (d)) + (x) + (UINT4)(ac); \ - (a) = ROTATE_LEFT ((a), (s)); \ - (a) += (b); \ - } -#define GG(a, b, c, d, x, s, ac) { \ - (a) += G ((b), (c), (d)) + (x) + (UINT4)(ac); \ - (a) = ROTATE_LEFT ((a), (s)); \ - (a) += (b); \ - } -#define HH(a, b, c, d, x, s, ac) { \ - (a) += H ((b), (c), (d)) + (x) + (UINT4)(ac); \ - (a) = ROTATE_LEFT ((a), (s)); \ - (a) += (b); \ - } -#define II(a, b, c, d, x, s, ac) { \ - (a) += I ((b), (c), (d)) + (x) + (UINT4)(ac); \ - (a) = ROTATE_LEFT ((a), (s)); \ - (a) += (b); \ - } - -/* MD5 initialization. Begins an MD5 operation, writing a new context. - */ -void my_MD5Init (my_MD5_CTX *context) /* context */ +static uint32 getu32 (const unsigned char *addr) { - context->count[0] = context->count[1] = 0; - /* Load magic initialization constants. -*/ - context->state[0] = 0x67452301; - context->state[1] = 0xefcdab89; - context->state[2] = 0x98badcfe; - context->state[3] = 0x10325476; + return (((((unsigned long)addr[3] << 8) | addr[2]) << 8) + | addr[1]) << 8 | addr[0]; } -/* MD5 block update operation. Continues an MD5 message-digest - operation, processing another message block, and updating the - context. - */ - -void my_MD5Update ( -my_MD5_CTX *context, /* context */ -unsigned char *input, /* input block */ -unsigned int inputLen) /* length of input block */ +static void +putu32 (uint32 data, unsigned char *addr) { - unsigned int i, idx, partLen; - - /* Compute number of bytes mod 64 */ - idx = (unsigned int)((context->count[0] >> 3) & 0x3F); - + addr[0] = (unsigned char)data; + addr[1] = (unsigned char)(data >> 8); + addr[2] = (unsigned char)(data >> 16); + addr[3] = (unsigned char)(data >> 24); +} - /* Update number of bits */ - if ((context->count[0] += ((UINT4)inputLen << 3)) - < ((UINT4)inputLen << 3)) - context->count[1]++; - context->count[1] += ((UINT4)inputLen >> 29); +/* + Start MD5 accumulation. Set bit count to 0 and buffer to mysterious + initialization constants. +*/ +void +my_MD5Init (my_MD5Context *ctx) +{ + ctx->buf[0] = 0x67452301; + ctx->buf[1] = 0xefcdab89; + ctx->buf[2] = 0x98badcfe; + ctx->buf[3] = 0x10325476; - partLen = 64 - idx; + ctx->bits[0] = 0; + ctx->bits[1] = 0; +} - /* Transform as many times as possible. +/* + Update context to reflect the concatenation of another buffer full + of bytes. */ - if (inputLen >= partLen) { - MD5_memcpy((POINTER)&context->buffer[idx], (POINTER)input, partLen); - MD5Transform(context->state, context->buffer); +void +my_MD5Update (my_MD5Context *ctx, unsigned char const *buf, unsigned len) +{ + uint32 t; - for (i = partLen; i + 63 < inputLen; i += 64) - MD5Transform (context->state, &input[i]); + /* Update bitcount */ - idx = 0; - } - else - i = 0; + t = ctx->bits[0]; + if ((ctx->bits[0] = (t + ((uint32)len << 3)) & 0xffffffff) < t) + ctx->bits[1]++; /* Carry from low to high */ + ctx->bits[1] += len >> 29; - /* Buffer remaining input */ - MD5_memcpy((POINTER)&context->buffer[idx], (POINTER)&input[i], - inputLen-i); -} + t = (t >> 3) & 0x3f; /* Bytes already in shsInfo->data */ -/* MD5 finalization. Ends an MD5 message-digest operation, writing the - the message digest and zeroizing the context. - */ + /* Handle any leading odd-sized chunks */ -void my_MD5Final ( -unsigned char digest[16], /* message digest */ -my_MD5_CTX *context) /* context */ -{ - unsigned char bits[8]; - unsigned int idx, padLen; + if ( t ) { + unsigned char *p = ctx->in + t; - /* Save number of bits */ - Encode (bits, context->count, 8); + t = 64-t; + if (len < t) { + memcpy(p, buf, len); + return; + } + memcpy(p, buf, t); + my_MD5Transform (ctx->buf, ctx->in); + buf += t; + len -= t; + } - /* Pad out to 56 mod 64. -*/ - idx = (unsigned int)((context->count[0] >> 3) & 0x3f); - padLen = (idx < 56) ? (56 - idx) : (120 - idx); - my_MD5Update (context, PADDING, padLen); + /* Process data in 64-byte chunks */ - /* Append length (before padding) */ - my_MD5Update (context, bits, 8); + while (len >= 64) { + memcpy(ctx->in, buf, 64); + my_MD5Transform (ctx->buf, ctx->in); + buf += 64; + len -= 64; + } - /* Store state in digest */ - Encode (digest, context->state, 16); + /* Handle any remaining bytes of data. */ - /* Zeroize sensitive information. -*/ - MD5_memset ((POINTER)context, 0, sizeof (*context)); + memcpy(ctx->in, buf, len); } -/* MD5 basic transformation. Transforms state based on block. - */ -static void MD5Transform ( -UINT4 state[4], -unsigned char block[64]) -{ - UINT4 a = state[0], b = state[1], c = state[2], d = state[3], x[16]; - - Decode (x, block, 64); - - /* Round 1 */ - FF (a, b, c, d, x[ 0], S11, 0xd76aa478); /* 1 */ - FF (d, a, b, c, x[ 1], S12, 0xe8c7b756); /* 2 */ - FF (c, d, a, b, x[ 2], S13, 0x242070db); /* 3 */ - FF (b, c, d, a, x[ 3], S14, 0xc1bdceee); /* 4 */ - FF (a, b, c, d, x[ 4], S11, 0xf57c0faf); /* 5 */ - FF (d, a, b, c, x[ 5], S12, 0x4787c62a); /* 6 */ - FF (c, d, a, b, x[ 6], S13, 0xa8304613); /* 7 */ - FF (b, c, d, a, x[ 7], S14, 0xfd469501); /* 8 */ - FF (a, b, c, d, x[ 8], S11, 0x698098d8); /* 9 */ - FF (d, a, b, c, x[ 9], S12, 0x8b44f7af); /* 10 */ - FF (c, d, a, b, x[10], S13, 0xffff5bb1); /* 11 */ - FF (b, c, d, a, x[11], S14, 0x895cd7be); /* 12 */ - FF (a, b, c, d, x[12], S11, 0x6b901122); /* 13 */ - FF (d, a, b, c, x[13], S12, 0xfd987193); /* 14 */ - FF (c, d, a, b, x[14], S13, 0xa679438e); /* 15 */ - FF (b, c, d, a, x[15], S14, 0x49b40821); /* 16 */ - - /* Round 2 */ - GG (a, b, c, d, x[ 1], S21, 0xf61e2562); /* 17 */ - GG (d, a, b, c, x[ 6], S22, 0xc040b340); /* 18 */ - GG (c, d, a, b, x[11], S23, 0x265e5a51); /* 19 */ - GG (b, c, d, a, x[ 0], S24, 0xe9b6c7aa); /* 20 */ - GG (a, b, c, d, x[ 5], S21, 0xd62f105d); /* 21 */ - GG (d, a, b, c, x[10], S22, 0x2441453); /* 22 */ - GG (c, d, a, b, x[15], S23, 0xd8a1e681); /* 23 */ - GG (b, c, d, a, x[ 4], S24, 0xe7d3fbc8); /* 24 */ - GG (a, b, c, d, x[ 9], S21, 0x21e1cde6); /* 25 */ - GG (d, a, b, c, x[14], S22, 0xc33707d6); /* 26 */ - GG (c, d, a, b, x[ 3], S23, 0xf4d50d87); /* 27 */ - GG (b, c, d, a, x[ 8], S24, 0x455a14ed); /* 28 */ - GG (a, b, c, d, x[13], S21, 0xa9e3e905); /* 29 */ - GG (d, a, b, c, x[ 2], S22, 0xfcefa3f8); /* 30 */ - GG (c, d, a, b, x[ 7], S23, 0x676f02d9); /* 31 */ - GG (b, c, d, a, x[12], S24, 0x8d2a4c8a); /* 32 */ - - /* Round 3 */ - HH (a, b, c, d, x[ 5], S31, 0xfffa3942); /* 33 */ - HH (d, a, b, c, x[ 8], S32, 0x8771f681); /* 34 */ - HH (c, d, a, b, x[11], S33, 0x6d9d6122); /* 35 */ - HH (b, c, d, a, x[14], S34, 0xfde5380c); /* 36 */ - HH (a, b, c, d, x[ 1], S31, 0xa4beea44); /* 37 */ - HH (d, a, b, c, x[ 4], S32, 0x4bdecfa9); /* 38 */ - HH (c, d, a, b, x[ 7], S33, 0xf6bb4b60); /* 39 */ - HH (b, c, d, a, x[10], S34, 0xbebfbc70); /* 40 */ - HH (a, b, c, d, x[13], S31, 0x289b7ec6); /* 41 */ - HH (d, a, b, c, x[ 0], S32, 0xeaa127fa); /* 42 */ - HH (c, d, a, b, x[ 3], S33, 0xd4ef3085); /* 43 */ - HH (b, c, d, a, x[ 6], S34, 0x4881d05); /* 44 */ - HH (a, b, c, d, x[ 9], S31, 0xd9d4d039); /* 45 */ - HH (d, a, b, c, x[12], S32, 0xe6db99e5); /* 46 */ - HH (c, d, a, b, x[15], S33, 0x1fa27cf8); /* 47 */ - HH (b, c, d, a, x[ 2], S34, 0xc4ac5665); /* 48 */ - - /* Round 4 */ - II (a, b, c, d, x[ 0], S41, 0xf4292244); /* 49 */ - II (d, a, b, c, x[ 7], S42, 0x432aff97); /* 50 */ - II (c, d, a, b, x[14], S43, 0xab9423a7); /* 51 */ - II (b, c, d, a, x[ 5], S44, 0xfc93a039); /* 52 */ - II (a, b, c, d, x[12], S41, 0x655b59c3); /* 53 */ - II (d, a, b, c, x[ 3], S42, 0x8f0ccc92); /* 54 */ - II (c, d, a, b, x[10], S43, 0xffeff47d); /* 55 */ - II (b, c, d, a, x[ 1], S44, 0x85845dd1); /* 56 */ - II (a, b, c, d, x[ 8], S41, 0x6fa87e4f); /* 57 */ - II (d, a, b, c, x[15], S42, 0xfe2ce6e0); /* 58 */ - II (c, d, a, b, x[ 6], S43, 0xa3014314); /* 59 */ - II (b, c, d, a, x[13], S44, 0x4e0811a1); /* 60 */ - II (a, b, c, d, x[ 4], S41, 0xf7537e82); /* 61 */ - II (d, a, b, c, x[11], S42, 0xbd3af235); /* 62 */ - II (c, d, a, b, x[ 2], S43, 0x2ad7d2bb); /* 63 */ - II (b, c, d, a, x[ 9], S44, 0xeb86d391); /* 64 */ - - - state[0] += a; - state[1] += b; - state[2] += c; - state[3] += d; - - /* Zeroize sensitive information. +/* + Final wrapup - pad to 64-byte boundary with the bit pattern + 1 0* (64-bit count of bits processed, MSB-first) */ - MD5_memset ((POINTER)x, 0, sizeof (x)); -} - -/* Encodes input (UINT4) into output (unsigned char). Assumes len is - a multiple of 4. - */ -static void Encode ( -unsigned char *output, -UINT4 *input, -unsigned int len) +void +my_MD5Final (unsigned char digest[16], my_MD5Context *ctx) { - unsigned int i, j; + unsigned count; + unsigned char *p; - for (i = 0, j = 0; j < len; i++, j += 4) { - output[j] = (unsigned char)(input[i] & 0xff); - output[j+1] = (unsigned char)((input[i] >> 8) & 0xff); - output[j+2] = (unsigned char)((input[i] >> 16) & 0xff); - output[j+3] = (unsigned char)((input[i] >> 24) & 0xff); + /* Compute number of bytes mod 64 */ + count = (ctx->bits[0] >> 3) & 0x3F; + + /* Set the first char of padding to 0x80. This is safe since there is + always at least one byte free */ + p = ctx->in + count; + *p++ = 0x80; + + /* Bytes of padding needed to make 64 bytes */ + count = 64 - 1 - count; + + /* Pad out to 56 mod 64 */ + if (count < 8) { + /* Two lots of padding: Pad the first block to 64 bytes */ + memset(p, 0, count); + my_MD5Transform (ctx->buf, ctx->in); + + /* Now fill the next block with 56 bytes */ + memset(ctx->in, 0, 56); + } else { + /* Pad block to 56 bytes */ + memset(p, 0, count-8); } + + /* Append length in bits and transform */ + putu32(ctx->bits[0], ctx->in + 56); + putu32(ctx->bits[1], ctx->in + 60); + + my_MD5Transform (ctx->buf, ctx->in); + putu32(ctx->buf[0], digest); + putu32(ctx->buf[1], digest + 4); + putu32(ctx->buf[2], digest + 8); + putu32(ctx->buf[3], digest + 12); + memset(ctx, 0, sizeof(ctx)); /* In case it's sensitive */ } +#ifndef ASM_MD5 -/* Decodes input (unsigned char) into output (UINT4). Assumes len is - a multiple of 4. - */ -static void Decode ( -UINT4 *output, -unsigned char *input, -unsigned int len) -{ - unsigned int i, j; +/* The four core functions - F1 is optimized somewhat */ - for (i = 0, j = 0; j < len; i++, j += 4) - output[i] = ((UINT4)input[j]) | (((UINT4)input[j+1]) << 8) | - (((UINT4)input[j+2]) << 16) | (((UINT4)input[j+3]) << 24); -} +/* #define F1(x, y, z) (x & y | ~x & z) */ +#define F1(x, y, z) (z ^ (x & (y ^ z))) +#define F2(x, y, z) F1(z, x, y) +#define F3(x, y, z) (x ^ y ^ z) +#define F4(x, y, z) (y ^ (x | ~z)) -/* Note: Replace "for loop" with standard memcpy if possible. - */ +/* This is the central step in the MD5 algorithm. */ +#define MD5STEP(f, w, x, y, z, data, s) \ + ( w += f(x, y, z) + data, w &= 0xffffffff, w = w<<s | w>>(32-s), w += x ) -#ifndef MD5_memcpy -static void MD5_memcpy (output, input, len) -POINTER output; -POINTER input; -unsigned int len; +/* + * The core of the MD5 algorithm, this alters an existing MD5 hash to + * reflect the addition of 16 longwords of new data. MD5Update blocks + * the data and converts bytes into longwords for this routine. + */ +static void +my_MD5Transform (uint32 buf[4], const unsigned char inraw[64]) { - unsigned int i; - - for (i = 0; i < len; i++) - output[i] = input[i]; + register uint32 a, b, c, d; + uint32 in[16]; + int i; + + for (i = 0; i < 16; ++i) + in[i] = getu32 (inraw + 4 * i); + + a = buf[0]; + b = buf[1]; + c = buf[2]; + d = buf[3]; + + MD5STEP(F1, a, b, c, d, in[ 0]+0xd76aa478, 7); + MD5STEP(F1, d, a, b, c, in[ 1]+0xe8c7b756, 12); + MD5STEP(F1, c, d, a, b, in[ 2]+0x242070db, 17); + MD5STEP(F1, b, c, d, a, in[ 3]+0xc1bdceee, 22); + MD5STEP(F1, a, b, c, d, in[ 4]+0xf57c0faf, 7); + MD5STEP(F1, d, a, b, c, in[ 5]+0x4787c62a, 12); + MD5STEP(F1, c, d, a, b, in[ 6]+0xa8304613, 17); + MD5STEP(F1, b, c, d, a, in[ 7]+0xfd469501, 22); + MD5STEP(F1, a, b, c, d, in[ 8]+0x698098d8, 7); + MD5STEP(F1, d, a, b, c, in[ 9]+0x8b44f7af, 12); + MD5STEP(F1, c, d, a, b, in[10]+0xffff5bb1, 17); + MD5STEP(F1, b, c, d, a, in[11]+0x895cd7be, 22); + MD5STEP(F1, a, b, c, d, in[12]+0x6b901122, 7); + MD5STEP(F1, d, a, b, c, in[13]+0xfd987193, 12); + MD5STEP(F1, c, d, a, b, in[14]+0xa679438e, 17); + MD5STEP(F1, b, c, d, a, in[15]+0x49b40821, 22); + + MD5STEP(F2, a, b, c, d, in[ 1]+0xf61e2562, 5); + MD5STEP(F2, d, a, b, c, in[ 6]+0xc040b340, 9); + MD5STEP(F2, c, d, a, b, in[11]+0x265e5a51, 14); + MD5STEP(F2, b, c, d, a, in[ 0]+0xe9b6c7aa, 20); + MD5STEP(F2, a, b, c, d, in[ 5]+0xd62f105d, 5); + MD5STEP(F2, d, a, b, c, in[10]+0x02441453, 9); + MD5STEP(F2, c, d, a, b, in[15]+0xd8a1e681, 14); + MD5STEP(F2, b, c, d, a, in[ 4]+0xe7d3fbc8, 20); + MD5STEP(F2, a, b, c, d, in[ 9]+0x21e1cde6, 5); + MD5STEP(F2, d, a, b, c, in[14]+0xc33707d6, 9); + MD5STEP(F2, c, d, a, b, in[ 3]+0xf4d50d87, 14); + MD5STEP(F2, b, c, d, a, in[ 8]+0x455a14ed, 20); + MD5STEP(F2, a, b, c, d, in[13]+0xa9e3e905, 5); + MD5STEP(F2, d, a, b, c, in[ 2]+0xfcefa3f8, 9); + MD5STEP(F2, c, d, a, b, in[ 7]+0x676f02d9, 14); + MD5STEP(F2, b, c, d, a, in[12]+0x8d2a4c8a, 20); + + MD5STEP(F3, a, b, c, d, in[ 5]+0xfffa3942, 4); + MD5STEP(F3, d, a, b, c, in[ 8]+0x8771f681, 11); + MD5STEP(F3, c, d, a, b, in[11]+0x6d9d6122, 16); + MD5STEP(F3, b, c, d, a, in[14]+0xfde5380c, 23); + MD5STEP(F3, a, b, c, d, in[ 1]+0xa4beea44, 4); + MD5STEP(F3, d, a, b, c, in[ 4]+0x4bdecfa9, 11); + MD5STEP(F3, c, d, a, b, in[ 7]+0xf6bb4b60, 16); + MD5STEP(F3, b, c, d, a, in[10]+0xbebfbc70, 23); + MD5STEP(F3, a, b, c, d, in[13]+0x289b7ec6, 4); + MD5STEP(F3, d, a, b, c, in[ 0]+0xeaa127fa, 11); + MD5STEP(F3, c, d, a, b, in[ 3]+0xd4ef3085, 16); + MD5STEP(F3, b, c, d, a, in[ 6]+0x04881d05, 23); + MD5STEP(F3, a, b, c, d, in[ 9]+0xd9d4d039, 4); + MD5STEP(F3, d, a, b, c, in[12]+0xe6db99e5, 11); + MD5STEP(F3, c, d, a, b, in[15]+0x1fa27cf8, 16); + MD5STEP(F3, b, c, d, a, in[ 2]+0xc4ac5665, 23); + + MD5STEP(F4, a, b, c, d, in[ 0]+0xf4292244, 6); + MD5STEP(F4, d, a, b, c, in[ 7]+0x432aff97, 10); + MD5STEP(F4, c, d, a, b, in[14]+0xab9423a7, 15); + MD5STEP(F4, b, c, d, a, in[ 5]+0xfc93a039, 21); + MD5STEP(F4, a, b, c, d, in[12]+0x655b59c3, 6); + MD5STEP(F4, d, a, b, c, in[ 3]+0x8f0ccc92, 10); + MD5STEP(F4, c, d, a, b, in[10]+0xffeff47d, 15); + MD5STEP(F4, b, c, d, a, in[ 1]+0x85845dd1, 21); + MD5STEP(F4, a, b, c, d, in[ 8]+0x6fa87e4f, 6); + MD5STEP(F4, d, a, b, c, in[15]+0xfe2ce6e0, 10); + MD5STEP(F4, c, d, a, b, in[ 6]+0xa3014314, 15); + MD5STEP(F4, b, c, d, a, in[13]+0x4e0811a1, 21); + MD5STEP(F4, a, b, c, d, in[ 4]+0xf7537e82, 6); + MD5STEP(F4, d, a, b, c, in[11]+0xbd3af235, 10); + MD5STEP(F4, c, d, a, b, in[ 2]+0x2ad7d2bb, 15); + MD5STEP(F4, b, c, d, a, in[ 9]+0xeb86d391, 21); + + buf[0] += a; + buf[1] += b; + buf[2] += c; + buf[3] += d; } #endif -/* Note: Replace "for loop" with standard memset if possible. - */ +#ifdef TEST +/* + Simple test program. Can use it to manually run the tests from + RFC1321 for example. +*/ +#include <stdio.h> -#ifndef MD5_memset -static void MD5_memset (output, value, len) -POINTER output; -int value; -unsigned int len; +int +main (int argc, char **argv) { - unsigned int i; - - for (i = 0; i < len; i++) - ((char *)output)[i] = (char)value; + my_MD5Context context; + unsigned char checksum[16]; + int i; + int j; + + if (argc < 2) + { + fprintf (stderr, "usage: %s string-to-hash\n", argv[0]); + exit (1); + } + for (j = 1; j < argc; ++j) + { + printf ("MD5 (\"%s\") = ", argv[j]); + my_MD5Init (&context); + my_MD5Update (&context, argv[j], strlen (argv[j])); + my_MD5Final (checksum, &context); + for (i = 0; i < 16; i++) + { + printf ("%02x", (unsigned int) checksum[i]); + } + printf ("\n"); + } + return 0; } -#endif +#endif /* TEST */ diff --git a/scripts/mysql_system_tables.sql b/scripts/mysql_system_tables.sql index fdab9601129..67e18517915 100644 --- a/scripts/mysql_system_tables.sql +++ b/scripts/mysql_system_tables.sql @@ -66,7 +66,7 @@ CREATE TABLE IF NOT EXISTS procs_priv ( Host char(60) binary DEFAULT '' NOT NULL -- Create general_log if CSV is enabled. -SET @str = IF (@@have_csv = 'YES', 'CREATE TABLE IF NOT EXISTS general_log (event_time TIMESTAMP NOT NULL, user_host MEDIUMTEXT NOT NULL, thread_id INTEGER NOT NULL, server_id INTEGER NOT NULL, command_type VARCHAR(64) NOT NULL, argument MEDIUMTEXT NOT NULL) engine=CSV CHARACTER SET utf8 comment="General log"', 'SET @dummy = 0'); +SET @str = IF (@@have_csv = 'YES', 'CREATE TABLE IF NOT EXISTS general_log (event_time TIMESTAMP NOT NULL, user_host MEDIUMTEXT NOT NULL, thread_id INTEGER NOT NULL, server_id INTEGER UNSIGNED NOT NULL, command_type VARCHAR(64) NOT NULL, argument MEDIUMTEXT NOT NULL) engine=CSV CHARACTER SET utf8 comment="General log"', 'SET @dummy = 0'); PREPARE stmt FROM @str; EXECUTE stmt; @@ -74,13 +74,13 @@ DROP PREPARE stmt; -- Create slow_log if CSV is enabled. -SET @str = IF (@@have_csv = 'YES', 'CREATE TABLE IF NOT EXISTS slow_log (start_time TIMESTAMP NOT NULL, user_host MEDIUMTEXT NOT NULL, query_time TIME NOT NULL, lock_time TIME NOT NULL, rows_sent INTEGER NOT NULL, rows_examined INTEGER NOT NULL, db VARCHAR(512) NOT NULL, last_insert_id INTEGER NOT NULL, insert_id INTEGER NOT NULL, server_id INTEGER NOT NULL, sql_text MEDIUMTEXT NOT NULL) engine=CSV CHARACTER SET utf8 comment="Slow log"', 'SET @dummy = 0'); +SET @str = IF (@@have_csv = 'YES', 'CREATE TABLE IF NOT EXISTS slow_log (start_time TIMESTAMP NOT NULL, user_host MEDIUMTEXT NOT NULL, query_time TIME NOT NULL, lock_time TIME NOT NULL, rows_sent INTEGER NOT NULL, rows_examined INTEGER NOT NULL, db VARCHAR(512) NOT NULL, last_insert_id INTEGER NOT NULL, insert_id INTEGER NOT NULL, server_id INTEGER UNSIGNED NOT NULL, sql_text MEDIUMTEXT NOT NULL) engine=CSV CHARACTER SET utf8 comment="Slow log"', 'SET @dummy = 0'); PREPARE stmt FROM @str; EXECUTE stmt; DROP PREPARE stmt; -CREATE TABLE IF NOT EXISTS event ( db char(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL default '', name char(64) CHARACTER SET utf8 NOT NULL default '', body longblob NOT NULL, definer char(77) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL default '', execute_at DATETIME default NULL, interval_value int(11) default NULL, interval_field ENUM('YEAR','QUARTER','MONTH','DAY','HOUR','MINUTE','WEEK','SECOND','MICROSECOND','YEAR_MONTH','DAY_HOUR','DAY_MINUTE','DAY_SECOND','HOUR_MINUTE','HOUR_SECOND','MINUTE_SECOND','DAY_MICROSECOND','HOUR_MICROSECOND','MINUTE_MICROSECOND','SECOND_MICROSECOND') default NULL, created TIMESTAMP NOT NULL, modified TIMESTAMP NOT NULL, last_executed DATETIME default NULL, starts DATETIME default NULL, ends DATETIME default NULL, status ENUM('ENABLED','DISABLED','SLAVESIDE_DISABLED') NOT NULL default 'ENABLED', on_completion ENUM('DROP','PRESERVE') NOT NULL default 'DROP', sql_mode set('REAL_AS_FLOAT','PIPES_AS_CONCAT','ANSI_QUOTES','IGNORE_SPACE','NOT_USED','ONLY_FULL_GROUP_BY','NO_UNSIGNED_SUBTRACTION','NO_DIR_IN_CREATE','POSTGRESQL','ORACLE','MSSQL','DB2','MAXDB','NO_KEY_OPTIONS','NO_TABLE_OPTIONS','NO_FIELD_OPTIONS','MYSQL323','MYSQL40','ANSI','NO_AUTO_VALUE_ON_ZERO','NO_BACKSLASH_ESCAPES','STRICT_TRANS_TABLES','STRICT_ALL_TABLES','NO_ZERO_IN_DATE','NO_ZERO_DATE','INVALID_DATES','ERROR_FOR_DIVISION_BY_ZERO','TRADITIONAL','NO_AUTO_CREATE_USER','HIGH_NOT_PRECEDENCE','NO_ENGINE_SUBSTITUTION','PAD_CHAR_TO_FULL_LENGTH') DEFAULT '' NOT NULL, comment char(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL default '', originator int(10) NOT NULL, time_zone char(64) CHARACTER SET latin1 NOT NULL DEFAULT 'SYSTEM', character_set_client char(32) collate utf8_bin, collation_connection char(32) collate utf8_bin, db_collation char(32) collate utf8_bin, body_utf8 longblob, PRIMARY KEY (db, name) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT 'Events'; +CREATE TABLE IF NOT EXISTS event ( db char(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL default '', name char(64) CHARACTER SET utf8 NOT NULL default '', body longblob NOT NULL, definer char(77) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL default '', execute_at DATETIME default NULL, interval_value int(11) default NULL, interval_field ENUM('YEAR','QUARTER','MONTH','DAY','HOUR','MINUTE','WEEK','SECOND','MICROSECOND','YEAR_MONTH','DAY_HOUR','DAY_MINUTE','DAY_SECOND','HOUR_MINUTE','HOUR_SECOND','MINUTE_SECOND','DAY_MICROSECOND','HOUR_MICROSECOND','MINUTE_MICROSECOND','SECOND_MICROSECOND') default NULL, created TIMESTAMP NOT NULL, modified TIMESTAMP NOT NULL, last_executed DATETIME default NULL, starts DATETIME default NULL, ends DATETIME default NULL, status ENUM('ENABLED','DISABLED','SLAVESIDE_DISABLED') NOT NULL default 'ENABLED', on_completion ENUM('DROP','PRESERVE') NOT NULL default 'DROP', sql_mode set('REAL_AS_FLOAT','PIPES_AS_CONCAT','ANSI_QUOTES','IGNORE_SPACE','NOT_USED','ONLY_FULL_GROUP_BY','NO_UNSIGNED_SUBTRACTION','NO_DIR_IN_CREATE','POSTGRESQL','ORACLE','MSSQL','DB2','MAXDB','NO_KEY_OPTIONS','NO_TABLE_OPTIONS','NO_FIELD_OPTIONS','MYSQL323','MYSQL40','ANSI','NO_AUTO_VALUE_ON_ZERO','NO_BACKSLASH_ESCAPES','STRICT_TRANS_TABLES','STRICT_ALL_TABLES','NO_ZERO_IN_DATE','NO_ZERO_DATE','INVALID_DATES','ERROR_FOR_DIVISION_BY_ZERO','TRADITIONAL','NO_AUTO_CREATE_USER','HIGH_NOT_PRECEDENCE','NO_ENGINE_SUBSTITUTION','PAD_CHAR_TO_FULL_LENGTH') DEFAULT '' NOT NULL, comment char(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL default '', originator INTEGER UNSIGNED NOT NULL, time_zone char(64) CHARACTER SET latin1 NOT NULL DEFAULT 'SYSTEM', character_set_client char(32) collate utf8_bin, collation_connection char(32) collate utf8_bin, db_collation char(32) collate utf8_bin, body_utf8 longblob, PRIMARY KEY (db, name) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT 'Events'; CREATE TABLE IF NOT EXISTS ndb_binlog_index (Position BIGINT UNSIGNED NOT NULL, File VARCHAR(255) NOT NULL, epoch BIGINT UNSIGNED NOT NULL, inserts BIGINT UNSIGNED NOT NULL, updates BIGINT UNSIGNED NOT NULL, deletes BIGINT UNSIGNED NOT NULL, schemaops BIGINT UNSIGNED NOT NULL, PRIMARY KEY(epoch)) ENGINE=MYISAM; diff --git a/scripts/mysql_system_tables_fix.sql b/scripts/mysql_system_tables_fix.sql index a33c4fcb9fa..a6497f57f0a 100644 --- a/scripts/mysql_system_tables_fix.sql +++ b/scripts/mysql_system_tables_fix.sql @@ -216,6 +216,20 @@ ALTER TABLE func MODIFY type enum ('function','aggregate') COLLATE utf8_general_ci NOT NULL; # +# Modify log tables. +# + +SET @old_log_state = @@global.general_log; +SET GLOBAL general_log = 'OFF'; +ALTER TABLE general_log MODIFY COLUMN server_id INTEGER UNSIGNED NOT NULL; +SET GLOBAL general_log = @old_log_state; + +SET @old_log_state = @@global.slow_query_log; +SET GLOBAL slow_query_log = 'OFF'; +ALTER TABLE slow_log MODIFY COLUMN server_id INTEGER UNSIGNED NOT NULL; +SET GLOBAL slow_query_log = @old_log_state; + +# # Detect whether we had Create_view_priv # SET @hadCreateViewPriv:=0; @@ -471,7 +485,10 @@ ALTER TABLE event MODIFY sql_mode 'PAD_CHAR_TO_FULL_LENGTH' ) DEFAULT '' NOT NULL AFTER on_completion; ALTER TABLE event MODIFY name char(64) CHARACTER SET utf8 NOT NULL default ''; -ALTER TABLE event ADD COLUMN originator INT(10) NOT NULL AFTER comment; + +ALTER TABLE event MODIFY COLUMN originator INT UNSIGNED NOT NULL; +ALTER TABLE event ADD COLUMN originator INT UNSIGNED NOT NULL AFTER comment; + ALTER TABLE event MODIFY COLUMN status ENUM('ENABLED','DISABLED','SLAVESIDE_DISABLED') NOT NULL default 'ENABLED'; ALTER TABLE event ADD COLUMN time_zone char(64) CHARACTER SET latin1 diff --git a/sql-bench/TODO b/sql-bench/TODO deleted file mode 100644 index 8a103e89199..00000000000 --- a/sql-bench/TODO +++ /dev/null @@ -1,21 +0,0 @@ -When comparing with ms-sql: - -Check how to get MySQL faster mysql ms-sql - -count_distinct (2000) | 89.00| 39.00| -count_distinct_big (120) | 324.00| 121.00| -count_distinct_group (1000) | 158.00| 107.00| -count_distinct_group_on_key (1000) | 49.00| 17.00| -count_distinct_group_on_key_parts (1| 157.00| 108.00| -order_by_big (10) | 197.00| 89.00| -order_by_big_key (10) | 170.00| 82.00| -order_by_big_key2 (10) | 163.00| 73.00| -order_by_big_key_desc (10) | 172.00| 84.00| -order_by_big_key_diff (10) | 193.00| 89.00| -order_by_big_key_prefix (10) | 165.00| 72.00| - - -Why is the following slow on NT: - NT Linux -update_of_primary_key_many_keys (256| 560.00| 65.00| - diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index fc9375e68a5..05b9563c121 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -105,13 +105,10 @@ String *Item_func_md5::val_str(String *str) str->set_charset(&my_charset_bin); if (sptr) { - my_MD5_CTX context; uchar digest[16]; null_value=0; - my_MD5Init (&context); - my_MD5Update (&context,(uchar *) sptr->ptr(), sptr->length()); - my_MD5Final (digest, &context); + MY_MD5_HASH(digest,(uchar *) sptr->ptr(), sptr->length()); if (str->alloc(32)) // Ensure that memory is free { null_value=1; diff --git a/sql/item_sum.cc b/sql/item_sum.cc index 1821136cc9d..a6d8bb8a52d 100644 --- a/sql/item_sum.cc +++ b/sql/item_sum.cc @@ -439,7 +439,8 @@ void Item_sum::make_field(Send_field *tmp_field) void Item_sum::print(String *str, enum_query_type query_type) { - Item **pargs= orig_args; + /* orig_args is not filled with valid values until fix_fields() */ + Item **pargs= fixed ? orig_args : args; str->append(func_name()); for (uint i=0 ; i < arg_count ; i++) { diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 1391b87e8e3..921bcfcf68e 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -6249,7 +6249,7 @@ Can't be set to 1 if --log-slave-updates is used.", GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"server-id", OPT_SERVER_ID, "Uniquely identifies the server instance in the community of replication partners.", - (uchar**) &server_id, (uchar**) &server_id, 0, GET_ULONG, REQUIRED_ARG, 0, 0, 0, + (uchar**) &server_id, (uchar**) &server_id, 0, GET_ULONG, REQUIRED_ARG, 0, 0, UINT_MAX32, 0, 0, 0}, {"set-variable", 'O', "Change the value of a variable. Please note that this option is deprecated;you can set variables directly with --variable-name=value.", diff --git a/sql/table.cc b/sql/table.cc index 17454ffb012..00a06f51518 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -2982,11 +2982,8 @@ void st_table::reset_item_list(List<Item> *item_list) const void TABLE_LIST::calc_md5(char *buffer) { - my_MD5_CTX context; uchar digest[16]; - my_MD5Init(&context); - my_MD5Update(&context,(uchar *) select_stmt.str, select_stmt.length); - my_MD5Final(digest, &context); + MY_MD5_HASH(digest, (uchar *) select_stmt.str, select_stmt.length); sprintf((char *) buffer, "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x", digest[0], digest[1], digest[2], digest[3], diff --git a/storage/innobase/btr/btr0sea.c b/storage/innobase/btr/btr0sea.c index 3482e16497a..84ad0e27110 100644 --- a/storage/innobase/btr/btr0sea.c +++ b/storage/innobase/btr/btr0sea.c @@ -1105,12 +1105,20 @@ btr_search_drop_page_hash_when_freed( page = buf_page_get_gen(space, page_no, RW_S_LATCH, NULL, BUF_GET_IF_IN_POOL, __FILE__, __LINE__, &mtr); + /* Because the buffer pool mutex was released by + buf_page_peek_if_search_hashed(), it is possible that the + block was removed from the buffer pool by another thread + before buf_page_get_gen() got a chance to acquire the buffer + pool mutex again. Thus, we must check for a NULL return. */ + + if (UNIV_LIKELY(page != NULL)) { #ifdef UNIV_SYNC_DEBUG - buf_page_dbg_add_level(page, SYNC_TREE_NODE_FROM_HASH); + buf_page_dbg_add_level(page, SYNC_TREE_NODE_FROM_HASH); #endif /* UNIV_SYNC_DEBUG */ - btr_search_drop_page_hash_index(page); + btr_search_drop_page_hash_index(page); + } mtr_commit(&mtr); } diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index 522392edc7a..a019b95a2bb 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -953,6 +953,12 @@ innobase_next_autoinc( /* Should never be 0. */ ut_a(increment > 0); + /* According to MySQL documentation, if the offset is greater than + the increment then the offset is ignored. */ + if (offset > increment) { + offset = 0; + } + if (max_value <= current) { next_value = max_value; } else if (offset <= 1) { @@ -3312,8 +3318,8 @@ build_template( goto include_field; } - if (bitmap_is_set(table->read_set, i) || - bitmap_is_set(table->write_set, i)) { + if (bitmap_is_set(table->read_set, i) || + bitmap_is_set(table->write_set, i)) { /* This field is needed in the query */ goto include_field; @@ -3405,7 +3411,7 @@ skip_field: } /************************************************************************ -Get the upper limit of the MySQL integral type. */ +Get the upper limit of the MySQL integral and floating-point type. */ ulonglong ha_innobase::innobase_get_int_col_max_value( @@ -3416,7 +3422,7 @@ ha_innobase::innobase_get_int_col_max_value( switch(field->key_type()) { /* TINY */ - case HA_KEYTYPE_BINARY: + case HA_KEYTYPE_BINARY: max_value = 0xFFULL; break; case HA_KEYTYPE_INT8: @@ -3430,7 +3436,7 @@ ha_innobase::innobase_get_int_col_max_value( max_value = 0x7FFFULL; break; /* MEDIUM */ - case HA_KEYTYPE_UINT24: + case HA_KEYTYPE_UINT24: max_value = 0xFFFFFFULL; break; case HA_KEYTYPE_INT24: @@ -3444,12 +3450,20 @@ ha_innobase::innobase_get_int_col_max_value( max_value = 0x7FFFFFFFULL; break; /* BIG */ - case HA_KEYTYPE_ULONGLONG: + case HA_KEYTYPE_ULONGLONG: max_value = 0xFFFFFFFFFFFFFFFFULL; break; case HA_KEYTYPE_LONGLONG: max_value = 0x7FFFFFFFFFFFFFFFULL; break; + case HA_KEYTYPE_FLOAT: + /* We use the maximum as per IEEE754-2008 standard, 2^24 */ + max_value = 0x1000000ULL; + break; + case HA_KEYTYPE_DOUBLE: + /* We use the maximum as per IEEE754-2008 standard, 2^53 */ + max_value = 0x20000000000000ULL; + break; default: ut_error; } @@ -3772,7 +3786,7 @@ no_commit: will be 0 if get_auto_increment() was not called.*/ if (auto_inc <= col_max_value - && auto_inc > prebuilt->autoinc_last_value) { + && auto_inc >= prebuilt->autoinc_last_value) { set_max_autoinc: ut_a(prebuilt->autoinc_increment > 0); @@ -7650,11 +7664,13 @@ ha_innobase::get_auto_increment( prebuilt->autoinc_last_value = next_value; - ut_a(prebuilt->autoinc_last_value >= *first_value); - - /* Update the table autoinc variable */ - dict_table_autoinc_update_if_greater( - prebuilt->table, prebuilt->autoinc_last_value); + if (prebuilt->autoinc_last_value < *first_value) { + *first_value = (~(ulonglong) 0); + } else { + /* Update the table autoinc variable */ + dict_table_autoinc_update_if_greater( + prebuilt->table, prebuilt->autoinc_last_value); + } } else { /* This will force write_row() into attempting an update of the table's AUTOINC counter. */ |