diff options
-rwxr-xr-x | BUILD/compile-solaris-sparc-debug | 2 | ||||
-rw-r--r-- | client/client_priv.h | 4 | ||||
-rw-r--r-- | client/mysql.cc | 23 | ||||
-rw-r--r-- | client/mysql_upgrade.c | 33 | ||||
-rw-r--r-- | client/mysqladmin.cc | 23 | ||||
-rw-r--r-- | client/mysqlbinlog.cc | 23 | ||||
-rw-r--r-- | client/mysqlcheck.c | 21 | ||||
-rw-r--r-- | client/mysqldump.c | 23 | ||||
-rw-r--r-- | client/mysqlimport.c | 20 | ||||
-rw-r--r-- | client/mysqlshow.c | 20 | ||||
-rw-r--r-- | client/mysqlslap.c | 22 | ||||
-rw-r--r-- | client/mysqltest.c | 19 | ||||
-rw-r--r-- | include/my_sys.h | 4 | ||||
-rw-r--r-- | libmysql/libmysql.c | 2 | ||||
-rwxr-xr-x | mysql-test/mysql-test-run.pl | 12 | ||||
-rw-r--r-- | mysys/my_getsystime.c | 68 | ||||
-rw-r--r-- | mysys/my_init.c | 11 | ||||
-rw-r--r-- | mysys/my_static.c | 2 | ||||
-rw-r--r-- | mysys/safemalloc.c | 18 | ||||
-rw-r--r-- | sql/item_xmlfunc.cc | 4 | ||||
-rw-r--r-- | sql/sql_test.cc | 2 | ||||
-rw-r--r-- | unittest/mysys/base64-t.c | 2 | ||||
-rw-r--r-- | unittest/mysys/bitmap-t.c | 9 | ||||
-rw-r--r-- | unittest/mysys/my_atomic-t.c | 3 |
24 files changed, 244 insertions, 126 deletions
diff --git a/BUILD/compile-solaris-sparc-debug b/BUILD/compile-solaris-sparc-debug index 58fcecf5a71..43cabd644fa 100755 --- a/BUILD/compile-solaris-sparc-debug +++ b/BUILD/compile-solaris-sparc-debug @@ -6,6 +6,6 @@ make -k clean || true path=`dirname $0` . "$path/autorun.sh" -CFLAGS="-g -Wimplicit -Wreturn-type -Wswitch -Wtrigraphs -Wcomment -W -Wchar-subscripts -Wformat -Wparentheses -Wsign-compare -Wwrite-strings -Wunused -O3 -fno-omit-frame-pointer -mcpu=v8 -Wa,-xarch=v8plusa" CXX=gcc CXXFLAGS="-Wimplicit -Wreturn-type -Wid-clash-51 -Wswitch -Wtrigraphs -Wcomment -W -Wchar-subscripts -Wformat -Wparentheses -Wsign-compare -Wwrite-strings -Woverloaded-virtual -Wsign-promo -Wreorder -Wctor-dtor-privacy -Wnon-virtual-dtor -felide-constructors -fno-exceptions -fno-rtti -O3 -fno-omit-frame-pointer -mcpu=v8 -Wa,-xarch=v8plusa -g" ./configure --prefix=/usr/local/mysql --enable-assembler --with-extra-charsets=complex --enable-thread-safe-client --with-debug +CFLAGS="-g -Wimplicit -Wreturn-type -Wswitch -Wtrigraphs -Wcomment -W -Wchar-subscripts -Wformat -Wparentheses -Wsign-compare -Wwrite-strings -Wunused -O3 -fno-omit-frame-pointer" CXX=gcc CXXFLAGS="-g -Wimplicit -Wreturn-type -Wswitch -Wtrigraphs -Wcomment -W -Wchar-subscripts -Wformat -Wparentheses -Wsign-compare -Wwrite-strings -Woverloaded-virtual -Wsign-promo -Wreorder -Wctor-dtor-privacy -Wnon-virtual-dtor -felide-constructors -fno-exceptions -fno-rtti -O3 -fno-omit-frame-pointer" ./configure --prefix=/usr/local/mysql --enable-assembler --with-extra-charsets=complex --enable-thread-safe-client --with-debug make -j 4 diff --git a/client/client_priv.h b/client/client_priv.h index 25241cc8c59..12264b6e98d 100644 --- a/client/client_priv.h +++ b/client/client_priv.h @@ -75,6 +75,6 @@ enum options_client OPT_SLAP_POST_QUERY, OPT_MYSQL_REPLACE_INTO, OPT_BASE64_OUTPUT, OPT_SERVER_ID, OPT_FIX_TABLE_NAMES, OPT_FIX_DB_NAMES, OPT_SSL_VERIFY_SERVER_CERT, - OPT_DEBUG_INFO, OPT_COLUMN_TYPES, OPT_ERROR_LOG_FILE, OPT_WRITE_BINLOG, - OPT_MAX_CLIENT_OPTION + OPT_DEBUG_INFO, OPT_DEBUG_CHECK, OPT_COLUMN_TYPES, OPT_ERROR_LOG_FILE, + OPT_WRITE_BINLOG, OPT_MAX_CLIENT_OPTION }; diff --git a/client/mysql.cc b/client/mysql.cc index fe057c8b8a4..c0423e0c897 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -43,7 +43,7 @@ #include <locale.h> #endif -const char *VER= "14.13"; +const char *VER= "14.14"; /* Don't try to make a nice table if the data is too big */ #define MAX_COLUMN_LENGTH 1024 @@ -129,7 +129,7 @@ enum enum_info_type { INFO_INFO,INFO_ERROR,INFO_RESULT}; typedef enum enum_info_type INFO_TYPE; static MYSQL mysql; /* The connection */ -static my_bool info_flag=0,ignore_errors=0,wait_flag=0,quick=0, +static my_bool ignore_errors=0,wait_flag=0,quick=0, connected=0,opt_raw_data=0,unbuffered=0,output_tables=0, opt_rehash=1,skip_updates=0,safe_updates=0,one_database=0, opt_compress=0, using_opt_local_infile=0, @@ -139,9 +139,11 @@ static my_bool info_flag=0,ignore_errors=0,wait_flag=0,quick=0, 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; +static my_bool debug_info_flag, debug_check_flag; static my_bool column_types_flag; static ulong opt_max_allowed_packet, opt_net_buffer_length; static uint verbose=0,opt_silent=0,opt_mysql_port=0, opt_local_infile=0; +static uint my_end_arg; static char * opt_mysql_unix_port=0; static int connect_flag=CLIENT_INTERACTIVE; static char *current_host,*current_db,*current_user=0,*opt_password=0, @@ -541,7 +543,7 @@ sig_handler mysql_end(int sig) my_free(current_prompt,MYF(MY_ALLOW_ZERO_PTR)); mysql_server_end(); free_defaults(defaults_argv); - my_end(info_flag ? MY_CHECK_ERROR : 0); + my_end(my_end_arg); exit(status.exit_status); } @@ -611,8 +613,11 @@ 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-info", 'T', "Print some debug info at exit.", (uchar**) &info_flag, - (uchar**) &info_flag, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, + {"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, + (uchar**) &debug_info_flag, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"database", 'D', "Database to use.", (uchar**) ¤t_db, (uchar**) ¤t_db, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"default-character-set", OPT_DEFAULT_CHARSET, @@ -927,7 +932,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), break; case '#': DBUG_PUSH(argument ? argument : default_dbug_option); - info_flag= 1; + debug_info_flag= 1; break; case 's': if (argument == disabled_my_option) @@ -1021,6 +1026,10 @@ static int get_options(int argc, char **argv) } if (tty_password) opt_password= get_tty_password(NullS); + if (debug_info_flag) + my_end_arg= MY_CHECK_ERROR | MY_GIVE_INFO; + if (debug_check_flag) + my_end_arg= MY_CHECK_ERROR; return(0); } @@ -3288,7 +3297,7 @@ sql_real_connect(char *host,char *database,char *user,char *password, } connected=1; #ifndef EMBEDDED_LIBRARY - mysql.reconnect=info_flag ? 1 : 0; // We want to know if this happens + mysql.reconnect= debug_info_flag; // We want to know if this happens #else mysql.reconnect= 1; #endif diff --git a/client/mysql_upgrade.c b/client/mysql_upgrade.c index 504b4c95a8b..6611a74ea7f 100644 --- a/client/mysql_upgrade.c +++ b/client/mysql_upgrade.c @@ -17,6 +17,8 @@ #include <sslopt-vars.h> #include "../scripts/mysql_fix_privilege_tables_sql.c" +#define VER "1.1" + #ifdef HAVE_SYS_WAIT_H #include <sys/wait.h> #endif @@ -32,7 +34,8 @@ static char mysql_path[FN_REFLEN]; static char mysqlcheck_path[FN_REFLEN]; -static my_bool opt_force, opt_verbose; +static my_bool opt_force, opt_verbose, debug_info_flag, debug_check_flag; +static uint my_end_arg= 0; static char *opt_user= (char*)"root"; static DYNAMIC_STRING ds_args; @@ -56,6 +59,11 @@ static struct my_option my_long_options[]= NO_ARG, 0, 0, 0, 0, 0, 0}, {"basedir", 'b', "Not used by mysql_upgrade. Only for backward compatibilty", 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, + {"character-sets-dir", OPT_CHARSETS_DIR, + "Directory where character sets are.", 0, + 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, + {"compress", OPT_COMPRESS, "Use compression in server/client protocol.", + (uchar**)¬_used, (uchar**)¬_used, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"datadir", 'd', "Not used by mysql_upgrade. Only for backward compatibilty", 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, @@ -66,14 +74,14 @@ 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 .", + (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, + (uchar**) &debug_info_flag, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"default-character-set", OPT_DEFAULT_CHARSET, "Set the default character set.", 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"character-sets-dir", OPT_CHARSETS_DIR, - "Directory where character sets are.", 0, - 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"compress", OPT_COMPRESS, "Use compression in server/client protocol.", - (uchar**)¬_used, (uchar**)¬_used, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"force", 'f', "Force execution of mysqlcheck even if mysql_upgrade " "has already been executed for the current version of MySQL.", (uchar**)&opt_force, (uchar**)&opt_force, 0, @@ -138,7 +146,7 @@ static void die(const char *fmt, ...) va_end(args); free_used_memory(); - my_end(MY_CHECK_ERROR); + my_end(my_end_arg); exit(1); } @@ -200,8 +208,9 @@ get_one_option(int optid, const struct my_option *opt, switch (optid) { case '?': - printf("MySQL utility for upgrading database to MySQL version %s\n", - MYSQL_SERVER_VERSION); + printf("%s Ver %s Distrib %s, for %s (%s)\n", + my_progname, VER, MYSQL_SERVER_VERSION, SYSTEM_TYPE, MACHINE_TYPE); + puts("MySQL utility for upgrading databases to new MySQL versions\n"); my_print_help(my_long_options); exit(0); break; @@ -732,6 +741,10 @@ int main(int argc, char **argv) if (handle_options(&argc, &argv, my_long_options, get_one_option)) die(NULL); + if (debug_info_flag) + my_end_arg= MY_CHECK_ERROR | MY_GIVE_INFO; + if (debug_check_flag) + my_end_arg= MY_CHECK_ERROR; if (tty_password) { @@ -780,7 +793,7 @@ int main(int argc, char **argv) create_mysql_upgrade_info_file(); free_used_memory(); - my_end(MY_CHECK_ERROR); + my_end(my_end_arg); exit(0); } diff --git a/client/mysqladmin.cc b/client/mysqladmin.cc index f6ff44c7d56..ce48ad03d33 100644 --- a/client/mysqladmin.cc +++ b/client/mysqladmin.cc @@ -40,9 +40,10 @@ ulonglong last_values[MAX_MYSQL_VAR]; static int interval=0; static my_bool option_force=0,interrupted=0,new_line=0, opt_compress=0, opt_relative=0, opt_verbose=0, opt_vertical=0, - tty_password= 0, info_flag= 0, opt_nobeep; -static uint tcp_port = 0, option_wait = 0, option_silent=0, nr_iterations, - opt_count_iterations= 0; + tty_password= 0, opt_nobeep; +static my_bool debug_info_flag= 0, debug_check_flag= 0; +static uint tcp_port = 0, option_wait = 0, option_silent=0, nr_iterations; +static uint opt_count_iterations= 0, my_end_arg; static ulong opt_connect_timeout, opt_shutdown_timeout; static char * unix_port=0; #ifdef LATER_HAVE_NDBCLUSTER_DB @@ -134,10 +135,16 @@ static struct my_option my_long_options[] = "Number of iterations to make. This works with -i (--sleep) only.", (uchar**) &nr_iterations, (uchar**) &nr_iterations, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, +#ifndef DBUG_OFF {"debug", '#', "Output debug log. Often this is 'd:t:o,filename'.", 0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, - {"debug-info", OPT_DEBUG_INFO, "Print some debug info at exit.", (uchar**) &info_flag, - (uchar**) &info_flag, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, +#endif + {"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", OPT_DEBUG_INFO, "Print some debug info at exit.", + (uchar**) &debug_info_flag, (uchar**) &debug_info_flag, + 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"force", 'f', "Don't ask for confirmation on drop database; with multiple commands, continue even if an error occurs.", (uchar**) &option_force, (uchar**) &option_force, 0, GET_BOOL, NO_ARG, 0, 0, @@ -315,6 +322,10 @@ int main(int argc,char *argv[]) free_defaults(save_argv); exit(ho_error); } + if (debug_info_flag) + my_end_arg= MY_CHECK_ERROR | MY_GIVE_INFO; + if (debug_check_flag) + my_end_arg= MY_CHECK_ERROR; if (argc == 0) { @@ -413,7 +424,7 @@ int main(int argc,char *argv[]) my_free(shared_memory_base_name,MYF(MY_ALLOW_ZERO_PTR)); #endif free_defaults(save_argv); - my_end(info_flag ? MY_CHECK_ERROR : 0); + my_end(my_end_arg); exit(error ? 1 : 0); return 0; } diff --git a/client/mysqlbinlog.cc b/client/mysqlbinlog.cc index edade347783..d8c4f4bbcbf 100644 --- a/client/mysqlbinlog.cc +++ b/client/mysqlbinlog.cc @@ -65,11 +65,13 @@ static bool one_database=0, to_last_remote_log= 0, disable_log_bin= 0; static bool opt_hexdump= 0; static bool opt_base64_output= 0; static const char* database= 0; -static my_bool force_opt= 0, short_form= 0, remote_opt= 0, info_flag; +static my_bool force_opt= 0, short_form= 0, remote_opt= 0; +static my_bool debug_info_flag, debug_check_flag; static my_bool force_if_open_opt= 1; static ulonglong offset = 0; static const char* host = 0; static int port= 0; +static uint my_end_arg; static const char* sock= 0; static const char* user = 0; static char* pass = 0; @@ -727,8 +729,12 @@ 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-info", OPT_DEBUG_INFO, "Print some debug info at exit.", (uchar**) &info_flag, - (uchar**) &info_flag, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, + {"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", OPT_DEBUG_INFO, "Print some debug info at exit.", + (uchar**) &debug_info_flag, (uchar**) &debug_info_flag, + 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"disable-log-bin", 'D', "Disable binary log. This is useful, if you " "enabled --to-last-log and are sending the output to the same MySQL server. " "This way you could avoid an endless loop. You would also like to use it " @@ -860,7 +866,7 @@ static void die(const char* fmt, ...) va_end(args); cleanup(); /* We cannot free DBUG, it is used in global destructors after exit(). */ - my_end((info_flag ? MY_CHECK_ERROR : 0) | MY_DONT_FREE_DBUG); + my_end(my_end_arg | MY_DONT_FREE_DBUG); exit(1); } @@ -868,7 +874,7 @@ static void die(const char* fmt, ...) static void print_version() { - printf("%s Ver 3.2 for %s at %s\n", my_progname, SYSTEM_TYPE, MACHINE_TYPE); + printf("%s Ver 3.3 for %s at %s\n", my_progname, SYSTEM_TYPE, MACHINE_TYPE); NETWARE_SET_SCREEN_MODE(1); } @@ -984,7 +990,10 @@ static int parse_args(int *argc, char*** argv) load_defaults("my",load_default_groups,argc,argv); if ((ho_error=handle_options(argc, argv, my_long_options, get_one_option))) exit(ho_error); - + if (debug_info_flag) + my_end_arg= MY_CHECK_ERROR | MY_GIVE_INFO; + if (debug_check_flag) + my_end_arg= MY_CHECK_ERROR; return 0; } @@ -1597,7 +1606,7 @@ int main(int argc, char** argv) my_free_open_file_info(); load_processor.destroy(); /* We cannot free DBUG, it is used in global destructors after exit(). */ - my_end((info_flag ? MY_CHECK_ERROR : 0) | MY_DONT_FREE_DBUG); + my_end(my_end_arg | MY_DONT_FREE_DBUG); if (file_not_closed_error) { diff --git a/client/mysqlcheck.c b/client/mysqlcheck.c index 372dfe860df..622975c51d5 100644 --- a/client/mysqlcheck.c +++ b/client/mysqlcheck.c @@ -15,7 +15,7 @@ /* By Jani Tolonen, 2001-04-20, MySQL Development Team */ -#define CHECK_VERSION "2.4.5" +#define CHECK_VERSION "2.5.0" #include "client_priv.h" #include <m_ctype.h> @@ -33,10 +33,11 @@ static my_bool opt_alldbs = 0, opt_check_only_changed = 0, opt_extended = 0, opt_compress = 0, opt_databases = 0, opt_fast = 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, info_flag= 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; static uint verbose = 0, opt_mysql_port=0; +static int my_end_arg; static char * opt_mysql_unix_port = 0; static char *opt_password = 0, *current_user = 0, *default_charset = (char *)MYSQL_DEFAULT_CHARSET_NAME, @@ -96,8 +97,12 @@ static struct my_option my_long_options[] = {"debug", '#', "Output debug log. Often this is 'd:t:o,filename'.", 0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, #endif - {"debug-info", OPT_DEBUG_INFO, "Print some debug info at exit.", (uchar**) &info_flag, - (uchar**) &info_flag, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, + {"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", OPT_DEBUG_INFO, "Print some debug info at exit.", + (uchar**) &debug_info_flag, (uchar**) &debug_info_flag, + 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"default-character-set", OPT_DEFAULT_CHARSET, "Set the default character set.", (uchar**) &default_charset, (uchar**) &default_charset, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, @@ -375,6 +380,10 @@ static int get_options(int *argc, char ***argv) } if (tty_password) opt_password = get_tty_password(NullS); + if (debug_info_flag) + my_end_arg= MY_CHECK_ERROR | MY_GIVE_INFO; + if (debug_check_flag) + my_end_arg= MY_CHECK_ERROR; return(0); } /* get_options */ @@ -762,7 +771,7 @@ int main(int argc, char **argv) */ if (get_options(&argc, &argv)) { - my_end(info_flag ? MY_CHECK_ERROR : 0); + my_end(my_end_arg); exit(EX_USAGE); } if (dbConnect(current_host, current_user, opt_password)) @@ -804,6 +813,6 @@ int main(int argc, char **argv) #ifdef HAVE_SMEM my_free(shared_memory_base_name,MYF(MY_ALLOW_ZERO_PTR)); #endif - my_end(info_flag ? MY_CHECK_ERROR : 0); + my_end(my_end_arg); return(first_error!=0); } /* main */ diff --git a/client/mysqldump.c b/client/mysqldump.c index 0f30ebddacc..60252be0910 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -36,7 +36,7 @@ ** 10 Jun 2003: SET NAMES and --no-set-names by Alexander Barkov */ -#define DUMP_VERSION "10.12" +#define DUMP_VERSION "10.13" #include <my_global.h> #include <my_sys.h> @@ -100,9 +100,9 @@ static my_bool verbose= 0, opt_no_create_info= 0, opt_no_data= 0, opt_dump_triggers= 0, opt_routines=0, opt_tz_utc=1, opt_events= 0, opt_alltspcs=0, opt_notspcs= 0; +static my_bool insert_pat_inited= 0, debug_info_flag= 0, debug_check_flag= 0; static ulong opt_max_allowed_packet, opt_net_buffer_length; static MYSQL mysql_connection,*mysql=0; -static my_bool insert_pat_inited= 0, info_flag; static DYNAMIC_STRING insert_pat; static char *opt_password=0,*current_user=0, *current_host=0,*path=0,*fields_terminated=0, @@ -116,7 +116,8 @@ static char compatible_mode_normal_str[255]; static ulong opt_compatible_mode= 0; #define MYSQL_OPT_MASTER_DATA_EFFECTIVE_SQL 1 #define MYSQL_OPT_MASTER_DATA_COMMENTED_SQL 2 -static uint opt_mysql_port= 0, opt_master_data; +static uint opt_mysql_port= 0, opt_master_data; +static uint my_end_arg; static char * opt_mysql_unix_port=0; static int first_error=0; static DYNAMIC_STRING extended_row; @@ -242,8 +243,12 @@ 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-info", OPT_DEBUG_INFO, "Print some debug info at exit.", (uchar**) &info_flag, - (uchar**) &info_flag, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, + {"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", OPT_DEBUG_INFO, "Print some debug info at exit.", + (uchar**) &debug_info_flag, (uchar**) &debug_info_flag, + 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"default-character-set", OPT_DEFAULT_CHARSET, "Set the default character set.", (uchar**) &default_charset, (uchar**) &default_charset, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, @@ -724,7 +729,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), break; case '#': DBUG_PUSH(argument ? argument : default_dbug_option); - info_flag= 1; + debug_info_flag= 1; break; #include <sslopt-case.h> case 'V': print_version(); exit(0); @@ -858,6 +863,10 @@ static int get_options(int *argc, char ***argv) *mysql_params->p_max_allowed_packet= opt_max_allowed_packet; *mysql_params->p_net_buffer_length= opt_net_buffer_length; + if (debug_info_flag) + my_end_arg= MY_CHECK_ERROR | MY_GIVE_INFO; + if (debug_check_flag) + my_end_arg= MY_CHECK_ERROR; if (opt_delayed) opt_lock=0; /* Can't have lock with delayed */ @@ -1262,7 +1271,7 @@ static void free_resources() dynstr_free(&insert_pat); if (defaults_argv) free_defaults(defaults_argv); - my_end(info_flag ? MY_CHECK_ERROR : 0); + my_end(my_end_arg); } diff --git a/client/mysqlimport.c b/client/mysqlimport.c index 396063731cf..b09ae7a172a 100644 --- a/client/mysqlimport.c +++ b/client/mysqlimport.c @@ -24,7 +24,7 @@ ** * * ** ************************* */ -#define IMPORT_VERSION "3.6" +#define IMPORT_VERSION "3.7" #include "client_priv.h" #include "mysql_version.h" @@ -49,8 +49,8 @@ static char *add_load_option(char *ptr,const char *object, static my_bool verbose=0,lock_tables=0,ignore_errors=0,opt_delete=0, replace=0,silent=0,ignore=0,opt_compress=0, opt_low_priority= 0, tty_password= 0; -static my_bool info_flag= 0; -static uint opt_use_threads=0, opt_local_file=0; +static my_bool debug_info_flag= 0, debug_check_flag= 0; +static uint opt_use_threads=0, opt_local_file=0, my_end_arg= 0; static char *opt_password=0, *current_user=0, *current_host=0, *current_db=0, *fields_terminated=0, *lines_terminated=0, *enclosed=0, *opt_enclosed=0, @@ -87,8 +87,12 @@ static struct my_option my_long_options[] = 0, 0, 0}, {"debug",'#', "Output debug log. Often this is 'd:t:o,filename'.", 0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, - {"debug-info", OPT_DEBUG_INFO, "Print some debug info at exit.", (uchar**) &info_flag, - (uchar**) &info_flag, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, + {"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", OPT_DEBUG_INFO, "Print some debug info at exit.", + (uchar**) &debug_info_flag, (uchar**) &debug_info_flag, + 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"delete", 'd', "First delete all rows from table.", (uchar**) &opt_delete, (uchar**) &opt_delete, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"fields-terminated-by", OPT_FTB, @@ -254,6 +258,10 @@ static int get_options(int *argc, char ***argv) if ((ho_error=handle_options(argc, argv, my_long_options, get_one_option))) exit(ho_error); + if (debug_info_flag) + my_end_arg= MY_CHECK_ERROR | MY_GIVE_INFO; + if (debug_check_flag) + my_end_arg= MY_CHECK_ERROR; if (enclosed && opt_enclosed) { @@ -659,6 +667,6 @@ int main(int argc, char **argv) my_free(shared_memory_base_name,MYF(MY_ALLOW_ZERO_PTR)); #endif free_defaults(argv_to_free); - my_end(info_flag ? MY_CHECK_ERROR : 0); + my_end(my_end_arg); return(exitcode); } diff --git a/client/mysqlshow.c b/client/mysqlshow.c index 649658d6223..fb89589f3e1 100644 --- a/client/mysqlshow.c +++ b/client/mysqlshow.c @@ -15,7 +15,7 @@ /* Show databases, tables or columns */ -#define SHOW_VERSION "9.6" +#define SHOW_VERSION "9.10" #include "client_priv.h" #include <my_sys.h> @@ -28,7 +28,9 @@ static char * host=0, *opt_password=0, *user=0; static my_bool opt_show_keys= 0, opt_compress= 0, opt_count=0, opt_status= 0; -static my_bool tty_password= 0, opt_table_type= 0, info_flag= 0; +static my_bool tty_password= 0, opt_table_type= 0; +static my_bool debug_info_flag= 0, debug_check_flag= 0; +static uint my_end_arg= 0; static uint opt_verbose=0; static char *default_charset= (char*) MYSQL_DEFAULT_CHARSET_NAME; @@ -150,7 +152,7 @@ int main(int argc, char **argv) #ifdef HAVE_SMEM my_free(shared_memory_base_name,MYF(MY_ALLOW_ZERO_PTR)); #endif - my_end(info_flag ? MY_CHECK_ERROR : 0); + my_end(my_end_arg); exit(error ? 1 : 0); return 0; /* No compiler warnings */ } @@ -176,8 +178,12 @@ static struct my_option my_long_options[] = 0, 0, 0}, {"debug", '#', "Output debug log. Often this is 'd:t:o,filename'.", 0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, - {"debug-info", OPT_DEBUG_INFO, "Print some debug info at exit.", (uchar**) &info_flag, - (uchar**) &info_flag, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, + {"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", OPT_DEBUG_INFO, "Print some debug info at exit.", + (uchar**) &debug_info_flag, (uchar**) &debug_info_flag, + 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"help", '?', "Display this help and exit.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, {"host", 'h', "Connect to host.", (uchar**) &host, (uchar**) &host, 0, GET_STR, @@ -326,6 +332,10 @@ get_options(int *argc,char ***argv) */ opt_verbose= 2; } + if (debug_info_flag) + my_end_arg= MY_CHECK_ERROR | MY_GIVE_INFO; + if (debug_check_flag) + my_end_arg= MY_CHECK_ERROR; return; } diff --git a/client/mysqlslap.c b/client/mysqlslap.c index 546b9dee3f5..33173858228 100644 --- a/client/mysqlslap.c +++ b/client/mysqlslap.c @@ -69,7 +69,7 @@ TODO: */ -#define SHOW_VERSION "0.9" +#define SLAP_VERSION "1.0" #define HUGE_STRING_LENGTH 8196 #define RAND_STRING_SIZE 126 @@ -128,10 +128,8 @@ const char *delimiter= "\n"; const char *create_schema_string= "mysqlslap"; -static my_bool opt_preserve; - +static my_bool opt_preserve= 0, debug_info_flag= 0, debug_check_flag= 0; static my_bool opt_only_print= FALSE; - static my_bool opt_compress= FALSE, tty_password= FALSE, opt_silent= FALSE, auto_generate_sql_autoincrement= FALSE, @@ -144,13 +142,14 @@ static unsigned long connect_flags= CLIENT_MULTI_RESULTS; static int verbose, delimiter_length; const char *num_int_cols_opt; const char *num_char_cols_opt; + /* Yes, we do set defaults here */ static unsigned int num_int_cols= 1; static unsigned int num_char_cols= 1; static unsigned int num_int_cols_index= 0; static unsigned int num_char_cols_index= 0; - static unsigned int iterations; +static uint my_end_arg= 0; static char *default_charset= (char*) MYSQL_DEFAULT_CHARSET_NAME; static ulonglong actual_queries= 0; static ulonglong auto_actual_queries; @@ -403,7 +402,7 @@ int main(int argc, char **argv) my_free(shared_memory_base_name, MYF(MY_ALLOW_ZERO_PTR)); #endif free_defaults(defaults_argv); - my_end(0); + my_end(my_end_arg); return 0; } @@ -546,6 +545,11 @@ static struct my_option my_long_options[] = {"debug", '#', "Output debug log. Often this is 'd:t:o,filename'.", (uchar**) &default_dbug_option, (uchar**) &default_dbug_option, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, + {"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, + (uchar**) &debug_info_flag, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"delimiter", 'F', "Delimiter to use in SQL statements supplied in file or command line.", (uchar**) &delimiter, (uchar**) &delimiter, 0, GET_STR, REQUIRED_ARG, @@ -636,7 +640,7 @@ static struct my_option my_long_options[] = static void print_version(void) { - printf("%s Ver %s Distrib %s, for %s (%s)\n",my_progname,SHOW_VERSION, + printf("%s Ver %s Distrib %s, for %s (%s)\n",my_progname, SLAP_VERSION, MYSQL_SERVER_VERSION,SYSTEM_TYPE,MACHINE_TYPE); } @@ -1090,6 +1094,10 @@ get_options(int *argc,char ***argv) DBUG_ENTER("get_options"); if ((ho_error= handle_options(argc, argv, my_long_options, get_one_option))) exit(ho_error); + if (debug_info_flag) + my_end_arg= MY_CHECK_ERROR | MY_GIVE_INFO; + if (debug_check_flag) + my_end_arg= MY_CHECK_ERROR; if (!user) user= (char *)"root"; diff --git a/client/mysqltest.c b/client/mysqltest.c index e5b9a2eaf12..cbe34bb6690 100644 --- a/client/mysqltest.c +++ b/client/mysqltest.c @@ -31,7 +31,7 @@ Holyfoot */ -#define MTEST_VERSION "3.2" +#define MTEST_VERSION "3.3" #include "client_priv.h" #include <mysql_version.h> @@ -80,6 +80,7 @@ const char *opt_include= 0, *opt_charsets_dir; static int opt_port= 0; static int opt_max_connect_retries; static my_bool opt_compress= 0, silent= 0, verbose= 0; +static my_bool debug_info_flag= 0, debug_check_flag= 0; static my_bool tty_password= 0; static my_bool opt_mark_progress= 0; static my_bool ps_protocol= 0, ps_protocol_enabled= 0; @@ -100,6 +101,7 @@ static const char *load_default_groups[]= { "mysqltest", "client", 0 }; static char line_buffer[MAX_DELIMITER_LENGTH], *line_buffer_pos= line_buffer; static uint start_lineno= 0; /* Start line of current command */ +static uint my_end_arg= 0; static char delimiter[MAX_DELIMITER_LENGTH]= ";"; static uint delimiter_length= 1; @@ -807,12 +809,11 @@ void free_used_memory() static void cleanup_and_exit(int exit_code) { free_used_memory(); - my_end(MY_CHECK_ERROR); + my_end(my_end_arg | MY_CHECK_ERROR); if (!silent) { - switch (exit_code) - { + switch (exit_code) { case 1: printf("not ok\n"); break; @@ -4482,6 +4483,12 @@ static struct my_option my_long_options[] = {"debug", '#', "Output debug log. Often this is 'd:t:o,filename'.", 0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, #endif + {"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", OPT_DEBUG_INFO, "Print some debug info at exit.", + (uchar**) &debug_info_flag, (uchar**) &debug_info_flag, + 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"host", 'h', "Connect to host.", (uchar**) &opt_host, (uchar**) &opt_host, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"include", 'i', "Include SQL before each test case.", (uchar**) &opt_include, @@ -4724,6 +4731,10 @@ int parse_args(int argc, char **argv) opt_db= *argv; if (tty_password) opt_pass= get_tty_password(NullS); /* purify tested */ + if (debug_info_flag) + my_end_arg= MY_CHECK_ERROR | MY_GIVE_INFO; + if (debug_check_flag) + my_end_arg= MY_CHECK_ERROR; return 0; } diff --git a/include/my_sys.h b/include/my_sys.h index c452bd21e15..76c9a7f02c7 100644 --- a/include/my_sys.h +++ b/include/my_sys.h @@ -150,7 +150,7 @@ extern ulonglong sf_malloc_mem_limit; #else #define my_checkmalloc() #undef TERMINATE -#define TERMINATE(A) {} +#define TERMINATE(A,B) {} #define QUICK_SAFEMALLOC #define NORMAL_SAFEMALLOC extern void *my_malloc(size_t Size,myf MyFlags); @@ -618,7 +618,7 @@ extern int nt_share_delete(const char *name,myf MyFlags); #endif #ifndef TERMINATE -extern void TERMINATE(FILE *file); +extern void TERMINATE(FILE *file, uint flag); #endif extern void init_glob_errs(void); extern FILE *my_fopen(const char *FileName,int Flags,myf MyFlags); diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c index 46d0c8f1037..b2f59ba2a5a 100644 --- a/libmysql/libmysql.c +++ b/libmysql/libmysql.c @@ -215,7 +215,7 @@ void STDCALL mysql_server_end() } static MYSQL_PARAMETERS mysql_internal_parameters= -{&max_allowed_packet, &net_buffer_length}; +{&max_allowed_packet, &net_buffer_length, 0}; MYSQL_PARAMETERS *STDCALL mysql_get_parameters(void) { diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index 6ec4045bb43..c8f4bf5db1b 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -1655,7 +1655,7 @@ sub generate_cmdline_mysqldump ($) { my($mysqld) = @_; return mtr_native_path($exe_mysqldump) . - " --no-defaults -uroot --debug-info " . + " --no-defaults -uroot --debug-check " . "--port=$mysqld->{'port'} " . "--socket=$mysqld->{'path_sock'} --password="; } @@ -1908,7 +1908,7 @@ sub environment_setup () { # ---------------------------------------------------- my $cmdline_mysqlcheck= mtr_native_path($exe_mysqlcheck) . - " --no-defaults --debug-info -uroot " . + " --no-defaults --debug-check -uroot " . "--port=$master->[0]->{'port'} " . "--socket=$master->[0]->{'path_sock'} --password="; @@ -1960,7 +1960,7 @@ sub environment_setup () { # ---------------------------------------------------- my $cmdline_mysqlimport= mtr_native_path($exe_mysqlimport) . - " -uroot --debug-info " . + " -uroot --debug-check " . "--port=$master->[0]->{'port'} " . "--socket=$master->[0]->{'path_sock'} --password="; @@ -1977,7 +1977,7 @@ sub environment_setup () { # ---------------------------------------------------- my $cmdline_mysqlshow= mtr_native_path($exe_mysqlshow) . - " -uroot --debug-info " . + " -uroot --debug-check " . "--port=$master->[0]->{'port'} " . "--socket=$master->[0]->{'path_sock'} --password="; @@ -1993,7 +1993,7 @@ sub environment_setup () { # ---------------------------------------------------- my $cmdline_mysqlbinlog= mtr_native_path($exe_mysqlbinlog) . - " --no-defaults --disable-force-if-open --debug-info"; + " --no-defaults --disable-force-if-open --debug-check"; if ( !$opt_extern && $mysql_version_id >= 50000 ) { $cmdline_mysqlbinlog .=" --character-sets-dir=$path_charsetsdir"; @@ -2011,7 +2011,7 @@ sub environment_setup () { # ---------------------------------------------------- my $cmdline_mysql= mtr_native_path($exe_mysql) . - " --no-defaults --debug-info --host=localhost --user=root --password= " . + " --no-defaults --debug-check --host=localhost --user=root --password= " . "--port=$master->[0]->{'port'} " . "--socket=$master->[0]->{'path_sock'} ". "--character-sets-dir=$path_charsetsdir"; diff --git a/mysys/my_getsystime.c b/mysys/my_getsystime.c index 17ba1232d7a..43bb6c08af9 100644 --- a/mysys/my_getsystime.c +++ b/mysys/my_getsystime.c @@ -17,11 +17,13 @@ /* thus to get the current time we should use the system function with the highest possible resolution */ +#include "mysys_priv.h" +#include "my_static.h" + #ifdef __NETWARE__ #include <nks/time.h> #endif -#include "mysys_priv.h" ulonglong my_getsystime() { #ifdef HAVE_CLOCK_GETTIME @@ -30,7 +32,6 @@ ulonglong my_getsystime() return (ulonglong)tp.tv_sec*10000000+(ulonglong)tp.tv_nsec/100; #elif defined(__WIN__) LARGE_INTEGER t_cnt; - struct timeval tv; if (query_performance_frequency) { QueryPerformanceCounter(&t_cnt); @@ -38,8 +39,7 @@ ulonglong my_getsystime() t_cnt.QuadPart % query_performance_frequency * 10000000/ query_performance_frequency+query_performance_offset); } - gettimeofday(&tv,NULL); - return (ulonglong)tv.tv_sec*10000000+(ulonglong)tv.tv_usec*10; + return 0; #elif defined(__NETWARE__) NXTime_t tm; NXGetTime(NX_SINCE_1970, NX_NSECONDS, &tm); @@ -62,26 +62,13 @@ ulonglong my_getsystime() */ -#define DELTA_FOR_SECONDS LL(500000000) /* Half a second */ - time_t my_time(myf flags __attribute__((unused))) { + time_t t; #ifdef HAVE_GETHRTIME - static hrtime_t prev_gethrtime= 0; - static time_t cur_time= 0; - - hrtime_t cur_gethrtime; - pthread_mutex_lock(&THR_LOCK_time); - cur_gethrtime= gethrtime(); - if ((prev_gethrtime - cur_gethrtime) > DELTA_FOR_SECONDS) - { - cur_time= time(0); - prev_gethrtime= cur_gethrtime; - } - pthread_mutex_unlock(&THR_LOCK_time); - return cur_time; + (void) my_micro_time_and_time(&t); + return t; #else - time_t t; /* The following loop is here beacuse time() may fail on some systems */ while ((t= time(0)) == (time_t) -1) { @@ -120,11 +107,12 @@ ulonglong my_micro_time() #if defined(__WIN__) if (query_performance_frequency) { - QueryPerformanceCounter(&newtime); + QueryPerformanceCounter((LARGE_INTEGER*) &newtime); newtime/= (query_performance_frequency * 1000000); } else - newtime= (GetTickCount() * 1000; /* GetTickCount only returns milliseconds */ + newtime= (GetTickCount() * 1000); /* GetTickCount only returns milliseconds */ + return newtime; #elif defined(HAVE_GETHRTIME) return gethrtime()/1000; #else @@ -133,13 +121,13 @@ ulonglong my_micro_time() while (gettimeofday(&t, NULL) != 0) {} newtime= (ulonglong)t.tv_sec * 1000000 + t.tv_usec; -#endif /* defined(__WIN__) */ return newtime; +#endif /* defined(__WIN__) */ } /* - Return time in seconds and timer in microseconds + Return time in seconds and timer in microseconds (not different start!) SYNOPSIS my_micro_time_and_time() @@ -152,24 +140,48 @@ ulonglong my_micro_time() to measure the time of a query (for the slow query log) IMPLEMENTATION - Same as my_micro_time() + Value of time is as in time() call. + Value of microtime is same as my_micro_time(), which may be totally unrealated + to time() RETURN Value in microseconds from some undefined point in time */ +#define DELTA_FOR_SECONDS LL(500000000) /* Half a second */ + ulonglong my_micro_time_and_time(time_t *time_arg) { ulonglong newtime; #if defined(__WIN__) if (query_performance_frequency) { - QueryPerformanceCounter((LARGE_INTEGER *) &newtime); + QueryPerformanceCounter((LARGE_INTEGER*) &newtime); newtime/= (query_performance_frequency * 1000000); } else - newtime= (GetTickCount() * 1000; /* GetTickCount only returns milliseconds */ + newtime= (GetTickCount() * 1000); /* GetTickCount only returns milliseconds */ (void) time(time_arg); + return newtime; +#elif defined(HAVE_GETHRTIME) + /* + Solaris has a very slow time() call. We optimize this by using the very fast + gethrtime() call and only calling time() every 1/2 second + */ + static hrtime_t prev_gethrtime= 0; + static time_t cur_time= 0; + hrtime_t cur_gethrtime; + + pthread_mutex_lock(&THR_LOCK_time); + cur_gethrtime= gethrtime(); + if ((cur_gethrtime - prev_gethrtime) > DELTA_FOR_SECONDS) + { + cur_time= time(0); + prev_gethrtime= cur_gethrtime; + } + *time_arg= cur_time; + pthread_mutex_unlock(&THR_LOCK_time); + return cur_gethrtime/1000; #else struct timeval t; /* The following loop is here because gettimeofday may fail on some systems */ @@ -177,8 +189,8 @@ ulonglong my_micro_time_and_time(time_t *time_arg) {} *time_arg= t.tv_sec; newtime= (ulonglong)t.tv_sec * 1000000 + t.tv_usec; -#endif /* defined(__WIN__) */ return newtime; +#endif /* defined(__WIN__) */ } diff --git a/mysys/my_init.c b/mysys/my_init.c index 8281d7ced99..127e94c958b 100644 --- a/mysys/my_init.c +++ b/mysys/my_init.c @@ -130,8 +130,9 @@ void my_end(int infoflag) */ FILE *info_file= DBUG_FILE; my_bool print_info= (info_file != stderr); - /* We do not use DBUG_ENTER here, as after cleanup DBUG is no longer - operational, so we cannot use DBUG_RETURN. + /* + We do not use DBUG_ENTER here, as after cleanup DBUG is no longer + operational, so we cannot use DBUG_RETURN. */ DBUG_PRINT("info",("Shutting down")); if (!info_file) @@ -185,7 +186,7 @@ Voluntary context switches %ld, Involuntary context switches %ld\n", fprintf(info_file,"\nRun time: %.1f\n",(double) clock()/CLOCKS_PER_SEC); #endif #if defined(SAFEMALLOC) - TERMINATE(stderr); /* Give statistic on screen */ + TERMINATE(stderr, 1); /* Give statistic on screen */ #elif defined(__WIN__) && defined(_MSC_VER) _CrtSetReportMode( _CRT_WARN, _CRTDBG_MODE_FILE ); _CrtSetReportFile( _CRT_WARN, _CRTDBG_FILE_STDERR ); @@ -197,6 +198,10 @@ Voluntary context switches %ld, Involuntary context switches %ld\n", _CrtDumpMemoryLeaks(); #endif } + else if (infoflag & MY_CHECK_ERROR) + { + TERMINATE(stderr, 0); /* Print memory leaks on screen */ + } if (!(infoflag & MY_DONT_FREE_DBUG)) { diff --git a/mysys/my_static.c b/mysys/my_static.c index 92c959c4c6c..b8bff0e9810 100644 --- a/mysys/my_static.c +++ b/mysys/my_static.c @@ -18,11 +18,9 @@ a shared library */ -#if !defined(stdin) #include "mysys_priv.h" #include "my_static.h" #include "my_alarm.h" -#endif my_bool timed_mutexes= 0; diff --git a/mysys/safemalloc.c b/mysys/safemalloc.c index 30c501c54ee..7a2f448b2dc 100644 --- a/mysys/safemalloc.c +++ b/mysys/safemalloc.c @@ -51,7 +51,7 @@ (equivalent to realloc()) FREE( pPtr ) Free memory allocated by NEW (equivalent to free()) - TERMINATE(file) End system, report errors and stats on file + TERMINATE(file,flag) End system, report errors and stats on file I personally use two more functions, but have not included them here: char *STRSAVE( sPtr ) Save a copy of the string in dynamic memory char *RENEW( pPtr, uSize ) @@ -352,12 +352,15 @@ static int check_ptr(const char *where, uchar *ptr, const char *filename, /* - TERMINATE(FILE *file) - Report on all the memory pieces that have not been - free'ed as well as the statistics. + Report on all the memory pieces that have not been free'ed + + SYNOPSIS + TERMINATE() + file Write output to this file + flag If <> 0, also write statistics */ -void TERMINATE(FILE *file) +void TERMINATE(FILE *file, uint flag) { struct st_irem *irem; DBUG_ENTER("TERMINATE"); @@ -373,8 +376,7 @@ void TERMINATE(FILE *file) { if (file) { - fprintf(file, "Warning: Not freed memory segments: %u\n", - sf_malloc_count); + fprintf(file, "Warning: Not freed memory segments: %u\n", sf_malloc_count); (void) fflush(file); } DBUG_PRINT("safe",("sf_malloc_count: %u", sf_malloc_count)); @@ -414,7 +416,7 @@ void TERMINATE(FILE *file) } } /* Report the memory usage statistics */ - if (file) + if (file && flag) { fprintf(file, "Maximum memory usage: %ld bytes (%ldk)\n", sf_malloc_max_memory, (sf_malloc_max_memory + 1023L) / 1024L); diff --git a/sql/item_xmlfunc.cc b/sql/item_xmlfunc.cc index 6bc73f49a5a..067af930d6f 100644 --- a/sql/item_xmlfunc.cc +++ b/sql/item_xmlfunc.cc @@ -2767,9 +2767,9 @@ String *Item_xml_str_func::parse_xml(String *raw_xml, String *parsed_xml_buf) if ((rc= my_xml_parse(&p, raw_xml->ptr(), raw_xml->length())) != MY_XML_OK) { char buf[128]; - my_snprintf(buf, sizeof(buf)-1, "parse error at line %d pos %u: %s", + my_snprintf(buf, sizeof(buf)-1, "parse error at line %d pos %lu: %s", my_xml_error_lineno(&p) + 1, - my_xml_error_pos(&p) + 1, + (ulong) my_xml_error_pos(&p) + 1, my_xml_error_string(&p)); push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN, ER_WRONG_VALUE, diff --git a/sql/sql_test.cc b/sql/sql_test.cc index 5bd01eea68c..0fe299d4505 100644 --- a/sql/sql_test.cc +++ b/sql/sql_test.cc @@ -509,7 +509,7 @@ Next alarm time: %lu\n", fflush(stdout); my_checkmalloc(); fprintf(stdout,"\nBegin safemalloc memory dump:\n"); // tag needed for test suite - TERMINATE(stdout); // Write malloc information + TERMINATE(stdout, 1); // Write malloc information fprintf(stdout,"\nEnd safemalloc memory dump.\n"); #ifdef HAVE_MALLINFO diff --git a/unittest/mysys/base64-t.c b/unittest/mysys/base64-t.c index 7e4afbb3128..1622fe22b4d 100644 --- a/unittest/mysys/base64-t.c +++ b/unittest/mysys/base64-t.c @@ -14,6 +14,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include <my_global.h> +#include <my_sys.h> #include <base64.h> #include <tap.h> #include <string.h> @@ -26,6 +27,7 @@ main(void) { int i, cmp; size_t j, k, l, dst_len, needed_length; + MY_INIT("base64-t"); plan(BASE64_LOOP_COUNT * BASE64_ROWS); diff --git a/unittest/mysys/bitmap-t.c b/unittest/mysys/bitmap-t.c index 779508ee228..069a14ff553 100644 --- a/unittest/mysys/bitmap-t.c +++ b/unittest/mysys/bitmap-t.c @@ -18,12 +18,11 @@ library. */ -#include <tap.h> - #include <my_global.h> +#include <my_sys.h> #include <my_bitmap.h> - -#include <string.h> +#include <tap.h> +#include <m_string.h> uint get_rand_bit(uint bitsize) { @@ -379,6 +378,8 @@ int main() int i; int const min_size = 1; int const max_size = 1024; + MY_INIT("bitmap-t"); + plan(max_size - min_size); for (i= min_size; i < max_size; i++) ok(do_test(i) == 0, "bitmap size %d", i); diff --git a/unittest/mysys/my_atomic-t.c b/unittest/mysys/my_atomic-t.c index 8280aff5422..a9e98a95cdb 100644 --- a/unittest/mysys/my_atomic-t.c +++ b/unittest/mysys/my_atomic-t.c @@ -14,9 +14,9 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include <my_global.h> -#include <tap.h> #include <my_sys.h> #include <my_atomic.h> +#include <tap.h> int32 a32,b32,c32; my_atomic_rwlock_t rwl; @@ -160,6 +160,7 @@ err: int main() { int err; + MY_INIT("my_atomic-t.c"); diag("N CPUs: %d", my_getncpus()); err= my_atomic_initialize(); |