diff options
198 files changed, 3740 insertions, 847 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 7c173c9cb49..e4dc16040a7 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -47,6 +47,10 @@ SET(WITH_MYISAMMRG_STORAGE_ENGINE TRUE) ADD_DEFINITIONS(-DWITH_MYISAMMRG_STORAGE_ENGINE) SET (mysql_plugin_defs "${mysql_plugin_defs},builtin_myisammrg_plugin") +IF(WITH_COMMUNITY_FEATURES) + ADD_DEFINITIONS(-DENABLED_PROFILING -DCOMMUNITY_SERVER) +ENDIF(WITH_COMMUNITY_FEATURES) + IF(WITH_ARCHIVE_STORAGE_ENGINE) ADD_DEFINITIONS(-DWITH_ARCHIVE_STORAGE_ENGINE) SET (mysql_plugin_defs "${mysql_plugin_defs},builtin_archive_plugin") diff --git a/client/mysql.cc b/client/mysql.cc index 46141cd975f..860fc3a5f6e 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -143,7 +143,8 @@ static my_bool ignore_errors=0,wait_flag=0,quick=0, tty_password= 0, opt_nobeep=0, opt_reconnect=1, default_charset_used= 0, opt_secure_auth= 0, default_pager_set= 0, opt_sigint_ignore= 0, - show_warnings= 0, executing_query= 0, interrupted_query= 0; + show_warnings= 0, executing_query= 0, interrupted_query= 0, + ignore_spaces= 0; static my_bool debug_info_flag, debug_check_flag; static my_bool column_types_flag; static my_bool preserve_comments= 0; @@ -1183,7 +1184,12 @@ int main(int argc,char *argv[]) histfile= 0; } } - if (histfile) + + /* We used to suggest setting MYSQL_HISTFILE=/dev/null. */ + if (histfile && strncmp(histfile, "/dev/null", 10) == 0) + histfile= NULL; + + if (histfile && histfile[0]) { if (verbose) tee_fprintf(stdout, "Reading history-file %s\n",histfile); @@ -1218,7 +1224,8 @@ sig_handler mysql_end(int sig) { mysql_close(&mysql); #ifdef HAVE_READLINE - if (!status.batch && !quick && !opt_html && !opt_xml && histfile) + if (!status.batch && !quick && !opt_html && !opt_xml && + histfile && histfile[0]) { /* write-history */ if (verbose) @@ -1345,7 +1352,7 @@ static struct my_option my_long_options[] = {"debug", '#', "Output debug log", (uchar**) &default_dbug_option, (uchar**) &default_dbug_option, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, #endif - {"debug-check", OPT_DEBUG_CHECK, "Check memory and open file usage at exit .", + {"debug-check", OPT_DEBUG_CHECK, "Check memory and open file usage at exit.", (uchar**) &debug_check_flag, (uchar**) &debug_check_flag, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"debug-info", 'T', "Print some debug info at exit.", (uchar**) &debug_info_flag, @@ -1372,8 +1379,9 @@ static struct my_option my_long_options[] = {"no-named-commands", 'g', "Named commands are disabled. Use \\* form only, or use named commands only in the beginning of a line ending with a semicolon (;) Since version 10.9 the client now starts with this option ENABLED by default! Disable with '-G'. Long format commands still work from the first line. WARNING: option deprecated; use --disable-named-commands instead.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"ignore-spaces", 'i', "Ignore space after function names.", 0, 0, 0, - GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, + {"ignore-spaces", 'i', "Ignore space after function names.", + (uchar**) &ignore_spaces, (uchar**) &ignore_spaces, 0, GET_BOOL, NO_ARG, 0, 0, + 0, 0, 0, 0}, {"local-infile", OPT_LOCAL_INFILE, "Enable/disable LOAD DATA LOCAL INFILE.", (uchar**) &opt_local_infile, (uchar**) &opt_local_infile, 0, GET_BOOL, OPT_ARG, 0, 0, 0, 0, 0, 0}, @@ -1794,6 +1802,10 @@ static int get_options(int argc, char **argv) my_end_arg= MY_CHECK_ERROR | MY_GIVE_INFO; if (debug_check_flag) my_end_arg= MY_CHECK_ERROR; + + if (ignore_spaces) + connect_flag|= CLIENT_IGNORE_SPACE; + return(0); } @@ -3381,9 +3393,12 @@ print_table_data_html(MYSQL_RES *result) { while((field = mysql_fetch_field(result))) { - tee_fprintf(PAGER, "<TH>%s</TH>", (field->name ? - (field->name[0] ? field->name : - " ") : "NULL")); + tee_fputs("<TH>", PAGER); + if (field->name && field->name[0]) + xmlencode_print(field->name, field->name_length); + else + tee_fputs(field->name ? " " : "NULL", PAGER); + tee_fputs("</TH>", PAGER); } (void) tee_fputs("</TR>", PAGER); } @@ -3396,7 +3411,7 @@ print_table_data_html(MYSQL_RES *result) for (uint i=0; i < mysql_num_fields(result); i++) { (void) tee_fputs("<TD>", PAGER); - safe_put_field(cur[i],lengths[i]); + xmlencode_print(cur[i], lengths[i]); (void) tee_fputs("</TD>", PAGER); } (void) tee_fputs("</TR>", PAGER); diff --git a/client/mysql_upgrade.c b/client/mysql_upgrade.c index 190bb2383e9..cbc60d8acad 100644 --- a/client/mysql_upgrade.c +++ b/client/mysql_upgrade.c @@ -115,11 +115,11 @@ static struct my_option my_long_options[]= #endif {"socket", 'S', "Socket file to use for connection.", 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, +#include <sslopt-longopts.h> {"tmpdir", 't', "Directory for temporary files", 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"user", 'u', "User for login if not current user.", (uchar**) &opt_user, (uchar**) &opt_user, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, -#include <sslopt-longopts.h> {"verbose", 'v', "Display more output about the process", (uchar**) &opt_verbose, (uchar**) &opt_verbose, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0}, @@ -231,6 +231,8 @@ get_one_option(int optid, const struct my_option *opt, break; case 'p': + if (argument == disabled_my_option) + argument= (char*) ""; // Don't require password tty_password= 1; add_option= FALSE; if (argument) diff --git a/client/mysqladmin.cc b/client/mysqladmin.cc index df0dc1e7049..9865b67bb3b 100644 --- a/client/mysqladmin.cc +++ b/client/mysqladmin.cc @@ -232,6 +232,8 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), opt_count_iterations= 1; break; case 'p': + if (argument == disabled_my_option) + argument= (char*) ""; // Don't require password if (argument) { char *start=argument; @@ -677,10 +679,16 @@ static int execute_commands(MYSQL *mysql,int argc, char **argv) pos=argv[1]; for (;;) { - if (mysql_kill(mysql,(ulong) atol(pos))) + /* We don't use mysql_kill(), since it only handles 32-bit IDs. */ + char buff[26], *out; /* "KILL " + max 20 digs + NUL */ + out= strxmov(buff, "KILL ", NullS); + ullstr(strtoull(pos, NULL, 0), out); + + if (mysql_query(mysql, buff)) { - my_printf_error(0, "kill failed on %ld; error: '%s'", error_flags, - atol(pos), mysql_error(mysql)); + /* out still points to just the number */ + my_printf_error(0, "kill failed on %s; error: '%s'", error_flags, + out, mysql_error(mysql)); error=1; } if (!(pos=strchr(pos,','))) diff --git a/client/mysqlbinlog.cc b/client/mysqlbinlog.cc index 1621db5ded8..2cf91ec7da5 100644 --- a/client/mysqlbinlog.cc +++ b/client/mysqlbinlog.cc @@ -1226,6 +1226,8 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), one_database = 1; break; case 'p': + if (argument == disabled_my_option) + argument= (char*) ""; // Don't require password if (argument) { my_free(pass,MYF(MY_ALLOW_ZERO_PTR)); @@ -1529,8 +1531,7 @@ static Exit_status dump_remote_log_entries(PRINT_EVENT_INFO *print_event_info, If reading from a remote host, ensure the temp_buf for the Log_event class is pointing to the incoming stream. */ - if (remote_opt) - ev->register_temp_buf((char*) net->read_pos + 1); + ev->register_temp_buf((char *) net->read_pos + 1); Log_event_type type= ev->get_type_code(); if (glob_description_event->binlog_version >= 3 || diff --git a/client/mysqlcheck.c b/client/mysqlcheck.c index d2edd084c57..1bdb28f5a11 100644 --- a/client/mysqlcheck.c +++ b/client/mysqlcheck.c @@ -286,6 +286,8 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), what_to_do= DO_UPGRADE; break; case 'p': + if (argument == disabled_my_option) + argument= (char*) ""; // Don't require password if (argument) { char *start = argument; diff --git a/client/mysqldump.c b/client/mysqldump.c index 5a1fa3cc090..323376dd8bf 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -221,7 +221,7 @@ static struct my_option my_long_options[] = (uchar**) &opt_compatible_mode_str, (uchar**) &opt_compatible_mode_str, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"compact", OPT_COMPACT, - "Give less verbose output (useful for debugging). Disables structure comments and header/footer constructs. Enables options --skip-add-drop-table --no-set-names --skip-disable-keys --skip-add-locks", + "Give less verbose output (useful for debugging). Disables structure comments and header/footer constructs. Enables options --skip-add-drop-table --skip-add-locks --skip-comments --skip-disable-keys --skip-set-charset", (uchar**) &opt_compact, (uchar**) &opt_compact, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"complete-insert", 'c', "Use complete insert statements.", @@ -702,6 +702,8 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), break; #endif case 'p': + if (argument == disabled_my_option) + argument= (char*) ""; // Don't require password if (argument) { char *start=argument; diff --git a/client/mysqlimport.c b/client/mysqlimport.c index 09ba27b287a..ec418244f3d 100644 --- a/client/mysqlimport.c +++ b/client/mysqlimport.c @@ -221,6 +221,8 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), break; #endif case 'p': + if (argument == disabled_my_option) + argument= (char*) ""; // Don't require password if (argument) { char *start=argument; diff --git a/client/mysqlshow.c b/client/mysqlshow.c index 0e696aed211..e401d6cad8f 100644 --- a/client/mysqlshow.c +++ b/client/mysqlshow.c @@ -281,6 +281,8 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), opt_verbose++; break; case 'p': + if (argument == disabled_my_option) + argument= (char*) ""; // Don't require password if (argument) { char *start=argument; diff --git a/client/mysqlslap.c b/client/mysqlslap.c index b8515289df5..4cf8c7204ed 100644 --- a/client/mysqlslap.c +++ b/client/mysqlslap.c @@ -712,6 +712,8 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), verbose++; break; case 'p': + if (argument == disabled_my_option) + argument= (char*) ""; // Don't require password if (argument) { char *start= argument; diff --git a/client/mysqltest.cc b/client/mysqltest.cc index fdd4ff141bc..f29fd36aa27 100644 --- a/client/mysqltest.cc +++ b/client/mysqltest.cc @@ -5665,11 +5665,11 @@ static struct my_option my_long_options[] = {"sp-protocol", OPT_SP_PROTOCOL, "Use stored procedures for select", (uchar**) &sp_protocol, (uchar**) &sp_protocol, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, +#include "sslopt-longopts.h" {"tail-lines", OPT_TAIL_LINES, "Number of lines of the resul to include in a failure report", (uchar**) &opt_tail_lines, (uchar**) &opt_tail_lines, 0, GET_INT, REQUIRED_ARG, 0, 0, 10000, 0, 0, 0}, -#include "sslopt-longopts.h" {"test-file", 'x', "Read test from/in this file (default stdin).", 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"timer-file", 'm', "File where the timing in micro seconds is stored.", @@ -5803,6 +5803,8 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), break; } case 'p': + if (argument == disabled_my_option) + argument= (char*) ""; // Don't require password if (argument) { my_free(opt_pass, MYF(MY_ALLOW_ZERO_PTR)); diff --git a/extra/innochecksum.c b/extra/innochecksum.c index 524637a1729..9bd4bfcc0cd 100644 --- a/extra/innochecksum.c +++ b/extra/innochecksum.c @@ -224,7 +224,7 @@ int main(int argc, char **argv) } else if (verbose) { - printf("file %s= %llu bytes (%lu pages)...\n", argv[1], size, pages); + printf("file %s = %llu bytes (%lu pages)...\n", argv[optind], size, pages); printf("checking pages in range %lu to %lu\n", start_page, use_end_page ? end_page : (pages - 1)); } diff --git a/extra/perror.c b/extra/perror.c index 80eb2af2dae..a98a4fc3d1b 100644 --- a/extra/perror.c +++ b/extra/perror.c @@ -115,7 +115,7 @@ static void usage(void) { print_version(); puts("This software comes with ABSOLUTELY NO WARRANTY. This is free software,\nand you are welcome to modify and redistribute it under the GPL license\n"); - printf("Print a description for a system error code or an error code from\na MyISAM/ISAM/BDB table handler.\n"); + printf("Print a description for a system error code or a MySQL error code.\n"); printf("If you want to get the error for a negative error code, you should use\n-- before the first error code to tell perror that there was no more options.\n\n"); printf("Usage: %s [OPTIONS] [ERRORCODE [ERRORCODE...]]\n",my_progname); my_print_help(my_long_options); diff --git a/include/myisam.h b/include/myisam.h index d7bfdf7191e..02251eeacb4 100644 --- a/include/myisam.h +++ b/include/myisam.h @@ -404,7 +404,8 @@ typedef struct st_mi_check_param my_off_t keydata,totaldata,key_blocks,start_check_pos; ha_rows total_records,total_deleted; ha_checksum record_checksum,glob_crc; - ulong use_buffers,read_buffer_length,write_buffer_length, + ulonglong use_buffers; + ulong read_buffer_length,write_buffer_length, sort_buffer_length,sort_key_blocks; uint out_flag,warning_printed,error_printed,verbose; uint opt_sort_key,total_files,max_level; diff --git a/mysql-test/include/concurrent.inc b/mysql-test/include/concurrent.inc index 2180ec4cc9c..66f8a65a102 100644 --- a/mysql-test/include/concurrent.inc +++ b/mysql-test/include/concurrent.inc @@ -659,11 +659,16 @@ drop table t1; connection thread1; select * from t1; +--echo ** Cleanup +connection thread1; +disconnect thread1; +--source include/wait_until_disconnected.inc +--echo ** connection thread2 +connection thread2; +disconnect thread2; +--source include/wait_until_disconnected.inc --echo ** connection default connection default; drop table t1; drop user mysqltest@localhost; -disconnect thread1; -disconnect thread2; - diff --git a/mysql-test/include/grant_cache.inc b/mysql-test/include/grant_cache.inc index 501e115f0ee..47eef1cdb67 100644 --- a/mysql-test/include/grant_cache.inc +++ b/mysql-test/include/grant_cache.inc @@ -171,15 +171,30 @@ show status like "Qcache_not_cached"; # Cleanup ---echo ----- switch to connection default and close connections ----- -connection default; +--echo ----- close connections ----- +connection root; disconnect root; +--source include/wait_until_disconnected.inc +connection root2; disconnect root2; +--source include/wait_until_disconnected.inc +connection user1; disconnect user1; +--source include/wait_until_disconnected.inc +connection user2; disconnect user2; +--source include/wait_until_disconnected.inc +connection user3; disconnect user3; +--source include/wait_until_disconnected.inc +connection user4; disconnect user4; +--source include/wait_until_disconnected.inc +connection unkuser; disconnect unkuser; +--source include/wait_until_disconnected.inc +--echo ----- switch to connection default ----- +connection default; # # A temporary 4.1 workaround to make this test pass if diff --git a/mysql-test/include/handler.inc b/mysql-test/include/handler.inc index 96f90aba8e0..6e7f53ba9b2 100644 --- a/mysql-test/include/handler.inc +++ b/mysql-test/include/handler.inc @@ -719,6 +719,7 @@ connection con1; --reap drop table t1; disconnect con1; +--source include/wait_until_disconnected.inc connection default; # diff --git a/mysql-test/include/mix1.inc b/mysql-test/include/mix1.inc index 7c87949830f..303f896cdfe 100644 --- a/mysql-test/include/mix1.inc +++ b/mysql-test/include/mix1.inc @@ -1162,6 +1162,15 @@ ROLLBACK; --error 1305 ROLLBACK TO SAVEPOINT s4; +# +# Bug#39793 Foreign keys not constructed when column has a '#' in a comment or default value +# + +#This statement should be written on a single line for proper testing +CREATE TABLE t1 (f1 INTEGER PRIMARY KEY COMMENT 'My ID#', f2 INTEGER DEFAULT NULL, f3 CHAR(10) DEFAULT 'My ID#', CONSTRAINT f2_ref FOREIGN KEY (f2) REFERENCES t1 (f1)) ENGINE=INNODB; +SHOW CREATE TABLE t1; +DROP TABLE t1; + --echo End of 5.0 tests # Fix for BUG#19243 "wrong LAST_INSERT_ID() after ON DUPLICATE KEY @@ -1535,4 +1544,31 @@ SELECT 1 FROM (SELECT COUNT(DISTINCT c1) DROP TABLE t1; +eval +CREATE TABLE t1 (c1 REAL, c2 REAL, c3 REAL, KEY (c3), KEY (c2, c3)) + ENGINE=$engine_type; +INSERT INTO t1 VALUES (1,1,1), (1,1,1), (1,1,2), (1,1,1), (1,1,2); + +SELECT 1 FROM (SELECT COUNT(DISTINCT c1) + FROM t1 WHERE c2 IN (1, 1) AND c3 = 2 GROUP BY c2) x; +EXPLAIN +SELECT 1 FROM (SELECT COUNT(DISTINCT c1) + FROM t1 WHERE c2 IN (1, 1) AND c3 = 2 GROUP BY c2) x; + +DROP TABLE t1; + +eval +CREATE TABLE t1 (c1 DECIMAL(12,2), c2 DECIMAL(12,2), c3 DECIMAL(12,2), + KEY (c3), KEY (c2, c3)) + ENGINE=$engine_type; +INSERT INTO t1 VALUES (1,1,1), (1,1,1), (1,1,2), (1,1,1), (1,1,2); + +SELECT 1 FROM (SELECT COUNT(DISTINCT c1) + FROM t1 WHERE c2 IN (1, 1) AND c3 = 2 GROUP BY c2) x; +EXPLAIN +SELECT 1 FROM (SELECT COUNT(DISTINCT c1) + FROM t1 WHERE c2 IN (1, 1) AND c3 = 2 GROUP BY c2) x; + +DROP TABLE t1; + --echo End of 5.1 tests diff --git a/mysql-test/include/mtr_check.sql b/mysql-test/include/mtr_check.sql index 12cb2c870a2..9db631a2615 100644 --- a/mysql-test/include/mtr_check.sql +++ b/mysql-test/include/mtr_check.sql @@ -57,3 +57,13 @@ BEGIN mysql.user; END|| + +-- +-- Procedure used by test case used to force all +-- servers to restart after testcase and thus skipping +-- check test case after test +-- +CREATE DEFINER=root@localhost PROCEDURE force_restart() +BEGIN + SELECT 1 INTO OUTFILE 'force_restart'; +END|| diff --git a/mysql-test/include/mysqldump.inc b/mysql-test/include/mysqldump.inc new file mode 100644 index 00000000000..6227138b012 --- /dev/null +++ b/mysql-test/include/mysqldump.inc @@ -0,0 +1,50 @@ +################################################################################ +# mysqldump.inc +# +# SUMMARY: include file to facilitate testing the quality of mysqldump output +# +# INPUTS: Two variables: +# $table_name - the name of the table that was dumped +# $mysqldumpfile - the name of the file that captured mysqldump output +# +# OUTPUTS: minor echo data: +# We 'echo' some stage information to the .result file: +# 'altering original table', 'restoring from dumpfile', 'comparing' +# +# OTHER FILES: We use include/diff_tables.inc to compare the original, renamed +# table with the 'restored' one. +# +# DESCRIPTION: This file works by being fed the name of the original table +# and a mysqldump output file. The original table is then renamed +# to <table_name>_orig, the mysqldump file is used to recreate the +# table, then diff_tables.inc is called to compare them. +# +# LIMITATIONS: Does *NOT* work with xml output! +# +# AUTHOR: pcrews 2009-05-21 +# Bug#40465 mysqldump.test does no checking of dump or restore +# +# LAST CHANGE: 2009-05-21 +# +################################################################################ + +--echo # Begin testing mysqldump output + restore +--echo # Create 'original table name - <table>_orig +# NOTE: We use SET then let as query_get_value has issues with the extra commas +# used in the CONCAT statement. +eval SET @orig_table_name = CONCAT('$table_name', '_orig'); +let $orig_table_name = query_get_value(SELECT @orig_table_name,@orig_table_name,1); +--echo # Rename original table +eval ALTER TABLE $table_name RENAME to $orig_table_name; +--echo # Recreate table from mysqldump output +--exec $MYSQL test < $mysqldumpfile +--echo # Compare original and recreated tables +--echo # Recreated table: $table_name +--echo # Original table: $orig_table_name +let $diff_table_1 = $table_name; +let $diff_table_2 = $orig_table_name; +--source include/diff_tables.inc +--echo # Cleanup +--remove_file $mysqldumpfile +eval DROP TABLE $table_name, $orig_table_name; + diff --git a/mysql-test/include/query_cache.inc b/mysql-test/include/query_cache.inc index 77ea0021a5d..7ce97b42158 100644 --- a/mysql-test/include/query_cache.inc +++ b/mysql-test/include/query_cache.inc @@ -177,6 +177,7 @@ show status like "Qcache_hits"; # Final cleanup eval set GLOBAL query_cache_size=$save_query_cache_size; +disconnect connection1; +--source include/wait_until_disconnected.inc connection default; drop table t2; -disconnect connection1; diff --git a/mysql-test/lib/My/CoreDump.pm b/mysql-test/lib/My/CoreDump.pm index f3e9f521384..3ac9e385070 100644 --- a/mysql-test/lib/My/CoreDump.pm +++ b/mysql-test/lib/My/CoreDump.pm @@ -22,6 +22,33 @@ use My::Platform; use File::Temp qw/ tempfile tempdir /; +my $hint_mysqld; # Last resort guess for executable path + +# If path in core file is 79 chars we assume it's been truncated +# Looks like we can still find the full path using 'strings' +# If that doesn't work, use the hint (mysqld path) as last resort. + +sub _verify_binpath { + my ($binary, $core_name)= @_; + my $binpath; + + if (length $binary != 79) { + $binpath= $binary; + print "Core generated by '$binpath'\n"; + } else { + # Last occurrence of path ending in /mysql*, cut from first / + if (`strings '$core_name' | grep "/mysql[^/. ]*\$" | tail -1` =~ /(\/.*)/) { + $binpath= $1; + print "Guessing that core was generated by '$binpath'\n"; + } else { + return unless $hint_mysqld; + $binpath= $hint_mysqld; + print "Wild guess that core was generated by '$binpath'\n"; + } + } + return $binpath; +} + sub _gdb { my ($core_name)= @_; @@ -33,7 +60,8 @@ sub _gdb { `gdb -c '$core_name' --batch 2>&1` =~ /Core was generated by `([^\s\'\`]+)/; my $binary= $1 or return; - print "Core generated by '$binary'\n"; + + $binary= _verify_binpath ($binary, $core_name) or return; # Create tempfile containing gdb commands my ($tmp, $tmp_name) = tempfile(); @@ -73,7 +101,8 @@ sub _dbx { `echo | dbx - '$core_name' 2>&1` =~ /Corefile specified executable: "([^"]+)"/; my $binary= $1 or return; - print "Core generated by '$binary'\n"; + + $binary= _verify_binpath ($binary, $core_name) or return; # Find all threads my @thr_ids = `echo threads | dbx '$binary' '$core_name' 2>&1` =~ /t@\d+/g; @@ -203,7 +232,7 @@ sub _cdb { my $cdb_cmd = "!sym prompts off; !analyze -v; .ecxr; !for_each_frame dv /t;!uniqstack -p;q"; my $cdb_output= - `cdb -z $core_name -i "$image_path" -y "$symbol_path" -t 0 -lines -c "$cdb_cmd" 2>&1`; + `cdb -c "$cdb_cmd" -z $core_name -i "$image_path" -y "$symbol_path" -t 0 -lines 2>&1`; return if $? >> 8; return unless $cdb_output; @@ -225,7 +254,8 @@ EOF sub show { - my ($class, $core_name)= @_; + my ($class, $core_name, $exe_mysqld)= @_; + $hint_mysqld= $exe_mysqld; # On Windows, rely on cdb to be there... if (IS_WINDOWS) diff --git a/mysql-test/lib/My/File/Path.pm b/mysql-test/lib/My/File/Path.pm index 99edeecdaf7..25a26568eee 100644 --- a/mysql-test/lib/My/File/Path.pm +++ b/mysql-test/lib/My/File/Path.pm @@ -164,6 +164,9 @@ sub copytree { copytree("$from_dir/$_", "$to_dir/$_"); next; } + + # Only copy plain files + next unless -f "$from_dir/$_"; copy("$from_dir/$_", "$to_dir/$_"); } closedir(DIR); diff --git a/mysql-test/lib/My/SafeProcess.pm b/mysql-test/lib/My/SafeProcess.pm index 5ef3286ad8e..7e102b628ca 100644 --- a/mysql-test/lib/My/SafeProcess.pm +++ b/mysql-test/lib/My/SafeProcess.pm @@ -536,7 +536,37 @@ sub wait_any { return $proc; } + +# +# Wait for all processes to exit +# +sub wait_all { + while(keys %running) + { + wait_any(); + } +} + + # +# Check if any process has exited, but don't wait. +# +# Returns a reference to the SafeProcess that +# exited or undefined +# +sub check_any { + for my $proc (values %running){ + if ( $proc->is_child($$) ) { + if (not $proc->wait_one(0)) { + _verbose ("Found exited $proc"); + return $proc; + } + } + } + return undef; +} + + # Overload string operator # and fallback to default functions if no # overloaded function is found diff --git a/mysql-test/lib/My/SafeProcess/Base.pm b/mysql-test/lib/My/SafeProcess/Base.pm index 3fc1b1be017..9a6871264b8 100644 --- a/mysql-test/lib/My/SafeProcess/Base.pm +++ b/mysql-test/lib/My/SafeProcess/Base.pm @@ -83,6 +83,13 @@ sub exit_status { }; } +# threads.pm may not exist everywhere, so use only on Windows. + +use if $^O eq "MSWin32", "threads"; +use if $^O eq "MSWin32", "threads::shared"; + +my $win32_spawn_lock :shared; + # # Create a new process @@ -104,6 +111,8 @@ sub create_process { if ($^O eq "MSWin32"){ + lock($win32_spawn_lock); + #printf STDERR "stdin %d, stdout %d, stderr %d\n", # fileno STDIN, fileno STDOUT, fileno STDERR; diff --git a/mysql-test/lib/My/SafeProcess/safe_process_win.cc b/mysql-test/lib/My/SafeProcess/safe_process_win.cc index 4fb89f098ed..80c1b7a97f2 100755 --- a/mysql-test/lib/My/SafeProcess/safe_process_win.cc +++ b/mysql-test/lib/My/SafeProcess/safe_process_win.cc @@ -259,22 +259,37 @@ int main(int argc, const char** argv ) the JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE flag, making sure it will be terminated when the last handle to it is closed(which is owned by this process). + + If breakaway from job fails on some reason, fallback is to create a + new process group. Process groups also allow to kill process and its + descedants, subject to some restrictions (processes have to run within + the same console,and must not ignore CTRL_BREAK) */ - if (CreateProcess(NULL, (LPSTR)child_args, + DWORD create_flags[]= {CREATE_BREAKAWAY_FROM_JOB, CREATE_NEW_PROCESS_GROUP, 0}; + BOOL process_created= FALSE; + BOOL jobobject_assigned= FALSE; + + for (int i=0; i < sizeof(create_flags)/sizeof(create_flags[0]); i++) + { + process_created= CreateProcess(NULL, (LPSTR)child_args, NULL, NULL, TRUE, /* inherit handles */ - CREATE_SUSPENDED | CREATE_BREAKAWAY_FROM_JOB, + CREATE_SUSPENDED | create_flags[i], NULL, NULL, &si, - &process_info) == 0) - die("CreateProcess failed"); + &process_info); + if (process_created) + { + jobobject_assigned= AssignProcessToJobObject(job_handle, process_info.hProcess); + break; + } + } - if (AssignProcessToJobObject(job_handle, process_info.hProcess) == 0) + if (!process_created) { - TerminateProcess(process_info.hProcess, 200); - die("AssignProcessToJobObject failed"); + die("CreateProcess failed"); } ResumeThread(process_info.hThread); CloseHandle(process_info.hThread); @@ -312,6 +327,13 @@ int main(int argc, const char** argv ) message("TerminateJobObject failed"); CloseHandle(job_handle); message("Job terminated and closed"); + + if (!jobobject_assigned) + { + GenerateConsoleCtrlEvent(CTRL_BREAK_EVENT, process_info.dwProcessId); + TerminateProcess(process_info.hProcess, 202); + } + if (wait_res != WAIT_OBJECT_0 + CHILD) { /* The child has not yet returned, wait for it */ diff --git a/mysql-test/lib/mtr_cases.pm b/mysql-test/lib/mtr_cases.pm index 23a85ef7ecc..2a7b07debd0 100644 --- a/mysql-test/lib/mtr_cases.pm +++ b/mysql-test/lib/mtr_cases.pm @@ -33,7 +33,7 @@ our $print_testcases; our $skip_rpl; our $do_test; our $skip_test; -our $opt_skip_combination; +our $skip_combinations; our $binlog_format; our $enable_disabled; our $default_storage_engine; @@ -119,11 +119,22 @@ sub collect_test_cases ($$) { if ( $test->{name} =~ /.*\.$tname/ ) { $found= 1; + last; } } if ( not $found ) { - mtr_error("Could not find '$tname' in '$suites' suite(s)"); + mtr_error("Could not find '$tname' in '$suites' suite(s)") unless $sname; + # If suite was part of name, find it there + my ($this_case) = collect_one_suite($sname, [ $tname ]); + if ($this_case) + { + push (@$cases, $this_case); + } + else + { + mtr_error("Could not find '$tname' in '$sname' suite"); + } } } } @@ -375,7 +386,7 @@ sub collect_one_suite($) # Read combinations for this suite and build testcases x combinations # if any combinations exists # ---------------------------------------------------------------------- - if ( ! $opt_skip_combination ) + if ( ! $skip_combinations ) { my @combinations; my $combination_file= "$suitedir/combinations"; @@ -887,7 +898,8 @@ sub collect_one_test_case { if ( $tinfo->{'innodb_test'} ) { # This is a test that need innodb - if ( $::mysqld_variables{'innodb'} ne "TRUE" ) + if ( $::mysqld_variables{'innodb'} eq "OFF" || + ! exists $::mysqld_variables{'innodb'} ) { # innodb is not supported, skip it $tinfo->{'skip'}= 1; diff --git a/mysql-test/lib/mtr_process.pl b/mysql-test/lib/mtr_process.pl index a99119a199d..a42627c93cd 100644 --- a/mysql-test/lib/mtr_process.pl +++ b/mysql-test/lib/mtr_process.pl @@ -21,7 +21,25 @@ use strict; use Socket; use Errno; - +use My::Platform; +use if IS_WINDOWS, "Net::Ping"; + +# Ancient perl might not have port_number method for Net::Ping. +# Check it and use fallback to connect() if it is not present. +BEGIN +{ + my $use_netping= 0; + if (IS_WINDOWS) + { + my $ping = Net::Ping->new(); + if ($ping->can("port_number")) + { + $use_netping= 1; + } + } + eval 'sub USE_NETPING { $use_netping }'; +} + sub sleep_until_file_created ($$$); sub mtr_ping_port ($); @@ -30,6 +48,24 @@ sub mtr_ping_port ($) { mtr_verbose("mtr_ping_port: $port"); + if (IS_WINDOWS && USE_NETPING) + { + # Under Windows, connect to a port that is not open is slow + # It takes ~1sec. Net::Ping with small timeout is much faster. + my $ping = Net::Ping->new(); + $ping->port_number($port); + if ($ping->ping("localhost",0.1)) + { + mtr_verbose("USED"); + return 1; + } + else + { + mtr_verbose("FREE"); + return 0; + } + } + my $remote= "localhost"; my $iaddr= inet_aton($remote); if ( ! $iaddr ) diff --git a/mysql-test/lib/mtr_report.pm b/mysql-test/lib/mtr_report.pm index 9c6ab35ee5e..93463d88d74 100644 --- a/mysql-test/lib/mtr_report.pm +++ b/mysql-test/lib/mtr_report.pm @@ -30,6 +30,8 @@ our @EXPORT= qw(report_option mtr_print_line mtr_print_thick_line mtr_report_test); use mtr_match; +use My::Platform; +use POSIX qw[ _exit ]; require "mtr_io.pl"; my $tot_real_time= 0; @@ -257,6 +259,17 @@ sub mtr_report_stats ($) { $tot_restarts++; } + # Add counts for repeated runs, if any. + # Note that the last run has already been counted above. + my $num_repeat = $tinfo->{'repeat'} - 1; + if ( $num_repeat > 0 ) + { + $tot_tests += $num_repeat; + my $rep_failed = $tinfo->{'rep_failures'} || 0; + $tot_failed += $rep_failed; + $tot_passed += $num_repeat - $rep_failed; + } + # Look for warnings produced by mysqltest my $base_file= mtr_match_extension($tinfo->{'result_file'}, "result"); # Trim extension @@ -336,7 +349,7 @@ sub mtr_report_stats ($) { foreach my $tinfo (@$tests) { my $tname= $tinfo->{'name'}; - if ( $tinfo->{failures} and ! $seen{$tname}) + if ( ($tinfo->{failures} || $tinfo->{rep_failures}) and ! $seen{$tname}) { print " $tname"; $seen{$tname}= 1; @@ -459,7 +472,14 @@ sub mtr_warning (@) { sub mtr_error (@) { print STDERR _name(), _timestamp(), "mysql-test-run: *** ERROR: ", join(" ", @_), "\n"; - exit(1); + if (IS_WINDOWS) + { + POSIX::_exit(1); + } + else + { + exit(1); + } } diff --git a/mysql-test/lib/mtr_unique.pm b/mysql-test/lib/mtr_unique.pm index 294a5d7b4d6..6b60157422d 100644 --- a/mysql-test/lib/mtr_unique.pm +++ b/mysql-test/lib/mtr_unique.pm @@ -28,32 +28,36 @@ sub msg { # print "### unique($$) - ", join(" ", @_), "\n"; } -my $file; +my $dir; if(!IS_WINDOWS) { - $file= "/tmp/mysql-test-ports"; + $dir= "/tmp/mysql-unique-ids"; } else { - $file= $ENV{'TEMP'}."/mysql-test-ports"; + # Try to use machine-wide directory location for unique IDs, + # $ALLUSERSPROFILE . IF it is not available, fallback to $TEMP + # which is typically a per-user temporary directory + if (exists $ENV{'ALLUSERSPROFILE'} && -w $ENV{'ALLUSERSPROFILE'}) + { + $dir= $ENV{'ALLUSERSPROFILE'}."/mysql-unique-ids"; + } + else + { + $dir= $ENV{'TEMP'}."/mysql-unique-ids"; + } } - -my %mtr_unique_ids; +my $mtr_unique_fh = undef; -END { - my $allocated_id= $mtr_unique_ids{$$}; - if (defined $allocated_id) - { - mtr_release_unique_id($allocated_id); - } - delete $mtr_unique_ids{$$}; +END +{ + mtr_release_unique_id(); } # -# Get a unique, numerical ID, given a file name (where all -# requested IDs are stored), a minimum and a maximum value. +# Get a unique, numerical ID in a specified range. # # If no unique ID within the specified parameters can be # obtained, return undef. @@ -61,135 +65,63 @@ END { sub mtr_get_unique_id($$) { my ($min, $max)= @_;; - msg("get, '$file', $min-$max"); - - die "Can only get one unique id per process!" if $mtr_unique_ids{$$}; + msg("get $min-$max, $$"); - my $ret = undef; - my $changed = 0; - - if(eval("readlink '$file'") || eval("readlink '$file.sem'")) { - die 'lock file is a symbolic link'; - } + die "Can only get one unique id per process!" if defined $mtr_unique_fh; - chmod 0777, "$file.sem"; - open SEM, ">", "$file.sem" or die "can't write to $file.sem"; - flock SEM, LOCK_EX or die "can't lock $file.sem"; - if(! -e $file) { - open FILE, ">", $file or die "can't create $file"; - close FILE; - } - msg("HAVE THE LOCK"); + # Make sure our ID directory exists + if (! -d $dir) + { + # If there is a file with the reserved + # directory name, just delete the file. + if (-e $dir) + { + unlink($dir); + } - if(eval("readlink '$file'") || eval("readlink '$file.sem'")) { - die 'lock file is a symbolic link'; - } + mkdir $dir; + chmod 0777, $dir; - chmod 0777, $file; - open FILE, "+<", $file or die "can't open $file"; - #select undef,undef,undef,0.2; - seek FILE, 0, 0; - my %taken = (); - while(<FILE>) { - chomp; - my ($id, $pid) = split / /; - $taken{$id} = $pid; - msg("taken: $id, $pid"); - # Check if process with given pid is alive - if(!process_alive($pid)) { - print "Removing slot $id used by missing process $pid\n"; - msg("Removing slot $id used by missing process $pid"); - delete $taken{$id}; - $changed++; + if(! -d $dir) + { + die "can't make directory $dir"; } } - for(my $i=$min; $i<=$max; ++$i) { - if(! exists $taken{$i}) { - $ret = $i; - $taken{$i} = $$; - $changed++; - # Remember the id this process got - $mtr_unique_ids{$$}= $i; - msg(" got $i"); - last; + + + my $fh; + for(my $id = $min; $id <= $max; $id++) + { + open( $fh, ">$dir/$id"); + chmod 0666, "$dir/$id"; + # Try to lock the file exclusively. If lock succeeds, we're done. + if (flock($fh, LOCK_EX|LOCK_NB)) + { + # Store file handle - we would need it to release the ID (==unlock the file) + $mtr_unique_fh = $fh; + return $id; } - } - if($changed) { - seek FILE, 0, 0; - truncate FILE, 0 or die "can't truncate $file"; - for my $k (keys %taken) { - print FILE $k . ' ' . $taken{$k} . "\n"; + else + { + close $fh; } } - close FILE; - - msg("RELEASING THE LOCK"); - flock SEM, LOCK_UN or warn "can't unlock $file.sem"; - close SEM; - - return $ret; + return undef; } # # Release a unique ID. # -sub mtr_release_unique_id($) { - my ($myid)= @_; - - msg("release, $myid"); - - - if(eval("readlink '$file'") || eval("readlink '$file.sem'")) { - die 'lock file is a symbolic link'; - } - - open SEM, ">", "$file.sem" or die "can't write to $file.sem"; - flock SEM, LOCK_EX or die "can't lock $file.sem"; - - msg("HAVE THE LOCK"); - - if(eval("readlink '$file'") || eval("readlink '$file.sem'")) { - die 'lock file is a symbolic link'; - } - - if(! -e $file) { - open FILE, ">", $file or die "can't create $file"; - close FILE; - } - open FILE, "+<", $file or die "can't open $file"; - #select undef,undef,undef,0.2; - seek FILE, 0, 0; - my %taken = (); - while(<FILE>) { - chomp; - my ($id, $pid) = split / /; - msg(" taken, $id $pid"); - $taken{$id} = $pid; - } - - if ($taken{$myid} != $$) +sub mtr_release_unique_id() +{ + msg("release $$"); + if (defined $mtr_unique_fh) { - msg(" The unique id for this process does not match pid"); + close $mtr_unique_fh; + $mtr_unique_fh = undef; } - - - msg(" removing $myid"); - delete $taken{$myid}; - seek FILE, 0, 0; - truncate FILE, 0 or die "can't truncate $file"; - for my $k (keys %taken) { - print FILE $k . ' ' . $taken{$k} . "\n"; - } - close FILE; - - msg("RELEASE THE LOCK"); - - 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 3949148ec49..45ee54442d6 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -209,6 +209,7 @@ sub check_timeout { return $opt_testcase_timeout * 6; }; my $opt_start; my $opt_start_dirty; +my $opt_wait_all; my $opt_repeat= 1; my $opt_retry= 3; my $opt_retry_failure= 2; @@ -429,6 +430,7 @@ sub run_test_server ($$$) { my $completed= []; my %running; my $result; + my $exe_mysqld= find_mysqld($basedir) || ""; # Used as hint to CoreDump my $suite_timeout_proc= My::SafeProcess->timer(suite_timeout()); @@ -500,7 +502,7 @@ sub run_test_server ($$$) { mtr_report(" - found '$core_name'", "($num_saved_cores/$opt_max_save_core)"); - My::CoreDump->show($core_file); + My::CoreDump->show($core_file, $exe_mysqld); if ($num_saved_cores >= $opt_max_save_core) { mtr_report(" - deleting it, already saved", @@ -515,6 +517,7 @@ sub run_test_server ($$$) { } } $num_saved_datadir++; + $num_failed_test++ unless $result->{retries}; if ( !$opt_force ) { # Test has failed, force is off @@ -529,7 +532,6 @@ sub run_test_server ($$$) { "Terminating..."); return undef; } - $num_failed_test++; } # Retry test run after test failure @@ -554,9 +556,11 @@ sub run_test_server ($$$) { # Repeat test $opt_repeat number of times my $repeat= $result->{repeat} || 1; - if ($repeat < $opt_repeat) + # Don't repeat if test was skipped + if ($repeat < $opt_repeat && $result->{'result'} ne 'MTR_RES_SKIPPED') { $result->{retries}= 0; + $result->{rep_failures}++ if $result->{failures}; $result->{failures}= 0; delete($result->{result}); $result->{repeat}= $repeat+1; @@ -876,6 +880,7 @@ sub command_line_setup { 'sleep=i' => \$opt_sleep, 'start-dirty' => \$opt_start_dirty, 'start' => \$opt_start, + 'wait-all' => \$opt_wait_all, 'print-testcases' => \&collect_option, 'repeat=i' => \$opt_repeat, 'retry=i' => \$opt_retry, @@ -1234,6 +1239,15 @@ sub command_line_setup { } # -------------------------------------------------------------------------- + # Check use of wait-all + # -------------------------------------------------------------------------- + + if ($opt_wait_all && ! ($opt_start_dirty || $opt_start)) + { + mtr_error("--wait-all can only be used with --start or --start-dirty"); + } + + # -------------------------------------------------------------------------- # Check timeout arguments # -------------------------------------------------------------------------- @@ -1323,29 +1337,31 @@ sub set_build_thread_ports($) { if ( lc($opt_build_thread) eq 'auto' ) { my $found_free = 0; - $build_thread = 250; # Start attempts from here + $build_thread = 300; # Start attempts from here while (! $found_free) { - $build_thread= mtr_get_unique_id($build_thread, 299); + $build_thread= mtr_get_unique_id($build_thread, 349); if ( !defined $build_thread ) { - mtr_error("Could not get a unique build thread id"); + 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; + if (! $found_free) { + mtr_release_unique_id(); + $build_thread++; + } } } else { $build_thread = $opt_build_thread + $thread - 1; + 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") + } } $ENV{MTR_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; if ( $baseport < 5001 or $baseport + 9 >= 32767 ) @@ -3134,6 +3150,26 @@ sub find_analyze_request } +# The test can leave a file in var/tmp/ to signal +# that all servers should be restarted +sub restart_forced_by_test +{ + my $restart = 0; + foreach my $mysqld ( mysqlds() ) + { + my $datadir = $mysqld->value('datadir'); + my $force_restart_file = "$datadir/mtr/force_restart"; + if ( -f $force_restart_file ) + { + mtr_verbose("Restart of servers forced by test"); + $restart = 1; + last; + } + } + return $restart; +} + + # Return timezone value of tinfo or default value sub timezone { my ($tinfo)= @_; @@ -3175,7 +3211,7 @@ sub run_testcase ($) { { # Remove old datadirs - clean_datadir(); + clean_datadir() unless $opt_start_dirty; # Restore old ENV while (my ($option, $value)= each( %old_env )) { @@ -3242,19 +3278,29 @@ sub run_testcase ($) { # -------------------------------------------------------------------- # If --start or --start-dirty given, stop here to let user manually # run tests + # If --wait-all is also given, do the same, but don't die if one + # server exits # ---------------------------------------------------------------------- + if ( $opt_start or $opt_start_dirty ) { mtr_print("\nStarted", started(all_servers())); mtr_print("Waiting for server(s) to exit..."); - my $proc= My::SafeProcess->wait_any(); - if ( grep($proc eq $_, started(all_servers())) ) - { - mtr_print("Server $proc died"); + if ( $opt_wait_all ) { + My::SafeProcess->wait_all(); + mtr_print( "All servers exited" ); + exit(1); + } + else { + my $proc= My::SafeProcess->wait_any(); + if ( grep($proc eq $_, started(all_servers())) ) + { + mtr_print("Server $proc died"); + exit(1); + } + mtr_print("Unknown process $proc died"); exit(1); } - mtr_print("Unknown process $proc died"); - exit(1); } my $test_timeout_proc= My::SafeProcess->timer(testcase_timeout()); @@ -3272,10 +3318,38 @@ sub run_testcase ($) { } my $test= start_mysqltest($tinfo); + # Set only when we have to keep waiting after expectedly died server + my $keep_waiting_proc = 0; while (1) { - my $proc= My::SafeProcess->wait_any(); + my $proc; + if ($keep_waiting_proc) + { + # Any other process exited? + $proc = My::SafeProcess->check_any(); + if ($proc) + { + mtr_verbose ("Found exited process $proc"); + # If that was the timeout, cancel waiting + if ( $proc eq $test_timeout_proc ) + { + $keep_waiting_proc = 0; + } + } + else + { + $proc = $keep_waiting_proc; + } + } + else + { + $proc= My::SafeProcess->wait_any(); + } + + # Will be restored if we need to keep waiting + $keep_waiting_proc = 0; + unless ( defined $proc ) { mtr_error("wait_any failed"); @@ -3302,7 +3376,11 @@ sub run_testcase ($) { if ( $res == 0 ) { my $check_res; - if ( $opt_check_testcases and + if ( restart_forced_by_test() ) + { + stop_all_servers(); + } + elsif ( $opt_check_testcases and $check_res= check_testcase($tinfo, "after")) { if ($check_res == 1) { @@ -3367,8 +3445,12 @@ sub run_testcase ($) { # ---------------------------------------------------- # Check if it was an expected crash # ---------------------------------------------------- - if ( check_expected_crash_and_restart($proc) ) + my $check_crash = check_expected_crash_and_restart($proc); + if ($check_crash) { + # Keep waiting if it returned 2, if 1 don't wait or stop waiting. + $keep_waiting_proc = 0 if $check_crash == 1; + $keep_waiting_proc = $proc if $check_crash == 2; next; } @@ -3709,16 +3791,16 @@ sub check_expected_crash_and_restart { { mtr_verbose("Crash was expected, file '$expect_file' exists"); - while (1){ - + for (my $waits = 0; $waits < 50; $waits++) + { # If last line in expect file starts with "wait" # sleep a little and try again, thus allowing the # test script to control when the server should start - # up again + # up again. Keep trying for up to 5s at a time. my $last_line= mtr_lastlinesfromfile($expect_file, 1); if ($last_line =~ /^wait/ ) { - mtr_verbose("Test says wait before restart"); + mtr_verbose("Test says wait before restart") if $waits == 0; mtr_milli_sleep(100); next; } @@ -3728,11 +3810,11 @@ sub check_expected_crash_and_restart { # Start server with same settings as last time mysqld_start($mysqld, $mysqld->{'started_opts'}); - last; + return 1; } + # Loop ran through: we should keep waiting after a re-check + return 2; } - - return 1; } # Not an expected crash @@ -4431,14 +4513,17 @@ sub start_servers($) { my $mysqld_basedir= $mysqld->value('basedir'); if ( $basedir eq $mysqld_basedir ) { - # Copy datadir from installed system db - for my $path ( "$opt_vardir", "$opt_vardir/..") { - my $install_db= "$path/install.db"; - copytree($install_db, $datadir) - if -d $install_db; + if (! $opt_start_dirty) # If dirty, keep possibly grown system db + { + # Copy datadir from installed system db + for my $path ( "$opt_vardir", "$opt_vardir/..") { + my $install_db= "$path/install.db"; + copytree($install_db, $datadir) + if -d $install_db; + } + mtr_error("Failed to copy system db to '$datadir'") + unless -d $datadir; } - mtr_error("Failed to copy system db to '$datadir'") - unless -d $datadir; } else { @@ -4978,10 +5063,13 @@ Options to control what engine/variation to run vs-config Visual Studio configuration used to create executables (default: MTR_VS_CONFIG environment variable) - config|defaults-file=<config template> Use fixed config template for all + defaults-file=<config template> Use fixed config template for all tests defaults_extra_file=<config template> Extra config template to add to all generated configs + combination=<opt> Use at least twice to run tests with specified + options to mysqld + skip-combinations Ignore combination file (or options) Options to control directories to use tmpdir=DIR The directory where temporary files are stored @@ -5004,7 +5092,6 @@ Options to control what test suites or cases to run force Continue to run the suite after failure with-ndbcluster-only Run only tests that include "ndb" in the filename skip-ndb[cluster] Skip all tests that need cluster - skip-ndb[cluster]-slave Skip all tests that need a slave cluster do-test=PREFIX or REGEX Run test cases which name are prefixed with PREFIX or fulfills REGEX @@ -5019,6 +5106,9 @@ Options to control what test suites or cases to run The default is: "$DEFAULT_SUITES" skip-rpl Skip the replication test cases. big-test Also run tests marked as "big" + enable-disabled Run also tests marked as disabled + print_testcases Don't run the tests but print details about all the + selected tests, in the order they would be run. Options that specify ports @@ -5087,7 +5177,7 @@ Options for valgrind valgrind-options=ARGS Deprecated, use --valgrind-option valgrind-option=ARGS Option to give valgrind, replaces default option(s), can be specified more then once - valgrind-path=[EXE] Path to the valgrind executable + valgrind-path=<EXE> Path to the valgrind executable callgrind Instruct valgrind to use callgrind Misc options @@ -5095,14 +5185,18 @@ Misc options comment=STR Write STR to the output notimer Don't show test case execution time verbose More verbose output(use multiple times for even more) + verbose-restart Write when and why servers are restarted start Only initialize and start the servers, using the startup settings for the first specified test case Example: $0 --start alias & start-dirty Only start the servers (without initialization) for the first specified test case + wait-all If --start or --start-dirty option is used, wait for all + servers to exit before finishing the process fast Run as fast as possible, dont't wait for servers to shutdown etc. + parallel=N Run tests in N parallel threads (default=1) repeat=N Run each test N number of times retry=N Retry tests that fail N times, limit number of failures to $opt_retry_failure @@ -5120,6 +5214,12 @@ Misc options sleep=SECONDS Passed to mysqltest, will be used as fixed sleep time gcov Collect coverage information after the test. The result is a gcov file per source and header file. + experimental=<file> Refer to list of tests considered experimental; + failures will be marked exp-fail instead of fail. + report-features First run a "test" that reports mysql features + timestamp Print timestamp before each test report line + timediff With --timestamp, also print time passed since + *previous* test started HERE exit(1); diff --git a/mysql-test/r/cast.result b/mysql-test/r/cast.result index c1af92c5f8d..dd61396e485 100644 --- a/mysql-test/r/cast.result +++ b/mysql-test/r/cast.result @@ -439,3 +439,16 @@ HOUR(NULL) MINUTE(NULL) SECOND(NULL) NULL NULL NULL DROP TABLE t1; End of 5.0 tests +# +# Bug #44766: valgrind error when using convert() in a subquery +# +CREATE TABLE t1(a tinyint); +INSERT INTO t1 VALUES (127); +SELECT 1 FROM +( +SELECT CONVERT(t2.a USING UTF8) FROM t1, t1 t2 LIMIT 1 +) AS s LIMIT 1; +1 +1 +DROP TABLE t1; +End of 5.1 tests diff --git a/mysql-test/r/concurrent_innodb_safelog.result b/mysql-test/r/concurrent_innodb_safelog.result index e6adaac1068..24a84afb9ce 100644 --- a/mysql-test/r/concurrent_innodb_safelog.result +++ b/mysql-test/r/concurrent_innodb_safelog.result @@ -785,6 +785,8 @@ eta tipo c 70 1 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii 80 22 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj 90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk +** Cleanup +** connection thread2 ** connection default drop table t1; drop user mysqltest@localhost; diff --git a/mysql-test/r/concurrent_innodb_unsafelog.result b/mysql-test/r/concurrent_innodb_unsafelog.result index e9c53d4cfa0..35fc2d89cfe 100644 --- a/mysql-test/r/concurrent_innodb_unsafelog.result +++ b/mysql-test/r/concurrent_innodb_unsafelog.result @@ -781,6 +781,8 @@ eta tipo c 70 1 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii 80 1 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj 90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk +** Cleanup +** connection thread2 ** connection default drop table t1; drop user mysqltest@localhost; diff --git a/mysql-test/r/consistent_snapshot.result b/mysql-test/r/consistent_snapshot.result index 694c996a58e..3a0227b1a1a 100644 --- a/mysql-test/r/consistent_snapshot.result +++ b/mysql-test/r/consistent_snapshot.result @@ -1,6 +1,9 @@ DROP TABLE IF EXISTS t1; # Establish connection con1 (user=root) # Establish connection con2 (user=root) +### Test 1: +### - While a consistent snapshot transaction is executed, +### no external inserts should be visible to the transaction. # Switch to connection con1 CREATE TABLE t1 (a INT) ENGINE=innodb; START TRANSACTION WITH CONSISTENT SNAPSHOT; @@ -10,6 +13,9 @@ INSERT INTO t1 VALUES(1); SELECT * FROM t1; a COMMIT; +### Test 2: +### - For any non-consistent snapshot transaction, external +### committed inserts should be visible to the transaction. DELETE FROM t1; START TRANSACTION; # Switch to connection con2 @@ -19,5 +25,18 @@ SELECT * FROM t1; a 1 COMMIT; +### Test 3: +### - Bug#44664: valgrind warning for COMMIT_AND_CHAIN and ROLLBACK_AND_CHAIN +### Chaining a transaction does not retain consistency level. +START TRANSACTION WITH CONSISTENT SNAPSHOT; +DELETE FROM t1; +COMMIT WORK AND CHAIN; +# Switch to connection con2 +INSERT INTO t1 VALUES(1); +# Switch to connection con1 +SELECT * FROM t1; +a +1 +COMMIT; # Switch to connection default + close connections con1 and con2 DROP TABLE t1; diff --git a/mysql-test/r/ctype_cp932_binlog_stm.result b/mysql-test/r/ctype_cp932_binlog_stm.result index 0cd2d395ebc..2f67eb16b2e 100644 --- a/mysql-test/r/ctype_cp932_binlog_stm.result +++ b/mysql-test/r/ctype_cp932_binlog_stm.result @@ -46,4 +46,12 @@ master-bin.000001 1137 Query 1 1216 use `test`; DROP TABLE t4 End of 5.0 tests SHOW BINLOG EVENTS FROM 364; ERROR HY000: Error when executing command SHOW BINLOG EVENTS: Wrong offset or I/O error +Bug#44352 UPPER/LOWER function doesn't work correctly on cp932 and sjis environment. +CREATE TABLE t1 (a varchar(16)) character set cp932; +INSERT INTO t1 VALUES (0x8372835E),(0x8352835E); +SELECT hex(a), hex(lower(a)), hex(upper(a)) FROM t1 ORDER BY binary(a); +hex(a) hex(lower(a)) hex(upper(a)) +8352835E 8352835E 8352835E +8372835E 8372835E 8372835E +DROP TABLE t1; End of 5.1 tests diff --git a/mysql-test/r/ctype_sjis.result b/mysql-test/r/ctype_sjis.result index 91d6ebd9795..1469e335f23 100644 --- a/mysql-test/r/ctype_sjis.result +++ b/mysql-test/r/ctype_sjis.result @@ -209,3 +209,13 @@ SET NAMES sjis; SELECT HEX('²“‘@Œ\') FROM DUAL; HEX('²“‘@Œ\') 8DB2939181408C5C +# Start of 5.1 tests +Bug#44352 UPPER/LOWER function doesn't work correctly on cp932 and sjis environment. +CREATE TABLE t1 (a varchar(16)) character set sjis; +INSERT INTO t1 VALUES (0x8372835E),(0x8352835E); +SELECT hex(a), hex(lower(a)), hex(upper(a)) FROM t1 ORDER BY binary(a); +hex(a) hex(lower(a)) hex(upper(a)) +8352835E 8352835E 8352835E +8372835E 8372835E 8372835E +DROP TABLE t1; +# End of 5.1 tests diff --git a/mysql-test/r/ddl_i18n_koi8r.result b/mysql-test/r/ddl_i18n_koi8r.result index af3a0899181..fe24c17a1c5 100644 --- a/mysql-test/r/ddl_i18n_koi8r.result +++ b/mysql-test/r/ddl_i18n_koi8r.result @@ -2829,7 +2829,11 @@ t2 CREATE TABLE `t2` ( `col1` varchar(10) COLLATE cp1251_general_cs DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=cp1251 COLLATE=cp1251_general_cs +---> connection: con2 + +---> connection: con3 + ---> connection: default -use test| -DROP DATABASE mysqltest1| -DROP DATABASE mysqltest2| +USE test; +DROP DATABASE mysqltest1; +DROP DATABASE mysqltest2; diff --git a/mysql-test/r/ddl_i18n_utf8.result b/mysql-test/r/ddl_i18n_utf8.result index 10c2afcadc1..cf4272bf90c 100644 --- a/mysql-test/r/ddl_i18n_utf8.result +++ b/mysql-test/r/ddl_i18n_utf8.result @@ -2829,7 +2829,11 @@ t2 CREATE TABLE `t2` ( `col1` varchar(10) COLLATE cp1251_general_cs DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=cp1251 COLLATE=cp1251_general_cs +---> connection: con2 + +---> connection: con3 + ---> connection: default -use test| -DROP DATABASE mysqltest1| -DROP DATABASE mysqltest2| +USE test; +DROP DATABASE mysqltest1; +DROP DATABASE mysqltest2; diff --git a/mysql-test/r/distinct.result b/mysql-test/r/distinct.result index f71bbd175e3..e0324af8cfd 100644 --- a/mysql-test/r/distinct.result +++ b/mysql-test/r/distinct.result @@ -629,21 +629,21 @@ SELECT DISTINCT @v5:= fruit_id, @v6:= fruit_name INTO @v7, @v8 FROM t1 WHERE fruit_name = 'APPLE'; SELECT @v5, @v6, @v7, @v8; @v5 @v6 @v7 @v8 -3 PEAR 3 PEAR +2 APPLE 2 APPLE SELECT DISTINCT @v5 + fruit_id, CONCAT(@v6, fruit_name) INTO @v9, @v10 FROM t1 WHERE fruit_name = 'APPLE'; SELECT @v5, @v6, @v7, @v8, @v9, @v10; @v5 @v6 @v7 @v8 @v9 @v10 -3 PEAR 3 PEAR 5 PEARAPPLE +2 APPLE 2 APPLE 4 APPLEAPPLE SELECT DISTINCT @v11:= @v5 + fruit_id, @v12:= CONCAT(@v6, fruit_name) INTO @v13, @v14 FROM t1 WHERE fruit_name = 'APPLE'; SELECT @v11, @v12, @v13, @v14; @v11 @v12 @v13 @v14 -6 PEARPEAR 6 PEARPEAR +4 APPLEAPPLE 4 APPLEAPPLE SELECT DISTINCT @v13, @v14 INTO @v15, @v16 FROM t1 WHERE fruit_name = 'APPLE'; SELECT @v15, @v16; @v15 @v16 -6 PEARPEAR +4 APPLEAPPLE SELECT DISTINCT 2 + 2, 'Bob' INTO @v17, @v18 FROM t1 WHERE fruit_name = 'APPLE'; SELECT @v17, @v18; diff --git a/mysql-test/r/events_stress.result b/mysql-test/r/events_stress.result index 17eb32b36b7..9b9f3caaff6 100644 --- a/mysql-test/r/events_stress.result +++ b/mysql-test/r/events_stress.result @@ -63,3 +63,4 @@ DROP TABLE fill_it1; DROP TABLE fill_it2; DROP TABLE fill_it3; DROP DATABASE events_test; +SET GLOBAL event_scheduler=off; diff --git a/mysql-test/r/func_compress.result b/mysql-test/r/func_compress.result index 8e14b7695ee..b4e61d0e4fc 100644 --- a/mysql-test/r/func_compress.result +++ b/mysql-test/r/func_compress.result @@ -117,4 +117,13 @@ Warnings: Error 1259 ZLIB: Input data corrupted Error 1259 ZLIB: Input data corrupted drop table t1; +CREATE TABLE t1 (c1 INT); +INSERT INTO t1 VALUES (1), (1111), (11111); +SELECT UNCOMPRESS(c1), UNCOMPRESSED_LENGTH(c1) FROM t1; +UNCOMPRESS(c1) UNCOMPRESSED_LENGTH(c1) +NULL NULL +NULL NULL +NULL 825307441 +EXPLAIN EXTENDED SELECT * FROM (SELECT UNCOMPRESSED_LENGTH(c1) FROM t1) AS s; +DROP TABLE t1; End of 5.0 tests diff --git a/mysql-test/r/func_concat.result b/mysql-test/r/func_concat.result index 7e7c163716e..75b4888fbb2 100644 --- a/mysql-test/r/func_concat.result +++ b/mysql-test/r/func_concat.result @@ -89,3 +89,34 @@ c1 c2 First DROP TABLE t1; # End of 5.0 tests +# +# Bug #44743: Join in combination with concat does not always work +# +CREATE TABLE t1 ( +a VARCHAR(100) NOT NULL DEFAULT '0', +b VARCHAR(2) NOT NULL DEFAULT '', +c VARCHAR(2) NOT NULL DEFAULT '', +d TEXT NOT NULL, +PRIMARY KEY (a, b, c), +KEY (a) +) DEFAULT CHARSET=utf8; +INSERT INTO t1 VALUES ('gui_A', 'a', 'b', 'str1'), +('gui_AB', 'a', 'b', 'str2'), ('gui_ABC', 'a', 'b', 'str3'); +CREATE TABLE t2 ( +a VARCHAR(100) NOT NULL DEFAULT '', +PRIMARY KEY (a) +) DEFAULT CHARSET=latin1; +INSERT INTO t2 VALUES ('A'), ('AB'), ('ABC'); +SELECT CONCAT('gui_', t2.a), t1.d FROM t2 +LEFT JOIN t1 ON t1.a = CONCAT('gui_', t2.a) AND t1.b = 'a' AND t1.c = 'b'; +CONCAT('gui_', t2.a) d +gui_A str1 +gui_AB str2 +gui_ABC str3 +EXPLAIN SELECT CONCAT('gui_', t2.a), t1.d FROM t2 +LEFT JOIN t1 ON t1.a = CONCAT('gui_', t2.a) AND t1.b = 'a' AND t1.c = 'b'; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 index NULL PRIMARY 102 NULL 3 Using index +1 SIMPLE t1 eq_ref PRIMARY,a PRIMARY 318 func,const,const 1 +DROP TABLE t1, t2; +# End of 5.1 tests diff --git a/mysql-test/r/func_in.result b/mysql-test/r/func_in.result index 1e967b668c5..88a822a2fa6 100644 --- a/mysql-test/r/func_in.result +++ b/mysql-test/r/func_in.result @@ -587,4 +587,25 @@ SELECT CASE c1 WHEN c1 + 1 THEN 1 END, ABS(AVG(c0)) FROM t1; CASE c1 WHEN c1 + 1 THEN 1 END ABS(AVG(c0)) NULL 1.0000 DROP TABLE t1; +CREATE TABLE t1(a TEXT, b INT, c INT UNSIGNED, d DECIMAL(12,2), e REAL); +INSERT INTO t1 VALUES('iynfj', 1, 1, 1, 1); +INSERT INTO t1 VALUES('innfj', 2, 2, 2, 2); +SELECT SUM( DISTINCT a ) FROM t1 GROUP BY a HAVING a IN ( AVG( 1 ), 1 + a); +SUM( DISTINCT a ) +SELECT SUM( DISTINCT b ) FROM t1 GROUP BY b HAVING b IN ( AVG( 1 ), 1 + b); +SUM( DISTINCT b ) +1 +SELECT SUM( DISTINCT c ) FROM t1 GROUP BY c HAVING c IN ( AVG( 1 ), 1 + c); +SUM( DISTINCT c ) +1 +SELECT SUM( DISTINCT d ) FROM t1 GROUP BY d HAVING d IN ( AVG( 1 ), 1 + d); +SUM( DISTINCT d ) +1.00 +SELECT SUM( DISTINCT e ) FROM t1 GROUP BY e HAVING e IN ( AVG( 1 ), 1 + e); +SUM( DISTINCT e ) +1 +SELECT SUM( DISTINCT e ) FROM t1 GROUP BY b,c,d HAVING (b,c,d) IN +((AVG( 1 ), 1 + c, 1 + d), (AVG( 1 ), 2 + c, 2 + d)); +SUM( DISTINCT e ) +DROP TABLE t1; End of 5.1 tests diff --git a/mysql-test/r/func_math.result b/mysql-test/r/func_math.result index c3d2db2d553..9bc83087232 100644 --- a/mysql-test/r/func_math.result +++ b/mysql-test/r/func_math.result @@ -456,4 +456,23 @@ NULL SELECT POW(10, 309); POW(10, 309) NULL +# +# Bug #44768: SIGFPE crash when selecting rand from a view +# containing null +# +CREATE OR REPLACE VIEW v1 AS SELECT NULL AS a; +SELECT RAND(a) FROM v1; +RAND(a) +0.155220427694936 +DROP VIEW v1; +SELECT RAND(a) FROM (SELECT NULL AS a) b; +RAND(a) +0.155220427694936 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (NULL); +SELECT RAND(i) FROM t1; +RAND(i) +0.155220427694936 +DROP TABLE t1; +# End of 5.1 tests diff --git a/mysql-test/r/func_str.result b/mysql-test/r/func_str.result index 25cbf2470ed..a0c3935fde0 100644 --- a/mysql-test/r/func_str.result +++ b/mysql-test/r/func_str.result @@ -2525,6 +2525,15 @@ SELECT DATE_FORMAT(c, GET_FORMAT(DATE, 'eur')) h, CONCAT(UPPER(aa),', ', aa) i F h i 31.12.2008 AAAAAA, aaaaaa DROP TABLE t1; +# +# BUG#44774: load_file function produces valgrind warnings +# +CREATE TABLE t1 (a TINYBLOB); +INSERT INTO t1 VALUES ('aaaaaaaa'); +SELECT LOAD_FILE(a) FROM t1; +LOAD_FILE(a) +NULL +DROP TABLE t1; End of 5.0 tests drop table if exists t1; create table t1(f1 tinyint default null)engine=myisam; diff --git a/mysql-test/r/grant_cache_no_prot.result b/mysql-test/r/grant_cache_no_prot.result index cb9acaf540d..32bb9cce90e 100644 --- a/mysql-test/r/grant_cache_no_prot.result +++ b/mysql-test/r/grant_cache_no_prot.result @@ -206,7 +206,8 @@ Qcache_hits 8 show status like "Qcache_not_cached"; Variable_name Value Qcache_not_cached 8 ------ switch to connection default and close connections ----- +----- close connections ----- +----- switch to connection default ----- set names binary; delete from mysql.user where user in ("mysqltest_1","mysqltest_2","mysqltest_3"); delete from mysql.db where user in ("mysqltest_1","mysqltest_2","mysqltest_3"); diff --git a/mysql-test/r/grant_cache_ps_prot.result b/mysql-test/r/grant_cache_ps_prot.result index cf1450f3b75..281468ee2e1 100644 --- a/mysql-test/r/grant_cache_ps_prot.result +++ b/mysql-test/r/grant_cache_ps_prot.result @@ -206,7 +206,8 @@ Qcache_hits 8 show status like "Qcache_not_cached"; Variable_name Value Qcache_not_cached 5 ------ switch to connection default and close connections ----- +----- close connections ----- +----- switch to connection default ----- set names binary; delete from mysql.user where user in ("mysqltest_1","mysqltest_2","mysqltest_3"); delete from mysql.db where user in ("mysqltest_1","mysqltest_2","mysqltest_3"); diff --git a/mysql-test/r/heap_btree.result b/mysql-test/r/heap_btree.result index 9db03855c01..7ad0f212d99 100644 --- a/mysql-test/r/heap_btree.result +++ b/mysql-test/r/heap_btree.result @@ -336,4 +336,11 @@ a b NULL NULL NULL 1 drop table t1; +# +# bug#39918 - memory (heap) engine crashing while executing self join with delete +# +CREATE TABLE t1(a INT, KEY USING BTREE (a)) ENGINE=MEMORY; +INSERT INTO t1 VALUES(1),(1); +DELETE a1 FROM t1 AS a1, t1 AS a2 WHERE a1.a=a2.a; +DROP TABLE t1; End of 5.0 tests diff --git a/mysql-test/r/information_schema_db.result b/mysql-test/r/information_schema_db.result index 475839569c7..6305f8cd47a 100644 --- a/mysql-test/r/information_schema_db.result +++ b/mysql-test/r/information_schema_db.result @@ -61,7 +61,7 @@ begin select table_name from information_schema.key_column_usage order by table_name; end| -create table t1 +create table t1 (f1 int(10) unsigned not null, f2 varchar(100) not null, primary key (f1), unique key (f2)); @@ -203,15 +203,15 @@ View Create View character_set_client collation_connection v2 CREATE ALGORITHM=UNDEFINED DEFINER=`testdb_2`@`localhost` SQL SECURITY DEFINER VIEW `v2` AS select `v1`.`f1` AS `f1` from `testdb_1`.`v1` latin1 latin1_swedish_ci show create view testdb_1.v1; ERROR 42000: SHOW VIEW command denied to user 'testdb_2'@'localhost' for table 'v1' -select table_name from information_schema.columns a +select table_name from information_schema.columns a where a.table_name = 'v2'; table_name v2 -select view_definition from information_schema.views a +select view_definition from information_schema.views a where a.table_name = 'v2'; view_definition select `v1`.`f1` AS `f1` from `testdb_1`.`v1` -select view_definition from information_schema.views a +select view_definition from information_schema.views a where a.table_name = 'testdb_1.v1'; view_definition select * from v2; diff --git a/mysql-test/r/init_file.result b/mysql-test/r/init_file.result index 8e014815a9c..43ed908ad01 100644 --- a/mysql-test/r/init_file.result +++ b/mysql-test/r/init_file.result @@ -4,6 +4,7 @@ SELECT * INTO @Y FROM init_file.startup limit 1,1; SELECT YEAR(@X)-YEAR(@Y); YEAR(@X)-YEAR(@Y) 0 +DROP DATABASE init_file; ok end of 4.1 tests select * from t1; @@ -19,3 +20,5 @@ y 3 11 13 +drop table t1, t2; +call mtr.force_restart(); diff --git a/mysql-test/r/innodb_bug42101-nonzero.result b/mysql-test/r/innodb_bug42101-nonzero.result new file mode 100644 index 00000000000..8a14296381c --- /dev/null +++ b/mysql-test/r/innodb_bug42101-nonzero.result @@ -0,0 +1,22 @@ +set global innodb_commit_concurrency=0; +ERROR HY000: Incorrect arguments to SET +select @@innodb_commit_concurrency; +@@innodb_commit_concurrency +1 +set global innodb_commit_concurrency=1; +select @@innodb_commit_concurrency; +@@innodb_commit_concurrency +1 +set global innodb_commit_concurrency=42; +select @@innodb_commit_concurrency; +@@innodb_commit_concurrency +42 +set global innodb_commit_concurrency=0; +ERROR HY000: Incorrect arguments to SET +select @@innodb_commit_concurrency; +@@innodb_commit_concurrency +42 +set global innodb_commit_concurrency=1; +select @@innodb_commit_concurrency; +@@innodb_commit_concurrency +1 diff --git a/mysql-test/r/innodb_bug42101.result b/mysql-test/r/innodb_bug42101.result new file mode 100644 index 00000000000..9a9c8e0ce9b --- /dev/null +++ b/mysql-test/r/innodb_bug42101.result @@ -0,0 +1,18 @@ +set global innodb_commit_concurrency=0; +select @@innodb_commit_concurrency; +@@innodb_commit_concurrency +0 +set global innodb_commit_concurrency=1; +ERROR HY000: Incorrect arguments to SET +select @@innodb_commit_concurrency; +@@innodb_commit_concurrency +0 +set global innodb_commit_concurrency=42; +ERROR HY000: Incorrect arguments to SET +select @@innodb_commit_concurrency; +@@innodb_commit_concurrency +0 +set global innodb_commit_concurrency=0; +select @@innodb_commit_concurrency; +@@innodb_commit_concurrency +0 diff --git a/mysql-test/r/innodb_mysql.result b/mysql-test/r/innodb_mysql.result index 191a8578d4c..83a2a2111d5 100644 --- a/mysql-test/r/innodb_mysql.result +++ b/mysql-test/r/innodb_mysql.result @@ -1408,6 +1408,18 @@ SAVEPOINT s4; ROLLBACK; ROLLBACK TO SAVEPOINT s4; ERROR 42000: SAVEPOINT s4 does not exist +CREATE TABLE t1 (f1 INTEGER PRIMARY KEY COMMENT 'My ID#', f2 INTEGER DEFAULT NULL, f3 CHAR(10) DEFAULT 'My ID#', CONSTRAINT f2_ref FOREIGN KEY (f2) REFERENCES t1 (f1)) ENGINE=INNODB; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `f1` int(11) NOT NULL COMMENT 'My ID#', + `f2` int(11) DEFAULT NULL, + `f3` char(10) DEFAULT 'My ID#', + PRIMARY KEY (`f1`), + KEY `f2_ref` (`f2`), + CONSTRAINT `f2_ref` FOREIGN KEY (`f2`) REFERENCES `t1` (`f1`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +DROP TABLE t1; End of 5.0 tests CREATE TABLE `t2` ( `k` int(11) NOT NULL auto_increment, @@ -1706,6 +1718,35 @@ id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY <derived2> system NULL NULL NULL NULL 1 2 DERIVED t1 index c3,c2 c2 10 NULL 5 DROP TABLE t1; +CREATE TABLE t1 (c1 REAL, c2 REAL, c3 REAL, KEY (c3), KEY (c2, c3)) +ENGINE=InnoDB; +INSERT INTO t1 VALUES (1,1,1), (1,1,1), (1,1,2), (1,1,1), (1,1,2); +SELECT 1 FROM (SELECT COUNT(DISTINCT c1) +FROM t1 WHERE c2 IN (1, 1) AND c3 = 2 GROUP BY c2) x; +1 +1 +EXPLAIN +SELECT 1 FROM (SELECT COUNT(DISTINCT c1) +FROM t1 WHERE c2 IN (1, 1) AND c3 = 2 GROUP BY c2) x; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY <derived2> system NULL NULL NULL NULL 1 +2 DERIVED t1 index c3,c2 c2 18 NULL 5 +DROP TABLE t1; +CREATE TABLE t1 (c1 DECIMAL(12,2), c2 DECIMAL(12,2), c3 DECIMAL(12,2), +KEY (c3), KEY (c2, c3)) +ENGINE=InnoDB; +INSERT INTO t1 VALUES (1,1,1), (1,1,1), (1,1,2), (1,1,1), (1,1,2); +SELECT 1 FROM (SELECT COUNT(DISTINCT c1) +FROM t1 WHERE c2 IN (1, 1) AND c3 = 2 GROUP BY c2) x; +1 +1 +EXPLAIN +SELECT 1 FROM (SELECT COUNT(DISTINCT c1) +FROM t1 WHERE c2 IN (1, 1) AND c3 = 2 GROUP BY c2) x; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY <derived2> system NULL NULL NULL NULL 1 +2 DERIVED t1 index c3,c2 c2 14 NULL 5 +DROP TABLE t1; End of 5.1 tests drop table if exists t1, t2, t3; create table t1(a int); @@ -2040,4 +2081,31 @@ DROP TABLE t4; DROP TABLE t1; DROP TABLE t2; DROP TABLE t3; +CREATE TABLE t1 (a INT, b INT, KEY (a)) ENGINE = INNODB; +CREATE TABLE t2 (a INT KEY, b INT, KEY (b)) ENGINE = INNODB; +CREATE TABLE t3 (a INT, b INT KEY, KEY (a)) ENGINE = INNODB; +CREATE TABLE t4 (a INT KEY, b INT, KEY (b)) ENGINE = INNODB; +INSERT INTO t1 VALUES (1, 1), (2, 2), (3, 3), (4, 4), (5, 5), (6, 6); +INSERT INTO t2 VALUES (1, 1), (2, 2), (3, 3), (4, 4), (5, 5); +INSERT INTO t3 VALUES (1, 101), (2, 102), (3, 103), (4, 104), (5, 105), (6, 106); +INSERT INTO t4 VALUES (1, 1), (2, 2), (3, 3), (4, 4), (5, 5); +UPDATE t1, t2 SET t1.a = t1.a + 100, t2.b = t1.a + 10 +WHERE t1.a BETWEEN 2 AND 4 AND t2.a = t1.b; +SELECT * FROM t2; +a b +1 1 +2 12 +3 13 +4 14 +5 5 +UPDATE t3, t4 SET t3.a = t3.a + 100, t4.b = t3.a + 10 +WHERE t3.a BETWEEN 2 AND 4 AND t4.a = t3.b - 100; +SELECT * FROM t4; +a b +1 1 +2 12 +3 13 +4 14 +5 5 +DROP TABLE t1, t2, t3, t4; End of 5.1 tests diff --git a/mysql-test/r/insert_select.result b/mysql-test/r/insert_select.result index 780e91ea73f..2f2cc6334a9 100644 --- a/mysql-test/r/insert_select.result +++ b/mysql-test/r/insert_select.result @@ -765,6 +765,11 @@ f1 f2 2 2 10 10 DROP TABLE t1, t2; +CREATE TABLE t1 ( a INT KEY, b INT ); +INSERT INTO t1 VALUES ( 0, 1 ); +INSERT INTO t1 ( b ) SELECT MAX( b ) FROM t1 WHERE b = 2; +ERROR 23000: Duplicate entry '0' for key 'PRIMARY' +DROP TABLE t1; SET SQL_MODE='STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'; CREATE TABLE t1 (c VARCHAR(30), INDEX ix_c (c(10))); CREATE TABLE t2 (d VARCHAR(10)); diff --git a/mysql-test/r/mysql.result b/mysql-test/r/mysql.result index 5054c3aa76f..a04eb1ca1aa 100644 --- a/mysql-test/r/mysql.result +++ b/mysql-test/r/mysql.result @@ -192,6 +192,12 @@ delimiter 1 1 1 +COUNT (*) +1 +COUNT (*) +1 +COUNT (*) +1 End of 5.0 tests WARNING: --server-arg option not supported in this configuration. Warning (Code 1286): Unknown table engine 'nonexistent' @@ -200,4 +206,5 @@ Warning (Code 1286): Unknown table engine 'nonexistent2' Warning (Code 1266): Using storage engine MyISAM for table 't2' Error (Code 1050): Table 't2' already exists drop tables t1, t2; +<TABLE BORDER=1><TR><TH><</TH></TR><TR><TD>< & ></TD></TR></TABLE> End of tests diff --git a/mysql-test/r/mysqlbinlog.result b/mysql-test/r/mysqlbinlog.result index b55a96b6f30..295a2f41d40 100644 --- a/mysql-test/r/mysqlbinlog.result +++ b/mysql-test/r/mysqlbinlog.result @@ -471,4 +471,7 @@ IS NOT NULL 1 *** Unsigned server_id 4294967295 is found: 1 *** SET @@global.server_id= 1; +RESET MASTER; +FLUSH LOGS; +End of 5.0 tests End of 5.1 tests diff --git a/mysql-test/r/mysqldump_restore.result b/mysql-test/r/mysqldump_restore.result new file mode 100644 index 00000000000..16698251913 --- /dev/null +++ b/mysql-test/r/mysqldump_restore.result @@ -0,0 +1,110 @@ +# Set concurrent_insert = 0 to prevent random errors +# will reset to original value at the end of the test +SET @old_concurrent_insert = @@global.concurrent_insert; +SET @@global.concurrent_insert = 0; +# Pre-test cleanup +DROP TABLE IF EXISTS t1; +# Begin tests +# +# Bug#2005 Long decimal comparison bug. +# +CREATE TABLE t1 (a DECIMAL(64, 20)); +INSERT INTO t1 VALUES ("1234567890123456789012345678901234567890"), +("0987654321098765432109876543210987654321"); +# Begin testing mysqldump output + restore +# Create 'original table name - <table>_orig +SET @orig_table_name = CONCAT('test.t1', '_orig'); +# Rename original table +ALTER TABLE test.t1 RENAME to test.t1_orig; +# Recreate table from mysqldump output +# Compare original and recreated tables +# Recreated table: test.t1 +# Original table: test.t1_orig +Comparing tables test.t1 and test.t1_orig +# Cleanup +DROP TABLE test.t1, test.t1_orig; +# +# Bug#3361 mysqldump quotes DECIMAL values inconsistently +# +CREATE TABLE t1 (a DECIMAL(10,5), b FLOAT); +INSERT INTO t1 VALUES (1.2345, 2.3456); +INSERT INTO t1 VALUES ('1.2345', 2.3456); +INSERT INTO t1 VALUES ("1.2345", 2.3456); +SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='ANSI_QUOTES'; +INSERT INTO t1 VALUES (1.2345, 2.3456); +INSERT INTO t1 VALUES ('1.2345', 2.3456); +INSERT INTO t1 VALUES ("1.2345", 2.3456); +ERROR 42S22: Unknown column '1.2345' in 'field list' +SET SQL_MODE=@OLD_SQL_MODE; +# Begin testing mysqldump output + restore +# Create 'original table name - <table>_orig +SET @orig_table_name = CONCAT('test.t1', '_orig'); +# Rename original table +ALTER TABLE test.t1 RENAME to test.t1_orig; +# Recreate table from mysqldump output +# Compare original and recreated tables +# Recreated table: test.t1 +# Original table: test.t1_orig +Comparing tables test.t1 and test.t1_orig +# Cleanup +DROP TABLE test.t1, test.t1_orig; +# +# Bug#1994 mysqldump does not correctly dump UCS2 data +# Bug#4261 mysqldump 10.7 (mysql 4.1.2) --skip-extended-insert drops NULL from inserts +# +CREATE TABLE t1 (a VARCHAR(255)) DEFAULT CHARSET koi8r; +INSERT INTO t1 VALUES (_koi8r x'C1C2C3C4C5'), (NULL); +# Begin testing mysqldump output + restore +# Create 'original table name - <table>_orig +SET @orig_table_name = CONCAT('test.t1', '_orig'); +# Rename original table +ALTER TABLE test.t1 RENAME to test.t1_orig; +# Recreate table from mysqldump output +# Compare original and recreated tables +# Recreated table: test.t1 +# Original table: test.t1_orig +Comparing tables test.t1 and test.t1_orig +# Cleanup +DROP TABLE test.t1, test.t1_orig; +# +# WL#2319 Exclude Tables from dump +# +CREATE TABLE t1 (a INT); +CREATE TABLE t2 (a INT); +INSERT INTO t1 VALUES (1),(2),(3); +INSERT INTO t2 VALUES (4),(5),(6); +# Begin testing mysqldump output + restore +# Create 'original table name - <table>_orig +SET @orig_table_name = CONCAT('test.t2', '_orig'); +# Rename original table +ALTER TABLE test.t2 RENAME to test.t2_orig; +# Recreate table from mysqldump output +# Compare original and recreated tables +# Recreated table: test.t2 +# Original table: test.t2_orig +Comparing tables test.t2 and test.t2_orig +# Cleanup +DROP TABLE test.t2, test.t2_orig; +DROP TABLE t1; +# +# Bug#8830 mysqldump --skip-extended-insert causes --hex-blob to dump wrong values +# +CREATE TABLE t1 (`b` blob); +INSERT INTO `t1` VALUES (0x602010000280100005E71A); +# Begin testing mysqldump output + restore +# Create 'original table name - <table>_orig +SET @orig_table_name = CONCAT('test.t1', '_orig'); +# Rename original table +ALTER TABLE test.t1 RENAME to test.t1_orig; +# Recreate table from mysqldump output +# Compare original and recreated tables +# Recreated table: test.t1 +# Original table: test.t1_orig +Comparing tables test.t1 and test.t1_orig +# Cleanup +DROP TABLE test.t1, test.t1_orig; +# End tests +# Cleanup +# Reset concurrent_insert to its original value +SET @@global.concurrent_insert = @old_concurrent_insert; +# remove mysqldumpfile diff --git a/mysql-test/r/openssl_1.result b/mysql-test/r/openssl_1.result index c408c14b716..b0dd3acd662 100644 --- a/mysql-test/r/openssl_1.result +++ b/mysql-test/r/openssl_1.result @@ -202,4 +202,10 @@ Ssl_cipher RC4-SHA select 'is still running; no cipher request crashed the server' as result from dual; result is still running; no cipher request crashed the server +GRANT SELECT ON test.* TO bug42158@localhost REQUIRE X509; +FLUSH PRIVILEGES; +SHOW STATUS LIKE 'Ssl_cipher'; +Variable_name Value +Ssl_cipher DHE-RSA-AES256-SHA +DROP USER bug42158@localhost; End of 5.1 tests diff --git a/mysql-test/r/subselect3.result b/mysql-test/r/subselect3.result index e0f361a0f4f..f055b40116a 100644 --- a/mysql-test/r/subselect3.result +++ b/mysql-test/r/subselect3.result @@ -849,6 +849,25 @@ ROW(1,2) = (SELECT 1, 1) ROW(1,2) IN (SELECT 1, 1) SELECT ROW(1,2) = (SELECT 1, 2), ROW(1,2) IN (SELECT 1, 2); ROW(1,2) = (SELECT 1, 2) ROW(1,2) IN (SELECT 1, 2) 1 1 +CREATE TABLE t1 (a INT, b INT, c INT); +INSERT INTO t1 VALUES (1,1,1), (1,1,1); +EXPLAIN EXTENDED +SELECT c FROM +( SELECT +(SELECT COUNT(a) FROM +(SELECT COUNT(b) FROM t1) AS x GROUP BY c +) FROM t1 GROUP BY b +) AS y; +ERROR 42S22: Unknown column 'c' in 'field list' +SHOW WARNINGS; +Level Code Message +Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #2 +Note 1276 Field or reference 'test.t1.c' of SELECT #3 was resolved in SELECT #2 +Error 1054 Unknown column 'c' in 'field list' +Note 1003 select `c` AS `c` from (select (select count(`test`.`t1`.`a`) AS `COUNT(a)` from (select count(`test`.`t1`.`b`) AS `COUNT(b)` from `test`.`t1`) `x` group by `c`) AS `(SELECT COUNT(a) FROM +(SELECT COUNT(b) FROM t1) AS x GROUP BY c +)` from `test`.`t1` group by `test`.`t1`.`b`) `y` +DROP TABLE t1; End of 5.0 tests create table t0 (a int); insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); diff --git a/mysql-test/r/type_time.result b/mysql-test/r/type_time.result index d80a3973555..e4b90196c2d 100644 --- a/mysql-test/r/type_time.result +++ b/mysql-test/r/type_time.result @@ -128,3 +128,13 @@ SELECT sum(f3) FROM t1 where f2='2007-07-01 00:00:00' group by f2; sum(f3) 3 drop table t1; +# +# Bug #44792: valgrind warning when casting from time to time +# +CREATE TABLE t1 (c TIME); +INSERT INTO t1 VALUES ('0:00:00'); +SELECT CAST(c AS TIME) FROM t1; +CAST(c AS TIME) +00:00:00 +DROP TABLE t1; +End of 5.0 tests diff --git a/mysql-test/r/union.result b/mysql-test/r/union.result index 23a7724984c..44a3812725a 100644 --- a/mysql-test/r/union.result +++ b/mysql-test/r/union.result @@ -1574,4 +1574,17 @@ SHOW FIELDS FROM t2; Field Type Null Key Default Extra d double(9,6) YES NULL DROP TABLE t1, t2; +CREATE TABLE t1(a INT); +EXPLAIN EXTENDED +SELECT a FROM t1 +UNION +SELECT a FROM t1 +ORDER BY a; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 system NULL NULL NULL NULL 0 0.00 const row not found +2 UNION t1 system NULL NULL NULL NULL 0 0.00 const row not found +NULL UNION RESULT <union1,2> ALL NULL NULL NULL NULL NULL NULL Using filesort +Warnings: +Note 1003 select '0' AS `a` from `test`.`t1` union select '0' AS `a` from `test`.`t1` order by `a` +DROP TABLE t1; End of 5.0 tests diff --git a/mysql-test/r/user_var.result b/mysql-test/r/user_var.result index 8961a935006..28da1dae931 100644 --- a/mysql-test/r/user_var.result +++ b/mysql-test/r/user_var.result @@ -399,6 +399,17 @@ select @lastid != id, @lastid, @lastid := id from t1; 0 3 3 1 3 4 drop table t1; +CREATE TABLE t1(a INT, b INT); +INSERT INTO t1 VALUES (0, 0), (2, 1), (2, 3), (1, 1), (30, 20); +SELECT a, b INTO @a, @b FROM t1 WHERE a=2 AND b=3 GROUP BY a, b; +SELECT @a, @b; +@a @b +2 3 +SELECT a, b FROM t1 WHERE a=2 AND b=3 GROUP BY a, b; +a b +2 3 +DROP TABLE t1; +End of 5.0 tests CREATE TABLE t1 (i INT); CREATE TRIGGER t_after_insert AFTER INSERT ON t1 FOR EACH ROW SET @bug42188 = 10; INSERT INTO t1 VALUES (1); diff --git a/mysql-test/r/variables.result b/mysql-test/r/variables.result index f27d0b9fdd5..3f79d81dd71 100644 --- a/mysql-test/r/variables.result +++ b/mysql-test/r/variables.result @@ -1436,7 +1436,7 @@ Warnings: Warning 1292 Truncated incorrect auto_increment_offset value: '0' select @@storage_engine; Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr -def @@storage_engine 253 6 6 N 1 31 8 +def @@storage_engine 253 6 6 Y 0 31 8 @@storage_engine MyISAM SET @old_server_id = @@GLOBAL.server_id; @@ -1467,4 +1467,14 @@ SELECT @@GLOBAL.server_id; @@GLOBAL.server_id 0 SET GLOBAL server_id = @old_server_id; +SELECT @@GLOBAL.INIT_FILE, @@GLOBAL.INIT_FILE IS NULL; +@@GLOBAL.INIT_FILE @@GLOBAL.INIT_FILE IS NULL +NULL 1 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (); +SET @bug42778= @@sql_safe_updates; +SET @@sql_safe_updates= 0; +DELETE FROM t1 ORDER BY (@@GLOBAL.INIT_FILE) ASC LIMIT 10; +SET @@sql_safe_updates= @bug42778; +DROP TABLE t1; End of 5.1 tests diff --git a/mysql-test/r/view.result b/mysql-test/r/view.result index 0905fc0109b..613939bfdf6 100644 --- a/mysql-test/r/view.result +++ b/mysql-test/r/view.result @@ -3700,6 +3700,25 @@ ERROR 42000: Key 'c2' doesn't exist in table 'v1' DROP VIEW v1; DROP TABLE t1; # ----------------------------------------------------------------- +# -- Bug#40825: Error 1356 while selecting from a view +# -- with a "HAVING" clause though query works +# ----------------------------------------------------------------- + +CREATE TABLE t1 (c INT); + +CREATE VIEW v1 (view_column) AS SELECT c AS alias FROM t1 HAVING alias; +SHOW CREATE VIEW v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`c` AS `view_column` from `t1` having `view_column` latin1 latin1_swedish_ci +SELECT * FROM v1; +view_column + +DROP VIEW v1; +DROP TABLE t1; + +# -- End of test case for Bug#40825 + +# ----------------------------------------------------------------- # -- End of 5.0 tests. # ----------------------------------------------------------------- DROP DATABASE IF EXISTS `d-1`; @@ -3817,6 +3836,14 @@ call p(); call p(); drop view a; drop procedure p; +# +# Bug #44860: ALTER TABLE on view crashes server +# +CREATE TABLE t1 (a INT); +CREATE VIEW v1 AS SELECT a FROM t1; +ALTER TABLE v1; +DROP VIEW v1; +DROP TABLE t1; # ----------------------------------------------------------------- # -- End of 5.1 tests. # ----------------------------------------------------------------- diff --git a/mysql-test/suite/binlog/r/binlog_incident.result b/mysql-test/suite/binlog/r/binlog_incident.result new file mode 100644 index 00000000000..d8b0357b8c4 --- /dev/null +++ b/mysql-test/suite/binlog/r/binlog_incident.result @@ -0,0 +1,12 @@ +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1),(2),(3); +SELECT * FROM t1; +a +1 +2 +3 +REPLACE INTO t1 VALUES (4); +DROP TABLE t1; +FLUSH LOGS; +Contain RELOAD DATABASE +1 diff --git a/mysql-test/suite/binlog/r/binlog_stm_ps.result b/mysql-test/suite/binlog/r/binlog_stm_ps.result index ea7cc6f16df..3af525e297c 100644 --- a/mysql-test/suite/binlog/r/binlog_stm_ps.result +++ b/mysql-test/suite/binlog/r/binlog_stm_ps.result @@ -11,7 +11,7 @@ prepare s from "insert into t1 select 100 limit ?"; set @a=100; execute s using @a; Warnings: -Note 1592 Statement is not safe to log in statement format. +Note 1592 Statement may not be safe to log in statement format. show binlog events from <binlog_start>; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Query # # use `test`; create table t1 (a int) diff --git a/mysql-test/suite/binlog/r/binlog_tbl_metadata.result b/mysql-test/suite/binlog/r/binlog_tbl_metadata.result new file mode 100644 index 00000000000..a2f185edc85 --- /dev/null +++ b/mysql-test/suite/binlog/r/binlog_tbl_metadata.result @@ -0,0 +1,156 @@ +RESET MASTER; +DROP TABLE IF EXISTS `t1`; +CREATE TABLE `t1` ( +`c1` int(11) NOT NULL AUTO_INCREMENT, +`c2` varchar(30) NOT NULL, +`c3` varchar(30) DEFAULT NULL, +`c4` varchar(30) DEFAULT NULL, +`c5` varchar(30) DEFAULT NULL, +`c6` varchar(30) DEFAULT NULL, +`c7` varchar(30) DEFAULT NULL, +`c8` varchar(30) DEFAULT NULL, +`c9` varchar(30) DEFAULT NULL, +`c10` varchar(30) DEFAULT NULL, +`c11` varchar(30) DEFAULT NULL, +`c12` varchar(30) DEFAULT NULL, +`c13` varchar(30) DEFAULT NULL, +`c14` varchar(30) DEFAULT NULL, +`c15` varchar(30) DEFAULT NULL, +`c16` varchar(30) DEFAULT NULL, +`c17` varchar(30) DEFAULT NULL, +`c18` varchar(30) DEFAULT NULL, +`c19` varchar(30) DEFAULT NULL, +`c20` varchar(30) DEFAULT NULL, +`c21` varchar(30) DEFAULT NULL, +`c22` varchar(30) DEFAULT NULL, +`c23` varchar(30) DEFAULT NULL, +`c24` varchar(30) DEFAULT NULL, +`c25` varchar(30) DEFAULT NULL, +`c26` varchar(30) DEFAULT NULL, +`c27` varchar(30) DEFAULT NULL, +`c28` varchar(30) DEFAULT NULL, +`c29` varchar(30) DEFAULT NULL, +`c30` varchar(30) DEFAULT NULL, +`c31` varchar(30) DEFAULT NULL, +`c32` varchar(30) DEFAULT NULL, +`c33` varchar(30) DEFAULT NULL, +`c34` varchar(30) DEFAULT NULL, +`c35` varchar(30) DEFAULT NULL, +`c36` varchar(30) DEFAULT NULL, +`c37` varchar(30) DEFAULT NULL, +`c38` varchar(30) DEFAULT NULL, +`c39` varchar(30) DEFAULT NULL, +`c40` varchar(30) DEFAULT NULL, +`c41` varchar(30) DEFAULT NULL, +`c42` varchar(30) DEFAULT NULL, +`c43` varchar(30) DEFAULT NULL, +`c44` varchar(30) DEFAULT NULL, +`c45` varchar(30) DEFAULT NULL, +`c46` varchar(30) DEFAULT NULL, +`c47` varchar(30) DEFAULT NULL, +`c48` varchar(30) DEFAULT NULL, +`c49` varchar(30) DEFAULT NULL, +`c50` varchar(30) DEFAULT NULL, +`c51` varchar(30) DEFAULT NULL, +`c52` varchar(30) DEFAULT NULL, +`c53` varchar(30) DEFAULT NULL, +`c54` varchar(30) DEFAULT NULL, +`c55` varchar(30) DEFAULT NULL, +`c56` varchar(30) DEFAULT NULL, +`c57` varchar(30) DEFAULT NULL, +`c58` varchar(30) DEFAULT NULL, +`c59` varchar(30) DEFAULT NULL, +`c60` varchar(30) DEFAULT NULL, +`c61` varchar(30) DEFAULT NULL, +`c62` varchar(30) DEFAULT NULL, +`c63` varchar(30) DEFAULT NULL, +`c64` varchar(30) DEFAULT NULL, +`c65` varchar(30) DEFAULT NULL, +`c66` varchar(30) DEFAULT NULL, +`c67` varchar(30) DEFAULT NULL, +`c68` varchar(30) DEFAULT NULL, +`c69` varchar(30) DEFAULT NULL, +`c70` varchar(30) DEFAULT NULL, +`c71` varchar(30) DEFAULT NULL, +`c72` varchar(30) DEFAULT NULL, +`c73` varchar(30) DEFAULT NULL, +`c74` varchar(30) DEFAULT NULL, +`c75` varchar(30) DEFAULT NULL, +`c76` varchar(30) DEFAULT NULL, +`c77` varchar(30) DEFAULT NULL, +`c78` varchar(30) DEFAULT NULL, +`c79` varchar(30) DEFAULT NULL, +`c80` varchar(30) DEFAULT NULL, +`c81` varchar(30) DEFAULT NULL, +`c82` varchar(30) DEFAULT NULL, +`c83` varchar(30) DEFAULT NULL, +`c84` varchar(30) DEFAULT NULL, +`c85` varchar(30) DEFAULT NULL, +`c86` varchar(30) DEFAULT NULL, +`c87` varchar(30) DEFAULT NULL, +`c88` varchar(30) DEFAULT NULL, +`c89` varchar(30) DEFAULT NULL, +`c90` varchar(30) DEFAULT NULL, +`c91` varchar(30) DEFAULT NULL, +`c92` varchar(30) DEFAULT NULL, +`c93` varchar(30) DEFAULT NULL, +`c94` varchar(30) DEFAULT NULL, +`c95` varchar(30) DEFAULT NULL, +`c96` varchar(30) DEFAULT NULL, +`c97` varchar(30) DEFAULT NULL, +`c98` varchar(30) DEFAULT NULL, +`c99` varchar(30) DEFAULT NULL, +`c100` varchar(30) DEFAULT NULL, +`c101` varchar(30) DEFAULT NULL, +`c102` varchar(30) DEFAULT NULL, +`c103` varchar(30) DEFAULT NULL, +`c104` varchar(30) DEFAULT NULL, +`c105` varchar(30) DEFAULT NULL, +`c106` varchar(30) DEFAULT NULL, +`c107` varchar(30) DEFAULT NULL, +`c108` varchar(30) DEFAULT NULL, +`c109` varchar(30) DEFAULT NULL, +`c110` varchar(30) DEFAULT NULL, +`c111` varchar(30) DEFAULT NULL, +`c112` varchar(30) DEFAULT NULL, +`c113` varchar(30) DEFAULT NULL, +`c114` varchar(30) DEFAULT NULL, +`c115` varchar(30) DEFAULT NULL, +`c116` varchar(30) DEFAULT NULL, +`c117` varchar(30) DEFAULT NULL, +`c118` varchar(30) DEFAULT NULL, +`c119` varchar(30) DEFAULT NULL, +`c120` varchar(30) DEFAULT NULL, +`c121` varchar(30) DEFAULT NULL, +`c122` varchar(30) DEFAULT NULL, +`c123` varchar(30) DEFAULT NULL, +`c124` varchar(30) DEFAULT NULL, +`c125` varchar(30) DEFAULT NULL, +`c126` varchar(30) DEFAULT NULL, +`c127` varchar(30) DEFAULT NULL, +`c128` varchar(30) DEFAULT NULL, +`c129` varchar(30) DEFAULT NULL, +`c130` varchar(30) DEFAULT NULL, +`c131` varchar(30) DEFAULT NULL, +`c132` varchar(30) DEFAULT NULL, +`c133` varchar(30) DEFAULT NULL, +`c134` varchar(30) DEFAULT NULL, +`c135` varchar(30) DEFAULT NULL, +`c136` varchar(30) DEFAULT NULL, +`c137` varchar(30) DEFAULT NULL, +`c138` varchar(30) DEFAULT NULL, +`c139` varchar(30) DEFAULT NULL, +`c140` varchar(30) DEFAULT NULL, +`c141` varchar(30) DEFAULT NULL, +`c142` varchar(30) DEFAULT NULL, +`c143` varchar(30) DEFAULT NULL, +`c144` varchar(30) DEFAULT NULL, +`c145` varchar(30) DEFAULT NULL, +`c146` varchar(30) DEFAULT NULL, +PRIMARY KEY (`c1`) +) ENGINE=InnoDB; +LOCK TABLES `t1` WRITE; +INSERT INTO `t1` VALUES ('1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1'); +DROP TABLE `t1`; +FLUSH LOGS; +=== Using mysqlbinlog to detect failure. Before the patch mysqlbinlog would find a corrupted event, thence would fail. diff --git a/mysql-test/suite/binlog/r/binlog_unsafe.result b/mysql-test/suite/binlog/r/binlog_unsafe.result index 675c327e9e7..4c2c32ad8f1 100644 --- a/mysql-test/suite/binlog/r/binlog_unsafe.result +++ b/mysql-test/suite/binlog/r/binlog_unsafe.result @@ -10,25 +10,25 @@ INSERT DELAYED INTO t1 VALUES (5); ---- Insert directly ---- INSERT INTO t1 VALUES (@@global.sync_binlog); Warnings: -Note 1592 Statement is not safe to log in statement format. +Note 1592 Statement may not be safe to log in statement format. INSERT INTO t1 VALUES (@@session.insert_id); Warnings: -Note 1592 Statement is not safe to log in statement format. +Note 1592 Statement may not be safe to log in statement format. INSERT INTO t1 VALUES (@@global.auto_increment_increment); Warnings: -Note 1592 Statement is not safe to log in statement format. +Note 1592 Statement may not be safe to log in statement format. INSERT INTO t2 SELECT UUID(); Warnings: -Note 1592 Statement is not safe to log in statement format. +Note 1592 Statement may not be safe to log in statement format. INSERT INTO t2 VALUES (@@session.sql_mode); Warnings: -Note 1592 Statement is not safe to log in statement format. +Note 1592 Statement may not be safe to log in statement format. INSERT INTO t2 VALUES (@@global.init_slave); Warnings: -Note 1592 Statement is not safe to log in statement format. +Note 1592 Statement may not be safe to log in statement format. INSERT INTO t2 VALUES (@@hostname); Warnings: -Note 1592 Statement is not safe to log in statement format. +Note 1592 Statement may not be safe to log in statement format. ---- Insert from stored procedure ---- CREATE PROCEDURE proc() BEGIN @@ -42,13 +42,13 @@ INSERT INTO t2 VALUES (@@hostname); END| CALL proc(); Warnings: -Note 1592 Statement is not safe to log in statement format. -Note 1592 Statement is not safe to log in statement format. -Note 1592 Statement is not safe to log in statement format. -Note 1592 Statement is not safe to log in statement format. -Note 1592 Statement is not safe to log in statement format. -Note 1592 Statement is not safe to log in statement format. -Note 1592 Statement is not safe to log in statement format. +Note 1592 Statement may not be safe to log in statement format. +Note 1592 Statement may not be safe to log in statement format. +Note 1592 Statement may not be safe to log in statement format. +Note 1592 Statement may not be safe to log in statement format. +Note 1592 Statement may not be safe to log in statement format. +Note 1592 Statement may not be safe to log in statement format. +Note 1592 Statement may not be safe to log in statement format. ---- Insert from stored function ---- CREATE FUNCTION func() RETURNS INT @@ -66,13 +66,13 @@ SELECT func(); func() 0 Warnings: -Note 1592 Statement is not safe to log in statement format. -Note 1592 Statement is not safe to log in statement format. -Note 1592 Statement is not safe to log in statement format. -Note 1592 Statement is not safe to log in statement format. -Note 1592 Statement is not safe to log in statement format. -Note 1592 Statement is not safe to log in statement format. -Note 1592 Statement is not safe to log in statement format. +Note 1592 Statement may not be safe to log in statement format. +Note 1592 Statement may not be safe to log in statement format. +Note 1592 Statement may not be safe to log in statement format. +Note 1592 Statement may not be safe to log in statement format. +Note 1592 Statement may not be safe to log in statement format. +Note 1592 Statement may not be safe to log in statement format. +Note 1592 Statement may not be safe to log in statement format. ---- Insert from trigger ---- CREATE TRIGGER trig BEFORE INSERT ON trigger_table @@ -88,14 +88,14 @@ INSERT INTO t2 VALUES (@@hostname); END| INSERT INTO trigger_table VALUES ('bye.'); Warnings: -Note 1592 Statement is not safe to log in statement format. -Note 1592 Statement is not safe to log in statement format. -Note 1592 Statement is not safe to log in statement format. -Note 1592 Statement is not safe to log in statement format. -Note 1592 Statement is not safe to log in statement format. -Note 1592 Statement is not safe to log in statement format. -Note 1592 Statement is not safe to log in statement format. -Note 1592 Statement is not safe to log in statement format. +Note 1592 Statement may not be safe to log in statement format. +Note 1592 Statement may not be safe to log in statement format. +Note 1592 Statement may not be safe to log in statement format. +Note 1592 Statement may not be safe to log in statement format. +Note 1592 Statement may not be safe to log in statement format. +Note 1592 Statement may not be safe to log in statement format. +Note 1592 Statement may not be safe to log in statement format. +Note 1592 Statement may not be safe to log in statement format. ---- Insert from prepared statement ---- PREPARE p1 FROM 'INSERT INTO t1 VALUES (@@global.sync_binlog)'; PREPARE p2 FROM 'INSERT INTO t1 VALUES (@@session.insert_id)'; @@ -106,25 +106,25 @@ PREPARE p6 FROM 'INSERT INTO t2 VALUES (@@global.init_slave)'; PREPARE p7 FROM 'INSERT INTO t2 VALUES (@@hostname)'; EXECUTE p1; Warnings: -Note 1592 Statement is not safe to log in statement format. +Note 1592 Statement may not be safe to log in statement format. EXECUTE p2; Warnings: -Note 1592 Statement is not safe to log in statement format. +Note 1592 Statement may not be safe to log in statement format. EXECUTE p3; Warnings: -Note 1592 Statement is not safe to log in statement format. +Note 1592 Statement may not be safe to log in statement format. EXECUTE p4; Warnings: -Note 1592 Statement is not safe to log in statement format. +Note 1592 Statement may not be safe to log in statement format. EXECUTE p5; Warnings: -Note 1592 Statement is not safe to log in statement format. +Note 1592 Statement may not be safe to log in statement format. EXECUTE p6; Warnings: -Note 1592 Statement is not safe to log in statement format. +Note 1592 Statement may not be safe to log in statement format. EXECUTE p7; Warnings: -Note 1592 Statement is not safe to log in statement format. +Note 1592 Statement may not be safe to log in statement format. ---- Insert from nested call of triggers / functions / procedures ---- CREATE PROCEDURE proc1() INSERT INTO trigger_table VALUES ('ha!')| @@ -154,13 +154,13 @@ EXECUTE prep6; func5() 0 Warnings: -Note 1592 Statement is not safe to log in statement format. -Note 1592 Statement is not safe to log in statement format. -Note 1592 Statement is not safe to log in statement format. -Note 1592 Statement is not safe to log in statement format. -Note 1592 Statement is not safe to log in statement format. -Note 1592 Statement is not safe to log in statement format. -Note 1592 Statement is not safe to log in statement format. +Note 1592 Statement may not be safe to log in statement format. +Note 1592 Statement may not be safe to log in statement format. +Note 1592 Statement may not be safe to log in statement format. +Note 1592 Statement may not be safe to log in statement format. +Note 1592 Statement may not be safe to log in statement format. +Note 1592 Statement may not be safe to log in statement format. +Note 1592 Statement may not be safe to log in statement format. ==== Variables that should *not* be unsafe ==== INSERT INTO t1 VALUES (@@session.pseudo_thread_id); INSERT INTO t1 VALUES (@@session.pseudo_thread_id); @@ -195,16 +195,16 @@ DROP TABLE t1, t2, t3, trigger_table, trigger_table2; CREATE TABLE t1(a INT, b INT, KEY(a), PRIMARY KEY(b)); INSERT INTO t1 SELECT * FROM t1 LIMIT 1; Warnings: -Note 1592 Statement is not safe to log in statement format. +Note 1592 Statement may not be safe to log in statement format. REPLACE INTO t1 SELECT * FROM t1 LIMIT 1; Warnings: -Note 1592 Statement is not safe to log in statement format. +Note 1592 Statement may not be safe to log in statement format. UPDATE t1 SET a=1 LIMIT 1; Warnings: -Note 1592 Statement is not safe to log in statement format. +Note 1592 Statement may not be safe to log in statement format. DELETE FROM t1 LIMIT 1; Warnings: -Note 1592 Statement is not safe to log in statement format. +Note 1592 Statement may not be safe to log in statement format. CREATE PROCEDURE p1() BEGIN INSERT INTO t1 SELECT * FROM t1 LIMIT 1; @@ -214,10 +214,10 @@ DELETE FROM t1 LIMIT 1; END| CALL p1(); Warnings: -Note 1592 Statement is not safe to log in statement format. -Note 1592 Statement is not safe to log in statement format. -Note 1592 Statement is not safe to log in statement format. -Note 1592 Statement is not safe to log in statement format. +Note 1592 Statement may not be safe to log in statement format. +Note 1592 Statement may not be safe to log in statement format. +Note 1592 Statement may not be safe to log in statement format. +Note 1592 Statement may not be safe to log in statement format. DROP PROCEDURE p1; DROP TABLE t1; DROP TABLE IF EXISTS t1; @@ -225,16 +225,16 @@ CREATE TABLE t1 (a VARCHAR(100), b VARCHAR(100)); INSERT INTO t1 VALUES ('a','b'); UPDATE t1 SET b = '%s%s%s%s%s%s%s%s%s%s%s%s%s%s' WHERE a = 'a' LIMIT 1; Warnings: -Note 1592 Statement is not safe to log in statement format. +Note 1592 Statement may not be safe to log in statement format. DROP TABLE t1; DROP TABLE IF EXISTS t1, t2; CREATE TABLE t1(i INT PRIMARY KEY); CREATE TABLE t2(i INT PRIMARY KEY); CREATE TABLE t3(i INT, ch CHAR(50)); -"Should issue message Statement is not safe to log in statement format." +"Should issue message Statement may not be safe to log in statement format." INSERT INTO t1 SELECT * FROM t2 LIMIT 1; Warnings: -Note 1592 Statement is not safe to log in statement format. +Note 1592 Statement may not be safe to log in statement format. CREATE FUNCTION func6() RETURNS INT BEGIN @@ -243,10 +243,10 @@ INSERT INTO t1 VALUES (11); INSERT INTO t1 VALUES (12); RETURN 0; END| -"Should issue message Statement is not safe to log in statement format only once" +"Should issue message Statement may not be safe to log in statement format only once" INSERT INTO t3 VALUES(func6(), UUID()); Warnings: -Note 1592 Statement is not safe to log in statement format. +Note 1592 Statement may not be safe to log in statement format. "Check whether SET @@SQL_LOG_BIN = 0/1 doesn't work in substatements" CREATE FUNCTION fun_check_log_bin() RETURNS INT BEGIN @@ -259,7 +259,7 @@ SELECT fun_check_log_bin(); fun_check_log_bin() 100 Warnings: -Note 1592 Statement is not safe to log in statement format. +Note 1592 Statement may not be safe to log in statement format. "SQL_LOG_BIN should be ON still" SHOW VARIABLES LIKE "SQL_LOG_BIN"; Variable_name Value @@ -315,16 +315,16 @@ CREATE TABLE t1(i INT PRIMARY KEY); CREATE TABLE t2(i INT PRIMARY KEY); INSERT INTO t1 SELECT * FROM t2 LIMIT 1; Warnings: -Note 1592 Statement is not safe to log in statement format. +Note 1592 Statement may not be safe to log in statement format. INSERT INTO t1 VALUES(@@global.sync_binlog); Warnings: -Note 1592 Statement is not safe to log in statement format. +Note 1592 Statement may not be safe to log in statement format. UPDATE t1 SET i = 999 LIMIT 1; Warnings: -Note 1592 Statement is not safe to log in statement format. +Note 1592 Statement may not be safe to log in statement format. DELETE FROM t1 LIMIT 1; Warnings: -Note 1592 Statement is not safe to log in statement format. +Note 1592 Statement may not be safe to log in statement format. DROP TABLE t1, t2; SET @@SESSION.SQL_MODE = @save_sql_mode; "End of tests" diff --git a/mysql-test/suite/binlog/t/binlog_incident-master.opt b/mysql-test/suite/binlog/t/binlog_incident-master.opt new file mode 100644 index 00000000000..57ce0081ae5 --- /dev/null +++ b/mysql-test/suite/binlog/t/binlog_incident-master.opt @@ -0,0 +1 @@ +--loose-debug=+d,incident_database_resync_on_replace
\ No newline at end of file diff --git a/mysql-test/suite/binlog/t/binlog_incident.test b/mysql-test/suite/binlog/t/binlog_incident.test new file mode 100644 index 00000000000..208c7f24df2 --- /dev/null +++ b/mysql-test/suite/binlog/t/binlog_incident.test @@ -0,0 +1,27 @@ +# The purpose of this test is to provide a reference for how the +# incident log event is represented in the output from the mysqlbinlog +# program. + +source include/have_log_bin.inc; +source include/have_debug.inc; + +let $MYSQLD_DATADIR= `select @@datadir`; + +CREATE TABLE t1 (a INT); + +INSERT INTO t1 VALUES (1),(2),(3); +SELECT * FROM t1; + +# This will generate an incident log event and store it in the binary +# log before the replace statement. +REPLACE INTO t1 VALUES (4); + +DROP TABLE t1; +FLUSH LOGS; + +exec $MYSQL_BINLOG --start-position=106 $MYSQLD_DATADIR/master-bin.000001 >$MYSQLTEST_VARDIR/tmp/binlog_incident-bug44442.sql; +--disable_query_log +eval SELECT cont LIKE '%RELOAD DATABASE; # Shall generate syntax error%' AS `Contain RELOAD DATABASE` FROM (SELECT load_file('$MYSQLTEST_VARDIR/tmp/binlog_incident-bug44442.sql') AS cont) AS tbl; +--enable_query_log + +remove_file $MYSQLTEST_VARDIR/tmp/binlog_incident-bug44442.sql;
\ No newline at end of file diff --git a/mysql-test/suite/binlog/t/binlog_tbl_metadata.test b/mysql-test/suite/binlog/t/binlog_tbl_metadata.test new file mode 100644 index 00000000000..5e847ab5fbd --- /dev/null +++ b/mysql-test/suite/binlog/t/binlog_tbl_metadata.test @@ -0,0 +1,199 @@ +# +# BUG#42749: infinite loop writing to row based binlog - processlist shows +# "freeing items" +# +# WHY +# === +# +# This bug would make table map event to report data_written one byte less +# than what would actually be written in its body. This would cause one byte shorter +# event end_log_pos. The ultimate impact was that it would make fixing the +# position in MYSQL_BIN_LOG::write_cache bogus or end up in an infinite loop. +# +# HOW +# === +# +# Checking that the patch fixes the problem is done as follows: +# i) a table with several fields is created; +# ii) an insert is performed; +# iii) the logs are flushed; +# iv) mysqlbinlog is used to check if it succeeds. +# +# In step iv), before the bug was fixed, the test case would fail with +# mysqlbinlog reporting that it was unable to succeed in reading the event. +# + +-- source include/have_log_bin.inc +-- source include/have_innodb.inc +-- source include/have_binlog_format_row.inc +-- connection default + +RESET MASTER; + +-- disable_warnings +DROP TABLE IF EXISTS `t1`; +-- enable_warnings + +CREATE TABLE `t1` ( + `c1` int(11) NOT NULL AUTO_INCREMENT, + `c2` varchar(30) NOT NULL, + `c3` varchar(30) DEFAULT NULL, + `c4` varchar(30) DEFAULT NULL, + `c5` varchar(30) DEFAULT NULL, + `c6` varchar(30) DEFAULT NULL, + `c7` varchar(30) DEFAULT NULL, + `c8` varchar(30) DEFAULT NULL, + `c9` varchar(30) DEFAULT NULL, + `c10` varchar(30) DEFAULT NULL, + `c11` varchar(30) DEFAULT NULL, + `c12` varchar(30) DEFAULT NULL, + `c13` varchar(30) DEFAULT NULL, + `c14` varchar(30) DEFAULT NULL, + `c15` varchar(30) DEFAULT NULL, + `c16` varchar(30) DEFAULT NULL, + `c17` varchar(30) DEFAULT NULL, + `c18` varchar(30) DEFAULT NULL, + `c19` varchar(30) DEFAULT NULL, + `c20` varchar(30) DEFAULT NULL, + `c21` varchar(30) DEFAULT NULL, + `c22` varchar(30) DEFAULT NULL, + `c23` varchar(30) DEFAULT NULL, + `c24` varchar(30) DEFAULT NULL, + `c25` varchar(30) DEFAULT NULL, + `c26` varchar(30) DEFAULT NULL, + `c27` varchar(30) DEFAULT NULL, + `c28` varchar(30) DEFAULT NULL, + `c29` varchar(30) DEFAULT NULL, + `c30` varchar(30) DEFAULT NULL, + `c31` varchar(30) DEFAULT NULL, + `c32` varchar(30) DEFAULT NULL, + `c33` varchar(30) DEFAULT NULL, + `c34` varchar(30) DEFAULT NULL, + `c35` varchar(30) DEFAULT NULL, + `c36` varchar(30) DEFAULT NULL, + `c37` varchar(30) DEFAULT NULL, + `c38` varchar(30) DEFAULT NULL, + `c39` varchar(30) DEFAULT NULL, + `c40` varchar(30) DEFAULT NULL, + `c41` varchar(30) DEFAULT NULL, + `c42` varchar(30) DEFAULT NULL, + `c43` varchar(30) DEFAULT NULL, + `c44` varchar(30) DEFAULT NULL, + `c45` varchar(30) DEFAULT NULL, + `c46` varchar(30) DEFAULT NULL, + `c47` varchar(30) DEFAULT NULL, + `c48` varchar(30) DEFAULT NULL, + `c49` varchar(30) DEFAULT NULL, + `c50` varchar(30) DEFAULT NULL, + `c51` varchar(30) DEFAULT NULL, + `c52` varchar(30) DEFAULT NULL, + `c53` varchar(30) DEFAULT NULL, + `c54` varchar(30) DEFAULT NULL, + `c55` varchar(30) DEFAULT NULL, + `c56` varchar(30) DEFAULT NULL, + `c57` varchar(30) DEFAULT NULL, + `c58` varchar(30) DEFAULT NULL, + `c59` varchar(30) DEFAULT NULL, + `c60` varchar(30) DEFAULT NULL, + `c61` varchar(30) DEFAULT NULL, + `c62` varchar(30) DEFAULT NULL, + `c63` varchar(30) DEFAULT NULL, + `c64` varchar(30) DEFAULT NULL, + `c65` varchar(30) DEFAULT NULL, + `c66` varchar(30) DEFAULT NULL, + `c67` varchar(30) DEFAULT NULL, + `c68` varchar(30) DEFAULT NULL, + `c69` varchar(30) DEFAULT NULL, + `c70` varchar(30) DEFAULT NULL, + `c71` varchar(30) DEFAULT NULL, + `c72` varchar(30) DEFAULT NULL, + `c73` varchar(30) DEFAULT NULL, + `c74` varchar(30) DEFAULT NULL, + `c75` varchar(30) DEFAULT NULL, + `c76` varchar(30) DEFAULT NULL, + `c77` varchar(30) DEFAULT NULL, + `c78` varchar(30) DEFAULT NULL, + `c79` varchar(30) DEFAULT NULL, + `c80` varchar(30) DEFAULT NULL, + `c81` varchar(30) DEFAULT NULL, + `c82` varchar(30) DEFAULT NULL, + `c83` varchar(30) DEFAULT NULL, + `c84` varchar(30) DEFAULT NULL, + `c85` varchar(30) DEFAULT NULL, + `c86` varchar(30) DEFAULT NULL, + `c87` varchar(30) DEFAULT NULL, + `c88` varchar(30) DEFAULT NULL, + `c89` varchar(30) DEFAULT NULL, + `c90` varchar(30) DEFAULT NULL, + `c91` varchar(30) DEFAULT NULL, + `c92` varchar(30) DEFAULT NULL, + `c93` varchar(30) DEFAULT NULL, + `c94` varchar(30) DEFAULT NULL, + `c95` varchar(30) DEFAULT NULL, + `c96` varchar(30) DEFAULT NULL, + `c97` varchar(30) DEFAULT NULL, + `c98` varchar(30) DEFAULT NULL, + `c99` varchar(30) DEFAULT NULL, + `c100` varchar(30) DEFAULT NULL, + `c101` varchar(30) DEFAULT NULL, + `c102` varchar(30) DEFAULT NULL, + `c103` varchar(30) DEFAULT NULL, + `c104` varchar(30) DEFAULT NULL, + `c105` varchar(30) DEFAULT NULL, + `c106` varchar(30) DEFAULT NULL, + `c107` varchar(30) DEFAULT NULL, + `c108` varchar(30) DEFAULT NULL, + `c109` varchar(30) DEFAULT NULL, + `c110` varchar(30) DEFAULT NULL, + `c111` varchar(30) DEFAULT NULL, + `c112` varchar(30) DEFAULT NULL, + `c113` varchar(30) DEFAULT NULL, + `c114` varchar(30) DEFAULT NULL, + `c115` varchar(30) DEFAULT NULL, + `c116` varchar(30) DEFAULT NULL, + `c117` varchar(30) DEFAULT NULL, + `c118` varchar(30) DEFAULT NULL, + `c119` varchar(30) DEFAULT NULL, + `c120` varchar(30) DEFAULT NULL, + `c121` varchar(30) DEFAULT NULL, + `c122` varchar(30) DEFAULT NULL, + `c123` varchar(30) DEFAULT NULL, + `c124` varchar(30) DEFAULT NULL, + `c125` varchar(30) DEFAULT NULL, + `c126` varchar(30) DEFAULT NULL, + `c127` varchar(30) DEFAULT NULL, + `c128` varchar(30) DEFAULT NULL, + `c129` varchar(30) DEFAULT NULL, + `c130` varchar(30) DEFAULT NULL, + `c131` varchar(30) DEFAULT NULL, + `c132` varchar(30) DEFAULT NULL, + `c133` varchar(30) DEFAULT NULL, + `c134` varchar(30) DEFAULT NULL, + `c135` varchar(30) DEFAULT NULL, + `c136` varchar(30) DEFAULT NULL, + `c137` varchar(30) DEFAULT NULL, + `c138` varchar(30) DEFAULT NULL, + `c139` varchar(30) DEFAULT NULL, + `c140` varchar(30) DEFAULT NULL, + `c141` varchar(30) DEFAULT NULL, + `c142` varchar(30) DEFAULT NULL, + `c143` varchar(30) DEFAULT NULL, + `c144` varchar(30) DEFAULT NULL, + `c145` varchar(30) DEFAULT NULL, + `c146` varchar(30) DEFAULT NULL, + PRIMARY KEY (`c1`) +) ENGINE=InnoDB; + +LOCK TABLES `t1` WRITE; + +INSERT INTO `t1` VALUES ('1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1'); + +DROP TABLE `t1`; + +FLUSH LOGS; + +-- echo === Using mysqlbinlog to detect failure. Before the patch mysqlbinlog would find a corrupted event, thence would fail. + +-- let $MYSQLD_DATADIR= `SELECT @@datadir`; +-- exec $MYSQL_BINLOG $MYSQLD_DATADIR/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/mysqlbinlog_bug42749.binlog +-- remove_file $MYSQLTEST_VARDIR/tmp/mysqlbinlog_bug42749.binlog diff --git a/mysql-test/suite/binlog/t/binlog_unsafe.test b/mysql-test/suite/binlog/t/binlog_unsafe.test index 1b0f0a6c30a..c4e1f31cbce 100644 --- a/mysql-test/suite/binlog/t/binlog_unsafe.test +++ b/mysql-test/suite/binlog/t/binlog_unsafe.test @@ -289,7 +289,7 @@ CREATE TABLE t1(i INT PRIMARY KEY); CREATE TABLE t2(i INT PRIMARY KEY); CREATE TABLE t3(i INT, ch CHAR(50)); ---echo "Should issue message Statement is not safe to log in statement format." +--echo "Should issue message Statement may not be safe to log in statement format." INSERT INTO t1 SELECT * FROM t2 LIMIT 1; DELIMITER |; @@ -302,7 +302,7 @@ BEGIN RETURN 0; END| DELIMITER ;| ---echo "Should issue message Statement is not safe to log in statement format only once" +--echo "Should issue message Statement may not be safe to log in statement format only once" INSERT INTO t3 VALUES(func6(), UUID()); --echo "Check whether SET @@SQL_LOG_BIN = 0/1 doesn't work in substatements" diff --git a/mysql-test/suite/funcs_1/datadict/is_routines.inc b/mysql-test/suite/funcs_1/datadict/is_routines.inc index 573967cbc1b..19f7ed5d230 100644 --- a/mysql-test/suite/funcs_1/datadict/is_routines.inc +++ b/mysql-test/suite/funcs_1/datadict/is_routines.inc @@ -96,10 +96,11 @@ CREATE FUNCTION function_for_routines() RETURNS INT RETURN 0; SELECT specific_name,routine_catalog,routine_schema,routine_name,routine_type, routine_body,external_name,external_language,parameter_style,sql_path FROM information_schema.routines -WHERE routine_catalog IS NOT NULL OR external_name IS NOT NULL +WHERE routine_schema = 'test' AND + (routine_catalog IS NOT NULL OR external_name IS NOT NULL OR external_language IS NOT NULL OR sql_path IS NOT NULL OR routine_body <> 'SQL' OR parameter_style <> 'SQL' - OR specific_name <> routine_name; + OR specific_name <> routine_name); DROP PROCEDURE sp_for_routines; DROP FUNCTION function_for_routines; diff --git a/mysql-test/suite/funcs_1/r/is_routines.result b/mysql-test/suite/funcs_1/r/is_routines.result index e7a900f5c0b..14a7107778c 100644 --- a/mysql-test/suite/funcs_1/r/is_routines.result +++ b/mysql-test/suite/funcs_1/r/is_routines.result @@ -111,10 +111,11 @@ CREATE FUNCTION function_for_routines() RETURNS INT RETURN 0; SELECT specific_name,routine_catalog,routine_schema,routine_name,routine_type, routine_body,external_name,external_language,parameter_style,sql_path FROM information_schema.routines -WHERE routine_catalog IS NOT NULL OR external_name IS NOT NULL +WHERE routine_schema = 'test' AND +(routine_catalog IS NOT NULL OR external_name IS NOT NULL OR external_language IS NOT NULL OR sql_path IS NOT NULL OR routine_body <> 'SQL' OR parameter_style <> 'SQL' - OR specific_name <> routine_name; + OR specific_name <> routine_name); specific_name routine_catalog routine_schema routine_name routine_type routine_body external_name external_language parameter_style sql_path DROP PROCEDURE sp_for_routines; DROP FUNCTION function_for_routines; diff --git a/mysql-test/suite/ibmdb2i/include/have_i54.inc b/mysql-test/suite/ibmdb2i/include/have_i54.inc new file mode 100755 index 00000000000..7054e196153 --- /dev/null +++ b/mysql-test/suite/ibmdb2i/include/have_i54.inc @@ -0,0 +1,20 @@ +# Check for IBM i 6.1 or later +--disable_query_log +system uname -rv > $MYSQLTEST_VARDIR/tmp/version; +--disable_warnings +drop table if exists uname_vr; +--enable_warnings +create temporary table uname_vr (r int, v int); +--disable_warnings +eval LOAD DATA INFILE "$MYSQLTEST_VARDIR/tmp/version" into table uname_vr fields terminated by ' '; +--enable_warnings +let $ok = `select count(*) from uname_vr where v = 5 and r = 4`; +drop table uname_vr; +remove_file $MYSQLTEST_VARDIR/tmp/version; +--enable_query_log +if (!$ok) +{ + skip "Need IBM i 5.4 or later"; +} + + diff --git a/mysql-test/suite/ibmdb2i/r/ibmdb2i_bug_44232.result b/mysql-test/suite/ibmdb2i/r/ibmdb2i_bug_44232.result new file mode 100755 index 00000000000..8276b401073 --- /dev/null +++ b/mysql-test/suite/ibmdb2i/r/ibmdb2i_bug_44232.result @@ -0,0 +1,4 @@ +create table t1 (c char(1) character set armscii8) engine=ibmdb2i; +ERROR HY000: Can't create table 'test.t1' (errno: 2504) +create table t1 (c char(1) character set eucjpms ) engine=ibmdb2i; +ERROR HY000: Can't create table 'test.t1' (errno: 2504) diff --git a/mysql-test/suite/ibmdb2i/r/ibmdb2i_bug_44610.result b/mysql-test/suite/ibmdb2i/r/ibmdb2i_bug_44610.result new file mode 100755 index 00000000000..311e800e1b0 --- /dev/null +++ b/mysql-test/suite/ibmdb2i/r/ibmdb2i_bug_44610.result @@ -0,0 +1,18 @@ +create table ABC (i int) engine=ibmdb2i; +drop table ABC; +create table `1234567890ABC` (i int) engine=ibmdb2i; +drop table `1234567890ABC`; +create table `!@#$%` (i int) engine=ibmdb2i; +drop table `!@#$%`; +create table `ABCD#########` (i int) engine=ibmdb2i; +drop table `ABCD#########`; +create table `_` (i int) engine=ibmdb2i; +drop table `_`; +create table `abc##def` (i int) engine=ibmdb2i; +drop table `abc##def`; +set names utf8; +create table Ä° (s1 int) engine=ibmdb2i; +drop table Ä°; +create table Ä°Ä° (s1 int) engine=ibmdb2i; +drop table Ä°Ä°; +set names latin1; diff --git a/mysql-test/suite/ibmdb2i/t/ibmdb2i_bug_44232.test b/mysql-test/suite/ibmdb2i/t/ibmdb2i_bug_44232.test new file mode 100755 index 00000000000..ea29b5abcd4 --- /dev/null +++ b/mysql-test/suite/ibmdb2i/t/ibmdb2i_bug_44232.test @@ -0,0 +1,8 @@ +--source suite/ibmdb2i/include/have_ibmdb2i.inc +--source suite/ibmdb2i/include/have_i54.inc + +--error 1005 +create table t1 (c char(1) character set armscii8) engine=ibmdb2i; + +--error 1005 +create table t1 (c char(1) character set eucjpms ) engine=ibmdb2i; diff --git a/mysql-test/suite/ibmdb2i/t/ibmdb2i_bug_44610.test b/mysql-test/suite/ibmdb2i/t/ibmdb2i_bug_44610.test new file mode 100755 index 00000000000..da69b5d9148 --- /dev/null +++ b/mysql-test/suite/ibmdb2i/t/ibmdb2i_bug_44610.test @@ -0,0 +1,28 @@ +source suite/ibmdb2i/include/have_ibmdb2i.inc; + +# Test RCDFMT generation for a variety of kinds of table names +create table ABC (i int) engine=ibmdb2i; +drop table ABC; + +create table `1234567890ABC` (i int) engine=ibmdb2i; +drop table `1234567890ABC`; + +create table `!@#$%` (i int) engine=ibmdb2i; +drop table `!@#$%`; + +create table `ABCD#########` (i int) engine=ibmdb2i; +drop table `ABCD#########`; + +create table `_` (i int) engine=ibmdb2i; +drop table `_`; + +create table `abc##def` (i int) engine=ibmdb2i; +drop table `abc##def`; + +set names utf8; +create table Ä° (s1 int) engine=ibmdb2i; +drop table Ä°; + +create table Ä°Ä° (s1 int) engine=ibmdb2i; +drop table Ä°Ä°; +set names latin1; diff --git a/mysql-test/suite/rpl/r/rpl_slave_load_tmpdir_not_exist.result b/mysql-test/suite/rpl/r/rpl_slave_load_tmpdir_not_exist.result index a158fb5dfc4..3ed14a9cb6b 100644 --- a/mysql-test/suite/rpl/r/rpl_slave_load_tmpdir_not_exist.result +++ b/mysql-test/suite/rpl/r/rpl_slave_load_tmpdir_not_exist.result @@ -3,4 +3,4 @@ MASTER_CONNECT_RETRY=1, MASTER_HOST='127.0.0.1', MASTER_PORT=MASTER_MYPORT; START SLAVE; -Unable to use slave's temporary directory ../../../error - Can't read dir of '../../../error' (Errcode: 2) +12 diff --git a/mysql-test/suite/rpl/r/rpl_slave_skip.result b/mysql-test/suite/rpl/r/rpl_slave_skip.result index 747e8f235a8..93b3e124a01 100644 --- a/mysql-test/suite/rpl/r/rpl_slave_skip.result +++ b/mysql-test/suite/rpl/r/rpl_slave_skip.result @@ -39,8 +39,8 @@ a b SELECT * FROM t2; c d 1 2 -2 16 -3 54 +2 8 +3 18 **** On Slave **** START SLAVE UNTIL MASTER_LOG_FILE='master-bin.000001', MASTER_LOG_POS=762; SHOW SLAVE STATUS; @@ -50,7 +50,7 @@ Master_User root Master_Port MASTER_PORT Connect_Retry 1 Master_Log_File master-bin.000001 -Read_Master_Log_Pos 1133 +Read_Master_Log_Pos 1115 Relay_Log_File # Relay_Log_Pos # Relay_Master_Log_File master-bin.000001 diff --git a/mysql-test/suite/rpl/r/rpl_stm_loadfile.result b/mysql-test/suite/rpl/r/rpl_stm_loadfile.result index 72f58268d5f..ca76695f4d4 100644 --- a/mysql-test/suite/rpl/r/rpl_stm_loadfile.result +++ b/mysql-test/suite/rpl/r/rpl_stm_loadfile.result @@ -10,7 +10,7 @@ CREATE TABLE test.t1 (a INT, blob_column LONGBLOB, PRIMARY KEY(a)); INSERT INTO test.t1 VALUES(1,'test'); UPDATE test.t1 SET blob_column=LOAD_FILE('../../std_data/words2.dat') WHERE a=1; Warnings: -Note 1592 Statement is not safe to log in statement format. +Note 1592 Statement may not be safe to log in statement format. create procedure test.p1() begin INSERT INTO test.t1 VALUES(2,'test'); @@ -18,7 +18,7 @@ UPDATE test.t1 SET blob_column=LOAD_FILE('../../std_data/words2.dat') WHERE a=2; end| CALL test.p1(); Warnings: -Note 1592 Statement is not safe to log in statement format. +Note 1592 Statement may not be safe to log in statement format. SELECT * FROM test.t1 ORDER BY blob_column; a blob_column 1 abase diff --git a/mysql-test/suite/rpl/r/rpl_temporary.result b/mysql-test/suite/rpl/r/rpl_temporary.result index 8a9ddaec9f6..631eb0677b0 100644 --- a/mysql-test/suite/rpl/r/rpl_temporary.result +++ b/mysql-test/suite/rpl/r/rpl_temporary.result @@ -6,6 +6,25 @@ drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; start slave; call mtr.add_suppression("Slave: Can\'t find record in \'user\' Error_code: 1032"); reset master; +DROP TABLE IF EXISTS t1; +CREATE TEMPORARY TABLE t1 (a char(1)); +INSERT INTO t1 VALUES ('a'); +include/stop_slave.inc +include/start_slave.inc +INSERT INTO t1 VALUES ('b'); +DROP TABLE IF EXISTS t1; +CREATE TEMPORARY TABLE `t1`(`a` tinyint,`b` char(1))engine=myisam; +INSERT INTO `t1` set `a`=128,`b`='128'; +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +Warning 1265 Data truncated for column 'b' at row 1 +include/stop_slave.inc +include/start_slave.inc +INSERT INTO `t1` set `a`=128,`b`='128'; +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +Warning 1265 Data truncated for column 'b' at row 1 +DROP TABLE t1; SET @save_select_limit=@@session.sql_select_limit; SET @@session.sql_select_limit=10, @@session.pseudo_thread_id=100; ERROR 42000: Access denied; you need the SUPER privilege for this operation diff --git a/mysql-test/suite/rpl/r/rpl_udf.result b/mysql-test/suite/rpl/r/rpl_udf.result index 56df5b30d93..ccf16271d01 100644 --- a/mysql-test/suite/rpl/r/rpl_udf.result +++ b/mysql-test/suite/rpl/r/rpl_udf.result @@ -182,19 +182,19 @@ CREATE TABLE t1(sum INT, price FLOAT(24)) ENGINE=MyISAM; affected rows: 0 INSERT INTO t1 VALUES(myfunc_int(100), myfunc_double(50.00)); Warnings: -Note 1592 Statement is not safe to log in statement format. +Note 1592 Statement may not be safe to log in statement format. affected rows: 1 INSERT INTO t1 VALUES(myfunc_int(10), myfunc_double(5.00)); Warnings: -Note 1592 Statement is not safe to log in statement format. +Note 1592 Statement may not be safe to log in statement format. affected rows: 1 INSERT INTO t1 VALUES(myfunc_int(200), myfunc_double(25.00)); Warnings: -Note 1592 Statement is not safe to log in statement format. +Note 1592 Statement may not be safe to log in statement format. affected rows: 1 INSERT INTO t1 VALUES(myfunc_int(1), myfunc_double(500.00)); Warnings: -Note 1592 Statement is not safe to log in statement format. +Note 1592 Statement may not be safe to log in statement format. affected rows: 1 SELECT * FROM t1 ORDER BY sum; sum price diff --git a/mysql-test/suite/rpl/t/disabled.def b/mysql-test/suite/rpl/t/disabled.def index b7cb6da8127..fcc3d56a9f5 100644 --- a/mysql-test/suite/rpl/t/disabled.def +++ b/mysql-test/suite/rpl/t/disabled.def @@ -10,4 +10,5 @@ # ############################################################################## -rpl_cross_version : BUG#42311 2009-03-27 joro rpl_cross_version fails on macosx +rpl_cross_version : Bug#42311 2009-03-27 joro rpl_cross_version fails on macosx +rpl_init_slave : Bug#44920 2009-05-18 pcrews MTR2 is not processing master.opt input properly on Windows diff --git a/mysql-test/suite/rpl/t/rpl_incident.test b/mysql-test/suite/rpl/t/rpl_incident.test index 38fcc116736..66893ebb93f 100644 --- a/mysql-test/suite/rpl/t/rpl_incident.test +++ b/mysql-test/suite/rpl/t/rpl_incident.test @@ -14,42 +14,13 @@ REPLACE INTO t1 VALUES (4); SELECT * FROM t1; connection slave; -source include/wait_for_slave_sql_to_stop.inc; +# Wait until SQL thread stops with error LOST_EVENT on master +let $slave_sql_errno= 1590; +source include/wait_for_slave_sql_error.inc; # The 4 should not be inserted into the table, since the incident log # event should have stop the slave. --echo **** On Slave **** -#### BEGIN DEBUG INFO ADDED BY SVEN 2008-07-18 -- SEE BUG#38077 #### -let $tables= query_get_value(SHOW TABLES, Tables_in_test, 1); -if (`SELECT '$tables' != 't1'`) -{ - --echo **** TEST CASE BUG! PRINTING DEBUG INFO! **** - --echo **** Dear developer, if you see this in the output of a test - --echo **** case run, please add all the information below as a - --echo **** comment to BUG#38077. If it's a pushbuild failure, please - --echo **** include a link to the push page. - --echo **** Thank you! /Sven - SHOW BINLOG EVENTS; - --echo **** master binlog **** - --error 0,1 - --exec $MYSQL_BINLOG --hexdump $MYSQLTEST_VARDIR/log/master-bin.000001 - --echo **** slave binlog **** - --error 0,1 - --exec $MYSQL_BINLOG --hexdump $MYSQLTEST_VARDIR/log/slave-bin.000001 - --echo **** slave status **** - query_vertical SHOW SLAVE STATUS; - --echo **** slave's master status **** - SHOW MASTER STATUS; - --echo **** slave binlog events **** - --echo [on master] - connection master; - --echo **** master status **** - SHOW MASTER STATUS; - --echo **** master binlog events **** - SHOW BINLOG EVENTS; - exit; -} -#### END DEBUG INFO #### SELECT * FROM t1; --replace_result $MASTER_MYPORT MASTER_PORT diff --git a/mysql-test/suite/rpl/t/rpl_slave_load_tmpdir_not_exist.test b/mysql-test/suite/rpl/t/rpl_slave_load_tmpdir_not_exist.test index 3a80fa43f20..68c41abf537 100644 --- a/mysql-test/suite/rpl/t/rpl_slave_load_tmpdir_not_exist.test +++ b/mysql-test/suite/rpl/t/rpl_slave_load_tmpdir_not_exist.test @@ -20,5 +20,5 @@ eval CHANGE MASTER TO MASTER_USER='root', START SLAVE; source include/wait_for_slave_sql_to_stop.inc; -let $error=query_get_value("show slave status", Last_SQL_Error, 1); -echo $error; +let $errno=query_get_value("show slave status", Last_SQL_Errno, 1); +echo $errno; diff --git a/mysql-test/suite/rpl/t/rpl_temporary.test b/mysql-test/suite/rpl/t/rpl_temporary.test index 4e83d39710c..a59e4f2fd21 100644 --- a/mysql-test/suite/rpl/t/rpl_temporary.test +++ b/mysql-test/suite/rpl/t/rpl_temporary.test @@ -22,6 +22,77 @@ call mtr.add_suppression("Slave: Can\'t find record in \'user\' Error_code: 1032 sync_with_master; reset master; + +# ################################################################## +# BUG#41725: slave crashes when inserting into temporary table after +# stop/start slave +# +# This test checks that both reported issues (assertion failure and +# crash) go away. It is implemented as follows: +# +# case 1: assertion failure +# i) create and insert into temporary table on master +# ii) sync slave with master +# iii) stop and restart slave +# iv) insert into master another value +# v) sync slave with master +# +# +# case 2: crash (SIGSEV) +# i) create and insert into temporary table on master (insert +# produces warnings) +# ii) sync slave with master +# iii) stop and restart slave +# iv) insert into master more values +# v) sync slave with master + +# case 1: Assertion in Field_string::store() failed because current +# thread reference differed from table->in_use after slave +# restart + +connection master; + +disable_warnings; +DROP TABLE IF EXISTS t1; +enable_warnings; + +CREATE TEMPORARY TABLE t1 (a char(1)); +INSERT INTO t1 VALUES ('a'); +sync_slave_with_master; + +source include/stop_slave.inc; +source include/start_slave.inc; + +connection master; +INSERT INTO t1 VALUES ('b'); +sync_slave_with_master; + +# case 2: crash on sp_rcontext::find_handler because it used +# reference to invalid THD object after slave restart + +connection master; + +disable_warnings; +DROP TABLE IF EXISTS t1; +enable_warnings; +CREATE TEMPORARY TABLE `t1`(`a` tinyint,`b` char(1))engine=myisam; +INSERT INTO `t1` set `a`=128,`b`='128'; + +sync_slave_with_master; + +source include/stop_slave.inc; +source include/start_slave.inc; + +connection master; +INSERT INTO `t1` set `a`=128,`b`='128'; +sync_slave_with_master; + +# cleanup + +connection master; +DROP TABLE t1; +sync_slave_with_master; + connection master; connect (con1,localhost,root,,); diff --git a/mysql-test/suite/rpl_ndb/t/rpl_ndb_2other-slave.opt b/mysql-test/suite/rpl_ndb/t/rpl_ndb_2other-slave.opt index 188b31efa8a..dff423702b4 100644 --- a/mysql-test/suite/rpl_ndb/t/rpl_ndb_2other-slave.opt +++ b/mysql-test/suite/rpl_ndb/t/rpl_ndb_2other-slave.opt @@ -1 +1 @@ ---innodb --ndbcluster=0 --log-slave-updates=0 +--innodb --loose-ndbcluster=OFF --log-slave-updates=0 diff --git a/mysql-test/suite/sys_vars/r/innodb_data_home_dir_basic.result b/mysql-test/suite/sys_vars/r/innodb_data_home_dir_basic.result index e4bdd79b7c3..52a97bb6c95 100644 --- a/mysql-test/suite/sys_vars/r/innodb_data_home_dir_basic.result +++ b/mysql-test/suite/sys_vars/r/innodb_data_home_dir_basic.result @@ -1,16 +1,16 @@ '#---------------------BS_STVARS_025_01----------------------#' SELECT COUNT(@@GLOBAL.innodb_data_home_dir); COUNT(@@GLOBAL.innodb_data_home_dir) -1 -1 Expected +0 +0 Expected '#---------------------BS_STVARS_025_02----------------------#' SET @@GLOBAL.innodb_data_home_dir=1; ERROR HY000: Variable 'innodb_data_home_dir' is a read only variable Expected error 'Read only variable' SELECT COUNT(@@GLOBAL.innodb_data_home_dir); COUNT(@@GLOBAL.innodb_data_home_dir) -1 -1 Expected +0 +0 Expected '#---------------------BS_STVARS_025_03----------------------#' SELECT @@GLOBAL.innodb_data_home_dir = VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES @@ -20,8 +20,8 @@ NULL 1 Expected SELECT COUNT(@@GLOBAL.innodb_data_home_dir); COUNT(@@GLOBAL.innodb_data_home_dir) -1 -1 Expected +0 +0 Expected SELECT COUNT(VARIABLE_VALUE) FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES WHERE VARIABLE_NAME='innodb_data_home_dir'; @@ -36,8 +36,8 @@ NULL '#---------------------BS_STVARS_025_05----------------------#' SELECT COUNT(@@innodb_data_home_dir); COUNT(@@innodb_data_home_dir) -1 -1 Expected +0 +0 Expected SELECT COUNT(@@local.innodb_data_home_dir); ERROR HY000: Variable 'innodb_data_home_dir' is a GLOBAL variable Expected error 'Variable is a GLOBAL variable' @@ -46,8 +46,8 @@ ERROR HY000: Variable 'innodb_data_home_dir' is a GLOBAL variable Expected error 'Variable is a GLOBAL variable' SELECT COUNT(@@GLOBAL.innodb_data_home_dir); COUNT(@@GLOBAL.innodb_data_home_dir) -1 -1 Expected +0 +0 Expected SELECT innodb_data_home_dir = @@SESSION.innodb_data_home_dir; ERROR 42S22: Unknown column 'innodb_data_home_dir' in 'field list' Expected error 'Readonly variable' diff --git a/mysql-test/suite/sys_vars/r/innodb_flush_method_basic.result b/mysql-test/suite/sys_vars/r/innodb_flush_method_basic.result index 8c8924cdd86..4a85748092d 100644 --- a/mysql-test/suite/sys_vars/r/innodb_flush_method_basic.result +++ b/mysql-test/suite/sys_vars/r/innodb_flush_method_basic.result @@ -1,16 +1,16 @@ '#---------------------BS_STVARS_029_01----------------------#' SELECT COUNT(@@GLOBAL.innodb_flush_method); COUNT(@@GLOBAL.innodb_flush_method) -1 -1 Expected +0 +0 Expected '#---------------------BS_STVARS_029_02----------------------#' SET @@GLOBAL.innodb_flush_method=1; ERROR HY000: Variable 'innodb_flush_method' is a read only variable Expected error 'Read only variable' SELECT COUNT(@@GLOBAL.innodb_flush_method); COUNT(@@GLOBAL.innodb_flush_method) -1 -1 Expected +0 +0 Expected '#---------------------BS_STVARS_029_03----------------------#' SELECT @@GLOBAL.innodb_flush_method = VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES @@ -20,8 +20,8 @@ NULL 1 Expected SELECT COUNT(@@GLOBAL.innodb_flush_method); COUNT(@@GLOBAL.innodb_flush_method) -1 -1 Expected +0 +0 Expected SELECT COUNT(VARIABLE_VALUE) FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES WHERE VARIABLE_NAME='innodb_flush_method'; @@ -36,8 +36,8 @@ NULL '#---------------------BS_STVARS_029_05----------------------#' SELECT COUNT(@@innodb_flush_method); COUNT(@@innodb_flush_method) -1 -1 Expected +0 +0 Expected SELECT COUNT(@@local.innodb_flush_method); ERROR HY000: Variable 'innodb_flush_method' is a GLOBAL variable Expected error 'Variable is a GLOBAL variable' @@ -46,8 +46,8 @@ ERROR HY000: Variable 'innodb_flush_method' is a GLOBAL variable Expected error 'Variable is a GLOBAL variable' SELECT COUNT(@@GLOBAL.innodb_flush_method); COUNT(@@GLOBAL.innodb_flush_method) -1 -1 Expected +0 +0 Expected SELECT innodb_flush_method = @@SESSION.innodb_flush_method; ERROR 42S22: Unknown column 'innodb_flush_method' in 'field list' Expected error 'Readonly variable' diff --git a/mysql-test/suite/sys_vars/r/rpl_init_slave_func.result b/mysql-test/suite/sys_vars/r/rpl_init_slave_func.result index 5f730bff882..bdb586e84c2 100644 --- a/mysql-test/suite/sys_vars/r/rpl_init_slave_func.result +++ b/mysql-test/suite/sys_vars/r/rpl_init_slave_func.result @@ -12,7 +12,7 @@ DROP TABLE IF EXISTS t1; CREATE TEMPORARY TABLE t1 AS SELECT @@global.init_slave AS my_column; DESCRIBE t1; Field Type Null Key Default Extra -my_column varchar(59) NO +my_column varchar(59) YES NULL DROP TABLE t1; SELECT @@global.init_slave = 'SET @@global.max_connections = @@global.max_connections + 1'; @@global.init_slave = 'SET @@global.max_connections = @@global.max_connections + 1' diff --git a/mysql-test/suite/sys_vars/r/ssl_capath_basic.result b/mysql-test/suite/sys_vars/r/ssl_capath_basic.result index 3d161392917..f04b85b956f 100644 --- a/mysql-test/suite/sys_vars/r/ssl_capath_basic.result +++ b/mysql-test/suite/sys_vars/r/ssl_capath_basic.result @@ -1,16 +1,16 @@ '#---------------------BS_STVARS_046_01----------------------#' SELECT COUNT(@@GLOBAL.ssl_capath); COUNT(@@GLOBAL.ssl_capath) -1 -1 Expected +0 +0 Expected '#---------------------BS_STVARS_046_02----------------------#' SET @@GLOBAL.ssl_capath=1; ERROR HY000: Variable 'ssl_capath' is a read only variable Expected error 'Read only variable' SELECT COUNT(@@GLOBAL.ssl_capath); COUNT(@@GLOBAL.ssl_capath) -1 -1 Expected +0 +0 Expected '#---------------------BS_STVARS_046_03----------------------#' SELECT @@GLOBAL.ssl_capath = VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES @@ -20,8 +20,8 @@ NULL 1 Expected SELECT COUNT(@@GLOBAL.ssl_capath); COUNT(@@GLOBAL.ssl_capath) -1 -1 Expected +0 +0 Expected SELECT COUNT(VARIABLE_VALUE) FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES WHERE VARIABLE_NAME='ssl_capath'; @@ -36,8 +36,8 @@ NULL '#---------------------BS_STVARS_046_05----------------------#' SELECT COUNT(@@ssl_capath); COUNT(@@ssl_capath) -1 -1 Expected +0 +0 Expected SELECT COUNT(@@local.ssl_capath); ERROR HY000: Variable 'ssl_capath' is a GLOBAL variable Expected error 'Variable is a GLOBAL variable' @@ -46,8 +46,8 @@ ERROR HY000: Variable 'ssl_capath' is a GLOBAL variable Expected error 'Variable is a GLOBAL variable' SELECT COUNT(@@GLOBAL.ssl_capath); COUNT(@@GLOBAL.ssl_capath) -1 -1 Expected +0 +0 Expected SELECT ssl_capath = @@SESSION.ssl_capath; ERROR 42S22: Unknown column 'ssl_capath' in 'field list' Expected error 'Readonly variable' diff --git a/mysql-test/suite/sys_vars/r/ssl_cipher_basic.result b/mysql-test/suite/sys_vars/r/ssl_cipher_basic.result index df0fc8b5aad..0eed40d0580 100644 --- a/mysql-test/suite/sys_vars/r/ssl_cipher_basic.result +++ b/mysql-test/suite/sys_vars/r/ssl_cipher_basic.result @@ -1,16 +1,16 @@ '#---------------------BS_STVARS_048_01----------------------#' SELECT COUNT(@@GLOBAL.ssl_cipher); COUNT(@@GLOBAL.ssl_cipher) -1 -1 Expected +0 +0 Expected '#---------------------BS_STVARS_048_02----------------------#' SET @@GLOBAL.ssl_cipher=1; ERROR HY000: Variable 'ssl_cipher' is a read only variable Expected error 'Read only variable' SELECT COUNT(@@GLOBAL.ssl_cipher); COUNT(@@GLOBAL.ssl_cipher) -1 -1 Expected +0 +0 Expected '#---------------------BS_STVARS_048_03----------------------#' SELECT @@GLOBAL.ssl_cipher = VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES @@ -20,8 +20,8 @@ NULL 1 Expected SELECT COUNT(@@GLOBAL.ssl_cipher); COUNT(@@GLOBAL.ssl_cipher) -1 -1 Expected +0 +0 Expected SELECT COUNT(VARIABLE_VALUE) FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES WHERE VARIABLE_NAME='ssl_cipher'; @@ -36,8 +36,8 @@ NULL '#---------------------BS_STVARS_048_05----------------------#' SELECT COUNT(@@ssl_cipher); COUNT(@@ssl_cipher) -1 -1 Expected +0 +0 Expected SELECT COUNT(@@local.ssl_cipher); ERROR HY000: Variable 'ssl_cipher' is a GLOBAL variable Expected error 'Variable is a GLOBAL variable' @@ -46,8 +46,8 @@ ERROR HY000: Variable 'ssl_cipher' is a GLOBAL variable Expected error 'Variable is a GLOBAL variable' SELECT COUNT(@@GLOBAL.ssl_cipher); COUNT(@@GLOBAL.ssl_cipher) -1 -1 Expected +0 +0 Expected SELECT ssl_cipher = @@SESSION.ssl_cipher; ERROR 42S22: Unknown column 'ssl_cipher' in 'field list' Expected error 'Readonly variable' diff --git a/mysql-test/suite/sys_vars/t/innodb_data_home_dir_basic.test b/mysql-test/suite/sys_vars/t/innodb_data_home_dir_basic.test index f3b02edf83b..acf3741d5fa 100644 --- a/mysql-test/suite/sys_vars/t/innodb_data_home_dir_basic.test +++ b/mysql-test/suite/sys_vars/t/innodb_data_home_dir_basic.test @@ -29,7 +29,7 @@ # Displaying default value # #################################################################### SELECT COUNT(@@GLOBAL.innodb_data_home_dir); ---echo 1 Expected +--echo 0 Expected --echo '#---------------------BS_STVARS_025_02----------------------#' @@ -42,7 +42,7 @@ SET @@GLOBAL.innodb_data_home_dir=1; --echo Expected error 'Read only variable' SELECT COUNT(@@GLOBAL.innodb_data_home_dir); ---echo 1 Expected +--echo 0 Expected @@ -58,7 +58,7 @@ WHERE VARIABLE_NAME='innodb_data_home_dir'; --echo 1 Expected SELECT COUNT(@@GLOBAL.innodb_data_home_dir); ---echo 1 Expected +--echo 0 Expected SELECT COUNT(VARIABLE_VALUE) FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES @@ -82,7 +82,7 @@ SELECT @@innodb_data_home_dir = @@GLOBAL.innodb_data_home_dir; ################################################################################ SELECT COUNT(@@innodb_data_home_dir); ---echo 1 Expected +--echo 0 Expected --Error ER_INCORRECT_GLOBAL_LOCAL_VAR SELECT COUNT(@@local.innodb_data_home_dir); @@ -93,7 +93,7 @@ SELECT COUNT(@@SESSION.innodb_data_home_dir); --echo Expected error 'Variable is a GLOBAL variable' SELECT COUNT(@@GLOBAL.innodb_data_home_dir); ---echo 1 Expected +--echo 0 Expected --Error ER_BAD_FIELD_ERROR SELECT innodb_data_home_dir = @@SESSION.innodb_data_home_dir; diff --git a/mysql-test/suite/sys_vars/t/innodb_flush_method_basic.test b/mysql-test/suite/sys_vars/t/innodb_flush_method_basic.test index 531df4a2464..75af00e33af 100644 --- a/mysql-test/suite/sys_vars/t/innodb_flush_method_basic.test +++ b/mysql-test/suite/sys_vars/t/innodb_flush_method_basic.test @@ -29,7 +29,7 @@ # Displaying default value # #################################################################### SELECT COUNT(@@GLOBAL.innodb_flush_method); ---echo 1 Expected +--echo 0 Expected --echo '#---------------------BS_STVARS_029_02----------------------#' @@ -42,7 +42,7 @@ SET @@GLOBAL.innodb_flush_method=1; --echo Expected error 'Read only variable' SELECT COUNT(@@GLOBAL.innodb_flush_method); ---echo 1 Expected +--echo 0 Expected @@ -58,7 +58,7 @@ WHERE VARIABLE_NAME='innodb_flush_method'; --echo 1 Expected SELECT COUNT(@@GLOBAL.innodb_flush_method); ---echo 1 Expected +--echo 0 Expected SELECT COUNT(VARIABLE_VALUE) FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES @@ -82,7 +82,7 @@ SELECT @@innodb_flush_method = @@GLOBAL.innodb_flush_method; ################################################################################ SELECT COUNT(@@innodb_flush_method); ---echo 1 Expected +--echo 0 Expected --Error ER_INCORRECT_GLOBAL_LOCAL_VAR SELECT COUNT(@@local.innodb_flush_method); @@ -93,7 +93,7 @@ SELECT COUNT(@@SESSION.innodb_flush_method); --echo Expected error 'Variable is a GLOBAL variable' SELECT COUNT(@@GLOBAL.innodb_flush_method); ---echo 1 Expected +--echo 0 Expected --Error ER_BAD_FIELD_ERROR SELECT innodb_flush_method = @@SESSION.innodb_flush_method; diff --git a/mysql-test/suite/sys_vars/t/ssl_capath_basic.test b/mysql-test/suite/sys_vars/t/ssl_capath_basic.test index c32b572fb1b..ece9fe992d9 100644 --- a/mysql-test/suite/sys_vars/t/ssl_capath_basic.test +++ b/mysql-test/suite/sys_vars/t/ssl_capath_basic.test @@ -27,7 +27,7 @@ # Displaying default value # #################################################################### SELECT COUNT(@@GLOBAL.ssl_capath); ---echo 1 Expected +--echo 0 Expected --echo '#---------------------BS_STVARS_046_02----------------------#' @@ -40,7 +40,7 @@ SET @@GLOBAL.ssl_capath=1; --echo Expected error 'Read only variable' SELECT COUNT(@@GLOBAL.ssl_capath); ---echo 1 Expected +--echo 0 Expected @@ -56,7 +56,7 @@ WHERE VARIABLE_NAME='ssl_capath'; --echo 1 Expected SELECT COUNT(@@GLOBAL.ssl_capath); ---echo 1 Expected +--echo 0 Expected SELECT COUNT(VARIABLE_VALUE) FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES @@ -80,7 +80,7 @@ SELECT @@ssl_capath = @@GLOBAL.ssl_capath; ################################################################################ SELECT COUNT(@@ssl_capath); ---echo 1 Expected +--echo 0 Expected --Error ER_INCORRECT_GLOBAL_LOCAL_VAR SELECT COUNT(@@local.ssl_capath); @@ -91,7 +91,7 @@ SELECT COUNT(@@SESSION.ssl_capath); --echo Expected error 'Variable is a GLOBAL variable' SELECT COUNT(@@GLOBAL.ssl_capath); ---echo 1 Expected +--echo 0 Expected --Error ER_BAD_FIELD_ERROR SELECT ssl_capath = @@SESSION.ssl_capath; diff --git a/mysql-test/suite/sys_vars/t/ssl_cipher_basic.test b/mysql-test/suite/sys_vars/t/ssl_cipher_basic.test index 425f7aae442..c58b22da2d5 100644 --- a/mysql-test/suite/sys_vars/t/ssl_cipher_basic.test +++ b/mysql-test/suite/sys_vars/t/ssl_cipher_basic.test @@ -27,7 +27,7 @@ # Displaying default value # #################################################################### SELECT COUNT(@@GLOBAL.ssl_cipher); ---echo 1 Expected +--echo 0 Expected --echo '#---------------------BS_STVARS_048_02----------------------#' @@ -40,7 +40,7 @@ SET @@GLOBAL.ssl_cipher=1; --echo Expected error 'Read only variable' SELECT COUNT(@@GLOBAL.ssl_cipher); ---echo 1 Expected +--echo 0 Expected @@ -56,7 +56,7 @@ WHERE VARIABLE_NAME='ssl_cipher'; --echo 1 Expected SELECT COUNT(@@GLOBAL.ssl_cipher); ---echo 1 Expected +--echo 0 Expected SELECT COUNT(VARIABLE_VALUE) FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES @@ -80,7 +80,7 @@ SELECT @@ssl_cipher = @@GLOBAL.ssl_cipher; ################################################################################ SELECT COUNT(@@ssl_cipher); ---echo 1 Expected +--echo 0 Expected --Error ER_INCORRECT_GLOBAL_LOCAL_VAR SELECT COUNT(@@local.ssl_cipher); @@ -91,7 +91,7 @@ SELECT COUNT(@@SESSION.ssl_cipher); --echo Expected error 'Variable is a GLOBAL variable' SELECT COUNT(@@GLOBAL.ssl_cipher); ---echo 1 Expected +--echo 0 Expected --Error ER_BAD_FIELD_ERROR SELECT ssl_cipher = @@SESSION.ssl_cipher; diff --git a/mysql-test/t/archive_bitfield.test b/mysql-test/t/archive_bitfield.test index 1e4692270b5..2e90ce39708 100644 --- a/mysql-test/t/archive_bitfield.test +++ b/mysql-test/t/archive_bitfield.test @@ -94,5 +94,11 @@ INSERT INTO `t1` VALUES (NULL,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,b'100000',b'010010',b'011111',4,5,5,5,5,5,5,5,5,5,3,2,1), (NULL,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,b'000000',b'001100',b'111111',4,5,5,5,5,5,5,5,5,5,3,2,1), (NULL,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,b'111111',b'000000',b'000000',4,5,5,5,5,5,5,5,5,5,3,2,1); +# Determine the number of open sessions +--source include/count_sessions.inc --exec $MYSQL_DUMP --hex-blob --compact --order-by-primary --skip-extended-insert --no-create-info test t1 drop table t1; +# Wait till the number of open sessions is <= the number before the run with $MYSQL_DUMP +# = The session caused by mysqldump has finished its disconnect +--source include/wait_until_count_sessions.inc + diff --git a/mysql-test/t/cast.test b/mysql-test/t/cast.test index 50865215944..8e60d548c2f 100644 --- a/mysql-test/t/cast.test +++ b/mysql-test/t/cast.test @@ -269,3 +269,18 @@ SELECT HOUR(NULL), DROP TABLE t1; --echo End of 5.0 tests + +--echo # +--echo # Bug #44766: valgrind error when using convert() in a subquery +--echo # + +CREATE TABLE t1(a tinyint); +INSERT INTO t1 VALUES (127); +SELECT 1 FROM +( + SELECT CONVERT(t2.a USING UTF8) FROM t1, t1 t2 LIMIT 1 +) AS s LIMIT 1; +DROP TABLE t1; + + +--echo End of 5.1 tests diff --git a/mysql-test/t/client_xml.test b/mysql-test/t/client_xml.test index 739b56f5ab1..0847e2b366b 100644 --- a/mysql-test/t/client_xml.test +++ b/mysql-test/t/client_xml.test @@ -18,6 +18,10 @@ create table t1 ( `a>b` text ); insert into t1 values (1, 2, 'a&b a<b a>b'); + +# Determine the number of open sessions +--source include/count_sessions.inc + --exec $MYSQL --xml test -e "select * from t1" --exec $MYSQL_DUMP --xml --skip-create test @@ -33,3 +37,8 @@ drop table t1; # Restore global concurrent_insert value set @@global.concurrent_insert= @old_concurrent_insert; + +# Wait till the number of open sessions is <= the number before the runs with +# $MYSQL and $MYSQL_DUMP +# = The session caused by mysql and mysqldump have finished their disconnect +--source include/wait_until_count_sessions.inc diff --git a/mysql-test/t/consistent_snapshot.test b/mysql-test/t/consistent_snapshot.test index 82edf2e22b2..fb1f3bc007c 100644 --- a/mysql-test/t/consistent_snapshot.test +++ b/mysql-test/t/consistent_snapshot.test @@ -12,9 +12,9 @@ connect (con1,localhost,root,,); --echo # Establish connection con2 (user=root) connect (con2,localhost,root,,); -### Test 1: -### - While a consistent snapshot transaction is executed, -### no external inserts should be visible to the transaction. +--echo ### Test 1: +--echo ### - While a consistent snapshot transaction is executed, +--echo ### no external inserts should be visible to the transaction. --echo # Switch to connection con1 connection con1; @@ -31,9 +31,9 @@ SELECT * FROM t1; # if consistent snapshot was set as expected, we # should see nothing. COMMIT; -### Test 2: -### - For any non-consistent snapshot transaction, external -### committed inserts should be visible to the transaction. +--echo ### Test 2: +--echo ### - For any non-consistent snapshot transaction, external +--echo ### committed inserts should be visible to the transaction. DELETE FROM t1; START TRANSACTION; # Now we omit WITH CONSISTENT SNAPSHOT @@ -48,6 +48,24 @@ SELECT * FROM t1; # if consistent snapshot was not set, as expected, we # should see 1. COMMIT; +--echo ### Test 3: +--echo ### - Bug#44664: valgrind warning for COMMIT_AND_CHAIN and ROLLBACK_AND_CHAIN +--echo ### Chaining a transaction does not retain consistency level. + +START TRANSACTION WITH CONSISTENT SNAPSHOT; +DELETE FROM t1; +COMMIT WORK AND CHAIN; + +--echo # Switch to connection con2 +connection con2; +INSERT INTO t1 VALUES(1); + +--echo # Switch to connection con1 +connection con1; +SELECT * FROM t1; # if consistent snapshot was not set, as expected, we +# should see 1. +COMMIT; + --echo # Switch to connection default + close connections con1 and con2 connection default; disconnect con1; diff --git a/mysql-test/t/csv.test b/mysql-test/t/csv.test index abc161d014c..cdf274190dd 100644 --- a/mysql-test/t/csv.test +++ b/mysql-test/t/csv.test @@ -1800,10 +1800,11 @@ connect (con1,localhost,root,,); # EE_FILENOTFOUND 29 --error 29 select * from t1; +--disconnect con1 +--source include/wait_until_disconnected.inc connection default; unlock tables; drop table t1; ---disconnect con1 # # Bug#41441 repair csv table crashes debug server diff --git a/mysql-test/t/ctype_cp932_binlog_stm.test b/mysql-test/t/ctype_cp932_binlog_stm.test index 383009ae7c3..9e9716e5ddb 100644 --- a/mysql-test/t/ctype_cp932_binlog_stm.test +++ b/mysql-test/t/ctype_cp932_binlog_stm.test @@ -34,4 +34,10 @@ delimiter ;| --error 1220 SHOW BINLOG EVENTS FROM 364; +--echo Bug#44352 UPPER/LOWER function doesn't work correctly on cp932 and sjis environment. +CREATE TABLE t1 (a varchar(16)) character set cp932; +INSERT INTO t1 VALUES (0x8372835E),(0x8352835E); +SELECT hex(a), hex(lower(a)), hex(upper(a)) FROM t1 ORDER BY binary(a); +DROP TABLE t1; + --echo End of 5.1 tests diff --git a/mysql-test/t/ctype_sjis.test b/mysql-test/t/ctype_sjis.test index 27cbdff451b..7de94e34dea 100644 --- a/mysql-test/t/ctype_sjis.test +++ b/mysql-test/t/ctype_sjis.test @@ -83,3 +83,13 @@ SET NAMES sjis; SELECT HEX('²“‘@Œ\') FROM DUAL; # End of 4.1 tests + +--echo # Start of 5.1 tests + +--echo Bug#44352 UPPER/LOWER function doesn't work correctly on cp932 and sjis environment. +CREATE TABLE t1 (a varchar(16)) character set sjis; +INSERT INTO t1 VALUES (0x8372835E),(0x8352835E); +SELECT hex(a), hex(lower(a)), hex(upper(a)) FROM t1 ORDER BY binary(a); +DROP TABLE t1; + +--echo # End of 5.1 tests diff --git a/mysql-test/t/ddl_i18n_koi8r.test b/mysql-test/t/ddl_i18n_koi8r.test index 2d94a899aad..fecef2f95d5 100644 --- a/mysql-test/t/ddl_i18n_koi8r.test +++ b/mysql-test/t/ddl_i18n_koi8r.test @@ -1128,15 +1128,22 @@ SHOW CREATE TABLE mysqltest2.t2| # # Cleanup. # +delimiter ;| ---connection default +--connection con2 --echo ---echo ---> connection: default - +--echo ---> connection: con2 --disconnect con2 +--source include/wait_until_disconnected.inc +--connection con3 +--echo +--echo ---> connection: con3 --disconnect con3 +--source include/wait_until_disconnected.inc +--connection default +--echo +--echo ---> connection: default +USE test; +DROP DATABASE mysqltest1; +DROP DATABASE mysqltest2; -use test| - -DROP DATABASE mysqltest1| -DROP DATABASE mysqltest2| diff --git a/mysql-test/t/ddl_i18n_utf8.test b/mysql-test/t/ddl_i18n_utf8.test index 1d5415d9373..8788d0604f2 100644 --- a/mysql-test/t/ddl_i18n_utf8.test +++ b/mysql-test/t/ddl_i18n_utf8.test @@ -1128,15 +1128,22 @@ SHOW CREATE TABLE mysqltest2.t2| # # Cleanup. # +delimiter ;| ---connection default +--connection con2 --echo ---echo ---> connection: default - +--echo ---> connection: con2 --disconnect con2 +--source include/wait_until_disconnected.inc +--connection con3 +--echo +--echo ---> connection: con3 --disconnect con3 +--source include/wait_until_disconnected.inc +--connection default +--echo +--echo ---> connection: default +USE test; +DROP DATABASE mysqltest1; +DROP DATABASE mysqltest2; -use test| - -DROP DATABASE mysqltest1| -DROP DATABASE mysqltest2| diff --git a/mysql-test/t/derived.test b/mysql-test/t/derived.test index 4e79fac584f..bf5cd4aa8d8 100644 --- a/mysql-test/t/derived.test +++ b/mysql-test/t/derived.test @@ -273,7 +273,9 @@ select t2.* from ((select * from t1) as A inner join t2 on A.ID = t2.FID); select t2.* from (select * from t1) as A inner join t2 on A.ID = t2.FID; drop table t1, t2; +connection con1; disconnect con1; +--source include/wait_until_disconnected.inc connection default; drop user mysqltest_1; diff --git a/mysql-test/t/disabled.def b/mysql-test/t/disabled.def index 760c29bbae6..af4eb44b464 100644 --- a/mysql-test/t/disabled.def +++ b/mysql-test/t/disabled.def @@ -10,8 +10,6 @@ # ############################################################################## kill : Bug#37780 2008-12-03 HHunger need some changes to be robust enough for pushbuild. -innodb_bug39438 : BUG#42383 2009-01-28 lsoares "This fails in embedded and on windows. Note that this test is not run on windows and on embedded in PB for main trees currently" +innodb_bug39438 : Bug#42383 2009-01-28 lsoares "This fails in embedded and on windows. Note that this test is not run on windows and on embedded in PB for main trees currently" query_cache_28249 : Bug#43861 2009-03-25 main.query_cache_28249 fails sporadically - -#concurrent_innodb_safelog: disabled for embedded server due to bug#43733 Select on processlist let the embedded server crash (concurrent_innodb_safelog). -#concurrent_innodb_unsafelog: disabled for embedded server due to bug#43733. +init_connect : Bug#44920 2009-05-18 pcrews MTR2 is not processing master.opt input properly on Windows diff --git a/mysql-test/t/drop.test b/mysql-test/t/drop.test index 91345886e93..bb4dd3e11f9 100644 --- a/mysql-test/t/drop.test +++ b/mysql-test/t/drop.test @@ -117,8 +117,11 @@ connection addconroot1; --reap connection addconroot2; --reap -disconnect addconroot1; disconnect addconroot2; +--source include/wait_until_disconnected.inc +connection addconroot1; +disconnect addconroot1; +--source include/wait_until_disconnected.inc connection default; --echo End of 5.0 tests diff --git a/mysql-test/t/events_grant.test b/mysql-test/t/events_grant.test index cff2475c5aa..8db4333cc03 100644 --- a/mysql-test/t/events_grant.test +++ b/mysql-test/t/events_grant.test @@ -97,7 +97,9 @@ DROP EVENT one_event; connection default; --echo "One event should not be there" SELECT EVENT_CATALOG, EVENT_SCHEMA, EVENT_NAME, DEFINER, EVENT_BODY, EVENT_DEFINITION, EVENT_TYPE, EXECUTE_AT, INTERVAL_VALUE, INTERVAL_FIELD, STATUS,ON_COMPLETION, EVENT_COMMENT FROM INFORMATION_SCHEMA.EVENTS ORDER BY EVENT_SCHEMA, EVENT_NAME; +connection ev_con1; disconnect ev_con1; +--source include/wait_until_disconnected.inc connection default; DROP USER ev_test@localhost; DROP DATABASE events_test2; @@ -106,9 +108,6 @@ DROP DATABASE events_test2; # End of tests # -let $wait_condition= - select count(*) = 0 from information_schema.processlist - where db='events_test' and command = 'Connect' and user=current_user(); ---source include/wait_condition.inc +--source include/check_events_off.inc DROP DATABASE events_test; diff --git a/mysql-test/t/events_stress.test b/mysql-test/t/events_stress.test index 22959898b43..e51fa734256 100644 --- a/mysql-test/t/events_stress.test +++ b/mysql-test/t/events_stress.test @@ -109,7 +109,7 @@ connection conn3; --send DROP DATABASE events_conn3_db; connection default; ---send +# --send DROP DATABASE events_conn1_test2; DROP DATABASE events_conn1_test3; SET GLOBAL event_scheduler=off; @@ -135,3 +135,7 @@ DROP USER event_user3@localhost; # DROP DATABASE events_test; + +# Cleanup +SET GLOBAL event_scheduler=off; +--source include/check_events_off.inc diff --git a/mysql-test/t/events_trans_notembedded.test b/mysql-test/t/events_trans_notembedded.test index 3c151dd18b1..0353d183386 100644 --- a/mysql-test/t/events_trans_notembedded.test +++ b/mysql-test/t/events_trans_notembedded.test @@ -50,6 +50,7 @@ delete from t1; commit work; # Cleanup disconnect conn1; +--source include/wait_until_disconnected.inc connection default; drop user mysqltest_user1@localhost; drop database mysqltest_db2; diff --git a/mysql-test/t/fix_priv_tables.test b/mysql-test/t/fix_priv_tables.test index c7cd500f8d2..eeda9bc8d15 100644 --- a/mysql-test/t/fix_priv_tables.test +++ b/mysql-test/t/fix_priv_tables.test @@ -51,8 +51,13 @@ echo; -- disable_query_log # Run the mysql_fix_privilege_tables.sql using "mysql --force" +# Determine the number of open sessions +--source include/count_sessions.inc --exec $MYSQL --force mysql < $MYSQL_FIX_PRIVILEGE_TABLES > $MYSQLTEST_VARDIR/tmp/fix_priv_tables.log 2>&1 --remove_file $MYSQLTEST_VARDIR/tmp/fix_priv_tables.log +# Wait till the number of open sessions is <= the number before the run with $MYSQL +# = The session caused by mysql has finished its disconnect +--source include/wait_until_count_sessions.inc -- enable_query_log -- enable_result_log diff --git a/mysql-test/t/flush.test b/mysql-test/t/flush.test index c832cb79158..f27d4cf2fad 100644 --- a/mysql-test/t/flush.test +++ b/mysql-test/t/flush.test @@ -171,6 +171,7 @@ set session low_priority_updates=default; connect (con1,localhost,root,,); send select benchmark(200, (select sin(1))) > 1000; disconnect con1; +--source include/wait_until_disconnected.inc connection default; --echo End of 5.0 tests diff --git a/mysql-test/t/func_compress.test b/mysql-test/t/func_compress.test index 0a3a3823fee..d63130f190d 100644 --- a/mysql-test/t/func_compress.test +++ b/mysql-test/t/func_compress.test @@ -50,6 +50,7 @@ set @@global.max_allowed_packet=1048576*100; --connect (newconn, localhost, root,,) eval select compress(repeat('aaaaaaaaaa', IF('$LOW_MEMORY', 10, 10000000))) is null; disconnect newconn; +--source include/wait_until_disconnected.inc connection default; set @@global.max_allowed_packet=default; @@ -88,4 +89,24 @@ select *, uncompress(a) from t1; select *, uncompress(a), uncompress(a) is null from t1; drop table t1; +# +# Bug #44796: valgrind: too many my_longlong10_to_str_8bit warnings after +# uncompressed_length +# + +CREATE TABLE t1 (c1 INT); +INSERT INTO t1 VALUES (1), (1111), (11111); + +# Disable warnings to avoid dependency on max_allowed_packet value +--disable_warnings +SELECT UNCOMPRESS(c1), UNCOMPRESSED_LENGTH(c1) FROM t1; +--enable_warnings + +# We do not need the results, just make sure there are no valgrind errors +--disable_result_log +EXPLAIN EXTENDED SELECT * FROM (SELECT UNCOMPRESSED_LENGTH(c1) FROM t1) AS s; +--enable_result_log + +DROP TABLE t1; + --echo End of 5.0 tests diff --git a/mysql-test/t/func_concat.test b/mysql-test/t/func_concat.test index f2aa0d004e5..1c7e5823fb2 100644 --- a/mysql-test/t/func_concat.test +++ b/mysql-test/t/func_concat.test @@ -78,3 +78,37 @@ SELECT * FROM t1 WHERE CONCAT(c1,' ',c2) REGEXP 'First.*'; DROP TABLE t1; --echo # End of 5.0 tests + + +--echo # +--echo # Bug #44743: Join in combination with concat does not always work +--echo # +CREATE TABLE t1 ( + a VARCHAR(100) NOT NULL DEFAULT '0', + b VARCHAR(2) NOT NULL DEFAULT '', + c VARCHAR(2) NOT NULL DEFAULT '', + d TEXT NOT NULL, + PRIMARY KEY (a, b, c), + KEY (a) +) DEFAULT CHARSET=utf8; + +INSERT INTO t1 VALUES ('gui_A', 'a', 'b', 'str1'), + ('gui_AB', 'a', 'b', 'str2'), ('gui_ABC', 'a', 'b', 'str3'); + +CREATE TABLE t2 ( + a VARCHAR(100) NOT NULL DEFAULT '', + PRIMARY KEY (a) +) DEFAULT CHARSET=latin1; + +INSERT INTO t2 VALUES ('A'), ('AB'), ('ABC'); + +SELECT CONCAT('gui_', t2.a), t1.d FROM t2 + LEFT JOIN t1 ON t1.a = CONCAT('gui_', t2.a) AND t1.b = 'a' AND t1.c = 'b'; + +EXPLAIN SELECT CONCAT('gui_', t2.a), t1.d FROM t2 + LEFT JOIN t1 ON t1.a = CONCAT('gui_', t2.a) AND t1.b = 'a' AND t1.c = 'b'; + +DROP TABLE t1, t2; + + +--echo # End of 5.1 tests diff --git a/mysql-test/t/func_in.test b/mysql-test/t/func_in.test index 3fc1697f146..adc074259ad 100644 --- a/mysql-test/t/func_in.test +++ b/mysql-test/t/func_in.test @@ -439,4 +439,21 @@ SELECT CASE c1 WHEN c1 + 1 THEN 1 END, ABS(AVG(c0)) FROM t1; DROP TABLE t1; +# +# Bug #44399: crash with statement using TEXT columns, aggregates, GROUP BY, +# and HAVING +# + +CREATE TABLE t1(a TEXT, b INT, c INT UNSIGNED, d DECIMAL(12,2), e REAL); +INSERT INTO t1 VALUES('iynfj', 1, 1, 1, 1); +INSERT INTO t1 VALUES('innfj', 2, 2, 2, 2); +SELECT SUM( DISTINCT a ) FROM t1 GROUP BY a HAVING a IN ( AVG( 1 ), 1 + a); +SELECT SUM( DISTINCT b ) FROM t1 GROUP BY b HAVING b IN ( AVG( 1 ), 1 + b); +SELECT SUM( DISTINCT c ) FROM t1 GROUP BY c HAVING c IN ( AVG( 1 ), 1 + c); +SELECT SUM( DISTINCT d ) FROM t1 GROUP BY d HAVING d IN ( AVG( 1 ), 1 + d); +SELECT SUM( DISTINCT e ) FROM t1 GROUP BY e HAVING e IN ( AVG( 1 ), 1 + e); +SELECT SUM( DISTINCT e ) FROM t1 GROUP BY b,c,d HAVING (b,c,d) IN + ((AVG( 1 ), 1 + c, 1 + d), (AVG( 1 ), 2 + c, 2 + d)); +DROP TABLE t1; + --echo End of 5.1 tests diff --git a/mysql-test/t/func_math.test b/mysql-test/t/func_math.test index e67f5f29e3a..f9369943d6c 100644 --- a/mysql-test/t/func_math.test +++ b/mysql-test/t/func_math.test @@ -282,4 +282,22 @@ SELECT 1e300 / 1e-300; SELECT EXP(750); SELECT POW(10, 309); +--echo # +--echo # Bug #44768: SIGFPE crash when selecting rand from a view +--echo # containing null +--echo # + +CREATE OR REPLACE VIEW v1 AS SELECT NULL AS a; +SELECT RAND(a) FROM v1; +DROP VIEW v1; + +SELECT RAND(a) FROM (SELECT NULL AS a) b; + +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (NULL); +SELECT RAND(i) FROM t1; +DROP TABLE t1; + +--echo # + --echo End of 5.1 tests diff --git a/mysql-test/t/func_str.test b/mysql-test/t/func_str.test index ef406d2aeca..7cb7f7f72d2 100644 --- a/mysql-test/t/func_str.test +++ b/mysql-test/t/func_str.test @@ -1282,6 +1282,16 @@ INSERT INTO t1 VALUES ('2008-12-31','aaaaaa'); SELECT DATE_FORMAT(c, GET_FORMAT(DATE, 'eur')) h, CONCAT(UPPER(aa),', ', aa) i FROM t1; DROP TABLE t1; + +--echo # +--echo # BUG#44774: load_file function produces valgrind warnings +--echo # +CREATE TABLE t1 (a TINYBLOB); +INSERT INTO t1 VALUES ('aaaaaaaa'); +SELECT LOAD_FILE(a) FROM t1; +DROP TABLE t1; + + --echo End of 5.0 tests # diff --git a/mysql-test/t/heap_btree.test b/mysql-test/t/heap_btree.test index b51eeb27331..637c6ba1c81 100644 --- a/mysql-test/t/heap_btree.test +++ b/mysql-test/t/heap_btree.test @@ -253,5 +253,13 @@ insert into t1 values (1, 1), (3, 3), (2, 2), (NULL, 1), (NULL, NULL), (0, 0); select * from t1 where a is null; drop table t1; +-- echo # +-- echo # bug#39918 - memory (heap) engine crashing while executing self join with delete +-- echo # + +CREATE TABLE t1(a INT, KEY USING BTREE (a)) ENGINE=MEMORY; +INSERT INTO t1 VALUES(1),(1); +DELETE a1 FROM t1 AS a1, t1 AS a2 WHERE a1.a=a2.a; +DROP TABLE t1; --echo End of 5.0 tests diff --git a/mysql-test/t/information_schema_db.test b/mysql-test/t/information_schema_db.test index 6353e94fd51..0ff1d05f364 100644 --- a/mysql-test/t/information_schema_db.test +++ b/mysql-test/t/information_schema_db.test @@ -53,7 +53,7 @@ order by table_name; end| delimiter ;| -create table t1 +create table t1 (f1 int(10) unsigned not null, f2 varchar(100) not null, primary key (f1), unique key (f2)); @@ -105,8 +105,8 @@ drop function f2; drop view v1, v2; # -# Bug#20543: select on information_schema strange warnings, view, different -# schemas/users +# Bug#20543 select on information_schema strange warnings, view, different +# schemas/users # # create database testdb_1; @@ -125,7 +125,7 @@ grant insert on v1 to testdb_2@localhost; create view v5 as select f1 from t1; grant show view on v5 to testdb_2@localhost; ---error 1227 +--error ER_SPECIFIC_ACCESS_DENIED_ERROR create definer=`no_such_user`@`no_such_host` view v6 as select f1 from t1; connection default; @@ -169,46 +169,53 @@ use testdb_1; revoke show view on v6 from testdb_2@localhost; connection testdb_2; ---error 1142 +--error ER_TABLEACCESS_DENIED_ERROR show fields from testdb_1.v5; ---error 1142 +--error ER_TABLEACCESS_DENIED_ERROR show create view testdb_1.v5; ---error 1142 +--error ER_TABLEACCESS_DENIED_ERROR show fields from testdb_1.v6; ---error 1142 +--error ER_TABLEACCESS_DENIED_ERROR show create view testdb_1.v6; ---error 1142 +--error ER_TABLEACCESS_DENIED_ERROR show fields from testdb_1.v7; ---error 1142 +--error ER_TABLEACCESS_DENIED_ERROR show create view testdb_1.v7; ---error 1345 +--error ER_VIEW_NO_EXPLAIN show create view v4; -#--error 1345 +#--error ER_VIEW_NO_EXPLAIN show fields from v4; show fields from v2; show fields from testdb_1.v1; show create view v2; ---error 1142 +--error ER_TABLEACCESS_DENIED_ERROR show create view testdb_1.v1; -select table_name from information_schema.columns a +select table_name from information_schema.columns a where a.table_name = 'v2'; -select view_definition from information_schema.views a +select view_definition from information_schema.views a where a.table_name = 'v2'; -select view_definition from information_schema.views a +select view_definition from information_schema.views a where a.table_name = 'testdb_1.v1'; ---error 1356 +--error ER_VIEW_INVALID select * from v2; connection default; use test; drop view testdb_1.v1, v2, testdb_1.v3, v4; drop database testdb_1; +connection testdb_1; +disconnect testdb_1; +--source include/wait_until_disconnected.inc +connection testdb_2; +disconnect testdb_2; +--source include/wait_until_disconnected.inc +connection default; drop user testdb_1@localhost; drop user testdb_2@localhost; @@ -239,4 +246,7 @@ show create view testdb_1.v1; connection default; drop user mysqltest_1@localhost; drop database testdb_1; +connection user1; disconnect user1; +--source include/wait_until_disconnected.inc +connection default; diff --git a/mysql-test/t/init_file.test b/mysql-test/t/init_file.test index ceb5cae9743..7eb5381651d 100644 --- a/mysql-test/t/init_file.test +++ b/mysql-test/t/init_file.test @@ -14,7 +14,7 @@ SELECT * INTO @X FROM init_file.startup limit 0,1; SELECT * INTO @Y FROM init_file.startup limit 1,1; SELECT YEAR(@X)-YEAR(@Y); # Enable this DROP DATABASE only after resolving bug #42507 -# DROP DATABASE init_file; +DROP DATABASE init_file; --echo ok --echo end of 4.1 tests @@ -28,4 +28,9 @@ select * from t1; # 30, 3, 11, 13 select * from t2; # Enable this DROP TABLE only after resolving bug #42507 -#drop table t1, t2; +drop table t1, t2; + +# MTR will restart server anyway, but by forcing it we avoid being warned +# about the apparent side effect + +call mtr.force_restart(); diff --git a/mysql-test/t/innodb_bug42101-nonzero-master.opt b/mysql-test/t/innodb_bug42101-nonzero-master.opt new file mode 100644 index 00000000000..d71dbe17d5b --- /dev/null +++ b/mysql-test/t/innodb_bug42101-nonzero-master.opt @@ -0,0 +1 @@ +--innodb_commit_concurrency=1 diff --git a/mysql-test/t/innodb_bug42101-nonzero.test b/mysql-test/t/innodb_bug42101-nonzero.test new file mode 100644 index 00000000000..c691a234c51 --- /dev/null +++ b/mysql-test/t/innodb_bug42101-nonzero.test @@ -0,0 +1,19 @@ +# +# Bug#42101 Race condition in innodb_commit_concurrency +# http://bugs.mysql.com/42101 +# + +-- source include/have_innodb.inc + +--error ER_WRONG_ARGUMENTS +set global innodb_commit_concurrency=0; +select @@innodb_commit_concurrency; +set global innodb_commit_concurrency=1; +select @@innodb_commit_concurrency; +set global innodb_commit_concurrency=42; +select @@innodb_commit_concurrency; +--error ER_WRONG_ARGUMENTS +set global innodb_commit_concurrency=0; +select @@innodb_commit_concurrency; +set global innodb_commit_concurrency=1; +select @@innodb_commit_concurrency; diff --git a/mysql-test/t/innodb_bug42101.test b/mysql-test/t/innodb_bug42101.test new file mode 100644 index 00000000000..13d531ecde7 --- /dev/null +++ b/mysql-test/t/innodb_bug42101.test @@ -0,0 +1,17 @@ +# +# Bug#42101 Race condition in innodb_commit_concurrency +# http://bugs.mysql.com/42101 +# + +-- source include/have_innodb.inc + +set global innodb_commit_concurrency=0; +select @@innodb_commit_concurrency; +--error ER_WRONG_ARGUMENTS +set global innodb_commit_concurrency=1; +select @@innodb_commit_concurrency; +--error ER_WRONG_ARGUMENTS +set global innodb_commit_concurrency=42; +select @@innodb_commit_concurrency; +set global innodb_commit_concurrency=0; +select @@innodb_commit_concurrency; diff --git a/mysql-test/t/innodb_mysql.test b/mysql-test/t/innodb_mysql.test index ad9e726f5b4..1b2b861dffb 100644 --- a/mysql-test/t/innodb_mysql.test +++ b/mysql-test/t/innodb_mysql.test @@ -332,4 +332,31 @@ DROP TABLE t1; DROP TABLE t2; DROP TABLE t3; +# +# Bug#43580: Issue with Innodb on multi-table update +# +CREATE TABLE t1 (a INT, b INT, KEY (a)) ENGINE = INNODB; +CREATE TABLE t2 (a INT KEY, b INT, KEY (b)) ENGINE = INNODB; + +CREATE TABLE t3 (a INT, b INT KEY, KEY (a)) ENGINE = INNODB; +CREATE TABLE t4 (a INT KEY, b INT, KEY (b)) ENGINE = INNODB; + +INSERT INTO t1 VALUES (1, 1), (2, 2), (3, 3), (4, 4), (5, 5), (6, 6); +INSERT INTO t2 VALUES (1, 1), (2, 2), (3, 3), (4, 4), (5, 5); + +INSERT INTO t3 VALUES (1, 101), (2, 102), (3, 103), (4, 104), (5, 105), (6, 106); +INSERT INTO t4 VALUES (1, 1), (2, 2), (3, 3), (4, 4), (5, 5); + +UPDATE t1, t2 SET t1.a = t1.a + 100, t2.b = t1.a + 10 +WHERE t1.a BETWEEN 2 AND 4 AND t2.a = t1.b; +--sorted_result +SELECT * FROM t2; + +UPDATE t3, t4 SET t3.a = t3.a + 100, t4.b = t3.a + 10 +WHERE t3.a BETWEEN 2 AND 4 AND t4.a = t3.b - 100; +--sorted_result +SELECT * FROM t4; + +DROP TABLE t1, t2, t3, t4; + --echo End of 5.1 tests diff --git a/mysql-test/t/insert_select.test b/mysql-test/t/insert_select.test index 499db086877..f8023fcfc60 100644 --- a/mysql-test/t/insert_select.test +++ b/mysql-test/t/insert_select.test @@ -324,6 +324,16 @@ SELECT * FROM t2; DROP TABLE t1, t2; # +# Bug#44306: Assertion fail on duplicate key error in 'INSERT ... SELECT' +# statements +# +CREATE TABLE t1 ( a INT KEY, b INT ); +INSERT INTO t1 VALUES ( 0, 1 ); +--error ER_DUP_ENTRY +INSERT INTO t1 ( b ) SELECT MAX( b ) FROM t1 WHERE b = 2; +DROP TABLE t1; + +# # Bug #26207: inserts don't work with shortened index # SET SQL_MODE='STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'; diff --git a/mysql-test/t/lowercase_fs_off.test b/mysql-test/t/lowercase_fs_off.test index 414027cb485..878564c32ab 100644 --- a/mysql-test/t/lowercase_fs_off.test +++ b/mysql-test/t/lowercase_fs_off.test @@ -14,16 +14,18 @@ flush privileges; connect (sample,localhost,sample,password,d1); connection sample; select database(); ---error 1044 +--error ER_DBACCESS_DENIED_ERROR create database d2; ---error 1044 +--error ER_DBACCESS_DENIED_ERROR create database D1; disconnect sample; +--source include/wait_until_disconnected.inc connection master; drop user 'sample'@'localhost'; drop database if exists d1; disconnect master; +--source include/wait_until_disconnected.inc connection default; # End of 4.1 tests diff --git a/mysql-test/t/mysql.test b/mysql-test/t/mysql.test index 7e970d5b104..ba5cc243c01 100644 --- a/mysql-test/t/mysql.test +++ b/mysql-test/t/mysql.test @@ -342,6 +342,13 @@ EOF remove_file $MYSQLTEST_VARDIR/tmp/bug31060.sql; +# +# Bug #39101: client -i (--ignore-spaces) option does not seem to work +# +--exec $MYSQL -i -e "SELECT COUNT (*)" +--exec $MYSQL --ignore-spaces -e "SELECT COUNT (*)" +--exec $MYSQL -b -i -e "SELECT COUNT (*)" + --echo End of 5.0 tests # @@ -367,4 +374,10 @@ remove_file $MYSQLTEST_VARDIR/tmp/bug31060.sql; drop tables t1, t2; +# +# Bug #27884: mysql --html does not quote HTML special characters in output +# +--exec $MYSQL --html test -e "select '< & >' as '<'" + +--echo --echo End of tests diff --git a/mysql-test/t/mysqlbinlog.test b/mysql-test/t/mysqlbinlog.test index 46060649784..7767abe43d0 100644 --- a/mysql-test/t/mysqlbinlog.test +++ b/mysql-test/t/mysqlbinlog.test @@ -367,4 +367,16 @@ echo *** Unsigned server_id $s_id_max is found: $s_id_unsigned ***; eval SET @@global.server_id= $save_server_id; --remove_file $binlog_file +# +# Bug #41943: mysqlbinlog.exe crashes if --hexdump option is used +# + +RESET MASTER; +FLUSH LOGS; + +# We do not need the results, just make sure that mysqlbinlog does not crash +--exec $MYSQL_BINLOG --hexdump --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001 >/dev/null + +--echo End of 5.0 tests + --echo End of 5.1 tests diff --git a/mysql-test/t/mysqldump.test b/mysql-test/t/mysqldump.test index fe89d7bdafa..4edf887a6b7 100644 --- a/mysql-test/t/mysqldump.test +++ b/mysql-test/t/mysqldump.test @@ -1,6 +1,5 @@ # Embedded server doesn't support external clients --source include/not_embedded.inc ---source include/have_log_bin.inc # Binlog is required --source include/have_log_bin.inc diff --git a/mysql-test/t/mysqldump_restore.test b/mysql-test/t/mysqldump_restore.test new file mode 100644 index 00000000000..835ee3ee9e9 --- /dev/null +++ b/mysql-test/t/mysqldump_restore.test @@ -0,0 +1,111 @@ +############################################################################### +# mysqldump_restore.test +# +# Purpose: Tests if mysqldump output can be used to successfully restore +# tables and data. +# We CREATE a table, mysqldump it to a file, ALTER the original +# table's name, recreate the table from the mysqldump file, then +# utilize include/diff_tables to compare the original and recreated +# tables. +# +# We use several examples from mysqldump.test here and include +# the relevant bug numbers and headers from that test. +# +# NOTE: This test is not currently complete and offers only basic +# cases of mysqldump output being restored. +# Also, does NOT work with -X (xml) output! +# +# Author: pcrews +# Created: 2009-05-21 +# Last Change: +# Change date: +############################################################################### + +# Embedded server doesn't support external clients +--source include/not_embedded.inc +--source include/have_log_bin.inc + +--echo # Set concurrent_insert = 0 to prevent random errors +--echo # will reset to original value at the end of the test +SET @old_concurrent_insert = @@global.concurrent_insert; +SET @@global.concurrent_insert = 0; + +# Define mysqldumpfile here. It is used to capture mysqldump output +# in order to test the output's ability to restore an exact copy of the table +let $mysqldumpfile = $MYSQLTEST_VARDIR/tmp/mysqldumpfile.sql; + +--echo # Pre-test cleanup +--disable_warnings +DROP TABLE IF EXISTS t1; +--enable_warnings + +--echo # Begin tests +--echo # +--echo # Bug#2005 Long decimal comparison bug. +--echo # +CREATE TABLE t1 (a DECIMAL(64, 20)); +INSERT INTO t1 VALUES ("1234567890123456789012345678901234567890"), +("0987654321098765432109876543210987654321"); +--exec $MYSQL_DUMP --compact test t1 > $mysqldumpfile +let $table_name = test.t1; +--source include/mysqldump.inc + +--echo # +--echo # Bug#3361 mysqldump quotes DECIMAL values inconsistently +--echo # +CREATE TABLE t1 (a DECIMAL(10,5), b FLOAT); +# Check at first how mysql work with quoted decimal +INSERT INTO t1 VALUES (1.2345, 2.3456); +INSERT INTO t1 VALUES ('1.2345', 2.3456); +INSERT INTO t1 VALUES ("1.2345", 2.3456); +SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='ANSI_QUOTES'; +INSERT INTO t1 VALUES (1.2345, 2.3456); +INSERT INTO t1 VALUES ('1.2345', 2.3456); +--error ER_BAD_FIELD_ERROR +INSERT INTO t1 VALUES ("1.2345", 2.3456); +SET SQL_MODE=@OLD_SQL_MODE; + +# check how mysqldump make quoting +--exec $MYSQL_DUMP --compact test t1 > $mysqldumpfile +let $table_name = test.t1; +--source include/mysqldump.inc + +--echo # +--echo # Bug#1994 mysqldump does not correctly dump UCS2 data +--echo # Bug#4261 mysqldump 10.7 (mysql 4.1.2) --skip-extended-insert drops NULL from inserts +--echo # +CREATE TABLE t1 (a VARCHAR(255)) DEFAULT CHARSET koi8r; +INSERT INTO t1 VALUES (_koi8r x'C1C2C3C4C5'), (NULL); +--exec $MYSQL_DUMP --skip-comments --skip-extended-insert test t1 > $mysqldumpfile +let $table_name = test.t1; +--source include/mysqldump.inc + +--echo # +--echo # WL#2319 Exclude Tables from dump +--echo # +CREATE TABLE t1 (a INT); +CREATE TABLE t2 (a INT); +INSERT INTO t1 VALUES (1),(2),(3); +INSERT INTO t2 VALUES (4),(5),(6); +--exec $MYSQL_DUMP --skip-comments --ignore-table=test.t1 test > $mysqldumpfile +let $table_name = test.t2; +--source include/mysqldump.inc +DROP TABLE t1; + +--echo # +--echo # Bug#8830 mysqldump --skip-extended-insert causes --hex-blob to dump wrong values +--echo # +CREATE TABLE t1 (`b` blob); +INSERT INTO `t1` VALUES (0x602010000280100005E71A); +--exec $MYSQL_DUMP --skip-extended-insert --hex-blob test --skip-comments t1 > $mysqldumpfile +let $table_name = test.t1; +--source include/mysqldump.inc + +--echo # End tests + +--echo # Cleanup +--echo # Reset concurrent_insert to its original value +SET @@global.concurrent_insert = @old_concurrent_insert; +--echo # remove mysqldumpfile +--error 0,1 +--remove_file $mysqldumpfile diff --git a/mysql-test/t/openssl_1.test b/mysql-test/t/openssl_1.test index 240a977fdca..baa1603faab 100644 --- a/mysql-test/t/openssl_1.test +++ b/mysql-test/t/openssl_1.test @@ -238,7 +238,18 @@ DROP TABLE t1; --enable_query_log select 'is still running; no cipher request crashed the server' as result from dual; -## +# +# Bug#42158: leak: SSL_get_peer_certificate() doesn't have matching X509_free() +# + +GRANT SELECT ON test.* TO bug42158@localhost REQUIRE X509; +FLUSH PRIVILEGES; +connect(con1,localhost,bug42158,,,,,SSL); +SHOW STATUS LIKE 'Ssl_cipher'; +disconnect con1; +connection default; +DROP USER bug42158@localhost; + --echo End of 5.1 tests # Wait till we reached the initial number of concurrent sessions diff --git a/mysql-test/t/subselect3.test b/mysql-test/t/subselect3.test index bf461f83a20..7a2a9f328ef 100644 --- a/mysql-test/t/subselect3.test +++ b/mysql-test/t/subselect3.test @@ -669,6 +669,25 @@ SELECT ROW(1,2) = (SELECT NULL, 1), ROW(1,2) IN (SELECT NULL, 1); SELECT ROW(1,2) = (SELECT 1, 1), ROW(1,2) IN (SELECT 1, 1); SELECT ROW(1,2) = (SELECT 1, 2), ROW(1,2) IN (SELECT 1, 2); +# +# Bug #37362 Crash in do_field_eq +# +CREATE TABLE t1 (a INT, b INT, c INT); +INSERT INTO t1 VALUES (1,1,1), (1,1,1); + +--error 1054 +EXPLAIN EXTENDED + SELECT c FROM + ( SELECT + (SELECT COUNT(a) FROM + (SELECT COUNT(b) FROM t1) AS x GROUP BY c + ) FROM t1 GROUP BY b + ) AS y; +SHOW WARNINGS; + +DROP TABLE t1; + + --echo End of 5.0 tests # diff --git a/mysql-test/t/type_time.test b/mysql-test/t/type_time.test index 5fc763be7fe..5bb521601e5 100644 --- a/mysql-test/t/type_time.test +++ b/mysql-test/t/type_time.test @@ -77,3 +77,16 @@ insert into t1 values('2007-07-02', 1); insert into t1 values('2007-07-02', 2); SELECT sum(f3) FROM t1 where f2='2007-07-01 00:00:00' group by f2; drop table t1; + + +--echo # +--echo # Bug #44792: valgrind warning when casting from time to time +--echo # + +CREATE TABLE t1 (c TIME); +INSERT INTO t1 VALUES ('0:00:00'); +SELECT CAST(c AS TIME) FROM t1; +DROP TABLE t1; + + +--echo End of 5.0 tests diff --git a/mysql-test/t/union.test b/mysql-test/t/union.test index ece7099f66e..ec169838d59 100644 --- a/mysql-test/t/union.test +++ b/mysql-test/t/union.test @@ -1089,4 +1089,16 @@ CREATE TABLE t2 AS SELECT d FROM t1 UNION SELECT d FROM t1; SHOW FIELDS FROM t2; DROP TABLE t1, t2; +# +# Bug#43612 crash with explain extended, union, order by +# +CREATE TABLE t1(a INT); +EXPLAIN EXTENDED +SELECT a FROM t1 +UNION +SELECT a FROM t1 +ORDER BY a; +DROP TABLE t1; + + --echo End of 5.0 tests diff --git a/mysql-test/t/user_var.test b/mysql-test/t/user_var.test index fd4e538ea6c..c0740458a88 100644 --- a/mysql-test/t/user_var.test +++ b/mysql-test/t/user_var.test @@ -286,6 +286,18 @@ select @lastid != id, @lastid, @lastid := id from t1; drop table t1; # +# Bug#42009: SELECT into variable gives different results to direct SELECT +# +CREATE TABLE t1(a INT, b INT); +INSERT INTO t1 VALUES (0, 0), (2, 1), (2, 3), (1, 1), (30, 20); +SELECT a, b INTO @a, @b FROM t1 WHERE a=2 AND b=3 GROUP BY a, b; +SELECT @a, @b; +SELECT a, b FROM t1 WHERE a=2 AND b=3 GROUP BY a, b; +DROP TABLE t1; + +--echo End of 5.0 tests + +# # Bug#42188: crash and/or memory corruption with user variables in trigger # diff --git a/mysql-test/t/variables.test b/mysql-test/t/variables.test index 6da20409639..c568b79185d 100644 --- a/mysql-test/t/variables.test +++ b/mysql-test/t/variables.test @@ -1201,4 +1201,20 @@ SET GLOBAL server_id = -1; SELECT @@GLOBAL.server_id; SET GLOBAL server_id = @old_server_id; +# +# Bug #42778: delete order by null global variable causes +# assertion .\filesort.cc, line 797 +# + +SELECT @@GLOBAL.INIT_FILE, @@GLOBAL.INIT_FILE IS NULL; + +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (); +SET @bug42778= @@sql_safe_updates; +SET @@sql_safe_updates= 0; +DELETE FROM t1 ORDER BY (@@GLOBAL.INIT_FILE) ASC LIMIT 10; +SET @@sql_safe_updates= @bug42778; + +DROP TABLE t1; + --echo End of 5.1 tests diff --git a/mysql-test/t/view.test b/mysql-test/t/view.test index c9d01266e9e..a788b5ab41e 100644 --- a/mysql-test/t/view.test +++ b/mysql-test/t/view.test @@ -3681,6 +3681,29 @@ DROP VIEW v1; DROP TABLE t1; --echo # ----------------------------------------------------------------- +--echo # -- Bug#40825: Error 1356 while selecting from a view +--echo # -- with a "HAVING" clause though query works +--echo # ----------------------------------------------------------------- +--echo + +CREATE TABLE t1 (c INT); + +--echo + +CREATE VIEW v1 (view_column) AS SELECT c AS alias FROM t1 HAVING alias; +SHOW CREATE VIEW v1; +SELECT * FROM v1; + +--echo + +DROP VIEW v1; +DROP TABLE t1; + +--echo +--echo # -- End of test case for Bug#40825 +--echo + +--echo # ----------------------------------------------------------------- --echo # -- End of 5.0 tests. --echo # ----------------------------------------------------------------- @@ -3836,6 +3859,17 @@ drop procedure p; ########################################################################### + +--echo # +--echo # Bug #44860: ALTER TABLE on view crashes server +--echo # +CREATE TABLE t1 (a INT); +CREATE VIEW v1 AS SELECT a FROM t1; +ALTER TABLE v1; +DROP VIEW v1; +DROP TABLE t1; + + --echo # ----------------------------------------------------------------- --echo # -- End of 5.1 tests. --echo # ----------------------------------------------------------------- diff --git a/mysys/mf_format.c b/mysys/mf_format.c index f199132626b..6afa2938fa3 100644 --- a/mysys/mf_format.c +++ b/mysys/mf_format.c @@ -79,7 +79,7 @@ char * fn_format(char * to, const char *name, const char *dir, /* To long path, return original or NULL */ size_t tmp_length; if (flag & MY_SAFE_PATH) - return NullS; + DBUG_RETURN(NullS); tmp_length= strlength(startpos); DBUG_PRINT("error",("dev: '%s' ext: '%s' length: %u",dev,ext, (uint) length)); diff --git a/mysys/mf_getdate.c b/mysys/mf_getdate.c index 3a8e1be6a0b..9475bebd107 100644 --- a/mysys/mf_getdate.c +++ b/mysys/mf_getdate.c @@ -45,15 +45,15 @@ void get_date(register char * to, int flag, time_t date) skr=date ? (time_t) date : my_time(0); #if defined(HAVE_LOCALTIME_R) && defined(_REENTRANT) if (flag & GETDATE_GMT) - localtime_r(&skr,&tm_tmp); - else gmtime_r(&skr,&tm_tmp); + else + localtime_r(&skr,&tm_tmp); start_time= &tm_tmp; #else if (flag & GETDATE_GMT) - start_time= localtime(&skr); - else start_time= gmtime(&skr); + else + start_time= localtime(&skr); #endif if (flag & GETDATE_SHORT_DATE) sprintf(to,"%02d%02d%02d", diff --git a/mysys/my_getopt.c b/mysys/my_getopt.c index 4b74cdbf266..33942d87e4f 100644 --- a/mysys/my_getopt.c +++ b/mysys/my_getopt.c @@ -410,7 +410,8 @@ invalid value '%s'", argument= optend; } else if (optp->arg_type == OPT_ARG && - (optp->var_type & GET_TYPE_MASK) == GET_BOOL) + (((optp->var_type & GET_TYPE_MASK) == GET_BOOL) || + (optp->var_type & GET_TYPE_MASK) == GET_ENUM)) { if (optend == disabled_my_option) *((my_bool*) value)= (my_bool) 0; diff --git a/scripts/mysql_convert_table_format.sh b/scripts/mysql_convert_table_format.sh index d15c7b28410..6f586d0e8e0 100644 --- a/scripts/mysql_convert_table_format.sh +++ b/scripts/mysql_convert_table_format.sh @@ -23,18 +23,30 @@ $opt_help=$opt_version=$opt_verbose=$opt_force=0; $opt_user=$opt_database=$opt_password=undef; $opt_host="localhost"; $opt_socket=""; -$opt_type="MYISAM"; +$opt_engine="MYISAM"; $opt_port=0; $exit_status=0; -GetOptions("force","help","host=s","password=s","user=s","type=s","verbose","version","socket=s", "port=i") || - usage(0); +GetOptions( + "e|engine|type=s" => \$opt_type, + "f|force" => \$opt_force, + "help|?" => \$opt_help, + "h|host=s" => \$opt_host, + "p|password=s" => \$opt_password, + "u|user=s" => \$opt_user, + "v|verbose" => \$opt_verbose, + "V|version" => \$opt_version, + "S|socket=s" => \$opt_socket, + "P|port=i" => \$opt_port +) || usage(0); + usage($opt_version) if ($#ARGV < 0 || $opt_help || $opt_version); + $opt_database=shift(@ARGV); -if (uc($opt_type) eq "HEAP") +if (grep { /^$opt_engine$/i } qw(HEAP MEMORY BLACKHOLE)) { - print "Converting to type HEAP would delete your tables; aborting\n"; + print "Converting to '$opt_engine' would delete your data; aborting\n"; exit(1); } @@ -54,21 +66,29 @@ $dbh = DBI->connect("DBI:mysql:$opt_database:${opt_host}$connect_opt", { PrintError => 0}) || die "Can't connect to database $opt_database: $DBI::errstr\n"; -if ($#ARGV < 0) +my @tables; + +push(@ARGV, "%") if(!@ARGV); + +foreach $pattern (@ARGV) { - # Fetch all table names from the database my ($sth,$row); - $sth=$dbh->prepare("show tables"); - $sth->execute || die "Can't get tables from $opt_database; $DBI::errstr\n"; + $sth=$dbh->prepare("SHOW TABLES LIKE ?"); + $rv= $sth->execute($pattern); + if(!int($rv)) + { + warn "Can't get tables matching '$pattern' from $opt_database; $DBI::errstr\n"; + exit(1) unless $opt_force; + } while (($row = $sth->fetchrow_arrayref)) { - push(@ARGV,$row->[0]); + push(@tables, $row->[0]); } $sth->finish; } print "Converting tables:\n" if ($opt_verbose); -foreach $table (@ARGV) +foreach $table (@tables) { my ($sth,$row); @@ -76,14 +96,15 @@ foreach $table (@ARGV) $sth=$dbh->prepare("show table status like '$table'"); if ($sth->execute && ($row = $sth->fetchrow_arrayref)) { - if (uc($row->[1]) eq uc($opt_type)) + if (uc($row->[1]) eq uc($opt_engine)) { - print "$table is already of type $opt_type; Ignored\n"; + print "$table already uses the '$opt_engine' engine; Ignored\n"; next; } } print "converting $table\n" if ($opt_verbose); - if (!$dbh->do("ALTER TABLE $table ENGINE=$opt_type")) + $table=~ s/`/``/g; + if (!$dbh->do("ALTER TABLE `$table` ENGINE=$opt_engine")) { print STDERR "Can't convert $table: Error $DBI::errstr\n"; exit(1) if (!$opt_force); @@ -103,43 +124,43 @@ sub usage print <<EOF; -Conversion of a MySQL tables to other table types. +Conversion of a MySQL tables to other storage engines - Usage: $0 database [tables] + Usage: $0 database [table[ table ...]] If no tables has been specifed, all tables in the database will be converted. + You can also use wildcards, ie "my%" The following options are available: ---force +-f, --force Continue even if there is some error. ---help or --Information +-?, --help Shows this help ---host='host name' (Default $opt_host) - Host name where the database server is located. +-e, --engine=ENGINE + Converts tables to the given storage engine (Default: $opt_engine) ---password='password' +-h, --host=HOST + Host name where the database server is located. (Default: $opt_host) + +-p, --password=PASSWORD Password for the current user. ---port=port +-P, --port=PORT TCP/IP port to connect to if host is not "localhost". ---socket='/path/to/socket' +-S, --socket=SOCKET Socket to connect with. ---ENGINE='table-type' - Converts tables to the given table type (Default: $opt_type) - MySQL 3.23 supports at least the BDB, ISAM and MYISAM types. - ---user='user_name' +-u, --user=USER User name to log into the SQL server. ---verbose +-v, --verbose This is a test specific option that is only used when debugging a test. Print more information about what is going on. ---version +-V, --version Shows the version of this program. EOF exit(1); diff --git a/scripts/mysql_zap.sh b/scripts/mysql_zap.sh index 6c05afb772c..3bb92aaec2e 100644 --- a/scripts/mysql_zap.sh +++ b/scripts/mysql_zap.sh @@ -27,8 +27,8 @@ $opt_f= 0; $opt_t= 0; $opt_a = ""; -$BSD = -f '/vmunix' || $ENV{"OS"} eq "SunOS4" || $^O eq 'darwin'; -$LINUX = $^O eq 'linux'; +$BSD = -f '/vmunix' || $ENV{"OS"} eq "SunOS4"; +$LINUX = $^O eq 'linux' || $^O eq 'darwin'; $pscmd = $BSD ? "/bin/ps -auxww" : $LINUX ? "/bin/ps axuw" : "/bin/ps -ef"; open(TTYIN, "</dev/tty") || die "can't read /dev/tty: $!"; diff --git a/scripts/mysqld_multi.sh b/scripts/mysqld_multi.sh index 3cb4665eb1c..f35be69c151 100644 --- a/scripts/mysqld_multi.sh +++ b/scripts/mysqld_multi.sh @@ -316,11 +316,11 @@ sub start_mysqlds() $tmp.= " $options[$j]"; } } - if ($opt_verbose && $com =~ m/\/safe_mysqld$/ && !$info_sent) + if ($opt_verbose && $com =~ m/\/(safe_mysqld|mysqld_safe)$/ && !$info_sent) { - print "WARNING: safe_mysqld is being used to start mysqld. In this case you "; + print "WARNING: $1 is being used to start mysqld. In this case you "; print "may need to pass\n\"ledir=...\" under groups [mysqldN] to "; - print "safe_mysqld in order to find the actual mysqld binary.\n"; + print "$1 in order to find the actual mysqld binary.\n"; print "ledir (library executable directory) should be the path to the "; print "wanted mysqld binary.\n\n"; $info_sent= 1; @@ -670,9 +670,9 @@ language = @datadir@/mysql/english user = unix_user1 [mysqld3] -mysqld = /path/to/safe_mysqld/safe_mysqld +mysqld = /path/to/mysqld_safe ledir = /path/to/mysqld-binary/ -mysqladmin = /path/to/mysqladmin/mysqladmin +mysqladmin = /path/to/mysqladmin socket = /tmp/mysql.sock3 port = 3308 pid-file = @localstatedir@3/hostname.pid3 diff --git a/scripts/mysqld_safe.sh b/scripts/mysqld_safe.sh index 960c3e39bab..23b5efcaf2b 100644 --- a/scripts/mysqld_safe.sh +++ b/scripts/mysqld_safe.sh @@ -67,7 +67,7 @@ my_which () ret=0 for file do - for dir in "$PATH" + for dir in $PATH do if [ -f "$dir/$file" ] then @@ -391,8 +391,8 @@ then fi # Change the err log to the right user, if it is in use if [ $want_syslog -eq 0 ]; then - touch $err_log - chown $user $err_log + touch "$err_log" + chown $user "$err_log" fi if test -n "$open_files" then @@ -509,9 +509,9 @@ fi # # If there exists an old pid file, check if the daemon is already running # Note: The switches to 'ps' may depend on your operating system -if test -f $pid_file +if test -f "$pid_file" then - PID=`cat $pid_file` + PID=`cat "$pid_file"` if @CHECK_PID@ then if @FIND_PROC@ @@ -520,8 +520,8 @@ then exit 1 fi fi - rm -f $pid_file - if test -f $pid_file + rm -f "$pid_file" + if test -f "$pid_file" then log_error "Fatal error: Can't remove the pid file: $pid_file @@ -563,11 +563,11 @@ test -n "$NOHUP_NICENESS" && cmd="$cmd < /dev/null" log_notice "Starting $MYSQLD daemon with databases from $DATADIR" while true do - rm -f $safe_mysql_unix_port $pid_file # Some extra safety + rm -f $safe_mysql_unix_port "$pid_file" # Some extra safety eval_log_error "$cmd" - if test ! -f $pid_file # This is removed if normal shutdown + if test ! -f "$pid_file" # This is removed if normal shutdown then break fi diff --git a/scripts/mysqldumpslow.sh b/scripts/mysqldumpslow.sh index ce2670b2abd..8580b8e6203 100644 --- a/scripts/mysqldumpslow.sh +++ b/scripts/mysqldumpslow.sh @@ -20,7 +20,7 @@ GetOptions(\%opt, 'v|verbose+',# verbose 'help+', # write usage info 'd|debug+', # debug - 's=s', # what to sort by (t, at, l, al, r, ar etc) + 's=s', # what to sort by (al, at, ar, c, t, l, r) 'r!', # reverse the sort order (largest last instead of first) 't=i', # just show the top n queries 'a!', # don't abstract all numbers to N and strings to 'S' @@ -163,7 +163,14 @@ Parse and summarize the MySQL slow query log. Options are -v verbose -d debug - -s ORDER what to sort by (t, at, l, al, r, ar etc), 'at' is default + -s ORDER what to sort by (al, at, ar, c, l, r, t), 'at' is default + al: average lock time + ar: average rows sent + at: average query time + c: count + l: lock time + r: rows sent + t: query time -r reverse the sort order (largest last instead of first) -t NUM just show the top n queries -a don't abstract all numbers to N and strings to 'S' diff --git a/sql-common/client.c b/sql-common/client.c index d2c7e02551d..a6a2be1086f 100644 --- a/sql-common/client.c +++ b/sql-common/client.c @@ -120,6 +120,7 @@ const char *def_shared_memory_base_name= default_shared_memory_base_name; static void mysql_close_free_options(MYSQL *mysql); static void mysql_close_free(MYSQL *mysql); +static void mysql_prune_stmt_list(MYSQL *mysql); #if !(defined(__WIN__) || defined(__NETWARE__)) static int wait_for_data(my_socket fd, uint timeout); @@ -924,6 +925,7 @@ void end_server(MYSQL *mysql) vio_delete(mysql->net.vio); reset_sigpipe(mysql); mysql->net.vio= 0; /* Marker */ + mysql_prune_stmt_list(mysql); } net_end(&mysql->net); free_old_query(mysql); @@ -2526,30 +2528,9 @@ my_bool mysql_reconnect(MYSQL *mysql) tmp_mysql.reconnect= 1; tmp_mysql.free_me= mysql->free_me; - /* - For each stmt in mysql->stmts, move it to tmp_mysql if it is - in state MYSQL_STMT_INIT_DONE, otherwise close it. - */ - { - LIST *element= mysql->stmts; - for (; element; element= element->next) - { - MYSQL_STMT *stmt= (MYSQL_STMT *) element->data; - if (stmt->state != MYSQL_STMT_INIT_DONE) - { - stmt->mysql= 0; - stmt->last_errno= CR_SERVER_LOST; - strmov(stmt->last_error, ER(CR_SERVER_LOST)); - strmov(stmt->sqlstate, unknown_sqlstate); - } - else - { - tmp_mysql.stmts= list_add(tmp_mysql.stmts, &stmt->list); - } - /* No need to call list_delete for statement here */ - } - mysql->stmts= NULL; - } + /* Move prepared statements (if any) over to the new mysql object */ + tmp_mysql.stmts= mysql->stmts; + mysql->stmts= 0; /* Don't free options as these are now used in tmp_mysql */ bzero((char*) &mysql->options,sizeof(mysql->options)); @@ -2639,6 +2620,46 @@ static void mysql_close_free(MYSQL *mysql) } +/** + For use when the connection to the server has been lost (in which case + the server has discarded all information about prepared statements + associated with the connection). + + Mark all statements in mysql->stmts by setting stmt->mysql= 0 if the + statement has transitioned beyond the MYSQL_STMT_INIT_DONE state, and + unlink the statement from the mysql->stmts list. + + The remaining pruned list of statements (if any) is kept in mysql->stmts. + + @param mysql pointer to the MYSQL object + + @return none +*/ +static void mysql_prune_stmt_list(MYSQL *mysql) +{ + LIST *element= mysql->stmts; + LIST *pruned_list= 0; + + for (; element; element= element->next) + { + MYSQL_STMT *stmt= (MYSQL_STMT *) element->data; + if (stmt->state != MYSQL_STMT_INIT_DONE) + { + stmt->mysql= 0; + stmt->last_errno= CR_SERVER_LOST; + strmov(stmt->last_error, ER(CR_SERVER_LOST)); + strmov(stmt->sqlstate, unknown_sqlstate); + } + else + { + pruned_list= list_add(pruned_list, element); + } + } + + mysql->stmts= pruned_list; +} + + /* Clear connection pointer of every statement: this is necessary to give error on attempt to use a prepared statement of closed diff --git a/sql/field.cc b/sql/field.cc index d11b509075b..98b3b91fcbd 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -5307,7 +5307,7 @@ bool Field_time::get_time(MYSQL_TIME *ltime) ltime->neg= 1; tmp=-tmp; } - ltime->day= 0; + ltime->year= ltime->month= ltime->day= 0; ltime->hour= (int) (tmp/10000); tmp-=ltime->hour*10000; ltime->minute= (int) tmp/100; diff --git a/sql/handler.h b/sql/handler.h index d43fc4725dd..5c7cfa4d58b 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -876,9 +876,9 @@ typedef struct { ulonglong delete_length; ha_rows records; ulong mean_rec_length; - time_t create_time; - time_t check_time; - time_t update_time; + ulong create_time; + ulong check_time; + ulong update_time; ulonglong check_sum; } PARTITION_INFO; @@ -1037,9 +1037,9 @@ public: ha_rows records; ha_rows deleted; /* Deleted records */ ulong mean_rec_length; /* physical reclength */ - time_t create_time; /* When table was created */ - time_t check_time; - time_t update_time; + ulong create_time; /* When table was created */ + ulong check_time; + ulong update_time; uint block_size; /* index block size */ ha_statistics(): diff --git a/sql/item.cc b/sql/item.cc index d1418b9a137..768af47d660 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -2472,8 +2472,9 @@ longlong_from_string_with_check (CHARSET_INFO *cs, const char *cptr, char *end) TODO: Give error if we wanted a signed integer and we got an unsigned one */ - if (err > 0 || - (end != org_end && !check_if_only_end_space(cs, end, org_end))) + if (!current_thd->no_errors && + (err > 0 || + (end != org_end && !check_if_only_end_space(cs, end, org_end)))) { push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN, ER_TRUNCATED_WRONG_VALUE, @@ -3268,9 +3269,57 @@ Item_param::set_param_type_and_swap_value(Item_param *src) } /**************************************************************************** + Item_copy +****************************************************************************/ +Item_copy *Item_copy::create (Item *item) +{ + switch (item->result_type()) + { + case STRING_RESULT: + return new Item_copy_string (item); + case REAL_RESULT: + return new Item_copy_float (item); + case INT_RESULT: + return item->unsigned_flag ? + new Item_copy_uint (item) : new Item_copy_int (item); + case DECIMAL_RESULT: + return new Item_copy_decimal (item); + + case ROW_RESULT: + DBUG_ASSERT (0); + } + /* should not happen */ + return NULL; +} + +/**************************************************************************** Item_copy_string ****************************************************************************/ +double Item_copy_string::val_real() +{ + int err_not_used; + char *end_not_used; + return (null_value ? 0.0 : + my_strntod(str_value.charset(), (char*) str_value.ptr(), + str_value.length(), &end_not_used, &err_not_used)); +} + +longlong Item_copy_string::val_int() +{ + int err; + return null_value ? LL(0) : my_strntoll(str_value.charset(),str_value.ptr(), + str_value.length(),10, (char**) 0, + &err); +} + + +int Item_copy_string::save_in_field(Field *field, bool no_conversions) +{ + return save_str_value_in_field(field, &str_value); +} + + void Item_copy_string::copy() { String *res=item->val_str(&str_value); @@ -3293,12 +3342,163 @@ my_decimal *Item_copy_string::val_decimal(my_decimal *decimal_value) { // Item_copy_string is used without fix_fields call if (null_value) - return 0; + return (my_decimal *) 0; string2my_decimal(E_DEC_FATAL_ERROR, &str_value, decimal_value); return (decimal_value); } +/**************************************************************************** + Item_copy_int +****************************************************************************/ + +void Item_copy_int::copy() +{ + cached_value= item->val_int(); + null_value=item->null_value; +} + +static int save_int_value_in_field (Field *field, longlong nr, + bool null_value, bool unsigned_flag); + +int Item_copy_int::save_in_field(Field *field, bool no_conversions) +{ + return save_int_value_in_field(field, cached_value, + null_value, unsigned_flag); +} + + +String *Item_copy_int::val_str(String *str) +{ + if (null_value) + return (String *) 0; + + str->set(cached_value, &my_charset_bin); + return str; +} + + +my_decimal *Item_copy_int::val_decimal(my_decimal *decimal_value) +{ + if (null_value) + return (my_decimal *) 0; + + int2my_decimal(E_DEC_FATAL_ERROR, cached_value, unsigned_flag, decimal_value); + return decimal_value; +} + + +/**************************************************************************** + Item_copy_uint +****************************************************************************/ + +String *Item_copy_uint::val_str(String *str) +{ + if (null_value) + return (String *) 0; + + str->set((ulonglong) cached_value, &my_charset_bin); + return str; +} + + +/**************************************************************************** + Item_copy_float +****************************************************************************/ + +String *Item_copy_float::val_str(String *str) +{ + if (null_value) + return (String *) 0; + else + { + double nr= val_real(); + str->set_real(nr,decimals, &my_charset_bin); + return str; + } +} + + +my_decimal *Item_copy_float::val_decimal(my_decimal *decimal_value) +{ + if (null_value) + return (my_decimal *) 0; + else + { + double nr= val_real(); + double2my_decimal(E_DEC_FATAL_ERROR, nr, decimal_value); + return decimal_value; + } +} + + +int Item_copy_float::save_in_field(Field *field, bool no_conversions) +{ + if (null_value) + return set_field_to_null(field); + field->set_notnull(); + return field->store(cached_value); +} + + +/**************************************************************************** + Item_copy_decimal +****************************************************************************/ + +int Item_copy_decimal::save_in_field(Field *field, bool no_conversions) +{ + if (null_value) + return set_field_to_null(field); + field->set_notnull(); + return field->store_decimal(&cached_value); +} + + +String *Item_copy_decimal::val_str(String *result) +{ + if (null_value) + return (String *) 0; + result->set_charset(&my_charset_bin); + my_decimal2string(E_DEC_FATAL_ERROR, &cached_value, 0, 0, 0, result); + return result; +} + + +double Item_copy_decimal::val_real() +{ + if (null_value) + return 0.0; + else + { + double result; + my_decimal2double(E_DEC_FATAL_ERROR, &cached_value, &result); + return result; + } +} + + +longlong Item_copy_decimal::val_int() +{ + if (null_value) + return LL(0); + else + { + longlong result; + my_decimal2int(E_DEC_FATAL_ERROR, &cached_value, unsigned_flag, &result); + return result; + } +} + + +void Item_copy_decimal::copy() +{ + my_decimal *nr= item->val_decimal(&cached_value); + if (nr && nr != &cached_value) + memcpy (&cached_value, nr, sizeof (my_decimal)); + null_value= item->null_value; +} + + /* Functions to convert item to field (for send_fields) */ @@ -3390,14 +3590,12 @@ static void mark_as_dependent(THD *thd, SELECT_LEX *last, SELECT_LEX *current, current->mark_as_dependent(last); if (thd->lex->describe & DESCRIBE_EXTENDED) { - char warn_buff[MYSQL_ERRMSG_SIZE]; - sprintf(warn_buff, ER(ER_WARN_FIELD_RESOLVED), - db_name, (db_name[0] ? "." : ""), - table_name, (table_name [0] ? "." : ""), - resolved_item->field_name, - current->select_number, last->select_number); - push_warning(thd, MYSQL_ERROR::WARN_LEVEL_NOTE, - ER_WARN_FIELD_RESOLVED, warn_buff); + push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_NOTE, + ER_WARN_FIELD_RESOLVED, ER(ER_WARN_FIELD_RESOLVED), + db_name, (db_name[0] ? "." : ""), + table_name, (table_name [0] ? "." : ""), + resolved_item->field_name, + current->select_number, last->select_number); } } @@ -4875,7 +5073,10 @@ int Item_null::save_safe_in_field(Field *field) /* This implementation can lose str_value content, so if the Item uses str_value to store something, it should - reimplement it's ::save_in_field() as Item_string, for example, does + reimplement it's ::save_in_field() as Item_string, for example, does. + + Note: all Item_XXX::val_str(str) methods must NOT rely on the fact that + str != str_value. For example, see fix for bug #44743. */ int Item::save_in_field(Field *field, bool no_conversions) @@ -4945,10 +5146,9 @@ int Item_uint::save_in_field(Field *field, bool no_conversions) return Item_int::save_in_field(field, no_conversions); } - -int Item_int::save_in_field(Field *field, bool no_conversions) +static int save_int_value_in_field (Field *field, longlong nr, + bool null_value, bool unsigned_flag) { - longlong nr=val_int(); if (null_value) return set_field_to_null(field); field->set_notnull(); @@ -4956,6 +5156,12 @@ int Item_int::save_in_field(Field *field, bool no_conversions) } +int Item_int::save_in_field(Field *field, bool no_conversions) +{ + return save_int_value_in_field (field, val_int(), null_value, unsigned_flag); +} + + int Item_decimal::save_in_field(Field *field, bool no_conversions) { field->set_notnull(); @@ -5812,7 +6018,8 @@ void Item_ref::print(String *str, enum_query_type query_type) !table_name && name && alias_name_used) { THD *thd= current_thd; - append_identifier(thd, str, name, (uint) strlen(name)); + append_identifier(thd, str, (*ref)->real_item()->name, + (*ref)->real_item()->name_length); } else (*ref)->print(str, query_type); diff --git a/sql/item.h b/sql/item.h index 96a4e9f7a31..3dfcd7c2612 100644 --- a/sql/item.h +++ b/sql/item.h @@ -2443,48 +2443,203 @@ public: #include "item_xmlfunc.h" #endif -class Item_copy_string :public Item +/** + Base class to implement typed value caching Item classes + + Item_copy_ classes are very similar to the corresponding Item_ + classes (e.g. Item_copy_int is similar to Item_int) but they add + the following additional functionality to Item_ : + 1. Nullability + 2. Possibility to store the value not only on instantiation time, + but also later. + Item_copy_ classes are a functionality subset of Item_cache_ + classes, as e.g. they don't support comparisons with the original Item + as Item_cache_ classes do. + Item_copy_ classes are used in GROUP BY calculation. + TODO: Item_copy should be made an abstract interface and Item_copy_ + classes should inherit both the respective Item_ class and the interface. + Ideally we should drop Item_copy_ classes altogether and merge + their functionality to Item_cache_ (and these should be made to inherit + from Item_). +*/ + +class Item_copy :public Item { +protected: + + /** + Stores the type of the resulting field that would be used to store the data + in the cache. This is to avoid calls to the original item. + */ enum enum_field_types cached_field_type; -public: + + /** The original item that is copied */ Item *item; - Item_copy_string(Item *i) :item(i) + + /** + Stores the result type of the original item, so it can be returned + without calling the original item's method + */ + Item_result cached_result_type; + + /** + Constructor of the Item_copy class + + stores metadata information about the original class as well as a + pointer to it. + */ + Item_copy(Item *i) { + item= i; null_value=maybe_null=item->maybe_null; decimals=item->decimals; max_length=item->max_length; name=item->name; cached_field_type= item->field_type(); + cached_result_type= item->result_type(); + unsigned_flag= item->unsigned_flag; } + +public: + /** + Factory method to create the appropriate subclass dependent on the type of + the original item. + + @param item the original item. + */ + static Item_copy *create (Item *item); + + /** + Update the cache with the value of the original item + + This is the method that updates the cached value. + It must be explicitly called by the user of this class to store the value + of the orginal item in the cache. + */ + virtual void copy() = 0; + + Item *get_item() { return item; } + /** All of the subclasses should have the same type tag */ enum Type type() const { return COPY_STR_ITEM; } - enum Item_result result_type () const { return STRING_RESULT; } enum_field_types field_type() const { return cached_field_type; } - double val_real() + enum Item_result result_type () const { return cached_result_type; } + + void make_field(Send_field *field) { item->make_field(field); } + table_map used_tables() const { return (table_map) 1L; } + bool const_item() const { return 0; } + bool is_null() { return null_value; } + + /* + Override the methods below as pure virtual to make sure all the + sub-classes implement them. + */ + + virtual String *val_str(String*) = 0; + virtual my_decimal *val_decimal(my_decimal *) = 0; + virtual double val_real() = 0; + virtual longlong val_int() = 0; + virtual int save_in_field(Field *field, bool no_conversions) = 0; +}; + +/** + Implementation of a string cache. + + Uses Item::str_value for storage +*/ +class Item_copy_string : public Item_copy +{ +public: + Item_copy_string (Item *item) : Item_copy(item) {} + + String *val_str(String*); + my_decimal *val_decimal(my_decimal *); + double val_real(); + longlong val_int(); + void copy(); + int save_in_field(Field *field, bool no_conversions); +}; + + +class Item_copy_int : public Item_copy +{ +protected: + longlong cached_value; +public: + Item_copy_int (Item *i) : Item_copy(i) {} + int save_in_field(Field *field, bool no_conversions); + + virtual String *val_str(String*); + virtual my_decimal *val_decimal(my_decimal *); + virtual double val_real() { - int err_not_used; - char *end_not_used; - return (null_value ? 0.0 : - my_strntod(str_value.charset(), (char*) str_value.ptr(), - str_value.length(), &end_not_used, &err_not_used)); + return null_value ? 0.0 : (double) cached_value; } - longlong val_int() + virtual longlong val_int() + { + return null_value ? LL(0) : cached_value; + } + virtual void copy(); +}; + + +class Item_copy_uint : public Item_copy_int +{ +public: + Item_copy_uint (Item *item) : Item_copy_int(item) + { + unsigned_flag= 1; + } + + String *val_str(String*); + double val_real() { - int err; - return null_value ? LL(0) : my_strntoll(str_value.charset(),str_value.ptr(), - str_value.length(),10, (char**) 0, - &err); + return null_value ? 0.0 : (double) (ulonglong) cached_value; } +}; + + +class Item_copy_float : public Item_copy +{ +protected: + double cached_value; +public: + Item_copy_float (Item *i) : Item_copy(i) {} + int save_in_field(Field *field, bool no_conversions); + String *val_str(String*); my_decimal *val_decimal(my_decimal *); - void make_field(Send_field *field) { item->make_field(field); } - void copy(); - int save_in_field(Field *field, bool no_conversions) + double val_real() { - return save_str_value_in_field(field, &str_value); + return null_value ? 0.0 : cached_value; } - table_map used_tables() const { return (table_map) 1L; } - bool const_item() const { return 0; } - bool is_null() { return null_value; } + longlong val_int() + { + return (longlong) rint(val_real()); + } + void copy() + { + cached_value= item->val_real(); + null_value= item->null_value; + } +}; + + +class Item_copy_decimal : public Item_copy +{ +protected: + my_decimal cached_value; +public: + Item_copy_decimal (Item *i) : Item_copy(i) {} + int save_in_field(Field *field, bool no_conversions); + + String *val_str(String*); + my_decimal *val_decimal(my_decimal *) + { + return null_value ? NULL: &cached_value; + } + double val_real(); + longlong val_int(); + void copy(); }; diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index a9bfea1b806..ee823517df8 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -2724,16 +2724,6 @@ void Item_func_case::fix_length_and_dec() nagg++; if (!(found_types= collect_cmp_types(agg, nagg))) return; - if (with_sum_func || current_thd->lex->current_select->group_list.elements) - { - /* - See TODO commentary in the setup_copy_fields function: - item in a group may be wrapped with an Item_copy_string item. - That item has a STRING_RESULT result type, so we need - to take this type into account. - */ - found_types |= (1 << item_cmp_type(left_result_type, STRING_RESULT)); - } for (i= 0; i <= (uint)DECIMAL_RESULT; i++) { diff --git a/sql/item_func.cc b/sql/item_func.cc index 876aee719a3..0c8f236a27c 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -2143,9 +2143,6 @@ bool Item_func_rand::fix_fields(THD *thd,Item **ref) if (!rand && !(rand= (struct rand_struct*) thd->stmt_arena->alloc(sizeof(*rand)))) return TRUE; - - if (args[0]->const_item()) - seed_random (args[0]); } else { @@ -2175,8 +2172,21 @@ void Item_func_rand::update_used_tables() double Item_func_rand::val_real() { DBUG_ASSERT(fixed == 1); - if (arg_count && !args[0]->const_item()) - seed_random (args[0]); + if (arg_count) + { + if (!args[0]->const_item()) + seed_random(args[0]); + else if (first_eval) + { + /* + Constantness of args[0] may be set during JOIN::optimize(), if arg[0] + is a field item of "constant" table. Thus, we have to evaluate + seed_random() for constant arg there but not at the fix_fields method. + */ + first_eval= FALSE; + seed_random(args[0]); + } + } return my_rnd(rand); } @@ -4178,6 +4188,41 @@ Item_func_set_user_var::check(bool use_result_field) /** + @brief Evaluate and store item's result. + This function is invoked on "SELECT ... INTO @var ...". + + @param item An item to get value from. +*/ + +void Item_func_set_user_var::save_item_result(Item *item) +{ + DBUG_ENTER("Item_func_set_user_var::save_item_result"); + + switch (cached_result_type) { + case REAL_RESULT: + save_result.vreal= item->val_result(); + break; + case INT_RESULT: + save_result.vint= item->val_int_result(); + unsigned_flag= item->unsigned_flag; + break; + case STRING_RESULT: + save_result.vstr= item->str_result(&value); + break; + case DECIMAL_RESULT: + save_result.vdec= item->val_decimal_result(&decimal_buff); + break; + case ROW_RESULT: + default: + // Should never happen + DBUG_ASSERT(0); + break; + } + DBUG_VOID_RETURN; +} + + +/** This functions is invoked on SET \@variable or \@variable:= expression. @@ -4835,10 +4880,20 @@ bool Item_func_get_system_var::is_written_to_binlog() } +void Item_func_get_system_var::update_null_value() +{ + THD *thd= current_thd; + int save_no_errors= thd->no_errors; + thd->no_errors= TRUE; + Item::update_null_value(); + thd->no_errors= save_no_errors; +} + + void Item_func_get_system_var::fix_length_and_dec() { char *cptr; - maybe_null=0; + maybe_null= TRUE; max_length= 0; if (var->check_type(var_type)) diff --git a/sql/item_func.h b/sql/item_func.h index d23d821baf6..67049af81a2 100644 --- a/sql/item_func.h +++ b/sql/item_func.h @@ -696,14 +696,16 @@ public: class Item_func_rand :public Item_real_func { struct rand_struct *rand; + bool first_eval; // TRUE if val_real() is called 1st time public: - Item_func_rand(Item *a) :Item_real_func(a), rand(0) {} + Item_func_rand(Item *a) :Item_real_func(a), rand(0), first_eval(TRUE) {} Item_func_rand() :Item_real_func() {} double val_real(); const char *func_name() const { return "rand"; } bool const_item() const { return 0; } void update_used_tables(); bool fix_fields(THD *thd, Item **ref); + void cleanup() { first_eval= TRUE; Item_real_func::cleanup(); } private: void seed_random (Item * val); }; @@ -1341,6 +1343,7 @@ public: bool send(Protocol *protocol, String *str_arg); void make_field(Send_field *tmp_field); bool check(bool use_result_field); + void save_item_result(Item *item); bool update(); enum Item_result result_type () const { return cached_result_type; } bool fix_fields(THD *thd, Item **ref); @@ -1452,6 +1455,7 @@ public: LEX_STRING *component_arg, const char *name_arg, size_t name_len_arg); enum Functype functype() const { return GSYSVAR_FUNC; } + void update_null_value(); void fix_length_and_dec(); void print(String *str, enum_query_type query_type); bool const_item() const { return true; } diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index 267036e4a3d..f9210c842bb 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -2706,8 +2706,15 @@ String *Item_func_conv_charset::val_str(String *str) DBUG_ASSERT(fixed == 1); if (use_cached_value) return null_value ? 0 : &str_value; - String *arg= args[0]->val_str(str); + /* + Here we don't pass 'str' as a parameter to args[0]->val_str() + as 'str' may points to 'str_value' (e.g. see Item::save_in_field()), + which we use below to convert string. + Use argument's 'str_value' instead. + */ + String *arg= args[0]->val_str(&args[0]->str_value);; uint dummy_errors; + arg= args[0]->val_str(&args[0]->str_value); if (!arg) { null_value=1; @@ -2943,7 +2950,7 @@ String *Item_load_file::val_str(String *str) ) goto err; - (void) fn_format(path, file_name->c_ptr(), mysql_real_data_home, "", + (void) fn_format(path, file_name->c_ptr_safe(), mysql_real_data_home, "", MY_RELATIVE_PATH | MY_UNPACK_FILENAME); /* Read only allowed from within dir specified by secure_file_priv */ @@ -2969,7 +2976,7 @@ String *Item_load_file::val_str(String *str) } if (tmp_value.alloc(stat_info.st_size)) goto err; - if ((file = my_open(file_name->c_ptr(), O_RDONLY, MYF(0))) < 0) + if ((file = my_open(file_name->ptr(), O_RDONLY, MYF(0))) < 0) goto err; if (my_read(file, (uchar*) tmp_value.ptr(), stat_info.st_size, MYF(MY_NABP))) { @@ -3219,7 +3226,21 @@ longlong Item_func_uncompressed_length::val_int() if (res->is_empty()) return 0; /* - res->ptr() using is safe because we have tested that string is not empty, + If length is <= 4 bytes, data is corrupt. This is the best we can do + to detect garbage input without decompressing it. + */ + if (res->length() <= 4) + { + push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_ERROR, + ER_ZLIB_Z_DATA_ERROR, + ER(ER_ZLIB_Z_DATA_ERROR)); + null_value= 1; + return 0; + } + + /* + res->ptr() using is safe because we have tested that string is at least + 5 bytes long. res->c_ptr() is not used because: - we do not need \0 terminated string to get first 4 bytes - c_ptr() tests simbol after string end (uninitialiozed memory) which diff --git a/sql/log_event.cc b/sql/log_event.cc index 1a8cb8ee4fa..651cd1418e3 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -7862,10 +7862,11 @@ Table_map_log_event::Table_map_log_event(THD *thd, TABLE *tbl, ulong tid, /* Now set the size of the data to the size of the field metadata array - plus one or two bytes for number of elements in the field metadata array. + plus one or three bytes (see pack.c:net_store_length) for number of + elements in the field metadata array. */ if (m_field_metadata_size > 255) - m_data_size+= m_field_metadata_size + 2; + m_data_size+= m_field_metadata_size + 3; else m_data_size+= m_field_metadata_size + 1; @@ -9312,7 +9313,7 @@ Incident_log_event::print(FILE *file, Write_on_release_cache cache(&print_event_info->head_cache, file); print_header(&cache, print_event_info, FALSE); - my_b_printf(&cache, "\n# Incident: %s", description()); + my_b_printf(&cache, "\n# Incident: %s\nRELOAD DATABASE; # Shall generate syntax error\n", description()); } #endif diff --git a/sql/rpl_rli.cc b/sql/rpl_rli.cc index e93417374fe..45c0efb10c2 100644 --- a/sql/rpl_rli.cc +++ b/sql/rpl_rli.cc @@ -104,9 +104,16 @@ int init_relay_log_info(Relay_log_info* rli, rli->tables_to_lock= 0; rli->tables_to_lock_count= 0; - fn_format(rli->slave_patternload_file, PREFIX_SQL_LOAD, slave_load_tmpdir, "", - MY_PACK_FILENAME | MY_UNPACK_FILENAME | - MY_RETURN_REAL_PATH); + char pattern[FN_REFLEN]; + if (fn_format(pattern, PREFIX_SQL_LOAD, slave_load_tmpdir, "", + MY_SAFE_PATH | MY_RETURN_REAL_PATH) == NullS) + { + pthread_mutex_unlock(&rli->data_lock); + sql_print_error("Unable to use slave's temporary directory %s", + slave_load_tmpdir); + DBUG_RETURN(1); + } + unpack_filename(rli->slave_patternload_file, pattern); rli->slave_patternload_file_size= strlen(rli->slave_patternload_file); /* diff --git a/sql/share/errmsg.txt b/sql/share/errmsg.txt index f9b66990e93..2dfc5310643 100644 --- a/sql/share/errmsg.txt +++ b/sql/share/errmsg.txt @@ -6076,7 +6076,7 @@ ER_SLAVE_INCIDENT ER_NO_PARTITION_FOR_GIVEN_VALUE_SILENT eng "Table has no partition for some existing values" ER_BINLOG_UNSAFE_STATEMENT - eng "Statement is not safe to log in statement format." + eng "Statement may not be safe to log in statement format." swe "Detta är inte säkert att logga i statement-format." ER_SLAVE_FATAL_ERROR eng "Fatal error: %s" diff --git a/sql/slave.cc b/sql/slave.cc index 81c18c5e04b..c379a67201a 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -389,6 +389,13 @@ void init_slave_skip_errors(const char* arg) DBUG_VOID_RETURN; } +static void set_thd_in_use_temporary_tables(Relay_log_info *rli) +{ + TABLE *table; + + for (table= rli->save_temporary_tables ; table ; table= table->next) + table->in_use= rli->sql_thd; +} int terminate_slave_threads(Master_info* mi,int thread_mask,bool skip_lock) { @@ -2668,14 +2675,21 @@ err: LOAD DATA INFILE. */ static -int check_temp_dir(char* tmp_dir, char *tmp_file) +int check_temp_dir(char* tmp_file) { int fd; MY_DIR *dirp; + char tmp_dir[FN_REFLEN]; + size_t tmp_dir_size; DBUG_ENTER("check_temp_dir"); /* + Get the directory from the temporary file. + */ + dirname_part(tmp_dir, tmp_file, &tmp_dir_size); + + /* Check if the directory exists. */ if (!(dirp=my_dir(tmp_dir,MYF(MY_WME)))) @@ -2750,6 +2764,7 @@ pthread_handler_t handle_slave_sql(void *arg) } thd->init_for_queries(); thd->temporary_tables = rli->save_temporary_tables; // restore temp tables + set_thd_in_use_temporary_tables(rli); // (re)set sql_thd in use for saved temp tables pthread_mutex_lock(&LOCK_thread_count); threads.append(thd); pthread_mutex_unlock(&LOCK_thread_count); @@ -2830,7 +2845,7 @@ log '%s' at position %s, relay log '%s' position: %s", RPL_LOG_NAME, llstr(rli->group_master_log_pos,llbuff),rli->group_relay_log_name, llstr(rli->group_relay_log_pos,llbuff1)); - if (check_temp_dir(slave_load_tmpdir, rli->slave_patternload_file)) + if (check_temp_dir(rli->slave_patternload_file)) { rli->report(ERROR_LEVEL, thd->main_da.sql_errno(), "Unable to use slave's temporary directory %s - %s", @@ -2996,6 +3011,7 @@ the slave SQL thread with \"SLAVE START\". We stopped at log \ DBUG_ASSERT(rli->sql_thd == thd); THD_CHECK_SENTRY(thd); rli->sql_thd= 0; + set_thd_in_use_temporary_tables(rli); // (re)set sql_thd in use for saved temp tables pthread_mutex_lock(&LOCK_thread_count); THD_CHECK_SENTRY(thd); delete thd; diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index b1dbb7031ce..4d4e4d24684 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -936,6 +936,7 @@ int acl_getroot(THD *thd, USER_RESOURCES *mqh, #ifdef HAVE_OPENSSL Vio *vio=thd->net.vio; SSL *ssl= (SSL*) vio->ssl_arg; + X509 *cert; #endif /* @@ -964,8 +965,11 @@ int acl_getroot(THD *thd, USER_RESOURCES *mqh, */ if (vio_type(vio) == VIO_TYPE_SSL && SSL_get_verify_result(ssl) == X509_V_OK && - SSL_get_peer_certificate(ssl)) + (cert= SSL_get_peer_certificate(ssl))) + { user_access= acl_user->access; + X509_free(cert); + } break; case SSL_TYPE_SPECIFIED: /* Client should have specified attrib */ /* @@ -974,7 +978,6 @@ int acl_getroot(THD *thd, USER_RESOURCES *mqh, If cipher name is specified, we compare it to actual cipher in use. */ - X509 *cert; if (vio_type(vio) != VIO_TYPE_SSL || SSL_get_verify_result(ssl) != X509_V_OK) break; @@ -1014,6 +1017,7 @@ int acl_getroot(THD *thd, USER_RESOURCES *mqh, sql_print_information("X509 issuer mismatch: should be '%s' " "but is '%s'", acl_user->x509_issuer, ptr); free(ptr); + X509_free(cert); user_access=NO_ACCESS; break; } @@ -1033,12 +1037,15 @@ int acl_getroot(THD *thd, USER_RESOURCES *mqh, sql_print_information("X509 subject mismatch: should be '%s' but is '%s'", acl_user->x509_subject, ptr); free(ptr); + X509_free(cert); user_access=NO_ACCESS; break; } user_access= acl_user->access; free(ptr); } + /* Deallocate the X509 certificate. */ + X509_free(cert); break; #else /* HAVE_OPENSSL */ default: diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 0dc29f7e3c2..d4d813d0fbd 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -5585,6 +5585,13 @@ static void update_field_dependencies(THD *thd, Field *field, TABLE *table) other_bitmap= table->read_set; } + /* + The test-and-set mechanism in the bitmap is not reliable during + multi-UPDATE statements under MARK_COLUMNS_READ mode + (thd->mark_used_columns == MARK_COLUMNS_READ), as this bitmap contains + only those columns that are used in the SET clause. I.e they are being + set here. See multi_update::prepare() + */ if (bitmap_fast_test_and_set(current_bitmap, field->field_index)) { if (thd->mark_used_columns == MARK_COLUMNS_WRITE) diff --git a/sql/sql_class.cc b/sql/sql_class.cc index b73822f5a48..cf5fdcf27a7 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -2599,7 +2599,7 @@ bool select_dumpvar::send_data(List<Item> &items) { Item_func_set_user_var *suv= new Item_func_set_user_var(mv->s, item); suv->fix_fields(thd, 0); - suv->check(0); + suv->save_item_result(item); suv->update(); } } diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc index 1b42e522491..7b967206305 100644 --- a/sql/sql_delete.cc +++ b/sql/sql_delete.cc @@ -582,6 +582,11 @@ int mysql_multi_delete_prepare(THD *thd) } } } + /* + Reset the exclude flag to false so it doesn't interfare + with further calls to unique_table + */ + lex->select_lex.exclude_from_table_unique_test= FALSE; DBUG_RETURN(FALSE); } @@ -617,11 +622,24 @@ multi_delete::initialize_tables(JOIN *join) DBUG_RETURN(1); table_map tables_to_delete_from=0; + delete_while_scanning= 1; for (walk= delete_tables; walk; walk= walk->next_local) + { tables_to_delete_from|= walk->table->map; + if (delete_while_scanning && + unique_table(thd, walk, join->tables_list, false)) + { + /* + If the table we are going to delete from appears + in join, we need to defer delete. So the delete + doesn't interfers with the scaning of results. + */ + delete_while_scanning= 0; + } + } + walk= delete_tables; - delete_while_scanning= 1; for (JOIN_TAB *tab=join->join_tab, *end=join->join_tab+join->tables; tab < end; tab++) diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 6dbe4a4fd8d..8f1d3842245 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -195,11 +195,8 @@ bool begin_trans(THD *thd) error= -1; else { - LEX *lex= thd->lex; thd->options|= OPTION_BEGIN; thd->server_status|= SERVER_STATUS_IN_TRANS; - if (lex->start_transaction_opt & MYSQL_START_TRANS_OPT_WITH_CONS_SNAPSHOT) - error= ha_start_consistent_snapshot(thd); } return error; } @@ -4027,6 +4024,11 @@ end_with_restore_list: } if (begin_trans(thd)) goto error; + if (lex->start_transaction_opt & MYSQL_START_TRANS_OPT_WITH_CONS_SNAPSHOT) + { + if (ha_start_consistent_snapshot(thd)) + goto error; + } my_ok(thd); break; case SQLCOM_COMMIT: diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc index 1465b6d2d30..da168d36429 100644 --- a/sql/sql_plugin.cc +++ b/sql/sql_plugin.cc @@ -29,6 +29,18 @@ extern struct st_mysql_plugin *mysqld_builtins[]; +/** + @note The order of the enumeration is critical. + @see construct_options +*/ +static const char *global_plugin_typelib_names[]= + { "OFF", "ON", "FORCE", NULL }; +enum enum_plugin_load_policy {PLUGIN_OFF, PLUGIN_ON, PLUGIN_FORCE}; +static TYPELIB global_plugin_typelib= + { array_elements(global_plugin_typelib_names)-1, + "", global_plugin_typelib_names, NULL }; + + char *opt_plugin_load= NULL; char *opt_plugin_dir_ptr; char opt_plugin_dir[FN_REFLEN]; @@ -192,7 +204,7 @@ static void plugin_load(MEM_ROOT *tmp_root, int *argc, char **argv); static bool plugin_load_list(MEM_ROOT *tmp_root, int *argc, char **argv, const char *list); static int test_plugin_options(MEM_ROOT *, struct st_plugin_int *, - int *, char **, my_bool); + int *, char **); static bool register_builtin(struct st_mysql_plugin *, struct st_plugin_int *, struct st_plugin_int **); static void unlock_variables(THD *thd, struct system_variables *vars); @@ -751,7 +763,7 @@ static bool plugin_add(MEM_ROOT *tmp_root, tmp.name.length= name_len; tmp.ref_count= 0; tmp.state= PLUGIN_IS_UNINITIALIZED; - if (test_plugin_options(tmp_root, &tmp, argc, argv, true)) + if (test_plugin_options(tmp_root, &tmp, argc, argv)) tmp.state= PLUGIN_IS_DISABLED; if ((tmp_plugin_ptr= plugin_insert_or_reuse(&tmp))) @@ -997,7 +1009,6 @@ static int plugin_initialize(struct st_plugin_int *plugin) DBUG_ENTER("plugin_initialize"); safe_mutex_assert_owner(&LOCK_plugin); - if (plugin_type_initialize[plugin->plugin->type]) { if ((*plugin_type_initialize[plugin->plugin->type])(plugin)) @@ -1083,6 +1094,20 @@ uchar *get_bookmark_hash_key(const uchar *buff, size_t *length, return (uchar*) var->key; } +static inline void convert_dash_to_underscore(char *str, int len) +{ + for (char *p= str; p <= str+len; p++) + if (*p == '-') + *p= '_'; +} + +static inline void convert_underscore_to_dash(char *str, int len) +{ + for (char *p= str; p <= str+len; p++) + if (*p == '_') + *p= '-'; +} + /* The logic is that we first load and initialize all compiled in plugins. @@ -1094,11 +1119,12 @@ uchar *get_bookmark_hash_key(const uchar *buff, size_t *length, int plugin_init(int *argc, char **argv, int flags) { uint i; - bool def_enabled, is_myisam; + bool is_myisam; struct st_mysql_plugin **builtins; struct st_mysql_plugin *plugin; struct st_plugin_int tmp, *plugin_ptr, **reap; MEM_ROOT tmp_root; + bool reaped_mandatory_plugin= FALSE; DBUG_ENTER("plugin_init"); if (initialized) @@ -1142,17 +1168,13 @@ int plugin_init(int *argc, char **argv, int flags) !my_strnncoll(&my_charset_latin1, (const uchar*) plugin->name, 6, (const uchar*) "InnoDB", 6)) continue; - /* by default, ndbcluster and federated are disabled */ - def_enabled= - my_strcasecmp(&my_charset_latin1, plugin->name, "NDBCLUSTER") != 0 && - my_strcasecmp(&my_charset_latin1, plugin->name, "FEDERATED") != 0; bzero(&tmp, sizeof(tmp)); tmp.plugin= plugin; tmp.name.str= (char *)plugin->name; tmp.name.length= strlen(plugin->name); tmp.state= 0; free_root(&tmp_root, MYF(MY_MARK_BLOCKS_FREE)); - if (test_plugin_options(&tmp_root, &tmp, argc, argv, def_enabled)) + if (test_plugin_options(&tmp_root, &tmp, argc, argv)) tmp.state= PLUGIN_IS_DISABLED; else tmp.state= PLUGIN_IS_UNINITIALIZED; @@ -1227,6 +1249,8 @@ int plugin_init(int *argc, char **argv, int flags) while ((plugin_ptr= *(--reap))) { pthread_mutex_unlock(&LOCK_plugin); + if (plugin_ptr->is_mandatory) + reaped_mandatory_plugin= TRUE; plugin_deinitialize(plugin_ptr, true); pthread_mutex_lock(&LOCK_plugin); plugin_del(plugin_ptr); @@ -1234,6 +1258,8 @@ int plugin_init(int *argc, char **argv, int flags) pthread_mutex_unlock(&LOCK_plugin); my_afree(reap); + if (reaped_mandatory_plugin) + goto err; end: free_root(&tmp_root, MYF(0)); @@ -1299,7 +1325,7 @@ bool plugin_register_builtin(THD *thd, struct st_mysql_plugin *plugin) pthread_mutex_lock(&LOCK_plugin); rw_wrlock(&LOCK_system_variables_hash); - if (test_plugin_options(thd->mem_root, &tmp, &dummy_argc, NULL, true)) + if (test_plugin_options(thd->mem_root, &tmp, &dummy_argc, NULL)) goto end; tmp.state= PLUGIN_IS_UNINITIALIZED; if ((result= register_builtin(plugin, &tmp, &ptr))) @@ -2889,59 +2915,78 @@ my_bool get_one_plugin_option(int optid __attribute__((unused)), } +/** + Creates a set of my_option objects associated with a specified plugin- + handle. + + @param mem_root Memory allocator to be used. + @param tmp A pointer to a plugin handle + @param[out] options A pointer to a pre-allocated static array + + The set is stored in the pre-allocated static array supplied to the function. + The size of the array is calculated as (number_of_plugin_varaibles*2+3). The + reason is that each option can have a prefix '--plugin-' in addtion to the + shorter form '--<plugin-name>'. There is also space allocated for + terminating NULL pointers. + + @return + @retval -1 An error occurred + @retval 0 Success +*/ + static int construct_options(MEM_ROOT *mem_root, struct st_plugin_int *tmp, - my_option *options, my_bool **enabled, - bool can_disable) + my_option *options) { const char *plugin_name= tmp->plugin->name; - uint namelen= strlen(plugin_name), optnamelen; - uint buffer_length= namelen * 4 + (can_disable ? 75 : 10); - char *name= (char*) alloc_root(mem_root, buffer_length) + 1; - char *optname, *p; + const LEX_STRING plugin_dash = { C_STRING_WITH_LEN("plugin-") }; + uint plugin_name_len= strlen(plugin_name); + uint optnamelen; + const int max_comment_len= 180; + char *comment= (char *) alloc_root(mem_root, max_comment_len + 1); + char *optname; + int index= 0, offset= 0; st_mysql_sys_var *opt, **plugin_option; st_bookmark *v; + + /** Used to circumvent the const attribute on my_option::name */ + char *plugin_name_ptr, *plugin_name_with_prefix_ptr; + DBUG_ENTER("construct_options"); - DBUG_PRINT("plugin", ("plugin: '%s' enabled: %d can_disable: %d", - plugin_name, **enabled, can_disable)); + options[0].name= plugin_name_ptr= (char*) alloc_root(mem_root, + plugin_name_len + 1); + strcpy(plugin_name_ptr, plugin_name); + my_casedn_str(&my_charset_latin1, plugin_name_ptr); + convert_underscore_to_dash(plugin_name_ptr, plugin_name_len); /* support --skip-plugin-foo syntax */ - memcpy(name, plugin_name, namelen + 1); - my_casedn_str(&my_charset_latin1, name); - strxmov(name + namelen + 1, "plugin-", name, NullS); - /* Now we have namelen + 1 + 7 + namelen + 1 == namelen * 2 + 9. */ - - for (p= name + namelen*2 + 8; p > name; p--) - if (*p == '_') - *p= '-'; + options[1].name= plugin_name_with_prefix_ptr= (char*) alloc_root(mem_root, + plugin_name_len + + plugin_dash.length + 1); + strxmov(plugin_name_with_prefix_ptr, plugin_dash.str, options[0].name, NullS); - if (can_disable) - { - strxmov(name + namelen*2 + 10, "Enable ", plugin_name, " plugin. " - "Disable with --skip-", name," (will save memory).", NullS); - /* - Now we have namelen * 2 + 10 (one char unused) + 7 + namelen + 9 + - 20 + namelen + 20 + 1 == namelen * 4 + 67. - */ + options[0].id= options[1].id= 256; /* must be >255. dup id ok */ + options[0].var_type= options[1].var_type= GET_ENUM; + options[0].arg_type= options[1].arg_type= OPT_ARG; + options[0].def_value= options[1].def_value= 1; /* ON */ + options[0].typelib= options[1].typelib= &global_plugin_typelib; - options[0].comment= name + namelen*2 + 10; - } + strxnmov(comment, max_comment_len, "Enable or disable ", plugin_name, + " plugin. Possible values are ON, OFF, FORCE (don't start " + "if the plugin fails to load).", NullS); + options[0].comment= comment; /* - NOTE: 'name' is one char above the allocated buffer! - NOTE: This code assumes that 'my_bool' and 'char' are of same size. + Allocate temporary space for the value of the tristate. + This option will have a limited lifetime and is not used beyond + server initialization. + GET_ENUM value is an integer. */ - *((my_bool *)(name -1))= **enabled; - *enabled= (my_bool *)(name - 1); - + options[0].value= options[1].value= (uchar **)alloc_root(mem_root, + sizeof(int)); + *((uint*) options[0].value)= *((uint*) options[1].value)= + (uint) options[0].def_value; - options[1].name= (options[0].name= name) + namelen + 1; - options[0].id= options[1].id= 256; /* must be >255. dup id ok */ - options[0].var_type= options[1].var_type= GET_BOOL; - options[0].arg_type= options[1].arg_type= NO_ARG; - options[0].def_value= options[1].def_value= **enabled; - options[0].value= options[0].u_max_value= - options[1].value= options[1].u_max_value= (uchar**) (name - 1); options+= 2; /* @@ -2955,7 +3000,7 @@ static int construct_options(MEM_ROOT *mem_root, struct st_plugin_int *tmp, opt= *plugin_option; if (!(opt->flags & PLUGIN_VAR_THDLOCAL)) continue; - if (!(register_var(name, opt->name, opt->flags))) + if (!(register_var(plugin_name_ptr, opt->name, opt->flags))) continue; switch (opt->flags & PLUGIN_VAR_TYPEMASK) { case PLUGIN_VAR_BOOL: @@ -3020,7 +3065,7 @@ static int construct_options(MEM_ROOT *mem_root, struct st_plugin_int *tmp, if (!opt->update) { opt->update= update_func_str; - if (!(opt->flags & PLUGIN_VAR_MEMALLOC | PLUGIN_VAR_READONLY)) + if (!(opt->flags & (PLUGIN_VAR_MEMALLOC | PLUGIN_VAR_READONLY))) { opt->flags|= PLUGIN_VAR_READONLY; sql_print_warning("Server variable %s of plugin %s was forced " @@ -3062,14 +3107,14 @@ static int construct_options(MEM_ROOT *mem_root, struct st_plugin_int *tmp, if (!(opt->flags & PLUGIN_VAR_THDLOCAL)) { optnamelen= strlen(opt->name); - optname= (char*) alloc_root(mem_root, namelen + optnamelen + 2); - strxmov(optname, name, "-", opt->name, NullS); - optnamelen= namelen + optnamelen + 1; + optname= (char*) alloc_root(mem_root, plugin_name_len + optnamelen + 2); + strxmov(optname, plugin_name_ptr, "-", opt->name, NullS); + optnamelen= plugin_name_len + optnamelen + 1; } else { /* this should not fail because register_var should create entry */ - if (!(v= find_bookmark(name, opt->name, opt->flags))) + if (!(v= find_bookmark(plugin_name_ptr, opt->name, opt->flags))) { sql_print_error("Thread local variable '%s' not allocated " "in plugin '%s'.", opt->name, plugin_name); @@ -3085,10 +3130,7 @@ static int construct_options(MEM_ROOT *mem_root, struct st_plugin_int *tmp, (optnamelen= v->name_len) + 1); } - /* convert '_' to '-' */ - for (p= optname; *p; p++) - if (*p == '_') - *p= '-'; + convert_underscore_to_dash(optname, optnamelen); options->name= optname; options->comment= opt->comment; @@ -3103,10 +3145,13 @@ static int construct_options(MEM_ROOT *mem_root, struct st_plugin_int *tmp, else options->value= options->u_max_value= *(uchar***) (opt + 1); + char *option_name_ptr; options[1]= options[0]; - options[1].name= p= (char*) alloc_root(mem_root, optnamelen + 8); - options[1].comment= 0; // hidden - strxmov(p, "plugin-", optname, NullS); + options[1].name= option_name_ptr= (char*) alloc_root(mem_root, + plugin_dash.length + + optnamelen + 1); + options[1].comment= 0; /* Hidden from the help text */ + strxmov(option_name_ptr, plugin_dash.str, optname, NullS); options+= 2; } @@ -3120,55 +3165,57 @@ static my_option *construct_help_options(MEM_ROOT *mem_root, { st_mysql_sys_var **opt; my_option *opts; - my_bool dummy, can_disable; - my_bool *dummy2= &dummy; uint count= EXTRA_OPTIONS; DBUG_ENTER("construct_help_options"); - for (opt= p->plugin->system_vars; opt && *opt; opt++, count+= 2); + for (opt= p->plugin->system_vars; opt && *opt; opt++, count+= 2) + ; if (!(opts= (my_option*) alloc_root(mem_root, sizeof(my_option) * count))) DBUG_RETURN(NULL); bzero(opts, sizeof(my_option) * count); - dummy= TRUE; /* plugin is enabled. */ - - can_disable= - my_strcasecmp(&my_charset_latin1, p->name.str, "MyISAM") && - my_strcasecmp(&my_charset_latin1, p->name.str, "MEMORY"); - - if (construct_options(mem_root, p, opts, &dummy2, can_disable)) + if (construct_options(mem_root, p, opts)) DBUG_RETURN(NULL); DBUG_RETURN(opts); } -/* - SYNOPSIS - test_plugin_options() - tmp_root temporary scratch space - plugin internal plugin structure - argc user supplied arguments - argv user supplied arguments - default_enabled default plugin enable status - RETURNS: - 0 SUCCESS - plugin should be enabled/loaded - NOTE: - Requires that a write-lock is held on LOCK_system_variables_hash +/** + Create and register system variables supplied from the plugin and + assigns initial values from corresponding command line arguments. + + @param tmp_root Temporary scratch space + @param[out] plugin Internal plugin structure + @param argc Number of command line arguments + @param argv Command line argument vector + + The plugin will be updated with a policy on how to handle errors during + initialization. + + @note Requires that a write-lock is held on LOCK_system_variables_hash + + @return How initialization of the plugin should be handled. + @retval 0 Initialization should proceed. + @retval 1 Plugin is disabled. + @retval -1 An error has occurred. */ + static int test_plugin_options(MEM_ROOT *tmp_root, struct st_plugin_int *tmp, - int *argc, char **argv, my_bool default_enabled) + int *argc, char **argv) { struct sys_var_chain chain= { NULL, NULL }; - my_bool enabled_saved= default_enabled, can_disable; - my_bool *enabled= &default_enabled; + my_bool can_disable; + bool disable_plugin; + enum_plugin_load_policy plugin_load_policy= PLUGIN_ON; + MEM_ROOT *mem_root= alloc_root_inited(&tmp->mem_root) ? &tmp->mem_root : &plugin_mem_root; st_mysql_sys_var **opt; my_option *opts= NULL; - char *p, *varname; + char *varname; int error; st_mysql_sys_var *o; sys_var *v; @@ -3177,13 +3224,17 @@ static int test_plugin_options(MEM_ROOT *tmp_root, struct st_plugin_int *tmp, DBUG_ENTER("test_plugin_options"); DBUG_ASSERT(tmp->plugin && tmp->name.str); + /* + The 'federated' and 'ndbcluster' storage engines are always disabled by + default. + */ + if (!(my_strcasecmp(&my_charset_latin1, tmp->name.str, "federated") && + my_strcasecmp(&my_charset_latin1, tmp->name.str, "ndbcluster"))) + plugin_load_policy= PLUGIN_OFF; + for (opt= tmp->plugin->system_vars; opt && *opt; opt++) count+= 2; /* --{plugin}-{optname} and --plugin-{plugin}-{optname} */ - can_disable= - my_strcasecmp(&my_charset_latin1, tmp->name.str, "MyISAM") && - my_strcasecmp(&my_charset_latin1, tmp->name.str, "MEMORY"); - if (count > EXTRA_OPTIONS || (*argc > 1)) { if (!(opts= (my_option*) alloc_root(tmp_root, sizeof(my_option) * count))) @@ -3193,12 +3244,18 @@ static int test_plugin_options(MEM_ROOT *tmp_root, struct st_plugin_int *tmp, } bzero(opts, sizeof(my_option) * count); - if (construct_options(tmp_root, tmp, opts, &enabled, can_disable)) + if (construct_options(tmp_root, tmp, opts)) { sql_print_error("Bad options for plugin '%s'.", tmp->name.str); DBUG_RETURN(-1); } + /* + We adjust the default value to account for the hardcoded exceptions + we have set for the federated and ndbcluster storage engines. + */ + opts[0].def_value= opts[1].def_value= (int)plugin_load_policy; + error= handle_options(argc, &argv, opts, get_one_plugin_option); (*argc)++; /* add back one for the program name */ @@ -3208,64 +3265,79 @@ static int test_plugin_options(MEM_ROOT *tmp_root, struct st_plugin_int *tmp, tmp->name.str); goto err; } + /* + Set plugin loading policy from option value. First element in the option + list is always the <plugin name> option value. + */ + plugin_load_policy= (enum_plugin_load_policy)*(uint*)opts[0].value; } - if (!*enabled && !can_disable) + disable_plugin= (plugin_load_policy == PLUGIN_OFF); + /* + The 'MyISAM' and 'Memory' storage engines currently can't be disabled. + */ + can_disable= + my_strcasecmp(&my_charset_latin1, tmp->name.str, "MyISAM") && + my_strcasecmp(&my_charset_latin1, tmp->name.str, "MEMORY"); + + tmp->is_mandatory= (plugin_load_policy == PLUGIN_FORCE) || !can_disable; + + if (disable_plugin && !can_disable) { sql_print_warning("Plugin '%s' cannot be disabled", tmp->name.str); - *enabled= TRUE; + disable_plugin= FALSE; } - error= 1; + /* + If the plugin is disabled it should not be initialized. + */ + if (disable_plugin) + { + if (global_system_variables.log_warnings) + sql_print_information("Plugin '%s' is disabled.", + tmp->name.str); + if (opts) + my_cleanup_options(opts); + DBUG_RETURN(1); + } - if (*enabled) + error= 1; + for (opt= tmp->plugin->system_vars; opt && *opt; opt++) { - for (opt= tmp->plugin->system_vars; opt && *opt; opt++) + if (((o= *opt)->flags & PLUGIN_VAR_NOSYSVAR)) + continue; + if ((var= find_bookmark(tmp->name.str, o->name, o->flags))) + v= new (mem_root) sys_var_pluginvar(var->key + 1, o); + else { - if (((o= *opt)->flags & PLUGIN_VAR_NOSYSVAR)) - continue; - - if ((var= find_bookmark(tmp->name.str, o->name, o->flags))) - v= new (mem_root) sys_var_pluginvar(var->key + 1, o); - else - { - len= tmp->name.length + strlen(o->name) + 2; - varname= (char*) alloc_root(mem_root, len); - strxmov(varname, tmp->name.str, "-", o->name, NullS); - my_casedn_str(&my_charset_latin1, varname); - - for (p= varname; *p; p++) - if (*p == '-') - *p= '_'; - - v= new (mem_root) sys_var_pluginvar(varname, o); - } - DBUG_ASSERT(v); /* check that an object was actually constructed */ - - /* - Add to the chain of variables. - Done like this for easier debugging so that the - pointer to v is not lost on optimized builds. - */ - v->chain_sys_var(&chain); + len= tmp->name.length + strlen(o->name) + 2; + varname= (char*) alloc_root(mem_root, len); + strxmov(varname, tmp->name.str, "-", o->name, NullS); + my_casedn_str(&my_charset_latin1, varname); + convert_dash_to_underscore(varname, len-1); + v= new (mem_root) sys_var_pluginvar(varname, o); } - if (chain.first) + DBUG_ASSERT(v); /* check that an object was actually constructed */ + /* + Add to the chain of variables. + Done like this for easier debugging so that the + pointer to v is not lost on optimized builds. + */ + v->chain_sys_var(&chain); + } /* end for */ + if (chain.first) + { + chain.last->next = NULL; + if (mysql_add_sys_var_chain(chain.first, NULL)) { - chain.last->next = NULL; - if (mysql_add_sys_var_chain(chain.first, NULL)) - { - sql_print_error("Plugin '%s' has conflicting system variables", - tmp->name.str); - goto err; - } - tmp->system_vars= chain.first; + sql_print_error("Plugin '%s' has conflicting system variables", + tmp->name.str); + goto err; } - DBUG_RETURN(0); + tmp->system_vars= chain.first; } - - if (enabled_saved && global_system_variables.log_warnings) - sql_print_information("Plugin '%s' disabled by command line option", - tmp->name.str); + DBUG_RETURN(0); + err: if (opts) my_cleanup_options(opts); diff --git a/sql/sql_plugin.h b/sql/sql_plugin.h index 8ae38d58845..004d0d5abb7 100644 --- a/sql/sql_plugin.h +++ b/sql/sql_plugin.h @@ -79,6 +79,7 @@ struct st_plugin_int void *data; /* plugin type specific, e.g. handlerton */ MEM_ROOT mem_root; /* memory for dynamic plugin structures */ sys_var *system_vars; /* server variables for this plugin */ + bool is_mandatory; /* If true then plugin must not fail to load */ }; diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc index cd11b6d4c24..cc7ea75dbbf 100644 --- a/sql/sql_prepare.cc +++ b/sql/sql_prepare.cc @@ -2461,6 +2461,9 @@ void mysql_stmt_execute(THD *thd, char *packet_arg, uint packet_length) stmt->execute_loop(&expanded_query, open_cursor, packet, packet_end); + /* Close connection socket; for use with client testing (Bug#43560). */ + DBUG_EXECUTE_IF("close_conn_after_stmt_execute", vio_close(thd->net.vio);); + DBUG_VOID_RETURN; } diff --git a/sql/sql_rename.cc b/sql/sql_rename.cc index d4331b12cd4..7cc9130cc4a 100644 --- a/sql/sql_rename.cc +++ b/sql/sql_rename.cc @@ -261,6 +261,8 @@ do_rename(THD *thd, TABLE_LIST *ren_table, char *new_db, char *new_table_name, old_alias= ren_table->table_name; new_alias= new_table_name; } + DBUG_ASSERT(new_alias); + build_table_filename(name, sizeof(name), new_db, new_alias, reg_ext, 0); if (!access(name,F_OK)) diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 21d22e250ec..fad533986d6 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -2248,6 +2248,14 @@ JOIN::destroy() cond_equal= 0; cleanup(1); + /* Cleanup items referencing temporary table columns */ + if (!tmp_all_fields3.is_empty()) + { + List_iterator_fast<Item> it(tmp_all_fields3); + Item *item; + while ((item= it++)) + item->cleanup(); + } if (exec_tmp_table1) free_tmp_table(thd, exec_tmp_table1); if (exec_tmp_table2) @@ -7084,15 +7092,17 @@ return_zero_rows(JOIN *join, select_result *result,TABLE_LIST *tables, if (!(result->send_fields(fields, Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF))) { + bool send_error= FALSE; if (send_row) { List_iterator_fast<Item> it(fields); Item *item; while ((item= it++)) item->no_rows_in_result(); - result->send_data(fields); + send_error= result->send_data(fields); } - result->send_eof(); // Should be safe + if (!send_error) + result->send_eof(); // Should be safe } /* Update results for FOUND_ROWS */ join->thd->limit_found_rows= join->thd->examined_row_count= 0; @@ -13845,7 +13855,7 @@ SORT_FIELD *make_unireg_sortorder(ORDER *order, uint *length, pos->field= ((Item_sum*) item)->get_tmp_table_field(); else if (item->type() == Item::COPY_STR_ITEM) { // Blob patch - pos->item= ((Item_copy_string*) item)->item; + pos->item= ((Item_copy*) item)->get_item(); } else pos->item= *order->item; @@ -14916,7 +14926,7 @@ setup_copy_fields(THD *thd, TMP_TABLE_PARAM *param, pos= item; if (item->field->flags & BLOB_FLAG) { - if (!(pos= new Item_copy_string(pos))) + if (!(pos= Item_copy::create(pos))) goto err; /* Item_copy_string::copy for function can call @@ -14970,7 +14980,7 @@ setup_copy_fields(THD *thd, TMP_TABLE_PARAM *param, on how the value is to be used: In some cases this may be an argument in a group function, like: IF(ISNULL(col),0,COUNT(*)) */ - if (!(pos=new Item_copy_string(pos))) + if (!(pos= Item_copy::create(pos))) goto err; if (i < border) // HAVING, ORDER and GROUP BY { @@ -15023,8 +15033,8 @@ copy_fields(TMP_TABLE_PARAM *param) (*ptr->do_copy)(ptr); List_iterator_fast<Item> it(param->copy_funcs); - Item_copy_string *item; - while ((item = (Item_copy_string*) it++)) + Item_copy *item; + while ((item = (Item_copy*) it++)) item->copy(); } diff --git a/sql/sql_string.cc b/sql/sql_string.cc index 1dd7b55d136..61731f3b984 100644 --- a/sql/sql_string.cc +++ b/sql/sql_string.cc @@ -328,6 +328,9 @@ bool String::copy(const char *str, uint32 arg_length, CHARSET_INFO *from_cs, CHARSET_INFO *to_cs, uint *errors) { uint32 offset; + + DBUG_ASSERT(str != Ptr); + if (!needs_conversion(arg_length, from_cs, to_cs, &offset)) { *errors= 0; diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 29d43155778..5397128855a 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -3126,7 +3126,7 @@ static bool prepare_blob_field(THD *thd, Create_field *sql_field) } sql_field->sql_type= MYSQL_TYPE_BLOB; sql_field->flags|= BLOB_FLAG; - sprintf(warn_buff, ER(ER_AUTO_CONVERT), sql_field->field_name, + my_snprintf(warn_buff, sizeof(warn_buff), ER(ER_AUTO_CONVERT), sql_field->field_name, (sql_field->charset == &my_charset_bin) ? "VARBINARY" : "VARCHAR", (sql_field->charset == &my_charset_bin) ? "BLOB" : "TEXT"); push_warning(thd, MYSQL_ERROR::WARN_LEVEL_NOTE, ER_AUTO_CONVERT, @@ -6140,6 +6140,20 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name, if (frm_type == FRMTYPE_VIEW && !(alter_info->flags & ~ALTER_RENAME)) { /* + The following branch handles "ALTER VIEW v1 /no arguments/;" + This feature is not documented one. + However, before "OPTIMIZE TABLE t1;" was implemented, + ALTER TABLE with no alter_specifications was used to force-rebuild + the table. That's why this grammar is allowed. That's why we ignore + it for views. So just do nothing in such a case. + */ + if (!new_name) + { + my_ok(thd); + DBUG_RETURN(FALSE); + } + + /* Avoid problems with a rename on a table that we have locked or if the user is trying to to do this in a transcation context */ diff --git a/sql/sql_union.cc b/sql/sql_union.cc index fd3036e3d80..cbf94ad7181 100644 --- a/sql/sql_union.cc +++ b/sql/sql_union.cc @@ -653,10 +653,22 @@ bool st_select_lex_unit::cleanup() join->tables= 0; } error|= fake_select_lex->cleanup(); - if (fake_select_lex->order_list.elements) + /* + There are two cases when we should clean order items: + 1. UNION with SELECTs which all enclosed into braces + in this case global_parameters == fake_select_lex + 2. UNION where last SELECT is not enclosed into braces + in this case global_parameters == 'last select' + So we should use global_parameters->order_list for + proper order list clean up. + Note: global_parameters and fake_select_lex are always + initialized for UNION + */ + DBUG_ASSERT(global_parameters); + if (global_parameters->order_list.elements) { ORDER *ord; - for (ord= (ORDER*)fake_select_lex->order_list.first; ord; ord= ord->next) + for (ord= (ORDER*)global_parameters->order_list.first; ord; ord= ord->next) (*ord->item)->cleanup(); } } diff --git a/sql/sql_update.cc b/sql/sql_update.cc index b3bd5d0bc57..dcccf7f147f 100644 --- a/sql/sql_update.cc +++ b/sql/sql_update.cc @@ -818,7 +818,7 @@ int mysql_update(THD *thd, if (error < 0) { char buff[STRING_BUFFER_USUAL_SIZE]; - sprintf(buff, ER(ER_UPDATE_INFO), (ulong) found, (ulong) updated, + my_snprintf(buff, sizeof(buff), ER(ER_UPDATE_INFO), (ulong) found, (ulong) updated, (ulong) thd->cuted_fields); thd->row_count_func= (thd->client_capabilities & CLIENT_FOUND_ROWS) ? found : updated; @@ -1031,7 +1031,6 @@ reopen_tables: DBUG_RETURN(TRUE); } - table->mark_columns_needed_for_update(); DBUG_PRINT("info",("setting table `%s` for update", tl->alias)); /* If table will be updated we should not downgrade lock for it and @@ -1275,12 +1274,40 @@ int multi_update::prepare(List<Item> ¬_used_values, } /* + We gather the set of columns read during evaluation of SET expression in + TABLE::tmp_set by pointing TABLE::read_set to it and then restore it after + setup_fields(). + */ + for (table_ref= leaves; table_ref; table_ref= table_ref->next_leaf) + { + TABLE *table= table_ref->table; + if (tables_to_update & table->map) + { + DBUG_ASSERT(table->read_set == &table->def_read_set); + table->read_set= &table->tmp_set; + bitmap_clear_all(table->read_set); + } + } + + /* We have to check values after setup_tables to get covering_keys right in reference tables */ - if (setup_fields(thd, 0, *values, MARK_COLUMNS_READ, 0, 0)) - DBUG_RETURN(1); + int error= setup_fields(thd, 0, *values, MARK_COLUMNS_READ, 0, 0); + + for (table_ref= leaves; table_ref; table_ref= table_ref->next_leaf) + { + TABLE *table= table_ref->table; + if (tables_to_update & table->map) + { + table->read_set= &table->def_read_set; + bitmap_union(table->read_set, &table->tmp_set); + } + } + + if (error) + DBUG_RETURN(1); /* Save tables beeing updated in update_tables @@ -1375,6 +1402,8 @@ int multi_update::prepare(List<Item> ¬_used_values, a row in this table will never be read twice. This is true under the following conditions: + - No column is both written to and read in SET expressions. + - We are doing a table scan and the data is in a separate file (MyISAM) or if we don't update a clustered key. @@ -1389,6 +1418,9 @@ int multi_update::prepare(List<Item> ¬_used_values, WARNING This code is a bit dependent of how make_join_readinfo() works. + The field table->tmp_set is used for keeping track of which fields are + read during evaluation of the SET expression. See multi_update::prepare. + RETURN 0 Not safe to update 1 Safe to update @@ -1409,6 +1441,8 @@ static bool safe_update_on_fly(THD *thd, JOIN_TAB *join_tab, case JT_REF_OR_NULL: return !is_key_used(table, join_tab->ref.key, table->write_set); case JT_ALL: + if (bitmap_is_overlapping(&table->tmp_set, table->write_set)) + return FALSE; /* If range search on index */ if (join_tab->quick) return !join_tab->quick->is_keys_used(table->write_set); @@ -1464,17 +1498,18 @@ multi_update::initialize_tables(JOIN *join) ORDER group; TMP_TABLE_PARAM *tmp_param; - table->mark_columns_needed_for_update(); if (ignore) table->file->extra(HA_EXTRA_IGNORE_DUP_KEY); if (table == main_table) // First table in join { if (safe_update_on_fly(thd, join->join_tab, table_ref, all_tables)) { - table_to_update= main_table; // Update table on the fly + table->mark_columns_needed_for_update(); + table_to_update= table; // Update table on the fly continue; } } + table->mark_columns_needed_for_update(); table->prepare_for_position(); /* @@ -2066,8 +2101,8 @@ bool multi_update::send_eof() id= thd->arg_of_last_insert_id_function ? thd->first_successful_insert_id_in_prev_stmt : 0; - sprintf(buff, ER(ER_UPDATE_INFO), (ulong) found, (ulong) updated, - (ulong) thd->cuted_fields); + my_snprintf(buff, sizeof(buff), ER(ER_UPDATE_INFO), + (ulong) found, (ulong) updated, (ulong) thd->cuted_fields); thd->row_count_func= (thd->client_capabilities & CLIENT_FOUND_ROWS) ? found : updated; ::my_ok(thd, (ulong) thd->row_count_func, id, buff); diff --git a/sql/table.cc b/sql/table.cc index d24ee4c6a27..066bbc953fa 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -779,7 +779,7 @@ static int open_binary_frm(THD *thd, TABLE_SHARE *share, uchar *head, strpos=disk_buff+6; if (!(rec_per_key= (ulong*) alloc_root(&share->mem_root, - sizeof(ulong*)*key_parts))) + sizeof(ulong)*key_parts))) goto err; for (i=0 ; i < keys ; i++, keyinfo++) diff --git a/sql/unireg.cc b/sql/unireg.cc index 51293184ad8..68a352e4a44 100644 --- a/sql/unireg.cc +++ b/sql/unireg.cc @@ -37,8 +37,7 @@ static bool pack_header(uchar *forminfo,enum legacy_db_type table_type, List<Create_field> &create_fields, uint info_length, uint screens, uint table_options, ulong data_offset, handler *file); -static uint get_interval_id(uint *int_count,List<Create_field> &create_fields, - Create_field *last_field); +static uint get_interval_id(uint *,List<Create_field> &, Create_field *); static bool pack_fields(File file, List<Create_field> &create_fields, ulong data_offset); static bool make_empty_rec(THD *thd, int file, enum legacy_db_type table_type, diff --git a/storage/archive/ha_archive.cc b/storage/archive/ha_archive.cc index 5e2a4ad5da3..1146b2eb73a 100644 --- a/storage/archive/ha_archive.cc +++ b/storage/archive/ha_archive.cc @@ -1474,8 +1474,8 @@ int ha_archive::info(uint flag) stats.mean_rec_length= table->s->reclength + buffer.alloced_length(); stats.data_file_length= file_stat.st_size; - stats.create_time= file_stat.st_ctime; - stats.update_time= file_stat.st_mtime; + stats.create_time= (ulong) file_stat.st_ctime; + stats.update_time= (ulong) file_stat.st_mtime; stats.max_data_file_length= share->rows_recorded * stats.mean_rec_length; } stats.delete_length= 0; diff --git a/storage/federated/ha_federated.cc b/storage/federated/ha_federated.cc index 1f4e1ae48b9..2fdf1bc7900 100644 --- a/storage/federated/ha_federated.cc +++ b/storage/federated/ha_federated.cc @@ -2850,10 +2850,10 @@ int ha_federated::info(uint flag) stats.data_file_length= stats.records * stats.mean_rec_length; if (row[12] != NULL) - stats.update_time= (time_t) my_strtoll10(row[12], (char**) 0, + stats.update_time= (ulong) my_strtoll10(row[12], (char**) 0, &error); if (row[13] != NULL) - stats.check_time= (time_t) my_strtoll10(row[13], (char**) 0, + stats.check_time= (ulong) my_strtoll10(row[13], (char**) 0, &error); } /* diff --git a/storage/ibmdb2i/db2i_charsetSupport.cc b/storage/ibmdb2i/db2i_charsetSupport.cc index 2609d42887e..1479776d71a 100644 --- a/storage/ibmdb2i/db2i_charsetSupport.cc +++ b/storage/ibmdb2i/db2i_charsetSupport.cc @@ -129,8 +129,8 @@ struct IconvMap { struct HashKey { - uint16 direction; // This is a uint16 instead of a uchar to avoid garbage data in the key from compiler padding - uint16 db2CCSID; + uint32 direction; // These are uint32s to avoid garbage data in the key from compiler padding + uint32 db2CCSID; const CHARSET_INFO* myCharset; } hashKey; iconv_t iconvDesc; @@ -268,8 +268,15 @@ static int32 getNewTextDesc(const int32 inType, RESULT_INT32); if (unlikely(arguments->base.result.s_int32.r_int32 < 0)) { - getErrTxt(DB2I_ERR_ILECALL,"QlgCvtTextDescToDesc",arguments->base.result.s_int32.r_int32); - DBUG_RETURN(DB2I_ERR_ILECALL); + if (arguments->base.result.s_int32.r_int32 == Qlg_InDescriptorNotFound) + { + DBUG_RETURN(DB2I_ERR_UNSUPP_CHARSET); + } + else + { + getErrTxt(DB2I_ERR_ILECALL,"QlgCvtTextDescToDesc",arguments->base.result.s_int32.r_int32); + DBUG_RETURN(DB2I_ERR_ILECALL); + } } // Store the conversion information into a cache entry @@ -428,8 +435,13 @@ int32 convertIANAToDb2Ccsid(const char* parmIANADesc, uint16* db2Ccsid) int aixEncodingScheme; int db2EncodingScheme; rc = convertTextDesc(Qlg_TypeIANA, Qlg_TypeAS400CCSID, parmIANADesc, aixCcsidString); - if (rc != 0) + if (unlikely(rc)) + { + if (rc == DB2I_ERR_UNSUPP_CHARSET) + getErrTxt(DB2I_ERR_UNSUPP_CHARSET, parmIANADesc); + return rc; + } aixCcsid = atoi(aixCcsidString); rc = getEncodingScheme(aixCcsid, aixEncodingScheme); if (rc != 0) @@ -646,32 +658,38 @@ static int32 openNewConversion(enum_conversionDirection direction, there equivalent iconv descriptions. */ rc = convertTextDesc(Qlg_TypeIANA, Qlg_TypeAix41, mysqlCSName, mysqlAix41Desc); - if (rc) + if (unlikely(rc)) + { + if (rc == DB2I_ERR_UNSUPP_CHARSET) + getErrTxt(DB2I_ERR_UNSUPP_CHARSET, mysqlCSName); + DBUG_RETURN(rc); + } CHARSET_INFO *cs= &my_charset_bin; (uint)(cs->cset->long10_to_str)(cs,db2CcsidString,sizeof(db2CcsidString), 10, db2CCSID); rc = convertTextDesc(Qlg_TypeAS400CCSID, Qlg_TypeAix41, db2CcsidString, db2Aix41Desc); - if (rc) - DBUG_RETURN(rc); + if (unlikely(rc)) + { + if (rc == DB2I_ERR_UNSUPP_CHARSET) + getErrTxt(DB2I_ERR_UNSUPP_CHARSET, mysqlCSName); + + DBUG_RETURN(rc); + } /* Call iconv to open the conversion. */ if (direction == toDB2) { newConversion = iconv_open(db2Aix41Desc, mysqlAix41Desc); - if (newConversion == (iconv_t) -1) - { - getErrTxt(DB2I_ERR_ICONV_OPEN, mysqlAix41Desc, db2Aix41Desc, errno); - DBUG_RETURN(DB2I_ERR_ICONV_OPEN); - } } else { newConversion = iconv_open(mysqlAix41Desc, db2Aix41Desc); - if (newConversion == (iconv_t) -1) - { - getErrTxt(DB2I_ERR_ICONV_OPEN, db2Aix41Desc, mysqlAix41Desc, errno); - DBUG_RETURN(DB2I_ERR_ICONV_OPEN); - } + } + + if (unlikely(newConversion == (iconv_t) -1)) + { + getErrTxt(DB2I_ERR_UNSUPP_CHARSET, mysqlCSName); + DBUG_RETURN(DB2I_ERR_UNSUPP_CHARSET); } /* Insert the new conversion into the cache. */ diff --git a/storage/ibmdb2i/db2i_conversion.cc b/storage/ibmdb2i/db2i_conversion.cc index f746be6ab50..bdb8085d937 100644 --- a/storage/ibmdb2i/db2i_conversion.cc +++ b/storage/ibmdb2i/db2i_conversion.cc @@ -151,7 +151,7 @@ int ha_ibmdb2i::convertFieldChars(enum_conversionDirection direction, if (unlikely(conversion == (iconv_t)(-1))) { - return (DB2I_ERR_ICONV_OPEN); + return (DB2I_ERR_UNSUPP_CHARSET); } size_t initOLen= olen; @@ -670,6 +670,13 @@ int ha_ibmdb2i::getFieldTypeMapping(Field* field, if (rtnCode) return rtnCode; } + + // Check whether there is a character conversion available. + iconv_t temp; + int32 rc = getConversion(toDB2, fieldCharSet, db2Ccsid, temp); + if (unlikely(rc)) + return rc; + sprintf(stringBuildBuffer, " CCSID %d ", db2Ccsid); mapping.append(stringBuildBuffer); } diff --git a/storage/ibmdb2i/db2i_errors.cc b/storage/ibmdb2i/db2i_errors.cc index 43dd539447f..dd50e40e61b 100644 --- a/storage/ibmdb2i/db2i_errors.cc +++ b/storage/ibmdb2i/db2i_errors.cc @@ -52,7 +52,7 @@ static const char* engineErrors[MAX_MSGSTRING] = {"Error opening codeset conversion from %.64s to %.64s (errno = %d)"}, {"Invalid %-.10s name '%-.128s'"}, {"Unsupported move from '%-.128s' to '%-.128s' on RENAME TABLE statement"}, - {"Unsupported schema '%-.128s' specified on RENAME TABLE statement"}, + {"The %-.64s character set is not supported."}, {"Auto_increment is not allowed for a partitioned table"}, {"Character set conversion error due to unknown encoding scheme %d"}, {""}, diff --git a/storage/ibmdb2i/db2i_errors.h b/storage/ibmdb2i/db2i_errors.h index 0f6fbef33f6..b6dd314ef50 100644 --- a/storage/ibmdb2i/db2i_errors.h +++ b/storage/ibmdb2i/db2i_errors.h @@ -54,7 +54,7 @@ enum DB2I_errors DB2I_ERR_ICONV_OPEN, DB2I_ERR_INVALID_NAME, DB2I_ERR_RENAME_MOVE, - DB2I_ERR_RENAME_QTEMP, + DB2I_ERR_UNSUPP_CHARSET, DB2I_ERR_PART_AUTOINC, DB2I_ERR_UNKNOWN_ENCODING, DB2I_ERR_RESERVED, diff --git a/storage/ibmdb2i/ha_ibmdb2i.cc b/storage/ibmdb2i/ha_ibmdb2i.cc index 46c84de4aee..5cf9568be67 100644 --- a/storage/ibmdb2i/ha_ibmdb2i.cc +++ b/storage/ibmdb2i/ha_ibmdb2i.cc @@ -2273,7 +2273,12 @@ int ha_ibmdb2i::create(const char *name, TABLE *table_arg, if (isTemporary) query.append(STRING_WITH_LEN(" ON COMMIT PRESERVE ROWS ")); - + + if (create_info->alias) + generateAndAppendRCDFMT(create_info->alias, query); + else if (((TABLE_LIST*)(thd->lex->select_lex.table_list.first))->table_name) + generateAndAppendRCDFMT((char*)((TABLE_LIST*)(thd->lex->select_lex.table_list.first))->table_name, query); + DBUG_PRINT("ha_ibmdb2i::create", ("Sent to DB2: %s",query.c_ptr())); SqlStatementStream sqlStream(query.length()); sqlStream.addStatement(query,fileSortSequence,fileSortSequenceLibrary); diff --git a/storage/ibmdb2i/ha_ibmdb2i.h b/storage/ibmdb2i/ha_ibmdb2i.h index e90f152919c..2a8d65825bf 100644 --- a/storage/ibmdb2i/ha_ibmdb2i.h +++ b/storage/ibmdb2i/ha_ibmdb2i.h @@ -746,5 +746,56 @@ private: free_root(&conversionBufferMemroot, MYF(0)); } } - + + +/** + Generate a valid RCDFMT name based on the name of the table. + + The RCDFMT name is devised by munging the name of the table, + uppercasing all ascii alpha-numeric characters and replacing all other + characters with underscores until up to ten characters have been generated. + + @param tableName The name of the table, as given on the MySQL + CREATE TABLE statement + @param[out] query The string to receive the generated RCDFMT name +*/ + static void generateAndAppendRCDFMT(const char* tableName, String& query) + { + char rcdfmt[11]; + + // The RCDFMT name must begin with an alpha character. + // We enforce this by skipping to the first alpha character in the table + // name. If no alpha character exists, we use 'X' for the RCDFMT name; + + while (*tableName && + (!my_isascii(*tableName) || + !my_isalpha(system_charset_info, *tableName))) + { + tableName += my_mbcharlen(system_charset_info, *tableName); + } + + if (unlikely(!(*tableName))) + { + rcdfmt[0]= 'X'; + rcdfmt[1]= 0; + } + else + { + int r= 0; + while ((r < sizeof(rcdfmt)-1) && *tableName) + { + if (my_isascii(*tableName) && + my_isalnum(system_charset_info, *tableName)) + rcdfmt[r] = my_toupper(system_charset_info, *tableName); + else + rcdfmt[r] = '_'; + + ++r; + tableName += my_mbcharlen(system_charset_info, *tableName); + } + rcdfmt[r]= 0; + } + query.append(STRING_WITH_LEN(" RCDFMT ")); + query.append(rcdfmt); + } }; diff --git a/storage/innobase/dict/dict0dict.c b/storage/innobase/dict/dict0dict.c index c7a57d6a2b8..8cb196bf983 100644 --- a/storage/innobase/dict/dict0dict.c +++ b/storage/innobase/dict/dict0dict.c @@ -2616,7 +2616,7 @@ scan_more: } else if (quote) { /* Within quotes: do not look for starting quotes or comments. */ - } else if (*sptr == '"' || *sptr == '`') { + } else if (*sptr == '"' || *sptr == '`' || *sptr == '\'') { /* Starting quote: remember the quote character. */ quote = *sptr; } else if (*sptr == '#' @@ -3932,7 +3932,7 @@ dict_table_print_low( (ulong) UT_LIST_GET_LEN(table->indexes), (ulong) table->stat_n_rows); - for (i = 0; i + 1 < (ulint) table->n_cols; i++) { + for (i = 0; i < (ulint) table->n_cols; i++) { dict_col_print_low(table, dict_table_get_nth_col(table, i)); fputs("; ", stderr); } diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index e9c3f62c9dc..56e28cf5f14 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -101,6 +101,7 @@ static long innobase_mirrored_log_groups, innobase_log_files_in_group, innobase_additional_mem_pool_size, innobase_file_io_threads, innobase_lock_wait_timeout, innobase_force_recovery, innobase_open_files, innobase_autoinc_lock_mode; +static ulong innobase_commit_concurrency = 0; static long long innobase_buffer_pool_size, innobase_log_file_size; @@ -165,6 +166,38 @@ static handler *innobase_create_handler(handlerton *hton, static const char innobase_hton_name[]= "InnoDB"; +/***************************************************************** +Check for a valid value of innobase_commit_concurrency. */ +static +int +innobase_commit_concurrency_validate( +/*=================================*/ + /* out: 0 for valid + innodb_commit_concurrency */ + THD* thd, /* in: thread handle */ + struct st_mysql_sys_var* var, /* in: pointer to system + variable */ + void* save, /* out: immediate result + for update function */ + struct st_mysql_value* value) /* in: incoming string */ +{ + long long intbuf; + ulong commit_concurrency; + + DBUG_ENTER("innobase_commit_concurrency_validate"); + + if (value->val_int(value, &intbuf)) { + /* The value is NULL. That is invalid. */ + DBUG_RETURN(1); + } + + *reinterpret_cast<ulong*>(save) = commit_concurrency + = static_cast<ulong>(intbuf); + + /* Allow the value to be updated, as long as it remains zero + or nonzero. */ + DBUG_RETURN(!(!commit_concurrency == !innobase_commit_concurrency)); +} static MYSQL_THDVAR_BOOL(support_xa, PLUGIN_VAR_OPCMDARG, "Enable InnoDB support for the XA two-phase commit", @@ -1951,11 +1984,11 @@ innobase_commit( Note, the position is current because of prepare_commit_mutex */ retry: - if (srv_commit_concurrency > 0) { + if (innobase_commit_concurrency > 0) { pthread_mutex_lock(&commit_cond_m); commit_threads++; - if (commit_threads > srv_commit_concurrency) { + if (commit_threads > innobase_commit_concurrency) { commit_threads--; pthread_cond_wait(&commit_cond, &commit_cond_m); @@ -1972,7 +2005,7 @@ retry: innobase_commit_low(trx); - if (srv_commit_concurrency > 0) { + if (innobase_commit_concurrency > 0) { pthread_mutex_lock(&commit_cond_m); commit_threads--; pthread_cond_signal(&commit_cond); @@ -6012,7 +6045,7 @@ ha_innobase::info( nor the CHECK TABLE time, nor the UPDATE or INSERT time. */ if (os_file_get_status(path,&stat_info)) { - stats.create_time = stat_info.ctime; + stats.create_time = (ulong) stat_info.ctime; } } @@ -8289,10 +8322,10 @@ static MYSQL_SYSVAR_LONGLONG(buffer_pool_size, innobase_buffer_pool_size, "The size of the memory buffer InnoDB uses to cache data and indexes of its tables.", NULL, NULL, 8*1024*1024L, 1024*1024L, LONGLONG_MAX, 1024*1024L); -static MYSQL_SYSVAR_ULONG(commit_concurrency, srv_commit_concurrency, +static MYSQL_SYSVAR_ULONG(commit_concurrency, innobase_commit_concurrency, PLUGIN_VAR_RQCMDARG, "Helps in performance tuning in heavily concurrent environments.", - NULL, NULL, 0, 0, 1000, 0); + innobase_commit_concurrency_validate, NULL, 0, 0, 1000, 0); static MYSQL_SYSVAR_ULONG(concurrency_tickets, srv_n_free_tickets_to_enter, PLUGIN_VAR_RQCMDARG, diff --git a/storage/innobase/include/srv0srv.h b/storage/innobase/include/srv0srv.h index 9ff3c225eb0..67144a41d3d 100644 --- a/storage/innobase/include/srv0srv.h +++ b/storage/innobase/include/srv0srv.h @@ -109,7 +109,6 @@ extern ulint srv_max_dirty_pages_pct; extern ulint srv_force_recovery; extern ulong srv_thread_concurrency; -extern ulong srv_commit_concurrency; extern ulint srv_max_n_threads; diff --git a/storage/innobase/page/page0cur.c b/storage/innobase/page/page0cur.c index 70b7de194fd..ea011843890 100644 --- a/storage/innobase/page/page0cur.c +++ b/storage/innobase/page/page0cur.c @@ -538,7 +538,7 @@ page_cur_open_on_rnd_user_rec( rnd = page_rnd % page_get_n_recs(page); } else { - rnd = (ulint) page_cur_lcg_prng() % page_get_n_recs(page); + rnd = (ulint) (page_cur_lcg_prng() % page_get_n_recs(page)); } rec = page_get_infimum_rec(page); diff --git a/storage/innobase/srv/srv0srv.c b/storage/innobase/srv/srv0srv.c index b8b63052394..71e74ab848b 100644 --- a/storage/innobase/srv/srv0srv.c +++ b/storage/innobase/srv/srv0srv.c @@ -285,7 +285,6 @@ computer. Bigger computers need bigger values. Value 0 will disable the concurrency check. */ ulong srv_thread_concurrency = 0; -ulong srv_commit_concurrency = 0; os_fast_mutex_t srv_conc_mutex; /* this mutex protects srv_conc data structures */ diff --git a/storage/myisam/ha_myisam.cc b/storage/myisam/ha_myisam.cc index e82246638ff..cf290e2018a 100644 --- a/storage/myisam/ha_myisam.cc +++ b/storage/myisam/ha_myisam.cc @@ -1784,7 +1784,7 @@ int ha_myisam::info(uint flag) stats.data_file_length= misam_info.data_file_length; stats.index_file_length= misam_info.index_file_length; stats.delete_length= misam_info.delete_length; - stats.check_time= misam_info.check_time; + stats.check_time= (ulong) misam_info.check_time; stats.mean_rec_length= misam_info.mean_reclength; } if (flag & HA_STATUS_CONST) @@ -1792,7 +1792,7 @@ int ha_myisam::info(uint flag) TABLE_SHARE *share= table->s; stats.max_data_file_length= misam_info.max_data_file_length; stats.max_index_file_length= misam_info.max_index_file_length; - stats.create_time= misam_info.create_time; + stats.create_time= (ulong) misam_info.create_time; ref_length= misam_info.reflength; share->db_options_in_use= misam_info.options; stats.block_size= myisam_block_size; /* record block size */ @@ -1807,7 +1807,7 @@ int ha_myisam::info(uint flag) if (share->key_parts) memcpy((char*) table->key_info[0].rec_per_key, (char*) misam_info.rec_per_key, - sizeof(table->key_info[0].rec_per_key[0])*share->key_parts); + sizeof(table->key_info[0].rec_per_key[0])*share->key_parts); if (share->tmp_table == NO_TMP_TABLE) pthread_mutex_unlock(&share->mutex); @@ -1831,7 +1831,7 @@ int ha_myisam::info(uint flag) my_store_ptr(dup_ref, ref_length, misam_info.dupp_key_pos); } if (flag & HA_STATUS_TIME) - stats.update_time = misam_info.update_time; + stats.update_time = (ulong) misam_info.update_time; if (flag & HA_STATUS_AUTO) stats.auto_increment_value= misam_info.auto_increment; diff --git a/storage/myisam/myisamchk.c b/storage/myisam/myisamchk.c index ac0be2f01cc..75678375ce7 100644 --- a/storage/myisam/myisamchk.c +++ b/storage/myisam/myisamchk.c @@ -287,8 +287,8 @@ static struct my_option my_long_options[] = 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, { "key_buffer_size", OPT_KEY_BUFFER_SIZE, "", (uchar**) &check_param.use_buffers, (uchar**) &check_param.use_buffers, 0, - GET_ULONG, REQUIRED_ARG, (long) USE_BUFFER_INIT, (long) MALLOC_OVERHEAD, - (long) ~0L, (long) MALLOC_OVERHEAD, (long) IO_SIZE, 0}, + GET_ULL, REQUIRED_ARG, USE_BUFFER_INIT, MALLOC_OVERHEAD, + SIZE_T_MAX, MALLOC_OVERHEAD, IO_SIZE, 0}, { "key_cache_block_size", OPT_KEY_CACHE_BLOCK_SIZE, "", (uchar**) &opt_key_cache_block_size, (uchar**) &opt_key_cache_block_size, 0, @@ -1102,7 +1102,7 @@ static int myisamchk(MI_CHECK *param, char * filename) { if (param->testflag & (T_EXTEND | T_MEDIUM)) VOID(init_key_cache(dflt_key_cache,opt_key_cache_block_size, - param->use_buffers, 0, 0)); + (size_t) param->use_buffers, 0, 0)); VOID(init_io_cache(¶m->read_cache,datafile, (uint) param->read_buffer_length, READ_CACHE, @@ -1525,8 +1525,8 @@ static int mi_sort_records(MI_CHECK *param, if (share->state.key_root[sort_key] == HA_OFFSET_ERROR) DBUG_RETURN(0); /* Nothing to do */ - init_key_cache(dflt_key_cache, opt_key_cache_block_size, param->use_buffers, - 0, 0); + init_key_cache(dflt_key_cache, opt_key_cache_block_size, + (size_t) param->use_buffers, 0, 0); if (init_io_cache(&info->rec_cache,-1,(uint) param->write_buffer_length, WRITE_CACHE,share->pack.header_length,1, MYF(MY_WME | MY_WAIT_IF_FULL))) diff --git a/storage/myisammrg/ha_myisammrg.cc b/storage/myisammrg/ha_myisammrg.cc index 7e25309ae70..1e82983b97c 100644 --- a/storage/myisammrg/ha_myisammrg.cc +++ b/storage/myisammrg/ha_myisammrg.cc @@ -925,11 +925,11 @@ int ha_myisammrg::info(uint flag) with such a number, it'll be an error later anyway. */ bzero((char*) table->key_info[0].rec_per_key, - sizeof(table->key_info[0].rec_per_key) * table->s->key_parts); + sizeof(table->key_info[0].rec_per_key[0]) * table->s->key_parts); #endif memcpy((char*) table->key_info[0].rec_per_key, (char*) mrg_info.rec_per_key, - sizeof(table->key_info[0].rec_per_key) * + sizeof(table->key_info[0].rec_per_key[0]) * min(file->keys, table->s->key_parts)); } } diff --git a/storage/ndb/src/kernel/blocks/backup/read.cpp b/storage/ndb/src/kernel/blocks/backup/read.cpp index 8f4d0485f0e..78f6f2f1b50 100644 --- a/storage/ndb/src/kernel/blocks/backup/read.cpp +++ b/storage/ndb/src/kernel/blocks/backup/read.cpp @@ -50,7 +50,7 @@ main(int argc, const char * argv[]){ ndb_init(); if(argc <= 1){ - printf("Usage: %s <filename>", argv[0]); + printf("Usage: %s <filename>\n", argv[0]); exit(1); } FILE * f = fopen(argv[1], "rb"); diff --git a/strings/ctype-cp932.c b/strings/ctype-cp932.c index c1aba0b35c6..07191c436b7 100644 --- a/strings/ctype-cp932.c +++ b/strings/ctype-cp932.c @@ -5489,10 +5489,10 @@ static MY_CHARSET_HANDLER my_charset_handler= my_mb_wc_cp932, /* mb_wc */ my_wc_mb_cp932, /* wc_mb */ my_mb_ctype_mb, - my_caseup_str_8bit, - my_casedn_str_8bit, - my_caseup_8bit, - my_casedn_8bit, + my_caseup_str_mb, + my_casedn_str_mb, + my_caseup_mb, + my_casedn_mb, my_snprintf_8bit, my_long10_to_str_8bit, my_longlong10_to_str_8bit, diff --git a/strings/ctype-sjis.c b/strings/ctype-sjis.c index 3925b76869c..ac426e0d7b5 100644 --- a/strings/ctype-sjis.c +++ b/strings/ctype-sjis.c @@ -4650,10 +4650,10 @@ static MY_CHARSET_HANDLER my_charset_handler= my_mb_wc_sjis, /* mb_wc */ my_wc_mb_sjis, /* wc_mb */ my_mb_ctype_mb, - my_caseup_str_8bit, - my_casedn_str_8bit, - my_caseup_8bit, - my_casedn_8bit, + my_caseup_str_mb, + my_casedn_str_mb, + my_caseup_mb, + my_casedn_mb, my_snprintf_8bit, my_long10_to_str_8bit, my_longlong10_to_str_8bit, diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c index 6025063846a..b836293442a 100644 --- a/tests/mysql_client_test.c +++ b/tests/mysql_client_test.c @@ -103,7 +103,7 @@ if (!opt_silent) \ static void print_error(const char *msg); static void print_st_error(MYSQL_STMT *stmt, const char *msg); -static void client_disconnect(void); +static void client_disconnect(MYSQL* mysql, my_bool drop_db); /* @@ -271,10 +271,20 @@ mysql_simple_prepare(MYSQL *mysql_arg, const char *query) } -/* Connect to the server */ - -static void client_connect(ulong flag) +/** + Connect to the server with options given by arguments to this application, + stored in global variables opt_host, opt_user, opt_password, opt_db, + opt_port and opt_unix_socket. + + @param flag[in] client_flag passed on to mysql_real_connect + @param protocol[in] MYSQL_PROTOCOL_* to use for this connection + @param auto_reconnect[in] set to 1 for auto reconnect + + @return pointer to initialized and connected MYSQL object +*/ +static MYSQL* client_connect(ulong flag, uint protocol, my_bool auto_reconnect) { + MYSQL* mysql; int rc; static char query[MAX_TEST_QUERY_LENGTH]; myheader_r("client_connect"); @@ -291,6 +301,7 @@ static void client_connect(ulong flag) } /* enable local infile, in non-binary builds often disabled by default */ mysql_options(mysql, MYSQL_OPT_LOCAL_INFILE, 0); + mysql_options(mysql, MYSQL_OPT_PROTOCOL, &protocol); if (!(mysql_real_connect(mysql, opt_host, opt_user, opt_password, opt_db ? opt_db:"test", opt_port, @@ -302,7 +313,7 @@ static void client_connect(ulong flag) fprintf(stdout, "\n Check the connection options using --help or -?\n"); exit(1); } - mysql->reconnect= 1; + mysql->reconnect= auto_reconnect; if (!opt_silent) fprintf(stdout, "OK"); @@ -329,12 +340,14 @@ static void client_connect(ulong flag) if (!opt_silent) fprintf(stdout, "OK"); + + return mysql; } /* Close the connection */ -static void client_disconnect() +static void client_disconnect(MYSQL* mysql, my_bool drop_db) { static char query[MAX_TEST_QUERY_LENGTH]; @@ -342,13 +355,16 @@ static void client_disconnect() if (mysql) { - if (!opt_silent) - fprintf(stdout, "\n dropping the test database '%s' ...", current_db); - strxmov(query, "DROP DATABASE IF EXISTS ", current_db, NullS); + if (drop_db) + { + if (!opt_silent) + fprintf(stdout, "\n dropping the test database '%s' ...", current_db); + strxmov(query, "DROP DATABASE IF EXISTS ", current_db, NullS); - mysql_query(mysql, query); - if (!opt_silent) - fprintf(stdout, "OK"); + mysql_query(mysql, query); + if (!opt_silent) + fprintf(stdout, "OK"); + } if (!opt_silent) fprintf(stdout, "\n closing the connection ..."); @@ -2464,6 +2480,9 @@ static void test_ps_query_cache() myheader("test_ps_query_cache"); + rc= mysql_query(mysql, "SET SQL_MODE=''"); + myquery(rc); + /* prepare the table */ rc= mysql_query(mysql, "drop table if exists t1"); @@ -2506,6 +2525,9 @@ static void test_ps_query_cache() mysql_close(lmysql); DIE_UNLESS(0); } + rc= mysql_query(lmysql, "SET SQL_MODE=''"); + myquery(rc); + if (!opt_silent) fprintf(stdout, "OK"); } @@ -4240,6 +4262,10 @@ static void test_fetch_date() myheader("test_fetch_date"); + /* Will not work if sql_mode is NO_ZERO_DATE (implicit if TRADITIONAL) /*/ + rc= mysql_query(mysql, "SET SQL_MODE=''"); + myquery(rc); + rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_bind_result"); myquery(rc); @@ -4954,6 +4980,9 @@ static void test_stmt_close() /* set AUTOCOMMIT to ON*/ mysql_autocommit(lmysql, TRUE); + rc= mysql_query(lmysql, "SET SQL_MODE = ''"); + myquery(rc); + rc= mysql_query(lmysql, "DROP TABLE IF EXISTS test_stmt_close"); myquery(rc); @@ -12088,6 +12117,9 @@ static void test_bug6058() myheader("test_bug6058"); + rc= mysql_query(mysql, "SET SQL_MODE=''"); + myquery(rc); + stmt_text= "SELECT CAST('0000-00-00' AS DATE)"; rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text)); @@ -13303,6 +13335,9 @@ static void test_bug8378() if (!opt_silent) fprintf(stdout, "OK"); + rc= mysql_query(lmysql, "SET SQL_MODE=''"); + myquery(rc); + len= mysql_real_escape_string(lmysql, out, TEST_BUG8378_IN, 4); /* No escaping should have actually happened. */ @@ -16390,12 +16425,27 @@ static void test_change_user() myquery(rc); sprintf(buff, + "grant select on %s.* to %s@'localhost' identified by '%s'", + db, + user_pw, + pw); + rc= mysql_query(mysql, buff); + myquery(rc); + + sprintf(buff, "grant select on %s.* to %s@'%%'", db, user_no_pw); rc= mysql_query(mysql, buff); myquery(rc); + sprintf(buff, + "grant select on %s.* to %s@'localhost'", + db, + user_no_pw); + rc= mysql_query(mysql, buff); + myquery(rc); + /* Try some combinations */ rc= mysql_change_user(mysql, NULL, NULL, NULL); @@ -16552,6 +16602,14 @@ static void test_change_user() rc= mysql_query(mysql, buff); myquery(rc); + sprintf(buff, "drop user %s@'localhost'", user_pw); + rc= mysql_query(mysql, buff); + myquery(rc); + + sprintf(buff, "drop user %s@'localhost'", user_no_pw); + rc= mysql_query(mysql, buff); + myquery(rc); + DBUG_VOID_RETURN; } @@ -17220,6 +17278,11 @@ static void test_bug31669() rc= mysql_query(mysql, query); myquery(rc); + strxmov(query, "GRANT ALL PRIVILEGES ON *.* TO '", user, "'@'localhost' IDENTIFIED BY " + "'", buff, "' WITH GRANT OPTION", NullS); + rc= mysql_query(mysql, query); + myquery(rc); + rc= mysql_query(mysql, "FLUSH PRIVILEGES"); myquery(rc); @@ -17257,7 +17320,7 @@ static void test_bug31669() strxmov(query, "DELETE FROM mysql.user WHERE User='", user, "'", NullS); rc= mysql_query(mysql, query); myquery(rc); - DIE_UNLESS(mysql_affected_rows(mysql) == 1); + DIE_UNLESS(mysql_affected_rows(mysql) == 2); #endif DBUG_VOID_RETURN; @@ -17469,6 +17532,9 @@ static void test_wl4166_2() myheader("test_wl4166_2"); + rc= mysql_query(mysql, "SET SQL_MODE=''"); + myquery(rc); + rc= mysql_query(mysql, "drop table if exists t1"); myquery(rc); rc= mysql_query(mysql, "create table t1 (c_int int, d_date date)"); @@ -17663,6 +17729,100 @@ static void test_bug40365(void) /** + Subtest for Bug#43560. Verifies that a loss of connection on the server side + is handled well by the mysql_stmt_execute() call, i.e., no SIGSEGV due to + a vio socket that is cleared upon closed connection. + + Assumes the presence of the close_conn_after_stmt_execute debug feature in + the server. Verifies that it is connected to a debug server before proceeding + with the test. + */ +static void test_bug43560(void) +{ + MYSQL* conn; + uint rc; + MYSQL_STMT *stmt= 0; + MYSQL_BIND bind; + my_bool is_null= 0; + char buffer[256]; + const uint BUFSIZE= sizeof(buffer); + const char* values[] = {"eins", "zwei", "drei", "viele", NULL}; + const char insert_str[] = "INSERT INTO t1 (c2) VALUES (?)"; + unsigned long length; + + DBUG_ENTER("test_bug43560"); + myheader("test_bug43560"); + + /* Make sure we only run against a debug server. */ + if (!strstr(mysql->server_version, "debug")) + { + fprintf(stdout, "Skipping test_bug43560: server not DEBUG version\n"); + DBUG_VOID_RETURN; + } + + /* + Set up a separate connection for this test to avoid messing up the + general MYSQL object used in other subtests. Use TCP protocol to avoid + problems with the buffer semantics of AF_UNIX, and turn off auto reconnect. + */ + conn= client_connect(0, MYSQL_PROTOCOL_TCP, 0); + + rc= mysql_query(conn, "DROP TABLE IF EXISTS t1"); + myquery(rc); + rc= mysql_query(conn, + "CREATE TABLE t1 (c1 INT PRIMARY KEY AUTO_INCREMENT, c2 CHAR(10))"); + myquery(rc); + + stmt= mysql_stmt_init(conn); + check_stmt(stmt); + rc= mysql_stmt_prepare(stmt, insert_str, strlen(insert_str)); + check_execute(stmt, rc); + + bind.buffer_type= MYSQL_TYPE_STRING; + bind.buffer_length= BUFSIZE; + bind.buffer= buffer; + bind.is_null= &is_null; + bind.length= &length; + rc= mysql_stmt_bind_param(stmt, &bind); + check_execute(stmt, rc); + + /* First execute; should succeed. */ + strncpy(buffer, values[0], BUFSIZE); + length= strlen(buffer); + rc= mysql_stmt_execute(stmt); + check_execute(stmt, rc); + + /* + Set up the server to close this session's server-side socket after + next execution of prep statement. + */ + rc= mysql_query(conn,"SET SESSION debug='+d,close_conn_after_stmt_execute'"); + myquery(rc); + + /* Second execute; should fail due to socket closed during execution. */ + strncpy(buffer, values[1], BUFSIZE); + length= strlen(buffer); + rc= mysql_stmt_execute(stmt); + DIE_UNLESS(rc && mysql_stmt_errno(stmt) == CR_SERVER_LOST); + + /* + Third execute; should fail (connection already closed), or SIGSEGV in + case of a Bug#43560 type regression in which case the whole test fails. + */ + strncpy(buffer, values[2], BUFSIZE); + length= strlen(buffer); + rc= mysql_stmt_execute(stmt); + DIE_UNLESS(rc && mysql_stmt_errno(stmt) == CR_SERVER_LOST); + + client_disconnect(conn, 0); + rc= mysql_query(mysql, "DROP TABLE t1"); + myquery(rc); + + DBUG_VOID_RETURN; +} + + +/** Bug#36326: nested transaction and select */ @@ -18090,6 +18250,7 @@ static struct my_tests_st my_tests[]= { { "test_wl4166_2", test_wl4166_2 }, { "test_bug38486", test_bug38486 }, { "test_bug40365", test_bug40365 }, + { "test_bug43560", test_bug43560 }, #ifdef HAVE_QUERY_CACHE { "test_bug36326", test_bug36326 }, #endif @@ -18218,7 +18379,8 @@ int main(int argc, char **argv) (char**) embedded_server_groups)) DIE("Can't initialize MySQL server"); - client_connect(0); /* connect to server */ + /* connect to server with no flags, default protocol, auto reconnect true */ + mysql= client_connect(0, MYSQL_PROTOCOL_DEFAULT, 1); total_time= 0; for (iter_count= 1; iter_count <= opt_count; iter_count++) @@ -18248,7 +18410,7 @@ int main(int argc, char **argv) fprintf(stderr, "\n\nGiven test not found: '%s'\n", *argv); fprintf(stderr, "See legal test names with %s -T\n\nAborting!\n", my_progname); - client_disconnect(); + client_disconnect(mysql, 1); free_defaults(defaults_argv); exit(1); } @@ -18261,7 +18423,7 @@ int main(int argc, char **argv) /* End of tests */ } - client_disconnect(); /* disconnect from server */ + client_disconnect(mysql, 1); /* disconnect from server */ free_defaults(defaults_argv); print_test_output(); |