From 2ed54c12e50270365cb53c7358ea47357d903b42 Mon Sep 17 00:00:00 2001 From: "lenz@mysql.com" <> Date: Thu, 26 Aug 2004 19:57:32 +0200 Subject: [PATCH 01/14] - fixed brain fart in Bootrap - it never actually caught failures when pulling BK trees before. --- Build-tools/Bootstrap | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Build-tools/Bootstrap b/Build-tools/Bootstrap index c1063363bdf..8cad093bc5f 100755 --- a/Build-tools/Bootstrap +++ b/Build-tools/Bootstrap @@ -123,14 +123,16 @@ if (($opt_directory ne $PWD) && (!-d $opt_directory && !$opt_dry_run)) if ($opt_pull) { &logger("Updating BK tree $REPO to latest ChangeSet first"); - $command= "cd $REPO; bk pull; cd .."; - &run_command($command, "Could not update $REPO!"); + chdir ($REPO) or &abort("Could not chdir to $REPO!"); + &run_command("bk pull", "Could not update $REPO!"); + chdir ($PWD) or &abort("Could not chdir to $PWD!"); unless ($opt_skip_manual) { &logger("Updating manual tree in $opt_docdir"); - $command= "cd $opt_docdir; bk pull; cd .."; - &run_command($command, "Could not update $opt_docdir!"); + chdir ($opt_docdir) or &abort("Could not chdir to $opt_docdir!"); + &run_command("bk pull", "Could not update $opt_docdir!"); + chdir ($PWD) or &abort("Could not chdir to $PWD!"); } } From caf1e73be7bf3d968dcf3fa00c0f69fbfab119f0 Mon Sep 17 00:00:00 2001 From: "rburnett@build.mysql.com" <> Date: Fri, 27 Aug 2004 01:08:57 +0200 Subject: [PATCH 02/14] Adding a file that was missed during the first push This file was part of the patch for Bug #4466 Nothing in .err when mysql service ends because of malformed my.ini options message.mc: new file --- VC++Files/sql/message.mc | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 VC++Files/sql/message.mc diff --git a/VC++Files/sql/message.mc b/VC++Files/sql/message.mc new file mode 100644 index 00000000000..a1a7c8cff7e --- /dev/null +++ b/VC++Files/sql/message.mc @@ -0,0 +1,8 @@ +MessageId = 100 +Severity = Error +Facility = Application +SymbolicName = MSG_DEFAULT +Language = English +%1For more information, see Help and Support Center at http://www.mysql.com. + + From 43b792d5cfa7cee89616197d72206d8dd42ce97d Mon Sep 17 00:00:00 2001 From: "bar@mysql.com" <> Date: Fri, 27 Aug 2004 10:54:57 +0500 Subject: [PATCH 03/14] win1251.conf: Wrong UPPER/LOWER translation for Cyrillic letter tse was fixed. bug#5110 --- BitKeeper/etc/logging_ok | 1 + sql/share/charsets/win1251.conf | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/BitKeeper/etc/logging_ok b/BitKeeper/etc/logging_ok index 8183cf5040d..698f7655b6e 100644 --- a/BitKeeper/etc/logging_ok +++ b/BitKeeper/etc/logging_ok @@ -16,6 +16,7 @@ arjen@george.bitbike.com bar@bar.intranet.mysql.r18.ru bar@bar.mysql.r18.ru bar@bar.udmsearch.izhnet.ru +bar@mysql.com bell@laptop.sanja.is.com.ua bell@sanja.is.com.ua bk@admin.bk diff --git a/sql/share/charsets/win1251.conf b/sql/share/charsets/win1251.conf index a5ccc3190ad..e05568323b4 100644 --- a/sql/share/charsets/win1251.conf +++ b/sql/share/charsets/win1251.conf @@ -41,7 +41,7 @@ A0 A1 A2 A3 A4 A5 A6 A7 B8 A9 AA AB AC AD AE AF B0 B1 B2 B3 B4 B5 B6 B7 B8 B9 BA BB BC BD BE BF E0 E1 E2 E3 E4 E5 E6 E7 E8 E9 EA EB EC ED EE EF - F0 F1 F2 F3 F4 F5 F5 F7 F8 F9 FA FB FC FD FE FF + F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 FA FB FC FD FE FF E0 E1 E2 E3 E4 E5 E6 E7 E8 E9 EA EB EC ED EE EF F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 FA FB FC FD FE FF @@ -59,7 +59,7 @@ A0 A1 A2 A3 A4 A5 A6 A7 A8 A9 AA AB AC AD AE AF B0 B1 B2 B3 B4 B5 B6 B7 A8 B9 BA BB BC BD BE BF C0 C1 C2 C3 C4 C5 C6 C7 C8 C9 CA CB CC CD CE CF - D0 D1 D2 D3 D4 D5 D5 D7 D8 D9 DA DB DC DD DE DF + D0 D1 D2 D3 D4 D5 D6 D7 D8 D9 DA DB DC DD DE DF C0 C1 C2 C3 C4 C5 C6 C7 C8 C9 CA CB CC CD CE CF D0 D1 D2 D3 D4 D5 D6 D7 D8 D9 DA DB DC DD DE DF From 5258ea12cf1ccc723e6bb304a1fbe0e3abf1d204 Mon Sep 17 00:00:00 2001 From: "bar@mysql.com" <> Date: Fri, 27 Aug 2004 12:09:28 +0500 Subject: [PATCH 04/14] table.cc: Bug #4558 Escape handling error for ENUM values in SJIS encoding --- sql/table.cc | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/sql/table.cc b/sql/table.cc index 7e6338a3f3f..898ed4bca3d 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -993,8 +993,26 @@ ulong next_io_size(register ulong pos) void append_unescaped(String *res,const char *pos) { - for (; *pos ; pos++) +#ifdef USE_MB + const char *end= pos + strlen(pos); +#endif + + for (; *pos ; ) { +#ifdef USE_MB + /* + Note, there is no needs to propagate this code into 4.1. + */ + uint mblen; + if (use_mb(default_charset_info) && + (mblen= my_ismbchar(default_charset_info, pos, end))) + { + res->append(pos, mblen); + pos+= mblen; + continue; + } +#endif + switch (*pos) { case 0: /* Must be escaped for 'mysql' */ res->append('\\'); @@ -1020,6 +1038,7 @@ void append_unescaped(String *res,const char *pos) res->append(*pos); break; } + pos++; } } From 4d1dedd70da4f5d325229d24d38bd81732ccbc99 Mon Sep 17 00:00:00 2001 From: "bar@mysql.com" <> Date: Fri, 27 Aug 2004 21:17:29 +0500 Subject: [PATCH 05/14] Compile all charset conversion tables if --with-extra-charsets=all or --with-extra-charsets=complex is given. --- acconfig.h | 3 +++ configure.in | 2 ++ sql/convert.cc | 3 +++ 3 files changed, 8 insertions(+) diff --git a/acconfig.h b/acconfig.h index 825842d256a..71dea4825f6 100644 --- a/acconfig.h +++ b/acconfig.h @@ -281,6 +281,9 @@ /* READLINE: */ #undef VOID_SIGHANDLER +/* Define this if you want extra character set conversion table*/ +#undef DEFINE_ALL_CHARACTER_SETS + /* Leave that blank line there!! Autoheader needs it. If you're adding to this file, keep in mind: diff --git a/configure.in b/configure.in index 2adf2208332..7853b615ae0 100644 --- a/configure.in +++ b/configure.in @@ -2262,9 +2262,11 @@ elif test "$extra_charsets" = complex; then CHARSETS=`/bin/ls -1 $srcdir/strings/ctype-*.c | \ sed -e 's;^.*/ctype-;;' -e 's;.c$;;'` CHARSETS=`echo $CHARSETS` # get rid of line breaks + AC_DEFINE([DEFINE_ALL_CHARACTER_SETS]) else if test "$extra_charsets" = all; then CHARSETS="$CHARSETS_AVAILABLE $CHARSETS_DEPRECATED" + AC_DEFINE([DEFINE_ALL_CHARACTER_SETS]) else CHARSETS=`echo $extra_charsets | sed -e 's/,/ /g'` fi diff --git a/sql/convert.cc b/sql/convert.cc index e4ae13d1e07..f84c80a6121 100644 --- a/sql/convert.cc +++ b/sql/convert.cc @@ -20,6 +20,9 @@ ** Some of the tables are hidden behind IFDEF to reduce some space. ** One can enable them by removing the // characters from the next comment ** One must also give a name to each mapping that one wants to use... +** +** All tables are activated if --with-extra-charsets=all or +** --with-extra-charsets=complex was given to configure. */ /* #define DEFINE_ALL_CHARACTER_SETS */ From f574cd4e8f7f9794385cf5b9f6ddfc8530245005 Mon Sep 17 00:00:00 2001 From: "monty@mysql.com" <> Date: Sat, 28 Aug 2004 00:49:54 +0300 Subject: [PATCH 06/14] Code style fixes. Initialize LOG_error_log before get_options to not use an uninitalized mutex in case of an error from handle_options() --- mysql-test/r/lowercase_table.result | 21 +++- mysql-test/t/lowercase_table.test | 17 ++- mysys/my_getopt.c | 87 +++++++------- sql/log.cc | 171 +++++++++++++++------------- sql/mysqld.cc | 20 ++-- sql/sql_base.cc | 13 ++- sql/table.cc | 5 +- 7 files changed, 187 insertions(+), 147 deletions(-) diff --git a/mysql-test/r/lowercase_table.result b/mysql-test/r/lowercase_table.result index 5acab254511..43d24b1ab17 100644 --- a/mysql-test/r/lowercase_table.result +++ b/mysql-test/r/lowercase_table.result @@ -1,4 +1,5 @@ drop table if exists t1,t2,t3,t4,T1; +drop database if exists mysqltest; create table T1 (id int primary key, Word varchar(40) not null, Index(Word)); create table t4 (id int primary key, Word varchar(40) not null); INSERT INTO T1 VALUES (1, 'a'), (2, 'b'), (3, 'c'); @@ -39,12 +40,22 @@ Unknown table 'T1' in field list select count(bags.a) from t1 as Bags; Unknown table 'bags' in field list drop table t1; -create database foo; -use foo; +create database mysqltest; +use MYSQLTEST; create table t1 (a int); -select FOO.t1.* from FOO.t1; +select T1.a from MYSQLTEST.T1; +a +select t1.a from MYSQLTEST.T1; +Unknown table 't1' in field list +select mysqltest.t1.* from MYSQLTEST.t1; +a +select MYSQLTEST.t1.* from MYSQLTEST.t1; +a +select MYSQLTEST.T1.* from MYSQLTEST.T1; +a +select MYSQLTEST.T1.* from T1; a alter table t1 rename to T1; -select FOO.t1.* from FOO.t1; +select MYSQLTEST.t1.* from MYSQLTEST.t1; a -drop database FOO; +drop database mysqltest; diff --git a/mysql-test/t/lowercase_table.test b/mysql-test/t/lowercase_table.test index d52c60baea7..1b431a9d920 100644 --- a/mysql-test/t/lowercase_table.test +++ b/mysql-test/t/lowercase_table.test @@ -3,6 +3,7 @@ # drop table if exists t1,t2,t3,t4,T1; +drop database if exists mysqltest; create table T1 (id int primary key, Word varchar(40) not null, Index(Word)); create table t4 (id int primary key, Word varchar(40) not null); INSERT INTO T1 VALUES (1, 'a'), (2, 'b'), (3, 'c'); @@ -34,10 +35,16 @@ drop table t1; # # Test all caps database name # -create database foo; -use foo; +create database mysqltest; +use MYSQLTEST; create table t1 (a int); -select FOO.t1.* from FOO.t1; +select T1.a from MYSQLTEST.T1; +--error 1109 +select t1.a from MYSQLTEST.T1; +select mysqltest.t1.* from MYSQLTEST.t1; +select MYSQLTEST.t1.* from MYSQLTEST.t1; +select MYSQLTEST.T1.* from MYSQLTEST.T1; +select MYSQLTEST.T1.* from T1; alter table t1 rename to T1; -select FOO.t1.* from FOO.t1; -drop database FOO; +select MYSQLTEST.t1.* from MYSQLTEST.t1; +drop database mysqltest; diff --git a/mysys/my_getopt.c b/mysys/my_getopt.c index c471a30eb35..f9df4afb55d 100644 --- a/mysys/my_getopt.c +++ b/mysys/my_getopt.c @@ -56,12 +56,12 @@ char *disabled_my_option= (char*) "0"; my_bool my_getopt_print_errors= 1; -void default_reporter( enum loglevel level, const char *format, ... ) +void default_reporter(enum loglevel level, const char *format, ...) { va_list args; - va_start( args, format ); - vfprintf( stderr, format, args ); - va_end( args ); + va_start(args, format); + vfprintf(stderr, format, args); + va_end(args); } /* @@ -75,8 +75,9 @@ void default_reporter( enum loglevel level, const char *format, ... ) */ int handle_options(int *argc, char ***argv, - const struct my_option *longopts, my_get_one_option get_one_option, - my_error_reporter reporter ) + const struct my_option *longopts, + my_get_one_option get_one_option, + my_error_reporter reporter) { uint opt_found, argvpos= 0, length, i; my_bool end_of_options= 0, must_be_var, set_maximum_value, special_used, @@ -90,7 +91,8 @@ int handle_options(int *argc, char ***argv, (*argv)++; /* --- || ---- */ init_variables(longopts); - if (! reporter) reporter = &default_reporter; + if (! reporter) + reporter= &default_reporter; for (pos= *argv, pos_end=pos+ *argc; pos != pos_end ; pos++) { @@ -116,7 +118,8 @@ int handle_options(int *argc, char ***argv, if (!*++pos) { if (my_getopt_print_errors) - reporter( ERROR_LEVEL, "%s: Option '-O' requires an argument\n", progname ); + reporter(ERROR_LEVEL, + "%s: Option '-O' requires an argument\n", progname); return EXIT_ARGUMENT_REQUIRED; } cur_arg= *pos; @@ -132,7 +135,9 @@ int handle_options(int *argc, char ***argv, if (!*cur_arg) { if (my_getopt_print_errors) - reporter( ERROR_LEVEL, "%s: Option '--set-variable' requires an argument\n", progname ); + reporter(ERROR_LEVEL, + "%s: Option '--set-variable' requires an argument\n", + progname); return EXIT_ARGUMENT_REQUIRED; } } @@ -144,7 +149,9 @@ int handle_options(int *argc, char ***argv, if (!*++pos) { if (my_getopt_print_errors) - reporter( ERROR_LEVEL, "%s: Option '--set-variable' requires an argument\n", progname ); + reporter(ERROR_LEVEL, + "%s: Option '--set-variable' requires an argument\n", + progname); return EXIT_ARGUMENT_REQUIRED; } cur_arg= *pos; @@ -203,10 +210,10 @@ int handle_options(int *argc, char ***argv, if (opt_found > 1) { if (my_getopt_print_errors) - reporter( ERROR_LEVEL, - "%s: ambiguous option '--%s-%s' (--%s-%s)\n", - progname, special_opt_prefix[i], cur_arg, - special_opt_prefix[i], prev_found); + reporter(ERROR_LEVEL, + "%s: ambiguous option '--%s-%s' (--%s-%s)\n", + progname, special_opt_prefix[i], cur_arg, + special_opt_prefix[i], prev_found); return EXIT_AMBIGUOUS_OPTION; } switch (i) { @@ -238,16 +245,16 @@ int handle_options(int *argc, char ***argv, if (must_be_var) { if (my_getopt_print_errors) - reporter( option_is_loose ? WARNING_LEVEL : ERROR_LEVEL, - "%s: unknown variable '%s'\n", progname, cur_arg ); + reporter(option_is_loose ? WARNING_LEVEL : ERROR_LEVEL, + "%s: unknown variable '%s'\n", progname, cur_arg); if (!option_is_loose) return EXIT_UNKNOWN_VARIABLE; } else { if (my_getopt_print_errors) - reporter( option_is_loose ? WARNING_LEVEL : ERROR_LEVEL, - "%s: unknown option '--%s'\n", progname, cur_arg ); + reporter(option_is_loose ? WARNING_LEVEL : ERROR_LEVEL, + "%s: unknown option '--%s'\n", progname, cur_arg); if (!option_is_loose) return EXIT_UNKNOWN_OPTION; } @@ -263,23 +270,23 @@ int handle_options(int *argc, char ***argv, if (must_be_var) { if (my_getopt_print_errors) - reporter( ERROR_LEVEL, "%s: variable prefix '%s' is not unique\n", - progname, cur_arg); + reporter(ERROR_LEVEL, "%s: variable prefix '%s' is not unique\n", + progname, cur_arg); return EXIT_VAR_PREFIX_NOT_UNIQUE; } else { if (my_getopt_print_errors) - reporter( ERROR_LEVEL, "%s: ambiguous option '--%s' (%s, %s)\n", - progname, cur_arg, prev_found, optp->name); + reporter(ERROR_LEVEL, "%s: ambiguous option '--%s' (%s, %s)\n", + progname, cur_arg, prev_found, optp->name); return EXIT_AMBIGUOUS_OPTION; } } if (must_be_var && optp->var_type == GET_NO_ARG) { if (my_getopt_print_errors) - reporter( ERROR_LEVEL, "%s: option '%s' cannot take an argument\n", - progname, optp->name); + reporter(ERROR_LEVEL, "%s: option '%s' cannot take an argument\n", + progname, optp->name); return EXIT_NO_ARGUMENT_ALLOWED; } if (optp->arg_type == NO_ARG) @@ -287,8 +294,9 @@ int handle_options(int *argc, char ***argv, if (optend && optp->var_type != GET_BOOL) { if (my_getopt_print_errors) - reporter( ERROR_LEVEL, "%s: option '--%s' cannot take an argument\n", - progname, optp->name); + reporter(ERROR_LEVEL, + "%s: option '--%s' cannot take an argument\n", + progname, optp->name); return EXIT_NO_ARGUMENT_ALLOWED; } if (optp->var_type == GET_BOOL) @@ -325,8 +333,9 @@ int handle_options(int *argc, char ***argv, if (!*++pos) { if (my_getopt_print_errors) - reporter( ERROR_LEVEL, "%s: option '--%s' requires an argument\n", - progname, optp->name); + reporter(ERROR_LEVEL, + "%s: option '--%s' requires an argument\n", + progname, optp->name); return EXIT_ARGUMENT_REQUIRED; } argument= *pos; @@ -375,9 +384,9 @@ int handle_options(int *argc, char ***argv, if (!pos[1]) { if (my_getopt_print_errors) - reporter( ERROR_LEVEL, - "%s: option '-%c' requires an argument\n", - progname, optp->id); + reporter(ERROR_LEVEL, + "%s: option '-%c' requires an argument\n", + progname, optp->id); return EXIT_ARGUMENT_REQUIRED; } argument= *++pos; @@ -387,9 +396,9 @@ int handle_options(int *argc, char ***argv, } if ((error= setval(optp, argument, set_maximum_value))) { - reporter( ERROR_LEVEL, - "%s: Error while setting value '%s' to '%s'\n", - progname, argument, optp->name); + reporter(ERROR_LEVEL, + "%s: Error while setting value '%s' to '%s'\n", + progname, argument, optp->name); return error; } get_one_option(optp->id, optp, argument); @@ -399,8 +408,8 @@ int handle_options(int *argc, char ***argv, if (!opt_found) { if (my_getopt_print_errors) - reporter( ERROR_LEVEL, - "%s: unknown option '-%c'\n", progname, *optend); + reporter(ERROR_LEVEL, + "%s: unknown option '-%c'\n", progname, *optend); return EXIT_UNKNOWN_OPTION; } } @@ -409,9 +418,9 @@ int handle_options(int *argc, char ***argv, } if ((error= setval(optp, argument, set_maximum_value))) { - reporter( ERROR_LEVEL, - "%s: Error while setting value '%s' to '%s'\n", - progname, argument, optp->name); + reporter(ERROR_LEVEL, + "%s: Error while setting value '%s' to '%s'\n", + progname, argument, optp->name); return error; } get_one_option(optp->id, optp, argument); diff --git a/sql/log.cc b/sql/log.cc index db7b80eb4f7..e9dd2e4a69b 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -43,37 +43,41 @@ static bool test_if_number(const char *str, #ifdef __NT__ static int eventSource = 0; -void setupWindowsEventSource() + +void setup_windows_event_source() { - if (eventSource) return; - - eventSource = 1; - HKEY hRegKey = NULL; - DWORD dwError = 0; - TCHAR szPath[ MAX_PATH ]; + HKEY hRegKey= NULL; + DWORD dwError= 0; + TCHAR szPath[MAX_PATH]; + DWORD dwTypes; - // Create the event source registry key - dwError = RegCreateKey( HKEY_LOCAL_MACHINE, - "SYSTEM\\CurrentControlSet\\Services\\EventLog\\Application\\MySQL", - &hRegKey ); + if (eventSource) // Ensure that we are only called once + return; + eventSource= 1; - // Name of the PE module that contains the message resource - GetModuleFileName( NULL, szPath, MAX_PATH ); + // Create the event source registry key + dwError= RegCreateKey(HKEY_LOCAL_MACHINE, + "SYSTEM\\CurrentControlSet\\Services\\EventLog\\Application\\MySQL", + &hRegKey); - // Register EventMessageFile - dwError = RegSetValueEx( hRegKey, "EventMessageFile", 0, REG_EXPAND_SZ, - (PBYTE) szPath, strlen(szPath)+1 ); + /* Name of the PE module that contains the message resource */ + GetModuleFileName(NULL, szPath, MAX_PATH); + + / Register EventMessageFile */ + dwError = RegSetValueEx(hRegKey, "EventMessageFile", 0, REG_EXPAND_SZ, + (PBYTE) szPath, strlen(szPath)+1); - // Register supported event types - DWORD dwTypes = EVENTLOG_ERROR_TYPE | EVENTLOG_WARNING_TYPE | EVENTLOG_INFORMATION_TYPE; - dwError = RegSetValueEx( hRegKey, "TypesSupported", 0, REG_DWORD, - (LPBYTE) &dwTypes, sizeof dwTypes ); + /* Register supported event types */ + dwTypes= (EVENTLOG_ERROR_TYPE | EVENTLOG_WARNING_TYPE | + EVENTLOG_INFORMATION_TYPE); + dwError= RegSetValueEx(hRegKey, "TypesSupported", 0, REG_DWORD, + (LPBYTE) &dwTypes, sizeof dwTypes); - RegCloseKey( hRegKey ); + RegCloseKey(hRegKey); } -#endif +#endif /* __NT__ */ /**************************************************************************** @@ -1732,33 +1736,33 @@ static bool test_if_number(register const char *str, } /* test_if_number */ -void print_buffer_to_file( enum loglevel level, const char *buffer ) +void print_buffer_to_file(enum loglevel level, const char *buffer) { time_t skr; struct tm tm_tmp; struct tm *start; - - DBUG_ENTER("print_buffer_to_log"); + DBUG_ENTER("print_buffer_to_file"); + DBUG_PRINT("enter",("buffer: %s", buffer)); VOID(pthread_mutex_lock(&LOCK_error_log)); skr=time(NULL); localtime_r(&skr, &tm_tmp); start=&tm_tmp; - fprintf( stderr, "%02d%02d%02d %2d:%02d:%02d [%s] %s\n", + fprintf(stderr, "%02d%02d%02d %2d:%02d:%02d [%s] %s\n", start->tm_year % 100, start->tm_mon+1, start->tm_mday, start->tm_hour, start->tm_min, start->tm_sec, - level == ERROR_LEVEL ? "ERROR" : level == WARNING_LEVEL ? "WARNING" : "INFORMATION", - buffer ); + (level == ERROR_LEVEL ? "ERROR" : level == WARNING_LEVEL ? + "WARNING" : "INFORMATION"), + buffer); fflush(stderr); VOID(pthread_mutex_unlock(&LOCK_error_log)); - DBUG_VOID_RETURN; } @@ -1772,6 +1776,7 @@ void sql_perror(const char *message) #endif } + bool flush_error_log() { bool result=0; @@ -1820,122 +1825,124 @@ bool flush_error_log() #ifdef __NT__ -void print_buffer_to_nt_eventlog( enum loglevel level, char *buff, int buffLen ) +void print_buffer_to_nt_eventlog(enum loglevel level, char *buff, + uint length, int buffLen) { HANDLE event; char *buffptr; LPCSTR *buffmsgptr; + DBUG_ENTER("print_buffer_to_nt_eventlog"); - DBUG_ENTER( "print_buffer_to_nt_eventlog" ); - - buffptr = buff; - if (strlen(buff) > (uint)(buffLen-4)) + buffptr= buff; + if (length > (uint)(buffLen-4)) { - char *newBuff = new char[ strlen(buff) + 4 ]; - strcpy( newBuff, buff ); - buffptr = newBuff; + char *newBuff= new char[length + 4]; + strcpy(newBuff, buff); + buffptr= newBuff; } - strcat( buffptr, "\r\n\r\n" ); - buffmsgptr = (LPCSTR*)&buffptr; + strmov(buffptr+length, "\r\n\r\n"); + buffmsgptr= (LPCSTR*) &buffptr; // Keep windows happy - setupWindowsEventSource(); - if (event = RegisterEventSource(NULL,"MySQL")) + setup_windows_event_source(); + if ((event= RegisterEventSource(NULL,"MySQL"))) { - switch (level){ + switch (level) { case ERROR_LEVEL: - ReportEvent(event, EVENTLOG_ERROR_TYPE, 0, MSG_DEFAULT, NULL, 1, 0, buffmsgptr, NULL); + ReportEvent(event, EVENTLOG_ERROR_TYPE, 0, MSG_DEFAULT, NULL, 1, 0, + buffmsgptr, NULL); break; case WARNING_LEVEL: - ReportEvent(event, EVENTLOG_WARNING_TYPE, 0, MSG_DEFAULT, NULL, 1, 0, buffmsgptr, NULL); + ReportEvent(event, EVENTLOG_WARNING_TYPE, 0, MSG_DEFAULT, NULL, 1, 0, + buffmsgptr, NULL); break; case INFORMATION_LEVEL: - ReportEvent(event, EVENTLOG_INFORMATION_TYPE, 0, MSG_DEFAULT, NULL, 1, 0, buffmsgptr, NULL); + ReportEvent(event, EVENTLOG_INFORMATION_TYPE, 0, MSG_DEFAULT, NULL, 1, + 0, buffmsgptr, NULL); break; } DeregisterEventSource(event); } - // if we created a string buffer, then delete it - if ( buffptr != buff ) + /* if we created a string buffer, then delete it */ + if (buffptr != buff) delete[] buffptr; - DBUG_VOID_RETURN; } -#endif +#endif /* __NT__ */ + /* - Prints a printf style message to the error log and, under NT, to the Windows event log. + Prints a printf style message to the error log and, under NT, to the + Windows event log. SYNOPSIS vprint_msg_to_log() - event_type Type of event to write (Error, Warning, or Info) - format Printf style format of message - args va_list list of arguments for the message + event_type Type of event to write (Error, Warning, or Info) + format Printf style format of message + args va_list list of arguments for the message NOTE IMPLEMENTATION - This function prints the message into a buffer and then sends that buffer to other - functions to write that message to other logging sources. + This function prints the message into a buffer and then sends that buffer + to other functions to write that message to other logging sources. RETURN VALUES void */ + void vprint_msg_to_log(enum loglevel level, const char *format, va_list args) { char buff[1024]; - + uint length; DBUG_ENTER("vprint_msg_to_log"); - my_vsnprintf( buff, sizeof(buff)-5, format, args ); - - print_buffer_to_file( level, buff ); - -#ifndef DBUG_OFF - DBUG_PRINT("error",("%s",buff)); -#endif + length= my_vsnprintf(buff, sizeof(buff)-5, format, args); + print_buffer_to_file(level, buff); #ifdef __NT__ - print_buffer_to_nt_eventlog( level, buff, sizeof(buff) ); + print_buffer_to_nt_eventlog(level, buff, length, sizeof(buff)); #endif DBUG_VOID_RETURN; } -void sql_print_error( const char *format, ... ) +void sql_print_error(const char *format, ...) { - DBUG_ENTER( "sql_print_error" ); - va_list args; - va_start( args, format ); - vprint_msg_to_log( ERROR_LEVEL, format, args ); - va_end( args ); + DBUG_ENTER("sql_print_error"); + + va_start(args, format); + vprint_msg_to_log(ERROR_LEVEL, format, args); + va_end(args); DBUG_VOID_RETURN; } -void sql_print_warning( const char *format, ... ) -{ - DBUG_ENTER( "sql_print_warning" ); +void sql_print_warning(const char *format, ...) +{ va_list args; - va_start( args, format ); - vprint_msg_to_log( WARNING_LEVEL, format, args ); - va_end( args ); + DBUG_ENTER("sql_print_warning"); + + va_start(args, format); + vprint_msg_to_log(WARNING_LEVEL, format, args); + va_end(args); DBUG_VOID_RETURN; } -void sql_print_information( const char *format, ... ) -{ - DBUG_ENTER( "sql_print_information" ); +void sql_print_information(const char *format, ...) +{ va_list args; - va_start( args, format ); - vprint_msg_to_log( INFORMATION_LEVEL, format, args ); - va_end( args ); + DBUG_ENTER("sql_print_information"); + + va_start(args, format); + vprint_msg_to_log(INFORMATION_LEVEL, format, args); + va_end(args); DBUG_VOID_RETURN; } diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 8b10627b323..1068c5ec9a1 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -2247,6 +2247,10 @@ int main(int argc, char **argv) if (!opt_mysql_tmpdir || !opt_mysql_tmpdir[0]) opt_mysql_tmpdir=(char*) P_tmpdir; /* purecov: inspected */ + /* needed by get_options */ + + (void) pthread_mutex_init(&LOCK_error_log,MY_MUTEX_INIT_FAST); + set_options(); get_options(argc,argv); set_server_version(); @@ -2263,7 +2267,6 @@ int main(int argc, char **argv) (void) pthread_mutex_init(&LOCK_thread_count,MY_MUTEX_INIT_FAST); (void) pthread_mutex_init(&LOCK_mapped_file,MY_MUTEX_INIT_SLOW); (void) pthread_mutex_init(&LOCK_status,MY_MUTEX_INIT_FAST); - (void) pthread_mutex_init(&LOCK_error_log,MY_MUTEX_INIT_FAST); (void) pthread_mutex_init(&LOCK_delayed_insert,MY_MUTEX_INIT_FAST); (void) pthread_mutex_init(&LOCK_delayed_status,MY_MUTEX_INIT_FAST); (void) pthread_mutex_init(&LOCK_delayed_create,MY_MUTEX_INIT_SLOW); @@ -5100,21 +5103,24 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), } return 0; } - /* Initiates DEBUG - but no debugging here ! */ -void option_error_reporter( enum loglevel level, const char *format, ... ) + +void option_error_reporter(enum loglevel level, const char *format, ...) { va_list args; - va_start( args, format ); - vprint_msg_to_log( level, format, args ); - va_end( args ); + va_start(args, format); + vprint_msg_to_log(level, format, args); + va_end(args); } + /* Initiates DEBUG - but no debugging here ! */ + static void get_options(int argc,char **argv) { int ho_error; - if ((ho_error=handle_options(&argc, &argv, my_long_options, get_one_option, option_error_reporter ))) + if ((ho_error=handle_options(&argc, &argv, my_long_options, get_one_option, + option_error_reporter))) exit(ho_error); #if defined(HAVE_BROKEN_REALPATH) diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 26ce394ec37..8fd7273fd78 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -2066,13 +2066,16 @@ insert_fields(THD *thd,TABLE_LIST *tables, const char *db_name, uint found; DBUG_ENTER("insert_fields"); - if (db_name && lower_case_table_names) { - /* convert database to lower case for comparison */ - strmake( name_buff, db_name, sizeof(name_buff)-1 ); - casedn_str( name_buff ); - db_name = name_buff; + /* + convert database to lower case for comparison + We can't do this in Item_field as this would change the + 'name' of the item which may be used in the select list + */ + strmake(name_buff, db_name, sizeof(name_buff)-1); + casedn_str(name_buff); + db_name= name_buff; } diff --git a/sql/table.cc b/sql/table.cc index 898ed4bca3d..573fa11a4c4 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -999,10 +999,7 @@ void append_unescaped(String *res,const char *pos) for (; *pos ; ) { -#ifdef USE_MB - /* - Note, there is no needs to propagate this code into 4.1. - */ +#if defined(USE_MB) && MYSQL_VERSION_ID < 40100 uint mblen; if (use_mb(default_charset_info) && (mblen= my_ismbchar(default_charset_info, pos, end))) From 0f023b3b9b1acf4ba81dbf2178e6d435cfe10712 Mon Sep 17 00:00:00 2001 From: "lenz@mysql.com" <> Date: Sat, 28 Aug 2004 09:31:15 +0200 Subject: [PATCH 07/14] - fixed typo so make dist does not fail --- support-files/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/support-files/Makefile.am b/support-files/Makefile.am index ddad52fbb2a..1f38b4c30c2 100644 --- a/support-files/Makefile.am +++ b/support-files/Makefile.am @@ -22,7 +22,7 @@ EXTRA_DIST = mysql.spec.sh \ my-medium.cnf.sh \ my-large.cnf.sh \ my-huge.cnf.sh \ - my-innodb-heavy-4G \ + my-innodb-heavy-4G.cnf.sh \ mysql-log-rotate.sh \ mysql.server.sh \ binary-configure.sh \ From 93101561fd3d49fde9b1408f1d2b9f036fcba658 Mon Sep 17 00:00:00 2001 From: "guilhem@mysql.com" <> Date: Sun, 29 Aug 2004 14:13:51 +0200 Subject: [PATCH 08/14] Fix for BUG#4500 "set character set replicates incorrectly" We must not reset the charset in slave after each statement, otherwise the SET CHARACTER SET is cancelled immediately. Instead, we write a SET CHARACTER SET DEFAULT to the master's binlog when needed (like we already do for SET FOREIGN_KEY_CHECKS); such writing is not necessary in 4.1 (in 4.1 the bug does not exist, as the SET ONE_SHOT syntax is used). I have written a test and it works, but I'm not pushing the test as it requires building with all charsets. I have noticed differences between what is inserted in the master's table in 4.0 and 4.1, and alerted Bar. --- sql/log.cc | 22 +++++++++++++++++----- sql/log_event.cc | 2 -- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/sql/log.cc b/sql/log.cc index db7b80eb4f7..9927bfe8d17 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -1208,12 +1208,24 @@ bool MYSQL_LOG::write(Log_event* event_info) /* Write log events to reset the 'run environment' of the SQL command */ - if (thd && thd->options & OPTION_NO_FOREIGN_KEY_CHECKS) + if (thd) { - Query_log_event e(thd, "SET FOREIGN_KEY_CHECKS=1", 24, 0); - e.set_log_pos(this); - if (e.write(file)) - goto err; + if (thd->options & OPTION_NO_FOREIGN_KEY_CHECKS) + { + Query_log_event e(thd, "SET FOREIGN_KEY_CHECKS=1", 24, 0); + e.set_log_pos(this); + if (e.write(file)) + goto err; + } +#if MYSQL_VERSION_ID < 40100 + if (thd->variables.convert_set) + { + Query_log_event e(thd, "SET CHARACTER SET DEFAULT", 25, 0); + e.set_log_pos(this); + if (e.write(file)) + goto err; + } +#endif } /* diff --git a/sql/log_event.cc b/sql/log_event.cc index 3e1544adf14..5526795c9d1 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -1932,8 +1932,6 @@ end: thd->query= 0; // just to be sure thd->query_length= 0; VOID(pthread_mutex_unlock(&LOCK_thread_count)); - // assume no convert for next query unless set explictly - thd->variables.convert_set = 0; close_thread_tables(thd); free_root(&thd->mem_root,MYF(MY_KEEP_PREALLOC)); return (thd->query_error ? thd->query_error : Log_event::exec_event(rli)); From 547b46b7c9ba441498c77cb9e1863a36ab56cdef Mon Sep 17 00:00:00 2001 From: "rburnett@build.mysql.com" <> Date: Mon, 30 Aug 2004 00:50:39 +0200 Subject: [PATCH 09/14] log.cc: Fixed missing * in comment in setup_windows_event_source --- sql/log.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/log.cc b/sql/log.cc index aa45e2f77ee..55ef2e72960 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -63,7 +63,7 @@ void setup_windows_event_source() /* Name of the PE module that contains the message resource */ GetModuleFileName(NULL, szPath, MAX_PATH); - / Register EventMessageFile */ + /* Register EventMessageFile */ dwError = RegSetValueEx(hRegKey, "EventMessageFile", 0, REG_EXPAND_SZ, (PBYTE) szPath, strlen(szPath)+1); From 9632f7d9c808bc6ab0b27d8bfaa3b5b0981e7dfa Mon Sep 17 00:00:00 2001 From: "lenz@mysql.com" <> Date: Mon, 30 Aug 2004 09:20:52 +0200 Subject: [PATCH 10/14] - removed mysql-test/t/flush_block_commit-master.opt as it collided with the sleep value we use for the test suite run during the release builds --- mysql-test/t/flush_block_commit-master.opt | 1 - 1 file changed, 1 deletion(-) delete mode 100644 mysql-test/t/flush_block_commit-master.opt diff --git a/mysql-test/t/flush_block_commit-master.opt b/mysql-test/t/flush_block_commit-master.opt deleted file mode 100644 index d1f6d58e9f7..00000000000 --- a/mysql-test/t/flush_block_commit-master.opt +++ /dev/null @@ -1 +0,0 @@ ---innodb_lock_wait_timeout=5 From 38d9ce96f943eadf18561fd565ea961b51c9e889 Mon Sep 17 00:00:00 2001 From: "serg@serg.mylan" <> Date: Mon, 30 Aug 2004 10:13:13 +0200 Subject: [PATCH 11/14] typo fixed --- sql/field.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/field.cc b/sql/field.cc index 71ec7545efc..394d53238c2 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -2341,7 +2341,7 @@ String *Field_double::val_str(String *val_buffer, else { #ifdef HAVE_FCONVERT - char buff[DOUBLE_TO_STRING_CONVERSION_BUFFER_SIZE], + char buff[DOUBLE_TO_STRING_CONVERSION_BUFFER_SIZE]; char *pos= buff; int decpt,sign,tmp_dec=dec; From 86fcffb3230cfe326da144db9e3009e5ab9c85ca Mon Sep 17 00:00:00 2001 From: "joerg@mysql.com" <> Date: Mon, 30 Aug 2004 17:41:41 +0200 Subject: [PATCH 12/14] If the system has 64 bit "long", then "long long" does not add new functionality. The existing code takes advantage of this when "typedef"ing 'longlong' in 'my_global.h'. This holds for Alpha CPUs. If the compiler then has prototypes for C99 functions 'strtoll()' and 'strtoull()' but no implementation, the existing code in 'strtoull.c' collides with that prototype. These collisions are avoided now. (backport from 4.1) --- include/m_string.h | 3 +++ strings/strto.c | 8 ++++++-- strings/strtol.c | 9 ++++++++- strings/strtoll.c | 13 +++++++++++-- strings/strtoul.c | 9 ++++++++- strings/strtoull.c | 13 ++++++++++++- 6 files changed, 48 insertions(+), 7 deletions(-) diff --git a/include/m_string.h b/include/m_string.h index eb2758ec506..419e70d93bf 100644 --- a/include/m_string.h +++ b/include/m_string.h @@ -238,6 +238,9 @@ extern char *str2int(const char *src,int radix,long lower,long upper, #ifndef HAVE_STRTOULL #define HAVE_STRTOULL #endif +#ifndef HAVE_STRTOLL +#define HAVE_STRTOLL +#endif #else #ifdef HAVE_LONG_LONG extern char *longlong2str(longlong val,char *dst,int radix); diff --git a/strings/strto.c b/strings/strto.c index c98b19a7e67..9ad4502faaf 100644 --- a/strings/strto.c +++ b/strings/strto.c @@ -35,8 +35,12 @@ it can be compiled with the UNSIGNED and/or LONGLONG flag set */ -#include -#include "m_string.h" + +#if !defined(_global_h) || !defined(_m_string_h) +# error Calling file must include 'my_global.h' and 'm_string.h' + /* see 'strtoll.c' and 'strtoull.c' for the reasons */ +#endif + #include "m_ctype.h" #include "my_sys.h" /* defines errno */ #include diff --git a/strings/strtol.c b/strings/strtol.c index 10d7f8f9da6..ed4ca86c846 100644 --- a/strings/strtol.c +++ b/strings/strtol.c @@ -14,9 +14,16 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* This defines strtol() if neaded */ +/* This implements strtol() if needed */ +/* + These includes are mandatory because they check for type sizes and + functions, especially they handle tricks for Tru64 where 'long' is + 64 bit already and our 'longlong' is just a 'long'. + */ #include +#include + #if !defined(MSDOS) && !defined(HAVE_STRTOL) && !defined(__WIN__) #include "strto.c" #endif diff --git a/strings/strtoll.c b/strings/strtoll.c index b0b4ef328fc..45352ffd360 100644 --- a/strings/strtoll.c +++ b/strings/strtoll.c @@ -14,11 +14,20 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* This is defines strtoll() if neaded */ +/* This implements strtoll() if needed */ -#define strtoll glob_strtoll /* Fix for True64 */ +/* + These includes are mandatory because they check for type sizes and + functions, especially they handle tricks for Tru64 where 'long' is + 64 bit already and our 'longlong' is just a 'long'. + This solves a problem on Tru64 where the C99 compiler has a prototype + for 'strtoll()' but no implementation, see "6.1 New C99 library functions" + in file '/usr/share/doclib/cc.dtk/release_notes.txt'. + */ #include +#include + #if !defined(HAVE_STRTOLL) && defined(HAVE_LONG_LONG) #define USE_LONGLONG #include "strto.c" diff --git a/strings/strtoul.c b/strings/strtoul.c index 00e1f820942..77bc267d218 100644 --- a/strings/strtoul.c +++ b/strings/strtoul.c @@ -14,9 +14,16 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* This is defines strtoul() if neaded */ +/* This implements strtoul() if needed */ +/* + These includes are mandatory because they check for type sizes and + functions, especially they handle tricks for Tru64 where 'long' is + 64 bit already and our 'longlong' is just a 'long'. + */ #include +#include + #if !defined(MSDOS) && !defined(HAVE_STRTOUL) #define USE_UNSIGNED #include "strto.c" diff --git a/strings/strtoull.c b/strings/strtoull.c index f4f3ce19bf7..0c2788bc188 100644 --- a/strings/strtoull.c +++ b/strings/strtoull.c @@ -14,9 +14,20 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* This is defines strtoull() */ +/* This implements strtoull() if needed */ + +/* + These includes are mandatory because they check for type sizes and + functions, especially they handle tricks for Tru64 where 'long' is + 64 bit already and our 'longlong' is just a 'long'. + This solves a problem on Tru64 where the C99 compiler has a prototype + for 'strtoull()' but no implementation, see "6.1 New C99 library functions" + in file '/usr/share/doclib/cc.dtk/release_notes.txt'. + */ #include +#include + #if !defined(HAVE_STRTOULL) && defined(HAVE_LONG_LONG) #define USE_UNSIGNED #define USE_LONGLONG From b93a973b1203b969fef15ef8c10d0d494423f9ed Mon Sep 17 00:00:00 2001 From: "ram@gw.mysql.r18.ru" <> Date: Tue, 31 Aug 2004 21:27:58 +0500 Subject: [PATCH 13/14] Added global my_getopt_error_reporter function pointer which is used in the handle_options() function (instead of using additional handle_option() parameter). The default value of the my_getopt_error_reporter is default_reporter(). One can set it to other functions if case of need. --- client/mysql.cc | 2 +- client/mysqladmin.c | 2 +- client/mysqlbinlog.cc | 2 +- client/mysqlcheck.c | 2 +- client/mysqldump.c | 2 +- client/mysqlimport.c | 2 +- client/mysqlmanager-pwgen.c | 2 +- client/mysqlmanagerc.c | 2 +- client/mysqlshow.c | 2 +- client/mysqltest.c | 2 +- extra/my_print_defaults.c | 2 +- extra/mysql_install.c | 2 +- extra/mysql_waitpid.c | 2 +- extra/perror.c | 2 +- extra/resolve_stack_dump.c | 2 +- extra/resolveip.c | 2 +- include/my_getopt.h | 10 ++-- isam/isamchk.c | 2 +- isam/pack_isam.c | 2 +- myisam/mi_test1.c | 2 +- myisam/myisam_ftdump.c | 2 +- myisam/myisamchk.c | 2 +- myisam/myisampack.c | 2 +- mysys/my_getopt.c | 101 ++++++++++++++++++++---------------- sql/gen_lex_hash.cc | 2 +- sql/mysqld.cc | 4 +- tools/mysqlmanager.c | 2 +- 27 files changed, 87 insertions(+), 76 deletions(-) diff --git a/client/mysql.cc b/client/mysql.cc index 73067700656..154695aa9e5 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -759,7 +759,7 @@ static int get_options(int argc, char **argv) opt_max_allowed_packet= *mysql_params->p_max_allowed_packet; opt_net_buffer_length= *mysql_params->p_net_buffer_length; - if ((ho_error=handle_options(&argc, &argv, my_long_options, get_one_option, 0))) + if ((ho_error=handle_options(&argc, &argv, my_long_options, get_one_option))) exit(ho_error); *mysql_params->p_max_allowed_packet= opt_max_allowed_packet; diff --git a/client/mysqladmin.c b/client/mysqladmin.c index e2843685d50..3bc11ec0fb0 100644 --- a/client/mysqladmin.c +++ b/client/mysqladmin.c @@ -254,7 +254,7 @@ int main(int argc,char *argv[]) mysql_init(&mysql); load_defaults("my",load_default_groups,&argc,&argv); save_argv = argv; /* Save for free_defaults */ - if ((ho_error=handle_options(&argc, &argv, my_long_options, get_one_option, 0))) + if ((ho_error=handle_options(&argc, &argv, my_long_options, get_one_option))) { free_defaults(save_argv); exit(ho_error); diff --git a/client/mysqlbinlog.cc b/client/mysqlbinlog.cc index 93e0b98b1e5..7c3d22c4900 100644 --- a/client/mysqlbinlog.cc +++ b/client/mysqlbinlog.cc @@ -559,7 +559,7 @@ static int parse_args(int *argc, char*** argv) result_file = stdout; load_defaults("my",load_default_groups,argc,argv); - if ((ho_error=handle_options(argc, argv, my_long_options, get_one_option, NULL))) + if ((ho_error=handle_options(argc, argv, my_long_options, get_one_option))) exit(ho_error); return 0; diff --git a/client/mysqlcheck.c b/client/mysqlcheck.c index 718b92da466..1c5638f3c52 100644 --- a/client/mysqlcheck.c +++ b/client/mysqlcheck.c @@ -273,7 +273,7 @@ static int get_options(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, 0))) + if ((ho_error=handle_options(argc, argv, my_long_options, get_one_option))) exit(ho_error); if (!what_to_do) diff --git a/client/mysqldump.c b/client/mysqldump.c index c0ef07a7670..6dad8182b87 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -413,7 +413,7 @@ static int get_options(int *argc, char ***argv) md_result_file= stdout; load_defaults("my",load_default_groups,argc,argv); - if ((ho_error=handle_options(argc, argv, my_long_options, get_one_option, 0))) + if ((ho_error=handle_options(argc, argv, my_long_options, get_one_option))) exit(ho_error); *mysql_params->p_max_allowed_packet= opt_max_allowed_packet; diff --git a/client/mysqlimport.c b/client/mysqlimport.c index 751379591ff..ca53b74c119 100644 --- a/client/mysqlimport.c +++ b/client/mysqlimport.c @@ -206,7 +206,7 @@ static int get_options(int *argc, char ***argv) { int ho_error; - if ((ho_error=handle_options(argc, argv, my_long_options, get_one_option, 0))) + if ((ho_error=handle_options(argc, argv, my_long_options, get_one_option))) exit(ho_error); if (enclosed && opt_enclosed) diff --git a/client/mysqlmanager-pwgen.c b/client/mysqlmanager-pwgen.c index dc845008ce0..57d91b52f49 100644 --- a/client/mysqlmanager-pwgen.c +++ b/client/mysqlmanager-pwgen.c @@ -95,7 +95,7 @@ int parse_args(int argc, char** argv) { int ho_error; - if ((ho_error=handle_options(&argc, &argv, my_long_options, get_one_option, NULL))) + if ((ho_error=handle_options(&argc, &argv, my_long_options, get_one_option))) exit(ho_error); return 0; diff --git a/client/mysqlmanagerc.c b/client/mysqlmanagerc.c index 78485427473..0001a0266e6 100644 --- a/client/mysqlmanagerc.c +++ b/client/mysqlmanagerc.c @@ -133,7 +133,7 @@ int parse_args(int argc, char **argv) load_defaults("my",load_default_groups,&argc,&argv); default_argv= argv; - if ((ho_error=handle_options(&argc, &argv, my_long_options, get_one_option, NULL))) + if ((ho_error=handle_options(&argc, &argv, my_long_options, get_one_option))) exit(ho_error); return 0; diff --git a/client/mysqlshow.c b/client/mysqlshow.c index cabe55cd95e..1a9aec02955 100644 --- a/client/mysqlshow.c +++ b/client/mysqlshow.c @@ -261,7 +261,7 @@ get_options(int *argc,char ***argv) { int ho_error; - if ((ho_error=handle_options(argc, argv, my_long_options, get_one_option, 0))) + if ((ho_error=handle_options(argc, argv, my_long_options, get_one_option))) exit(ho_error); if (tty_password) diff --git a/client/mysqltest.c b/client/mysqltest.c index df54b60dc97..2ec07692a4d 100644 --- a/client/mysqltest.c +++ b/client/mysqltest.c @@ -2062,7 +2062,7 @@ int parse_args(int argc, char **argv) load_defaults("my",load_default_groups,&argc,&argv); default_argv= argv; - if ((handle_options(&argc, &argv, my_long_options, get_one_option, 0))) + if ((handle_options(&argc, &argv, my_long_options, get_one_option))) exit(1); if (argc > 1) diff --git a/extra/my_print_defaults.c b/extra/my_print_defaults.c index 515e816f473..f8a7995432b 100644 --- a/extra/my_print_defaults.c +++ b/extra/my_print_defaults.c @@ -100,7 +100,7 @@ static int get_options(int *argc,char ***argv) { int ho_error; - if ((ho_error=handle_options(argc, argv, my_long_options, get_one_option, NULL))) + if ((ho_error=handle_options(argc, argv, my_long_options, get_one_option))) exit(ho_error); if (*argc < 1) diff --git a/extra/mysql_install.c b/extra/mysql_install.c index ab44e1a055b..e2783f906b9 100644 --- a/extra/mysql_install.c +++ b/extra/mysql_install.c @@ -218,7 +218,7 @@ static int parse_args(int argc, char **argv) { int ho_error; - if ((ho_error=handle_options(&argc, &argv, my_long_options, get_one_option, NULL))) + if ((ho_error=handle_options(&argc, &argv, my_long_options, get_one_option))) exit(ho_error); return 0; diff --git a/extra/mysql_waitpid.c b/extra/mysql_waitpid.c index 0894d81a5ae..c228cc52c8b 100644 --- a/extra/mysql_waitpid.c +++ b/extra/mysql_waitpid.c @@ -67,7 +67,7 @@ int main(int argc, char *argv[]) progname= argv[0]; - if (handle_options(&argc, &argv, my_long_options, get_one_option, NULL)) + if (handle_options(&argc, &argv, my_long_options, get_one_option)) exit(-1); if (!argv[0] || !argv[1] || (pid= atoi(argv[0])) <= 0 || (t= atoi(argv[1])) <= 0) diff --git a/extra/perror.c b/extra/perror.c index 212b313ade4..b4aeaf00671 100644 --- a/extra/perror.c +++ b/extra/perror.c @@ -145,7 +145,7 @@ static int get_options(int *argc,char ***argv) { int ho_error; - if ((ho_error=handle_options(argc, argv, my_long_options, get_one_option, NULL))) + if ((ho_error=handle_options(argc, argv, my_long_options, get_one_option))) exit(ho_error); if (!*argc && !print_all_codes) diff --git a/extra/resolve_stack_dump.c b/extra/resolve_stack_dump.c index 8b72ab1d864..c54f17a186e 100644 --- a/extra/resolve_stack_dump.c +++ b/extra/resolve_stack_dump.c @@ -121,7 +121,7 @@ static int parse_args(int argc, char **argv) { int ho_error; - if ((ho_error=handle_options(&argc, &argv, my_long_options, get_one_option, NULL))) + if ((ho_error=handle_options(&argc, &argv, my_long_options, get_one_option))) exit(ho_error); /* diff --git a/extra/resolveip.c b/extra/resolveip.c index 23ea34abc42..d3caa9e1d45 100644 --- a/extra/resolveip.c +++ b/extra/resolveip.c @@ -90,7 +90,7 @@ static int get_options(int *argc,char ***argv) { int ho_error; - if ((ho_error=handle_options(argc, argv, my_long_options, get_one_option, NULL))) + if ((ho_error=handle_options(argc, argv, my_long_options, get_one_option))) exit(ho_error); if (*argc == 0) diff --git a/include/my_getopt.h b/include/my_getopt.h index f5b847f7dda..e602773e181 100644 --- a/include/my_getopt.h +++ b/include/my_getopt.h @@ -50,15 +50,15 @@ struct my_option int app_type; /* To be used by an application */ }; -extern char *disabled_my_option; -extern my_bool my_getopt_print_errors; - typedef my_bool (* my_get_one_option) (int, const struct my_option *, char * ); typedef void (* my_error_reporter) (enum loglevel level, const char *format, ... ); +extern char *disabled_my_option; +extern my_bool my_getopt_print_errors; +extern my_error_reporter my_getopt_error_reporter; + extern int handle_options (int *argc, char ***argv, - const struct my_option *longopts, my_get_one_option, - my_error_reporter ); + const struct my_option *longopts, my_get_one_option); extern void my_print_help(const struct my_option *options); extern void my_print_variables(const struct my_option *options); diff --git a/isam/isamchk.c b/isam/isamchk.c index 8603b436841..daa9464eb4f 100644 --- a/isam/isamchk.c +++ b/isam/isamchk.c @@ -670,7 +670,7 @@ static void get_options(register int *argc, register char ***argv) if (isatty(fileno(stdout))) testflag|=T_WRITE_LOOP; - if ((ho_error=handle_options(argc, argv, my_long_options, get_one_option, NULL))) + if ((ho_error=handle_options(argc, argv, my_long_options, get_one_option))) exit(ho_error); if (*argc == 0) diff --git a/isam/pack_isam.c b/isam/pack_isam.c index 59594ccc929..b2e21afc743 100644 --- a/isam/pack_isam.c +++ b/isam/pack_isam.c @@ -353,7 +353,7 @@ static void get_options(int *argc, char ***argv) { int ho_error; - if ((ho_error=handle_options(argc, argv, my_long_options, get_one_option, NULL))) + if ((ho_error=handle_options(argc, argv, my_long_options, get_one_option))) exit(ho_error); my_progname= argv[0][0]; diff --git a/myisam/mi_test1.c b/myisam/mi_test1.c index 88e6c5c89d3..8ea97c8e489 100644 --- a/myisam/mi_test1.c +++ b/myisam/mi_test1.c @@ -643,7 +643,7 @@ static void get_options(int argc, char *argv[]) { int ho_error; - if ((ho_error=handle_options(&argc, &argv, my_long_options, get_one_option, NULL))) + if ((ho_error=handle_options(&argc, &argv, my_long_options, get_one_option))) exit(ho_error); return; diff --git a/myisam/myisam_ftdump.c b/myisam/myisam_ftdump.c index 35182bc8abb..838f90feae5 100644 --- a/myisam/myisam_ftdump.c +++ b/myisam/myisam_ftdump.c @@ -66,7 +66,7 @@ int main(int argc,char *argv[]) struct { MI_INFO *info; } aio0, *aio=&aio0; /* for GWS_IN_USE */ MY_INIT(argv[0]); - if (error=handle_options(&argc, &argv, my_long_options, get_one_option, NULL)) + if (error=handle_options(&argc, &argv, my_long_options, get_one_option)) exit(error); if (count || dump) verbose=0; diff --git a/myisam/myisamchk.c b/myisam/myisamchk.c index e8e85345897..5377ecc18a5 100644 --- a/myisam/myisamchk.c +++ b/myisam/myisamchk.c @@ -677,7 +677,7 @@ static void get_options(register int *argc,register char ***argv) if (isatty(fileno(stdout))) check_param.testflag|=T_WRITE_LOOP; - if ((ho_error=handle_options(argc, argv, my_long_options, get_one_option, NULL))) + if ((ho_error=handle_options(argc, argv, my_long_options, get_one_option))) exit(ho_error); /* If using repair, then update checksum if one uses --update-state */ diff --git a/myisam/myisampack.c b/myisam/myisampack.c index 51f8ad1bb11..872fcb49faf 100644 --- a/myisam/myisampack.c +++ b/myisam/myisampack.c @@ -350,7 +350,7 @@ static void get_options(int *argc,char ***argv) if (isatty(fileno(stdout))) write_loop=1; - if ((ho_error=handle_options(argc, argv, my_long_options, get_one_option, NULL))) + if ((ho_error=handle_options(argc, argv, my_long_options, get_one_option))) exit(ho_error); if (!*argc) diff --git a/mysys/my_getopt.c b/mysys/my_getopt.c index f9df4afb55d..71f8819756a 100644 --- a/mysys/my_getopt.c +++ b/mysys/my_getopt.c @@ -22,6 +22,9 @@ #include #include +static void default_reporter(enum loglevel level, const char *format, ...); +my_error_reporter my_getopt_error_reporter= &default_reporter; + static int findopt(char *optpat, uint length, const struct my_option **opt_res, char **ffname); @@ -56,7 +59,8 @@ char *disabled_my_option= (char*) "0"; my_bool my_getopt_print_errors= 1; -void default_reporter(enum loglevel level, const char *format, ...) +static void default_reporter(enum loglevel level __attribute__((unused)), + const char *format, ...) { va_list args; va_start(args, format); @@ -76,8 +80,7 @@ void default_reporter(enum loglevel level, const char *format, ...) int handle_options(int *argc, char ***argv, const struct my_option *longopts, - my_get_one_option get_one_option, - my_error_reporter reporter) + my_get_one_option get_one_option) { uint opt_found, argvpos= 0, length, i; my_bool end_of_options= 0, must_be_var, set_maximum_value, special_used, @@ -91,9 +94,6 @@ int handle_options(int *argc, char ***argv, (*argv)++; /* --- || ---- */ init_variables(longopts); - if (! reporter) - reporter= &default_reporter; - for (pos= *argv, pos_end=pos+ *argc; pos != pos_end ; pos++) { char *cur_arg= *pos; @@ -118,8 +118,9 @@ int handle_options(int *argc, char ***argv, if (!*++pos) { if (my_getopt_print_errors) - reporter(ERROR_LEVEL, - "%s: Option '-O' requires an argument\n", progname); + my_getopt_error_reporter(ERROR_LEVEL, + "%s: Option '-O' requires an argument\n", + progname); return EXIT_ARGUMENT_REQUIRED; } cur_arg= *pos; @@ -135,9 +136,9 @@ int handle_options(int *argc, char ***argv, if (!*cur_arg) { if (my_getopt_print_errors) - reporter(ERROR_LEVEL, - "%s: Option '--set-variable' requires an argument\n", - progname); + my_getopt_error_reporter(ERROR_LEVEL, + "%s: Option '--set-variable' requires an argument\n", + progname); return EXIT_ARGUMENT_REQUIRED; } } @@ -149,9 +150,9 @@ int handle_options(int *argc, char ***argv, if (!*++pos) { if (my_getopt_print_errors) - reporter(ERROR_LEVEL, - "%s: Option '--set-variable' requires an argument\n", - progname); + my_getopt_error_reporter(ERROR_LEVEL, + "%s: Option '--set-variable' requires an argument\n", + progname); return EXIT_ARGUMENT_REQUIRED; } cur_arg= *pos; @@ -210,10 +211,11 @@ int handle_options(int *argc, char ***argv, if (opt_found > 1) { if (my_getopt_print_errors) - reporter(ERROR_LEVEL, - "%s: ambiguous option '--%s-%s' (--%s-%s)\n", - progname, special_opt_prefix[i], cur_arg, - special_opt_prefix[i], prev_found); + my_getopt_error_reporter(ERROR_LEVEL, + "%s: ambiguous option '--%s-%s' (--%s-%s)\n", + progname, special_opt_prefix[i], + cur_arg, special_opt_prefix[i], + prev_found); return EXIT_AMBIGUOUS_OPTION; } switch (i) { @@ -245,16 +247,20 @@ int handle_options(int *argc, char ***argv, if (must_be_var) { if (my_getopt_print_errors) - reporter(option_is_loose ? WARNING_LEVEL : ERROR_LEVEL, - "%s: unknown variable '%s'\n", progname, cur_arg); + my_getopt_error_reporter(option_is_loose ? + WARNING_LEVEL : ERROR_LEVEL, + "%s: unknown variable '%s'\n", + progname, cur_arg); if (!option_is_loose) return EXIT_UNKNOWN_VARIABLE; } else { if (my_getopt_print_errors) - reporter(option_is_loose ? WARNING_LEVEL : ERROR_LEVEL, - "%s: unknown option '--%s'\n", progname, cur_arg); + my_getopt_error_reporter(option_is_loose ? + WARNING_LEVEL : ERROR_LEVEL, + "%s: unknown option '--%s'\n", + progname, cur_arg); if (!option_is_loose) return EXIT_UNKNOWN_OPTION; } @@ -270,23 +276,27 @@ int handle_options(int *argc, char ***argv, if (must_be_var) { if (my_getopt_print_errors) - reporter(ERROR_LEVEL, "%s: variable prefix '%s' is not unique\n", - progname, cur_arg); + my_getopt_error_reporter(ERROR_LEVEL, + "%s: variable prefix '%s' is not unique\n", + progname, cur_arg); return EXIT_VAR_PREFIX_NOT_UNIQUE; } else { if (my_getopt_print_errors) - reporter(ERROR_LEVEL, "%s: ambiguous option '--%s' (%s, %s)\n", - progname, cur_arg, prev_found, optp->name); + my_getopt_error_reporter(ERROR_LEVEL, + "%s: ambiguous option '--%s' (%s, %s)\n", + progname, cur_arg, prev_found, + optp->name); return EXIT_AMBIGUOUS_OPTION; } } if (must_be_var && optp->var_type == GET_NO_ARG) { if (my_getopt_print_errors) - reporter(ERROR_LEVEL, "%s: option '%s' cannot take an argument\n", - progname, optp->name); + my_getopt_error_reporter(ERROR_LEVEL, + "%s: option '%s' cannot take an argument\n", + progname, optp->name); return EXIT_NO_ARGUMENT_ALLOWED; } if (optp->arg_type == NO_ARG) @@ -294,9 +304,9 @@ int handle_options(int *argc, char ***argv, if (optend && optp->var_type != GET_BOOL) { if (my_getopt_print_errors) - reporter(ERROR_LEVEL, - "%s: option '--%s' cannot take an argument\n", - progname, optp->name); + my_getopt_error_reporter(ERROR_LEVEL, + "%s: option '--%s' cannot take an argument\n", + progname, optp->name); return EXIT_NO_ARGUMENT_ALLOWED; } if (optp->var_type == GET_BOOL) @@ -333,9 +343,9 @@ int handle_options(int *argc, char ***argv, if (!*++pos) { if (my_getopt_print_errors) - reporter(ERROR_LEVEL, - "%s: option '--%s' requires an argument\n", - progname, optp->name); + my_getopt_error_reporter(ERROR_LEVEL, + "%s: option '--%s' requires an argument\n", + progname, optp->name); return EXIT_ARGUMENT_REQUIRED; } argument= *pos; @@ -384,9 +394,9 @@ int handle_options(int *argc, char ***argv, if (!pos[1]) { if (my_getopt_print_errors) - reporter(ERROR_LEVEL, - "%s: option '-%c' requires an argument\n", - progname, optp->id); + my_getopt_error_reporter(ERROR_LEVEL, + "%s: option '-%c' requires an argument\n", + progname, optp->id); return EXIT_ARGUMENT_REQUIRED; } argument= *++pos; @@ -396,9 +406,9 @@ int handle_options(int *argc, char ***argv, } if ((error= setval(optp, argument, set_maximum_value))) { - reporter(ERROR_LEVEL, - "%s: Error while setting value '%s' to '%s'\n", - progname, argument, optp->name); + my_getopt_error_reporter(ERROR_LEVEL, + "%s: Error while setting value '%s' to '%s'\n", + progname, argument, optp->name); return error; } get_one_option(optp->id, optp, argument); @@ -408,8 +418,9 @@ int handle_options(int *argc, char ***argv, if (!opt_found) { if (my_getopt_print_errors) - reporter(ERROR_LEVEL, - "%s: unknown option '-%c'\n", progname, *optend); + my_getopt_error_reporter(ERROR_LEVEL, + "%s: unknown option '-%c'\n", + progname, *optend); return EXIT_UNKNOWN_OPTION; } } @@ -418,9 +429,9 @@ int handle_options(int *argc, char ***argv, } if ((error= setval(optp, argument, set_maximum_value))) { - reporter(ERROR_LEVEL, - "%s: Error while setting value '%s' to '%s'\n", - progname, argument, optp->name); + my_getopt_error_reporter(ERROR_LEVEL, + "%s: Error while setting value '%s' to '%s'\n", + progname, argument, optp->name); return error; } get_one_option(optp->id, optp, argument); diff --git a/sql/gen_lex_hash.cc b/sql/gen_lex_hash.cc index 72ab1184533..1e78aa35195 100644 --- a/sql/gen_lex_hash.cc +++ b/sql/gen_lex_hash.cc @@ -384,7 +384,7 @@ static int get_options(int argc, char **argv) { int ho_error; - if ((ho_error=handle_options(&argc, &argv, my_long_options, get_one_option, 0))) + if ((ho_error= handle_options(&argc, &argv, my_long_options, get_one_option))) exit(ho_error); if (argc >= 1) diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 1068c5ec9a1..1e682e16d1f 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -5119,8 +5119,8 @@ static void get_options(int argc,char **argv) { int ho_error; - if ((ho_error=handle_options(&argc, &argv, my_long_options, get_one_option, - option_error_reporter))) + my_getopt_error_reporter= option_error_reporter; + if ((ho_error= handle_options(&argc, &argv, my_long_options, get_one_option))) exit(ho_error); #if defined(HAVE_BROKEN_REALPATH) diff --git a/tools/mysqlmanager.c b/tools/mysqlmanager.c index 12b5519ae9c..ade6da895c6 100644 --- a/tools/mysqlmanager.c +++ b/tools/mysqlmanager.c @@ -1333,7 +1333,7 @@ static int parse_args(int argc, char **argv) { int ho_error; - if ((ho_error=handle_options(&argc, &argv, my_long_options, get_one_option, NULL))) + if ((ho_error=handle_options(&argc, &argv, my_long_options, get_one_option))) exit(ho_error); return 0; From 3f0f1a4fb2b3b1b8e60471a5ef8a83e2b978acda Mon Sep 17 00:00:00 2001 From: "mwagner@here.mwagner.org" <> Date: Tue, 31 Aug 2004 13:29:28 -0500 Subject: [PATCH 14/14] Do-compile: Remove --warnings for mysql-test-run. Devs don't use it, and Serg says it's not needed anymore. --- Build-tools/Do-compile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Build-tools/Do-compile b/Build-tools/Do-compile index 1650e3d4a09..f92af463a0a 100755 --- a/Build-tools/Do-compile +++ b/Build-tools/Do-compile @@ -361,7 +361,7 @@ if ($opt_stage <= 5 && !$opt_no_test && !$opt_no_mysqltest) log_timestamp(); system("mkdir $bench_tmpdir") if (! -d $bench_tmpdir); safe_cd("${test_dir}/mysql-test"); - check_system("./mysql-test-run --warnings --tmpdir=$bench_tmpdir --master_port=$mysql_tcp_port --slave_port=$slave_port --manager-port=$manager_port --no-manager --sleep=10", "tests were successful"); + check_system("./mysql-test-run --tmpdir=$bench_tmpdir --master_port=$mysql_tcp_port --slave_port=$slave_port --manager-port=$manager_port --no-manager --sleep=10", "tests were successful"); } #