From 69ffc06610136c45d79f5e430373ee9ce4c78cb5 Mon Sep 17 00:00:00 2001 From: Michael Widenius Date: Sat, 11 Jun 2011 14:28:15 +0300 Subject: [PATCH 01/14] Fixes BUG#60976 "Crash, valgrind warning and memory leak with partitioned archive tables" Noted that there was no memory leak, just a lot of used partitioned tables. Fixed old bug: 'show status' now shows memory usage when compiled with safemalloc. Added option --flush to mysqlcheck.c to run a 'flush tables' between each check to keep down memory usage. Changed '--safemalloc' options to mysqld so that one can use --safemalloc and --skip-safemalloc. Now skip-safemalloc is default (ie, we only do checking of memory overrun during free()) to speed up tests. client/client_priv.h: Added OPT_FLUSH_TABLES client/mysqlcheck.c: Added option --flush to mysqlcheck.c to run a 'flush tables' between each check to keep down memory usage. mysql-test/mysql-test-run.pl: Always run tests with --loose-skip-safemysqld for higher speed sql/mysqld.cc: Changed '--safemalloc' options so that one can use --safemalloc and --skip-safemalloc. Now skip-safemalloc is default (ie, we only do checking of memory overrun during free()) to speed up tests sql/sql_parse.cc: Fixed old bug: 'show status' now shows memory usage when compiled with safemalloc. storage/archive/archive_reader.c: Changed all malloc() calls to use my_malloc()/my_free() Added checks of malloc() calls. storage/archive/ha_archive.cc: Detect failure if init_archive_reader() and return errno. This fixed assert crash in my_seek(). Changed all malloc() calls to use my_malloc()/my_free() --- client/client_priv.h | 1 + client/mysqlcheck.c | 30 +++++++++++++++++++++++++----- mysql-test/mysql-test-run.pl | 3 +-- sql/ha_partition.cc | 2 +- sql/mysqld.cc | 23 ++++++++++------------- sql/sql_parse.cc | 2 +- storage/archive/archive_reader.c | 20 ++++++++++++-------- storage/archive/ha_archive.cc | 22 ++++++++++++++-------- 8 files changed, 65 insertions(+), 38 deletions(-) diff --git a/client/client_priv.h b/client/client_priv.h index 28edba5f8b2..fe9081c4b91 100644 --- a/client/client_priv.h +++ b/client/client_priv.h @@ -60,6 +60,7 @@ enum options_client OPT_OPEN_FILES_LIMIT, OPT_SET_CHARSET, OPT_SERVER_ARG, OPT_POSITION, OPT_STOP_POSITION, OPT_START_DATETIME, OPT_STOP_DATETIME, OPT_SIGINT_IGNORE, OPT_HEXBLOB, OPT_ORDER_BY_PRIMARY, OPT_COUNT, + OPT_FLUSH_TABLES, #ifdef HAVE_NDBCLUSTER_DB OPT_NDBCLUSTER, OPT_NDB_CONNECTSTRING, #endif diff --git a/client/mysqlcheck.c b/client/mysqlcheck.c index 14e02bbb328..22f4b70ed81 100644 --- a/client/mysqlcheck.c +++ b/client/mysqlcheck.c @@ -16,7 +16,7 @@ /* By Jani Tolonen, 2001-04-20, MySQL Development Team */ -#define CHECK_VERSION "2.6.0" +#define CHECK_VERSION "2.7.0" #include "client_priv.h" #include @@ -35,8 +35,8 @@ static my_bool opt_alldbs = 0, opt_check_only_changed = 0, opt_extended = 0, opt_medium_check = 0, opt_quick = 0, opt_all_in_1 = 0, opt_silent = 0, opt_auto_repair = 0, ignore_errors = 0, tty_password= 0, opt_frm= 0, debug_info_flag= 0, debug_check_flag= 0, - opt_fix_table_names= 0, opt_fix_db_names= 0, opt_upgrade= 0, - opt_write_binlog= 1; + opt_fix_table_names= 0, opt_fix_db_names= 0, opt_upgrade= 0; +static my_bool opt_write_binlog= 1, opt_flush_tables= 0; static uint verbose = 0, opt_mysql_port=0; static int my_end_arg; static char * opt_mysql_unix_port = 0; @@ -121,6 +121,9 @@ static struct my_option my_long_options[] = "If you are using this option with CHECK TABLE, it will ensure that the table is 100 percent consistent, but will take a long time. If you are using this option with REPAIR TABLE, it will force using old slow repair with keycache method, instead of much faster repair by sorting.", &opt_extended, &opt_extended, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, + {"flush", OPT_FLUSH_TABLES, "Flush each table after check. This is useful if you don't want to have the checked tables take up space in the caches after the check", + &opt_flush_tables, &opt_flush_tables, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, + 0, 0 }, {"help", '?', "Display this help message and exit.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, {"host",'h', "Connect to host.", ¤t_host, @@ -685,6 +688,7 @@ static int disable_binlog() static int handle_request_for_tables(char *tables, uint length) { char *query, *end, options[100], message[100]; + char table_name_buff[NAME_CHAR_LEN*2*2+1], *table_name; uint query_length= 0; const char *op = 0; @@ -723,13 +727,17 @@ static int handle_request_for_tables(char *tables, uint length) /* No backticks here as we added them before */ query_length= my_sprintf(query, (query, "%s TABLE %s %s", op, tables, options)); + table_name= tables; } else { - char *ptr; + char *ptr, *org; - ptr= strmov(strmov(query, op), " TABLE "); + org= ptr= strmov(strmov(query, op), " TABLE "); ptr= fix_table_name(ptr, tables); + strmake(table_name_buff, org, min((int) sizeof(table_name_buff)-1, + (int) (ptr - org))); + table_name= table_name_buff; ptr= strxmov(ptr, " ", options, NullS); query_length= (uint) (ptr - query); } @@ -737,9 +745,21 @@ static int handle_request_for_tables(char *tables, uint length) { sprintf(message, "when executing '%s TABLE ... %s'", op, options); DBerror(sock, message); + my_free(query, MYF(0)); return 1; } print_result(); + if (opt_flush_tables) + { + query_length= my_sprintf(query, + (query, "FLUSH TABLES %s", table_name)); + if (mysql_real_query(sock, query, query_length)) + { + DBerror(sock, query); + my_free(query, MYF(0)); + return 1; + } + } my_free(query, MYF(0)); return 0; } diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index b91f4f12d73..8d11abc8a37 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -4943,14 +4943,13 @@ sub mysqld_arguments ($$$) { if ( $opt_valgrind_mysqld ) { - mtr_add_arg($args, "--skip-safemalloc"); - if ( $mysql_version_id < 50100 ) { mtr_add_arg($args, "--skip-bdb"); } } + mtr_add_arg($args, "--loose-skip-safemalloc"); mtr_add_arg($args, "%s--disable-sync-frm"); if (!using_extern() and $mysql_version_id >= 50106 && !$opt_user_args) diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc index 9e39c8eec8b..406d20f073d 100644 --- a/sql/ha_partition.cc +++ b/sql/ha_partition.cc @@ -2456,7 +2456,7 @@ bool ha_partition::read_par_file(const char *name) fn_format(buff, name, "", ha_par_ext, MY_APPEND_EXT); /* Following could be done with my_stat to read in whole file */ - if ((file= my_open(buff, O_RDONLY | O_SHARE, MYF(0))) < 0) + if ((file= my_open(buff, O_RDONLY | O_SHARE, MYF(MY_WME))) < 0) DBUG_RETURN(true); if (my_read(file, (uchar *) & buff[0], PAR_WORD_SIZE, MYF(MY_NABP))) goto err1; diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 3fee65fe963..2a5ce27d649 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -427,7 +427,7 @@ static bool volatile ready_to_exit; static my_bool opt_debugging= 0, opt_external_locking= 0, opt_console= 0; static my_bool opt_short_log_format= 0; static my_bool opt_ignore_wrong_options= 0, opt_expect_abort= 0; -static my_bool opt_sync= 0; +static my_bool opt_sync= 0, sf_malloc_trough_check= 0; static uint kill_cached_threads, wake_thread; ulong thread_created; uint thread_handling; @@ -5944,7 +5944,7 @@ enum options_mysqld OPT_NDB_REPORT_THRESH_BINLOG_EPOCH_SLIP, OPT_NDB_REPORT_THRESH_BINLOG_MEM_USAGE, OPT_NDB_USE_COPYING_ALTER_TABLE, - OPT_SKIP_SAFEMALLOC, OPT_MUTEX_DEADLOCK_DETECTOR, + OPT_SAFEMALLOC, OPT_MUTEX_DEADLOCK_DETECTOR, OPT_TEMP_POOL, OPT_TX_ISOLATION, OPT_COMPLETION_TYPE, OPT_SKIP_SYMLINKS, OPT_MAX_BINLOG_DUMP_EVENTS, OPT_SPORADIC_BINLOG_DUMP_FAIL, @@ -6898,12 +6898,11 @@ each time the SQL thread starts.", {"skip-networking", OPT_SKIP_NETWORKING, "Don't allow connection with TCP/IP.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, -#ifndef DBUG_OFF -#ifdef SAFEMALLOC - {"skip-safemalloc", OPT_SKIP_SAFEMALLOC, - "Don't use the memory allocation checking.", 0, 0, 0, GET_NO_ARG, NO_ARG, - 0, 0, 0, 0, 0, 0}, -#endif +#if !defined(DBUG_OFF) && defined(SAFEMALLOC) + {"safemalloc", OPT_SAFEMALLOC, + "Check all memory allocation for every malloc/free call.", + &sf_malloc_trough_check, &sf_malloc_trough_check, 0, + GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, #endif {"skip-show-database", OPT_SKIP_SHOW_DB, "Don't allow 'SHOW DATABASE' commands.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, @@ -9238,11 +9237,6 @@ mysqld_get_one_option(int optid, } strmake(ft_boolean_syntax, argument, sizeof(ft_boolean_syntax)-1); break; - case OPT_SKIP_SAFEMALLOC: -#ifdef SAFEMALLOC - sf_malloc_quick=1; -#endif - break; case OPT_LOWER_CASE_TABLE_NAMES: lower_case_table_names= argument ? atoi(argument) : 1; lower_case_table_names_used= 1; @@ -9436,6 +9430,9 @@ static int get_options(int *argc,char **argv) &global_system_variables.datetime_format)) return 1; +#ifdef SAFEMALLOC + sf_malloc_quick= !sf_malloc_trough_check; +#endif #ifdef EMBEDDED_LIBRARY one_thread_scheduler(&thread_scheduler); one_thread_scheduler(&extra_thread_scheduler); diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index e8b94d11cd2..e4169b1da62 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -1540,7 +1540,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd, { char *end= buff + length; length+= my_snprintf(end, buff_len - length - 1, - end," Memory in use: %ldK Max memory used: %ldK", + " Memory in use: %ldK Max memory used: %ldK", (sf_malloc_cur_memory+1023L)/1024L, (sf_malloc_max_memory+1023L)/1024L); } diff --git a/storage/archive/archive_reader.c b/storage/archive/archive_reader.c index 0cf795cefdf..90220f26f6d 100644 --- a/storage/archive/archive_reader.c +++ b/storage/archive/archive_reader.c @@ -93,12 +93,16 @@ int main(int argc, char *argv[]) printf("\tFRM length %u\n", reader_handle.frm_length); if (reader_handle.comment_start_pos) { - char *comment = - (char *) malloc(sizeof(char) * reader_handle.comment_length); - azread_comment(&reader_handle, comment); - printf("\tComment length %u\n\t\t%.*s\n", reader_handle.comment_length, - reader_handle.comment_length, comment); - free(comment); + char *comment = (char *) my_malloc(reader_handle.comment_length, + MYF(MY_WME)); + if (comment) + { + azread_comment(&reader_handle, comment); + printf("\tComment length %u\n\t\t%.*s\n", + reader_handle.comment_length, + reader_handle.comment_length, comment); + my_free(comment,MYF(0)); + } } } else @@ -180,7 +184,7 @@ int main(int argc, char *argv[]) azio_stream writer_handle; - buffer= (char *)malloc(reader_handle.longest_row); + buffer= (char *) my_malloc(reader_handle.longest_row, MYF(0)); if (buffer == NULL) { printf("Could not allocate memory for row %llu\n", row_count); @@ -251,7 +255,7 @@ int main(int argc, char *argv[]) break; } - free(buffer); + my_free(buffer, MYF(0)); azclose(&writer_handle); } diff --git a/storage/archive/ha_archive.cc b/storage/archive/ha_archive.cc index d70de0dd13c..730d5b95abb 100644 --- a/storage/archive/ha_archive.cc +++ b/storage/archive/ha_archive.cc @@ -835,7 +835,7 @@ int ha_archive::write_row(uchar *buf) if (!share->archive_write_open) if (init_archive_writer()) - DBUG_RETURN(HA_ERR_CRASHED_ON_USAGE); + DBUG_RETURN(errno); if (table->next_number_field && record == table->record[0]) @@ -1020,7 +1020,8 @@ int ha_archive::rnd_init(bool scan) if (share->crashed) DBUG_RETURN(HA_ERR_CRASHED_ON_USAGE); - init_archive_reader(); + if (init_archive_reader()) + DBUG_RETURN(errno); /* We rewind the file so that we can read from the beginning if scan */ if (scan) @@ -1317,7 +1318,8 @@ int ha_archive::optimize(THD* thd, HA_CHECK_OPT* check_opt) char* frm_string; DBUG_ENTER("ha_archive::optimize"); - init_archive_reader(); + if (init_archive_reader()) + DBUG_RETURN(errno); // now we close both our writer and our reader for the rename if (share->archive_write_open) @@ -1326,7 +1328,7 @@ int ha_archive::optimize(THD* thd, HA_CHECK_OPT* check_opt) share->archive_write_open= FALSE; } - if (!(frm_string= (char*) malloc(archive.frm_length))) + if (!(frm_string= (char*) my_malloc(archive.frm_length, MYF(0)))) return ENOMEM; azread_frm(&archive, frm_string); @@ -1337,12 +1339,12 @@ int ha_archive::optimize(THD* thd, HA_CHECK_OPT* check_opt) if (!(azopen(&writer, writer_filename, O_CREAT|O_RDWR|O_BINARY))) { - free(frm_string); + my_free(frm_string, MYF(0)); DBUG_RETURN(HA_ERR_CRASHED_ON_USAGE); } rc= azwrite_frm(&writer, frm_string, archive.frm_length); - free(frm_string); + my_free(frm_string, MYF(0)); if (rc) { rc= HA_ERR_CRASHED_ON_USAGE; @@ -1547,7 +1549,9 @@ int ha_archive::info(uint flag) if (flag & HA_STATUS_AUTO) { - init_archive_reader(); + if (init_archive_reader()) + DBUG_RETURN(errno); + pthread_mutex_lock(&share->mutex); azflush(&archive, Z_SYNC_FLUSH); pthread_mutex_unlock(&share->mutex); @@ -1626,7 +1630,9 @@ int ha_archive::check(THD* thd, HA_CHECK_OPT* check_opt) Now we will rewind the archive file so that we are positioned at the start of the file. */ - init_archive_reader(); + if (init_archive_reader()) + DBUG_RETURN(errno); + read_data_header(&archive); while (!(rc= get_row(&archive, table->record[0]))) count--; From 6d6bde664590e1a4fdbf60afddaeb21636c1f7e4 Mon Sep 17 00:00:00 2001 From: Michael Widenius Date: Sat, 11 Jun 2011 14:28:37 +0300 Subject: [PATCH 02/14] Increased server version to 5.2.7 --- configure.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.in b/configure.in index febbf1d14ea..c9b097d2f84 100644 --- a/configure.in +++ b/configure.in @@ -13,7 +13,7 @@ dnl When changing the major version number please also check the switch dnl statement in mysqlbinlog::check_master_version(). You may also need dnl to update version.c in ndb. -AC_INIT([MariaDB Server], [5.2.6-MariaDB], [], [mysql]) +AC_INIT([MariaDB Server], [5.2.7-MariaDB], [], [mysql]) AC_CONFIG_SRCDIR([sql/mysqld.cc]) AC_CANONICAL_SYSTEM From ff0b30219f8b47b70f14211c1180148de3dee4d1 Mon Sep 17 00:00:00 2001 From: Michael Widenius Date: Sat, 11 Jun 2011 14:53:08 +0300 Subject: [PATCH 03/14] Updated to new error messages for partitions when .par file is missing --- mysql-test/r/partition_error.result | 5 +++-- mysql-test/t/partition_error.test | 7 +++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/mysql-test/r/partition_error.result b/mysql-test/r/partition_error.result index 269b6875430..a14b1280eb7 100644 --- a/mysql-test/r/partition_error.result +++ b/mysql-test/r/partition_error.result @@ -657,15 +657,16 @@ CREATE TABLE t1 (a INT) PARTITION BY HASH (a); FLUSH TABLES; CHECK TABLE t1; Table Op Msg_type Msg_text +test.t1 check Error File './test/t1.par' not found (Errcode: 2) test.t1 check Error Failed to read from the .par file test.t1 check Error Incorrect information in file: './test/t1.frm' test.t1 check error Corrupt SELECT * FROM t1; -ERROR HY000: Failed to read from the .par file +ERROR HY000: File './test/t1.par' not found (Errcode: 2) # Note that it is currently impossible to drop a partitioned table # without the .par file DROP TABLE t1; -ERROR 42S02: Unknown table 't1' +ERROR HY000: File './test/t1.par' not found (Errcode: 2) # # Bug#49477: Assertion `0' failed in ha_partition.cc:5530 # with temporary table and partitions diff --git a/mysql-test/t/partition_error.test b/mysql-test/t/partition_error.test index 7e574fd6a42..81bb7b55cec 100644 --- a/mysql-test/t/partition_error.test +++ b/mysql-test/t/partition_error.test @@ -695,12 +695,15 @@ CREATE TABLE t1 (a INT) PARTITION BY HASH (a); FLUSH TABLES; --remove_file $MYSQLD_DATADIR/test/t1.par --replace_result $MYSQLD_DATADIR ./ +--replace_result \\ / CHECK TABLE t1; ---error ER_UNKNOWN_ERROR +--replace_result \\ / +--error 29 SELECT * FROM t1; --echo # Note that it is currently impossible to drop a partitioned table --echo # without the .par file ---error ER_BAD_TABLE_ERROR +--replace_result \\ / +--error 29 DROP TABLE t1; --remove_file $MYSQLD_DATADIR/test/t1.frm --remove_file $MYSQLD_DATADIR/test/t1#P#p0.MYI From 2f6c43c5a02482ba92f2d463a6f5bf6383f0ec51 Mon Sep 17 00:00:00 2001 From: Michael Widenius Date: Sun, 12 Jun 2011 12:52:51 +0300 Subject: [PATCH 04/14] Fixed warning that sf_malloc_trough_check was not used when compiling without SAFEMALLOC --- sql/mysqld.cc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 2a5ce27d649..51824d23a14 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -427,7 +427,7 @@ static bool volatile ready_to_exit; static my_bool opt_debugging= 0, opt_external_locking= 0, opt_console= 0; static my_bool opt_short_log_format= 0; static my_bool opt_ignore_wrong_options= 0, opt_expect_abort= 0; -static my_bool opt_sync= 0, sf_malloc_trough_check= 0; +static my_bool opt_sync= 0; static uint kill_cached_threads, wake_thread; ulong thread_created; uint thread_handling; @@ -444,6 +444,9 @@ static const char *optimizer_switch_str="index_merge=on,index_merge_union=on," #else ; #endif +#ifdef SAFEMALLOC +my_bool sf_malloc_trough_check= 0; +#endif static char *mysqld_user, *mysqld_chroot, *log_error_file_ptr; static char *opt_init_slave, *language_ptr, *opt_init_connect; static char *default_character_set_name; @@ -6898,7 +6901,7 @@ each time the SQL thread starts.", {"skip-networking", OPT_SKIP_NETWORKING, "Don't allow connection with TCP/IP.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, -#if !defined(DBUG_OFF) && defined(SAFEMALLOC) +#ifdef SAFEMALLOC {"safemalloc", OPT_SAFEMALLOC, "Check all memory allocation for every malloc/free call.", &sf_malloc_trough_check, &sf_malloc_trough_check, 0, From bf0e1f44c6b3306e84bbfd783c898a1764836242 Mon Sep 17 00:00:00 2001 From: Michael Widenius Date: Mon, 13 Jun 2011 12:46:11 +0300 Subject: [PATCH 05/14] Fixed portability problem with partiton_error.test Added option to aria_read_log to crash recovery at certain points in the recovery process. Fixed bug that caused future recovery attempts to fail if we got a crash/got killed during closing of tables at end of recovery process. mysql-test/mysql-test-run.pl: Don't abort if 'var' points to stale place; Just remove it. mysql-test/suite/maria/r/maria.result: Fixed wrong indentation mysql-test/t/partition_error.test: Fixed portability problem with partiton_error.test storage/maria/ma_close.c: More DBUG_PRINT info storage/maria/ma_pagecache.c: Copy flush_log_callback when writing to page cache. This fixes problem in recovery when switching from mode of file storage/maria/ma_recovery.c: Added option to aria_read_log to crash recovery at certain points in the recovery process. storage/maria/ma_recovery.h: Added option to aria_read_log to crash recovery at certain points in the recovery process. storage/maria/maria_chk.c: Align aria_chk -d output Don't write warning Aria table '...' is usable but should be fixed if the table was before marked as crashed but now is ok storage/maria/maria_read_log.c: Added option to aria_read_log to crash recovery at certain points in the recovery process. --- mysql-test/mysql-test-run.pl | 15 ++++++++++----- mysql-test/suite/maria/r/maria.result | 2 +- mysql-test/t/partition_error.test | 5 ++--- storage/maria/ma_close.c | 3 ++- storage/maria/ma_pagecache.c | 9 ++++++++- storage/maria/ma_recovery.c | 15 ++++++++++++++- storage/maria/ma_recovery.h | 1 + storage/maria/maria_chk.c | 18 +++++++++++++++--- storage/maria/maria_read_log.c | 5 ++++- 9 files changed, 57 insertions(+), 16 deletions(-) diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index 8d11abc8a37..38042d1f272 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -2345,9 +2345,11 @@ sub remove_stale_vardir () { mtr_report(" - WARNING: Using the 'mysql-test/var' symlink"); # Make sure the directory where it points exist - mtr_error("The destination for symlink $opt_vardir does not exist") - if ! -d readlink($opt_vardir); - + if (! -d readlink($opt_vardir)) + { + mtr_report("The destination for symlink $opt_vardir does not exist; Removing it and creating a new var directory"); + unlink($opt_vardir); + } foreach my $bin ( glob("$opt_vardir/*") ) { mtr_verbose("Removing bin $bin"); @@ -2414,8 +2416,11 @@ sub setup_vardir() { # it's a symlink # Make sure the directory where it points exist - mtr_error("The destination for symlink $opt_vardir does not exist") - if ! -d readlink($opt_vardir); + if (! -d readlink($opt_vardir)) + { + mtr_report("The destination for symlink $opt_vardir does not exist; Removing it and creating a new var directory"); + unlink($opt_vardir); + } } elsif ( $opt_mem ) { diff --git a/mysql-test/suite/maria/r/maria.result b/mysql-test/suite/maria/r/maria.result index f7ce8efaa46..217955310f9 100644 --- a/mysql-test/suite/maria/r/maria.result +++ b/mysql-test/suite/maria/r/maria.result @@ -2131,7 +2131,7 @@ c3 VARCHAR(10) NOT NULL, KEY (c1), KEY (c2) ) ENGINE=aria DEFAULT CHARSET=utf8 PACK_KEYS=0; -Aria file: MYSQLD_DATADIR/test/t1 +Aria file: MYSQLD_DATADIR/test/t1 Record format: Block Crashsafe: yes Character set: utf8_general_ci (33) diff --git a/mysql-test/t/partition_error.test b/mysql-test/t/partition_error.test index 81bb7b55cec..9db3ff93634 100644 --- a/mysql-test/t/partition_error.test +++ b/mysql-test/t/partition_error.test @@ -695,14 +695,13 @@ CREATE TABLE t1 (a INT) PARTITION BY HASH (a); FLUSH TABLES; --remove_file $MYSQLD_DATADIR/test/t1.par --replace_result $MYSQLD_DATADIR ./ ---replace_result \\ / CHECK TABLE t1; ---replace_result \\ / +--replace_result $MYSQLD_DATADIR ./ --error 29 SELECT * FROM t1; --echo # Note that it is currently impossible to drop a partitioned table --echo # without the .par file ---replace_result \\ / +--replace_result $MYSQLD_DATADIR ./ --error 29 DROP TABLE t1; --remove_file $MYSQLD_DATADIR/test/t1.frm diff --git a/storage/maria/ma_close.c b/storage/maria/ma_close.c index e97664ebe42..2427dfd042d 100644 --- a/storage/maria/ma_close.c +++ b/storage/maria/ma_close.c @@ -28,7 +28,8 @@ int maria_close(register MARIA_HA *info) my_bool share_can_be_freed= FALSE; MARIA_SHARE *share= info->s; DBUG_ENTER("maria_close"); - DBUG_PRINT("enter",("base: 0x%lx reopen: %u locks: %u", + DBUG_PRINT("enter",("name: '%s' base: 0x%lx reopen: %u locks: %u", + share->open_file_name.str, (long) info, (uint) share->reopen, (uint) share->tot_locks)); diff --git a/storage/maria/ma_pagecache.c b/storage/maria/ma_pagecache.c index 0e44b0e7a22..8272aa970c5 100644 --- a/storage/maria/ma_pagecache.c +++ b/storage/maria/ma_pagecache.c @@ -1808,7 +1808,14 @@ restart: hash_link->requests++; DBUG_ASSERT(hash_link->block == 0); } - + else + { + /* + We have to copy the flush_log callback, as it may change if the table + goes from non_transactional to transactional during recovery + */ + hash_link->file.flush_log_callback= file->flush_log_callback; + } return hash_link; } diff --git a/storage/maria/ma_recovery.c b/storage/maria/ma_recovery.c index 5be30dee0b5..8752f70668c 100644 --- a/storage/maria/ma_recovery.c +++ b/storage/maria/ma_recovery.c @@ -60,6 +60,7 @@ static int (*save_error_handler_hook)(uint, const char *,myf); static uint recovery_warnings; /**< count of warnings */ static uint recovery_found_crashed_tables; HASH tables_to_redo; /* For maria_read_log */ +ulong maria_recovery_force_crash_counter; #define prototype_redo_exec_hook(R) \ static int exec_REDO_LOGREC_ ## R(const TRANSLOG_HEADER_BUFFER *rec) @@ -2939,6 +2940,12 @@ static int run_undo_phase(uint uncommitted) translog_free_record_header(&rec); } + /* Force a crash to test recovery of recovery */ + if (maria_recovery_force_crash_counter) + { + DBUG_ASSERT(--maria_recovery_force_crash_counter > 0); + } + if (trnman_rollback_trn(trn)) DBUG_RETURN(1); /* We could want to span a few threads (4?) instead of 1 */ @@ -3436,6 +3443,12 @@ static int close_all_tables(void) prepare_table_for_close(info, addr); error|= maria_close(info); pthread_mutex_lock(&THR_LOCK_maria); + + /* Force a crash to test recovery of recovery */ + if (maria_recovery_force_crash_counter) + { + DBUG_ASSERT(--maria_recovery_force_crash_counter > 0); + } } end: pthread_mutex_unlock(&THR_LOCK_maria); @@ -3510,7 +3523,7 @@ void _ma_tmp_disable_logging_for_table(MARIA_HA *info, /* Reset state pointers. This is needed as in ALTER table we may do - commit fllowed by _ma_renable_logging_for_table and then + commit followed by _ma_renable_logging_for_table and then info->state may point to a state that was deleted by _ma_trnman_end_trans_hook() */ diff --git a/storage/maria/ma_recovery.h b/storage/maria/ma_recovery.h index 5b22c4fd9b2..45dba0e86b3 100644 --- a/storage/maria/ma_recovery.h +++ b/storage/maria/ma_recovery.h @@ -32,4 +32,5 @@ int maria_apply_log(LSN lsn, LSN lsn_end, enum maria_apply_log_way apply, my_bool take_checkpoints, uint *warnings_count); /* Table of tables to recover */ extern HASH tables_to_redo; +extern ulong maria_recovery_force_crash_counter; C_MODE_END diff --git a/storage/maria/maria_chk.c b/storage/maria/maria_chk.c index bb345f63b02..ec8af652fe3 100644 --- a/storage/maria/maria_chk.c +++ b/storage/maria/maria_chk.c @@ -949,6 +949,7 @@ static void get_options(register int *argc,register char ***argv) static int maria_chk(HA_CHECK *param, char *filename) { int error,lock_type,recreate; + uint warning_printed_by_chk_status; my_bool rep_quick= test(param->testflag & (T_QUICK | T_FORCE_UNIQUENESS)); MARIA_HA *info; File datafile; @@ -961,6 +962,7 @@ static int maria_chk(HA_CHECK *param, char *filename) recreate=0; datafile=0; param->isam_file_name=filename; /* For error messages */ + warning_printed_by_chk_status= 0; if (!(info=maria_open(filename, (param->testflag & (T_DESCRIPT | T_READONLY)) ? O_RDONLY : O_RDWR, @@ -1303,7 +1305,12 @@ static int maria_chk(HA_CHECK *param, char *filename) maria_chk_init_for_check(param, info); if (opt_warning_for_wrong_transid == 0) param->max_trid= ~ (ulonglong) 0; + error= maria_chk_status(param,info); + /* Forget warning printed by maria_chk_status if no problems found */ + warning_printed_by_chk_status= param->warning_printed; + param->warning_printed= 0; + maria_intersect_keys_active(share->state.key_map, param->keys_in_use); error|= maria_chk_size(param,info); if (!error || !(param->testflag & (T_FAST | T_FORCE_CREATE))) @@ -1371,8 +1378,12 @@ static int maria_chk(HA_CHECK *param, char *filename) (state_updated ? UPDATE_STAT : 0) | ((param->testflag & T_SORT_RECORDS) ? UPDATE_SORT : 0))); - if (!(param->testflag & T_SILENT)) + if (warning_printed_by_chk_status) + _ma_check_print_info(param, "Aria table '%s' was ok. Status updated", + filename); + else if (!(param->testflag & T_SILENT)) printf("State updated\n"); + warning_printed_by_chk_status= 0; } info->update&= ~HA_STATE_CHANGED; _ma_reenable_logging_for_table(info, FALSE); @@ -1426,7 +1437,7 @@ end2: "Aria table '%s' is corrupted\nFix it using switch \"-r\" or \"-o\"\n", filename)); } - else if (param->warning_printed && + else if ((param->warning_printed || warning_printed_by_chk_status) && ! (param->testflag & (T_REP_ANY | T_SORT_RECORDS | T_SORT_INDEX | T_FORCE_CREATE))) { @@ -1435,6 +1446,7 @@ end2: VOID(fprintf(stderr, "Aria table '%s' is usable but should be fixed\n", filename)); } + VOID(fflush(stderr)); DBUG_RETURN(error); } /* maria_chk */ @@ -1464,7 +1476,7 @@ static void descript(HA_CHECK *param, register MARIA_HA *info, char *name) DBUG_VOID_RETURN; } - printf("Aria file: %s\n",name); + printf("Aria file: %s\n",name); printf("Record format: %s\n", record_formats[share->data_file_type]); printf("Crashsafe: %s\n", share->base.born_transactional ? "yes" : "no"); diff --git a/storage/maria/maria_read_log.c b/storage/maria/maria_read_log.c index b335aa3692e..9471f01dbc8 100644 --- a/storage/maria/maria_read_log.c +++ b/storage/maria/maria_read_log.c @@ -166,7 +166,7 @@ err: #include "ma_check_standalone.h" enum options_mc { - OPT_CHARSETS_DIR=256 + OPT_CHARSETS_DIR=256, OPT_FORCE_CRASH }; static struct my_option my_long_options[] = @@ -186,6 +186,9 @@ static struct my_option my_long_options[] = #ifndef DBUG_OFF {"debug", '#', "Output debug log. Often the argument is 'd:t:o,filename'.", 0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, + {"force-crash", OPT_FORCE_CRASH, "Force crash after # recovery events", + &maria_recovery_force_crash_counter, 0,0, GET_ULONG, REQUIRED_ARG, + 0, 0, ~(long) 0, 0, 0, 0}, #endif {"help", '?', "Display this help and exit.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, From 53270955bb38eebc1a4f0b19810817a0543b8f33 Mon Sep 17 00:00:00 2001 From: Michael Widenius Date: Mon, 13 Jun 2011 16:57:11 +0300 Subject: [PATCH 06/14] Change in PBXT to only use pth_set_priority() (not setpriority()) to set priority --- storage/pbxt/src/pthread_xt.cc | 39 ++++++++-------------------------- 1 file changed, 9 insertions(+), 30 deletions(-) diff --git a/storage/pbxt/src/pthread_xt.cc b/storage/pbxt/src/pthread_xt.cc index c5dc2e41fdd..64c03db734c 100755 --- a/storage/pbxt/src/pthread_xt.cc +++ b/storage/pbxt/src/pthread_xt.cc @@ -547,44 +547,23 @@ xtPublic void xt_p_init_threading(void) xtPublic int xt_p_set_low_priority(pthread_t thr) { - if (pth_min_priority == pth_max_priority) { - /* Under Linux the priority of normal (non-runtime) - * threads are set using the standard methods - * for setting process priority. - */ - - /* We could set who == 0 because it should have the same affect - * as using the PID. - */ - - /* -20 = highest, 20 = lowest */ -#ifdef SET_GLOBAL_PRIORITY - if (setpriority(PRIO_PROCESS, getpid(), 20) == -1) - return errno; -#endif - return 0; - } - return pth_set_priority(thr, pth_min_priority); + if (pth_min_priority != pth_max_priority) + return pth_set_priority(thr, pth_min_priority); + return 0; } xtPublic int xt_p_set_normal_priority(pthread_t thr) { - if (pth_min_priority == pth_max_priority) { - if (setpriority(PRIO_PROCESS, getpid(), 0) == -1) - return errno; - return 0; - } - return pth_set_priority(thr, pth_normal_priority); + if (pth_min_priority != pth_max_priority) + return pth_set_priority(thr, pth_normal_priority); + return 0; } xtPublic int xt_p_set_high_priority(pthread_t thr) { - if (pth_min_priority == pth_max_priority) { - if (setpriority(PRIO_PROCESS, getpid(), -20) == -1) - return errno; - return 0; - } - return pth_set_priority(thr, pth_max_priority); + if (pth_min_priority != pth_max_priority) + return pth_set_priority(thr, pth_max_priority); + return 0; } #ifdef DEBUG_LOCKING From 2c243b3199dd220a88476648b02aacd059968304 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Wed, 15 Jun 2011 19:44:00 +0200 Subject: [PATCH 07/14] fix "./configure --with-debug" builds (without CFLAGS=-DSAFEMALLOC). --- storage/heap/hp_test2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/storage/heap/hp_test2.c b/storage/heap/hp_test2.c index bf06cf03035..67471e93a7a 100644 --- a/storage/heap/hp_test2.c +++ b/storage/heap/hp_test2.c @@ -22,7 +22,7 @@ #undef DBUG_OFF #endif #ifndef SAFEMALLOC -#define SAFEMALLOC +#define SAFEMALLOC 1 #endif #include "heapdef.h" /* Because of hp_find_block */ From 018614e2b348598f4518e11156fb44c388d2bf32 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Wed, 15 Jun 2011 20:30:10 +0200 Subject: [PATCH 08/14] ./mtr --suite funcs_1 --ps-protocol --- .../funcs_1/r/processlist_priv_ps.result | 164 +++++----- .../suite/funcs_1/r/processlist_val_ps.result | 284 ++++++++++++------ 2 files changed, 276 insertions(+), 172 deletions(-) diff --git a/mysql-test/suite/funcs_1/r/processlist_priv_ps.result b/mysql-test/suite/funcs_1/r/processlist_priv_ps.result index c5aabfe315c..c05c9549334 100644 --- a/mysql-test/suite/funcs_1/r/processlist_priv_ps.result +++ b/mysql-test/suite/funcs_1/r/processlist_priv_ps.result @@ -29,28 +29,29 @@ PROCESSLIST CREATE TEMPORARY TABLE `PROCESSLIST` ( `COMMAND` varchar(16) NOT NULL DEFAULT '', `TIME` int(7) NOT NULL DEFAULT '0', `STATE` varchar(64) DEFAULT NULL, - `INFO` longtext + `INFO` longtext, + `TIME_MS` decimal(22,3) NOT NULL DEFAULT '0.000' ) DEFAULT CHARSET=utf8 SHOW processlist; Id User Host db Command Time State Info ID root HOST_NAME information_schema Query TIME NULL SHOW processlist ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL SELECT * FROM processlist ORDER BY id; -ID USER HOST DB COMMAND TIME STATE INFO -ID root HOST_NAME information_schema Execute TIME executing SELECT * FROM processlist ORDER BY id -ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL -SELECT ID, USER, HOST, DB, COMMAND, TIME, STATE, INFO FROM processlist ORDER BY id; -ID USER HOST DB COMMAND TIME STATE INFO -ID root HOST_NAME information_schema Execute TIME executing SELECT ID, USER, HOST, DB, COMMAND, TIME, STATE, INFO FROM processlist ORDER BY id -ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL +ID USER HOST DB COMMAND TIME STATE INFO TIME_MS +ID root HOST_NAME information_schema Execute TIME executing SELECT * FROM processlist ORDER BY id TIME_MS +ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL TIME_MS +SELECT ID, USER, HOST, DB, COMMAND, TIME, STATE, INFO, TIME_MS FROM processlist ORDER BY id; +ID USER HOST DB COMMAND TIME STATE INFO TIME_MS +ID root HOST_NAME information_schema Execute TIME executing SELECT ID, USER, HOST, DB, COMMAND, TIME, STATE, INFO, TIME_MS FROM processlist ORDER BY id TIME_MS +ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL TIME_MS CREATE TEMPORARY TABLE test.t_processlist AS SELECT * FROM processlist; UPDATE test.t_processlist SET user='horst' WHERE id=1 ; INSERT INTO processlist SELECT * FROM test.t_processlist; ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_schema' DROP TABLE test.t_processlist; -CREATE VIEW test.v_processlist (ID, USER, HOST, DB, COMMAND, TIME, STATE, INFO) AS SELECT * FROM processlist WITH CHECK OPTION; +CREATE VIEW test.v_processlist (ID, USER, HOST, DB, COMMAND, TIME, STATE, INFO, TIME_MS) AS SELECT * FROM processlist WITH CHECK OPTION; ERROR HY000: CHECK OPTION on non-updatable view 'test.v_processlist' -CREATE VIEW test.v_processlist (ID, USER, HOST, DB, COMMAND, TIME, STATE, INFO) AS SELECT * FROM processlist; +CREATE VIEW test.v_processlist (ID, USER, HOST, DB, COMMAND, TIME, STATE, INFO, TIME_MS) AS SELECT * FROM processlist; UPDATE test.v_processlist SET TIME=NOW() WHERE id = 1; ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_schema' DROP VIEW test.v_processlist; @@ -99,25 +100,26 @@ PROCESSLIST CREATE TEMPORARY TABLE `PROCESSLIST` ( `COMMAND` varchar(16) NOT NULL DEFAULT '', `TIME` int(7) NOT NULL DEFAULT '0', `STATE` varchar(64) DEFAULT NULL, - `INFO` longtext + `INFO` longtext, + `TIME_MS` decimal(22,3) NOT NULL DEFAULT '0.000' ) DEFAULT CHARSET=utf8 SHOW processlist; Id User Host db Command Time State Info ID ddicttestuser1 HOST_NAME information_schema Query TIME NULL SHOW processlist SELECT * FROM processlist ORDER BY id; -ID USER HOST DB COMMAND TIME STATE INFO -ID ddicttestuser1 HOST_NAME information_schema Execute TIME executing SELECT * FROM processlist ORDER BY id -SELECT ID, USER, HOST, DB, COMMAND, TIME, STATE, INFO FROM processlist ORDER BY id; -ID USER HOST DB COMMAND TIME STATE INFO -ID ddicttestuser1 HOST_NAME information_schema Execute TIME executing SELECT ID, USER, HOST, DB, COMMAND, TIME, STATE, INFO FROM processlist ORDER BY id +ID USER HOST DB COMMAND TIME STATE INFO TIME_MS +ID ddicttestuser1 HOST_NAME information_schema Execute TIME executing SELECT * FROM processlist ORDER BY id TIME_MS +SELECT ID, USER, HOST, DB, COMMAND, TIME, STATE, INFO, TIME_MS FROM processlist ORDER BY id; +ID USER HOST DB COMMAND TIME STATE INFO TIME_MS +ID ddicttestuser1 HOST_NAME information_schema Execute TIME executing SELECT ID, USER, HOST, DB, COMMAND, TIME, STATE, INFO, TIME_MS FROM processlist ORDER BY id TIME_MS CREATE TEMPORARY TABLE test.t_processlist AS SELECT * FROM processlist; UPDATE test.t_processlist SET user='horst' WHERE id=1 ; INSERT INTO processlist SELECT * FROM test.t_processlist; ERROR 42000: Access denied for user 'ddicttestuser1'@'localhost' to database 'information_schema' DROP TABLE test.t_processlist; -CREATE VIEW test.v_processlist (ID, USER, HOST, DB, COMMAND, TIME, STATE, INFO) AS SELECT * FROM processlist WITH CHECK OPTION; +CREATE VIEW test.v_processlist (ID, USER, HOST, DB, COMMAND, TIME, STATE, INFO, TIME_MS) AS SELECT * FROM processlist WITH CHECK OPTION; ERROR HY000: CHECK OPTION on non-updatable view 'test.v_processlist' -CREATE VIEW test.v_processlist (ID, USER, HOST, DB, COMMAND, TIME, STATE, INFO) AS SELECT * FROM processlist; +CREATE VIEW test.v_processlist (ID, USER, HOST, DB, COMMAND, TIME, STATE, INFO, TIME_MS) AS SELECT * FROM processlist; UPDATE test.v_processlist SET TIME=NOW() WHERE id = 1; ERROR 42000: Access denied for user 'ddicttestuser1'@'localhost' to database 'information_schema' DROP VIEW test.v_processlist; @@ -170,8 +172,8 @@ SHOW processlist; Id User Host db Command Time State Info ID ddicttestuser1 HOST_NAME information_schema Query TIME NULL SHOW processlist SELECT * FROM information_schema.processlist; -ID USER HOST DB COMMAND TIME STATE INFO -ID ddicttestuser1 HOST_NAME information_schema Execute TIME executing SELECT * FROM information_schema.processlist +ID USER HOST DB COMMAND TIME STATE INFO TIME_MS +ID ddicttestuser1 HOST_NAME information_schema Execute TIME executing SELECT * FROM information_schema.processlist TIME_MS #################################################################################### 4.2 New connection con101 (ddicttestuser1 with PROCESS privilege) SHOW/SELECT shows all processes/threads. @@ -185,10 +187,10 @@ ID root HOST_NAME information_schema Sleep TIME NULL ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL ID ddicttestuser1 HOST_NAME information_schema Query TIME NULL SHOW processlist SELECT * FROM information_schema.processlist; -ID USER HOST DB COMMAND TIME STATE INFO -ID ddicttestuser1 HOST_NAME information_schema Execute TIME executing SELECT * FROM information_schema.processlist -ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL -ID root HOST_NAME information_schema Sleep TIME NULL +ID USER HOST DB COMMAND TIME STATE INFO TIME_MS +ID ddicttestuser1 HOST_NAME information_schema Execute TIME executing SELECT * FROM information_schema.processlist TIME_MS +ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL TIME_MS +ID root HOST_NAME information_schema Sleep TIME NULL TIME_MS #################################################################################### 5 Grant PROCESS privilege to anonymous user. connection default (user=root) @@ -209,11 +211,11 @@ ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL ID HOST_NAME information_schema Query TIME NULL SHOW processlist SELECT * FROM information_schema.processlist; -ID USER HOST DB COMMAND TIME STATE INFO -ID HOST_NAME information_schema Execute TIME executing SELECT * FROM information_schema.processlist -ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL -ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL -ID root HOST_NAME information_schema Sleep TIME NULL +ID USER HOST DB COMMAND TIME STATE INFO TIME_MS +ID HOST_NAME information_schema Execute TIME executing SELECT * FROM information_schema.processlist TIME_MS +ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL TIME_MS +ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL TIME_MS +ID root HOST_NAME information_schema Sleep TIME NULL TIME_MS #################################################################################### 6 Revoke PROCESS privilege from ddicttestuser1 connection default (user=root) @@ -233,10 +235,10 @@ ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL ID ddicttestuser1 HOST_NAME information_schema Query TIME NULL SHOW processlist SELECT * FROM information_schema.processlist; -ID USER HOST DB COMMAND TIME STATE INFO -ID ddicttestuser1 HOST_NAME information_schema Execute TIME executing SELECT * FROM information_schema.processlist -ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL -ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL +ID USER HOST DB COMMAND TIME STATE INFO TIME_MS +ID ddicttestuser1 HOST_NAME information_schema Execute TIME executing SELECT * FROM information_schema.processlist TIME_MS +ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL TIME_MS +ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL TIME_MS #################################################################################### 7 Revoke PROCESS privilege from anonymous user connection default (user=root) @@ -251,9 +253,9 @@ SHOW GRANTS FOR ''@'localhost'; Grants for @localhost GRANT USAGE ON *.* TO ''@'localhost' SELECT * FROM information_schema.processlist; -ID USER HOST DB COMMAND TIME STATE INFO -ID HOST_NAME information_schema Execute TIME executing SELECT * FROM information_schema.processlist -ID HOST_NAME information_schema Sleep TIME NULL +ID USER HOST DB COMMAND TIME STATE INFO TIME_MS +ID HOST_NAME information_schema Execute TIME executing SELECT * FROM information_schema.processlist TIME_MS +ID HOST_NAME information_schema Sleep TIME NULL TIME_MS #################################################################################### 8 Grant SUPER (does not imply PROCESS) privilege to ddicttestuser1 connection default (user=root) @@ -273,11 +275,11 @@ ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL ID ddicttestuser1 HOST_NAME information_schema Query TIME NULL SHOW processlist SELECT * FROM information_schema.processlist; -ID USER HOST DB COMMAND TIME STATE INFO -ID ddicttestuser1 HOST_NAME information_schema Execute TIME executing SELECT * FROM information_schema.processlist -ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL -ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL -ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL +ID USER HOST DB COMMAND TIME STATE INFO TIME_MS +ID ddicttestuser1 HOST_NAME information_schema Execute TIME executing SELECT * FROM information_schema.processlist TIME_MS +ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL TIME_MS +ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL TIME_MS +ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL TIME_MS #################################################################################### 9 Revoke SUPER privilege from user ddicttestuser1 connection default (user=root) @@ -299,12 +301,12 @@ ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL ID ddicttestuser1 HOST_NAME information_schema Query TIME NULL SHOW processlist SELECT * FROM information_schema.processlist; -ID USER HOST DB COMMAND TIME STATE INFO -ID ddicttestuser1 HOST_NAME information_schema Execute TIME executing SELECT * FROM information_schema.processlist -ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL -ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL -ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL -ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL +ID USER HOST DB COMMAND TIME STATE INFO TIME_MS +ID ddicttestuser1 HOST_NAME information_schema Execute TIME executing SELECT * FROM information_schema.processlist TIME_MS +ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL TIME_MS +ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL TIME_MS +ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL TIME_MS +ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL TIME_MS #################################################################################### 10 Grant SUPER privilege with grant option to user ddicttestuser1. connection default (user=root) @@ -353,18 +355,18 @@ ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL ID ddicttestuser2 HOST_NAME information_schema Query TIME NULL SHOW processlist SELECT * FROM information_schema.processlist; -ID USER HOST DB COMMAND TIME STATE INFO -ID ddicttestuser2 HOST_NAME information_schema Execute TIME executing SELECT * FROM information_schema.processlist -ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL -ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL -ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL -ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL -ID HOST_NAME information_schema Sleep TIME NULL -ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL -ID HOST_NAME information_schema Sleep TIME NULL -ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL -ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL -ID root HOST_NAME information_schema Sleep TIME NULL +ID USER HOST DB COMMAND TIME STATE INFO TIME_MS +ID ddicttestuser2 HOST_NAME information_schema Execute TIME executing SELECT * FROM information_schema.processlist TIME_MS +ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL TIME_MS +ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL TIME_MS +ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL TIME_MS +ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL TIME_MS +ID HOST_NAME information_schema Sleep TIME NULL TIME_MS +ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL TIME_MS +ID HOST_NAME information_schema Sleep TIME NULL TIME_MS +ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL TIME_MS +ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL TIME_MS +ID root HOST_NAME information_schema Sleep TIME NULL TIME_MS #################################################################################### 11 User ddicttestuser1 revokes PROCESS privilege from user ddicttestuser2 connection ddicttestuser1; @@ -382,9 +384,9 @@ Id User Host db Command Time State Info ID ddicttestuser2 HOST_NAME information_schema Sleep TIME NULL ID ddicttestuser2 HOST_NAME information_schema Query TIME NULL SHOW processlist SELECT * FROM information_schema.processlist; -ID USER HOST DB COMMAND TIME STATE INFO -ID ddicttestuser2 HOST_NAME information_schema Execute TIME executing SELECT * FROM information_schema.processlist -ID ddicttestuser2 HOST_NAME information_schema Sleep TIME NULL +ID USER HOST DB COMMAND TIME STATE INFO TIME_MS +ID ddicttestuser2 HOST_NAME information_schema Execute TIME executing SELECT * FROM information_schema.processlist TIME_MS +ID ddicttestuser2 HOST_NAME information_schema Sleep TIME NULL TIME_MS #################################################################################### 11.2 Revoke SUPER,PROCESS,GRANT OPTION privilege from user ddicttestuser1 connection default (user=root) @@ -411,15 +413,15 @@ ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL ID ddicttestuser1 HOST_NAME information_schema Query TIME NULL SHOW processlist SELECT * FROM information_schema.processlist; -ID USER HOST DB COMMAND TIME STATE INFO -ID ddicttestuser1 HOST_NAME information_schema Execute TIME executing SELECT * FROM information_schema.processlist -ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL -ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL -ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL -ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL -ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL -ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL -ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL +ID USER HOST DB COMMAND TIME STATE INFO TIME_MS +ID ddicttestuser1 HOST_NAME information_schema Execute TIME executing SELECT * FROM information_schema.processlist TIME_MS +ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL TIME_MS +ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL TIME_MS +ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL TIME_MS +ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL TIME_MS +ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL TIME_MS +ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL TIME_MS +ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL TIME_MS #################################################################################### 12 Revoke the SELECT privilege from user ddicttestuser1 connection default (user=root) @@ -447,16 +449,16 @@ ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL ID ddicttestuser1 HOST_NAME information_schema Query TIME NULL SHOW processlist SELECT * FROM information_schema.processlist; -ID USER HOST DB COMMAND TIME STATE INFO -ID ddicttestuser1 HOST_NAME information_schema Execute TIME executing SELECT * FROM information_schema.processlist -ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL -ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL -ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL -ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL -ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL -ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL -ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL -ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL +ID USER HOST DB COMMAND TIME STATE INFO TIME_MS +ID ddicttestuser1 HOST_NAME information_schema Execute TIME executing SELECT * FROM information_schema.processlist TIME_MS +ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL TIME_MS +ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL TIME_MS +ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL TIME_MS +ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL TIME_MS +ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL TIME_MS +ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL TIME_MS +ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL TIME_MS +ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL TIME_MS #################################################################################### 12.2 Revoke only the SELECT privilege on the information_schema from ddicttestuser1. connection default (user=root) diff --git a/mysql-test/suite/funcs_1/r/processlist_val_ps.result b/mysql-test/suite/funcs_1/r/processlist_val_ps.result index 448c68eadb8..86f290daea7 100644 --- a/mysql-test/suite/funcs_1/r/processlist_val_ps.result +++ b/mysql-test/suite/funcs_1/r/processlist_val_ps.result @@ -19,140 +19,242 @@ PROCESSLIST CREATE TEMPORARY TABLE `PROCESSLIST` ( `COMMAND` varchar(16) NOT NULL DEFAULT '', `TIME` int(7) NOT NULL DEFAULT '0', `STATE` varchar(64) DEFAULT NULL, - `INFO` longtext + `INFO` longtext, + `TIME_MS` decimal(22,3) NOT NULL DEFAULT '0.000' ) DEFAULT CHARSET=utf8 -SELECT COUNT(*) FROM INFORMATION_SCHEMA.PROCESSLIST; -COUNT(*) -1 -USE test; +# Ensure that the information about the own connection is correct. +#-------------------------------------------------------------------------- + SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST; -ID USER HOST DB COMMAND TIME STATE INFO - root localhost test Execute 0 executing SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST +ID USER HOST DB COMMAND TIME STATE INFO TIME_MS + root test Execute