diff options
author | unknown <serg@serg.mylan> | 2004-08-26 15:19:46 +0200 |
---|---|---|
committer | unknown <serg@serg.mylan> | 2004-08-26 15:19:46 +0200 |
commit | e8d41a5b1bf0c559c5c3acab469eaa6ff56accfb (patch) | |
tree | 9299076637e9019c66560b2d68fe6b4bc6456487 | |
parent | 42771f9877c17050a230cdaf8a26afc5d077a712 (diff) | |
parent | ad1f3bb17d5a8117ff9feb987c04a52f22394189 (diff) | |
download | mariadb-git-e8d41a5b1bf0c559c5c3acab469eaa6ff56accfb.tar.gz |
merged
BitKeeper/etc/logging_ok:
auto-union
VC++Files/sql/mysqld.dsp:
Auto merged
client/mysql.cc:
Auto merged
client/mysqladmin.c:
Auto merged
BitKeeper/deleted/.del-mysql_install.c~8c089740d79a92:
Auto merged
client/mysqlbinlog.cc:
Auto merged
client/mysqlcheck.c:
Auto merged
client/mysqldump.c:
Auto merged
client/mysqlimport.c:
Auto merged
client/mysqlmanager-pwgen.c:
Auto merged
client/mysqlshow.c:
Auto merged
client/mysqltest.c:
Auto merged
extra/my_print_defaults.c:
Auto merged
extra/perror.c:
Auto merged
extra/resolve_stack_dump.c:
Auto merged
extra/resolveip.c:
Auto merged
include/my_getopt.h:
Auto merged
innobase/buf/buf0rea.c:
Auto merged
isam/isamchk.c:
Auto merged
isam/pack_isam.c:
Auto merged
libmysqld/Makefile.am:
Auto merged
myisam/mi_test1.c:
Auto merged
myisam/myisamchk.c:
Auto merged
myisam/myisampack.c:
Auto merged
mysql-test/mysql-test-run.sh:
Auto merged
sql/gen_lex_hash.cc:
Auto merged
sql/sql_base.cc:
Auto merged
sql/sql_parse.cc:
Auto merged
tools/mysqlmanager.c:
Auto merged
37 files changed, 385 insertions, 86 deletions
diff --git a/BitKeeper/etc/logging_ok b/BitKeeper/etc/logging_ok index 76a72fc9b4a..0eb4289c1d5 100644 --- a/BitKeeper/etc/logging_ok +++ b/BitKeeper/etc/logging_ok @@ -80,6 +80,7 @@ jcole@mugatu.jcole.us jcole@mugatu.spaceapes.com jcole@sarvik.tfr.cafe.ee jcole@tetra.spaceapes.com +joerg@mysql.com joreland@mysql.com jorge@linux.jorge.mysql.com jplindst@t41.(none) diff --git a/VC++Files/sql/mysqld.dsp b/VC++Files/sql/mysqld.dsp index 9bcdb4be24f..31c52009d9f 100644 --- a/VC++Files/sql/mysqld.dsp +++ b/VC++Files/sql/mysqld.dsp @@ -920,6 +920,89 @@ SOURCE=.\log_event.cpp # End Source File # Begin Source File +SOURCE=.\message.mc + +!IF "$(CFG)" == "mysqld - Win32 Release" + +!ELSEIF "$(CFG)" == "mysqld - Win32 Debug" + +!ELSEIF "$(CFG)" == "mysqld - Win32 nt" + +# Begin Custom Build - Compiling messages +InputDir=. +InputPath=.\message.mc +InputName=message + +BuildCmds= \ + mc.exe "$(InputDir)\$(InputName).mc" + +"$(InputDir)\$(InputName).rc" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" + $(BuildCmds) + +"$(InputDir)\$(InputName).h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" + $(BuildCmds) +# End Custom Build + +!ELSEIF "$(CFG)" == "mysqld - Win32 Max nt" +# Begin Custom Build - Compiling messages +InputDir=. +InputPath=.\message.mc +InputName=message + +BuildCmds= \ + mc.exe "$(InputDir)\$(InputName).mc" + +"$(InputDir)\$(InputName).rc" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" + $(BuildCmds) + +"$(InputDir)\$(InputName).h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" + $(BuildCmds) +# End Custom Build +!ELSEIF "$(CFG)" == "mysqld - Win32 Max" + +!ELSEIF "$(CFG)" == "mysqld - Win32 classic" + +!ELSEIF "$(CFG)" == "mysqld - Win32 pro" + +!ELSEIF "$(CFG)" == "mysqld - Win32 classic nt" +# Begin Custom Build - Compiling messages +InputDir=. +InputPath=.\message.mc +InputName=message + +BuildCmds= \ + mc.exe "$(InputDir)\$(InputName).mc" + +"$(InputDir)\$(InputName).rc" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" + $(BuildCmds) + +"$(InputDir)\$(InputName).h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" + $(BuildCmds) +# End Custom Build +!ELSEIF "$(CFG)" == "mysqld - Win32 pro nt" +# Begin Custom Build - Compiling messages +InputDir=. +InputPath=.\message.mc +InputName=message + +BuildCmds= \ + mc.exe "$(InputDir)\$(InputName).mc" + +"$(InputDir)\$(InputName).rc" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" + $(BuildCmds) + +"$(InputDir)\$(InputName).h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" + $(BuildCmds) +# End Custom Build +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\message.rc +# End Source File +# Begin Source File + SOURCE=.\mf_iocache.cpp !IF "$(CFG)" == "mysqld - Win32 Release" diff --git a/client/mysql.cc b/client/mysql.cc index dd472041b34..4138f94eb05 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -858,7 +858,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))) + if ((ho_error=handle_options(&argc, &argv, my_long_options, get_one_option, 0))) exit(ho_error); *mysql_params->p_max_allowed_packet= opt_max_allowed_packet; diff --git a/client/mysqladmin.c b/client/mysqladmin.c index a3bb0fea180..9e5c698bb93 100644 --- a/client/mysqladmin.c +++ b/client/mysqladmin.c @@ -276,7 +276,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))) + if ((ho_error=handle_options(&argc, &argv, my_long_options, get_one_option, 0))) { free_defaults(save_argv); exit(ho_error); diff --git a/client/mysqlbinlog.cc b/client/mysqlbinlog.cc index 5f9a499bd31..6d8ff665393 100644 --- a/client/mysqlbinlog.cc +++ b/client/mysqlbinlog.cc @@ -666,7 +666,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))) + if ((ho_error=handle_options(argc, argv, my_long_options, get_one_option, NULL))) exit(ho_error); return 0; diff --git a/client/mysqlcheck.c b/client/mysqlcheck.c index 47512b2a277..882efff37a2 100644 --- a/client/mysqlcheck.c +++ b/client/mysqlcheck.c @@ -295,7 +295,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))) + if ((ho_error=handle_options(argc, argv, my_long_options, get_one_option, 0))) exit(ho_error); if (!what_to_do) diff --git a/client/mysqldump.c b/client/mysqldump.c index 8fcf1bb1781..77c93e126e7 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -604,7 +604,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))) + if ((ho_error=handle_options(argc, argv, my_long_options, get_one_option, 0))) exit(ho_error); *mysql_params->p_max_allowed_packet= opt_max_allowed_packet; diff --git a/client/mysqlimport.c b/client/mysqlimport.c index 86f373d75fe..201bf51b1bd 100644 --- a/client/mysqlimport.c +++ b/client/mysqlimport.c @@ -228,7 +228,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))) + if ((ho_error=handle_options(argc, argv, my_long_options, get_one_option, 0))) exit(ho_error); if (enclosed && opt_enclosed) diff --git a/client/mysqlmanager-pwgen.c b/client/mysqlmanager-pwgen.c index 1d942e207ad..4c6fbf14dd9 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))) + if ((ho_error=handle_options(&argc, &argv, my_long_options, get_one_option, NULL))) exit(ho_error); return 0; diff --git a/client/mysqlmanagerc.c b/client/mysqlmanagerc.c index 0001a0266e6..78485427473 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))) + if ((ho_error=handle_options(&argc, &argv, my_long_options, get_one_option, NULL))) exit(ho_error); return 0; diff --git a/client/mysqlshow.c b/client/mysqlshow.c index 05108bd03c8..35d61f1fa2f 100644 --- a/client/mysqlshow.c +++ b/client/mysqlshow.c @@ -297,7 +297,7 @@ get_options(int *argc,char ***argv) { int ho_error; - if ((ho_error=handle_options(argc, argv, my_long_options, get_one_option))) + if ((ho_error=handle_options(argc, argv, my_long_options, get_one_option, 0))) exit(ho_error); if (tty_password) diff --git a/client/mysqltest.c b/client/mysqltest.c index 3287c9738d3..98818022047 100644 --- a/client/mysqltest.c +++ b/client/mysqltest.c @@ -2100,7 +2100,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))) + if ((handle_options(&argc, &argv, my_long_options, get_one_option, 0))) exit(1); if (argc > 1) diff --git a/extra/my_print_defaults.c b/extra/my_print_defaults.c index f4da839f8e2..a0af98e5f1c 100644 --- a/extra/my_print_defaults.c +++ b/extra/my_print_defaults.c @@ -99,7 +99,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))) + if ((ho_error=handle_options(argc, argv, my_long_options, get_one_option, NULL))) exit(ho_error); if (*argc < 1) diff --git a/extra/mysql_waitpid.c b/extra/mysql_waitpid.c index bff1752ec21..9fcabfbb53e 100644 --- a/extra/mysql_waitpid.c +++ b/extra/mysql_waitpid.c @@ -66,7 +66,7 @@ int main(int argc, char *argv[]) progname= argv[0]; - if (handle_options(&argc, &argv, my_long_options, get_one_option)) + if (handle_options(&argc, &argv, my_long_options, get_one_option, NULL)) 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 a28626fd873..b029d87040f 100644 --- a/extra/perror.c +++ b/extra/perror.c @@ -157,7 +157,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))) + if ((ho_error=handle_options(argc, argv, my_long_options, get_one_option, NULL))) exit(ho_error); if (!*argc && !print_all_codes) diff --git a/extra/resolve_stack_dump.c b/extra/resolve_stack_dump.c index 06a670b935d..3c26c315dea 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))) + if ((ho_error=handle_options(&argc, &argv, my_long_options, get_one_option, NULL))) exit(ho_error); /* diff --git a/extra/resolveip.c b/extra/resolveip.c index f8cff2a976c..a995b038770 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))) + if ((ho_error=handle_options(argc, argv, my_long_options, get_one_option, NULL))) exit(ho_error); if (*argc == 0) diff --git a/include/my_getopt.h b/include/my_getopt.h index bf119892a31..9d6ef40b399 100644 --- a/include/my_getopt.h +++ b/include/my_getopt.h @@ -14,6 +14,9 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifndef _my_getopt_h +#define _my_getopt_h + C_MODE_START #define GET_NO_ARG 1 @@ -54,11 +57,12 @@ struct my_option 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 int handle_options (int *argc, char ***argv, - const struct my_option *longopts, - my_bool (*get_one_option)(int, - const struct my_option *, - char *)); + const struct my_option *longopts, my_get_one_option, + my_error_reporter ); extern void my_print_help(const struct my_option *options); extern void my_print_variables(const struct my_option *options); extern void my_getopt_register_get_addr(gptr* (*func_addr)(const char *, uint, @@ -66,4 +70,8 @@ extern void my_getopt_register_get_addr(gptr* (*func_addr)(const char *, uint, ulonglong getopt_ull_limit_value(ulonglong num, const struct my_option *optp); my_bool getopt_compare_strings(const char *s, const char *t, uint length); + C_MODE_END + +#endif /* _my_getopt_h */ + diff --git a/include/my_sys.h b/include/my_sys.h index 922e6d8cff4..ad1966ba67f 100644 --- a/include/my_sys.h +++ b/include/my_sys.h @@ -244,6 +244,12 @@ typedef struct wild_file_pack /* Struct to hold info when selecting files */ my_string *wild; /* Pointer to wildcards */ } WF_PACK; +enum loglevel { + ERROR_LEVEL, + WARNING_LEVEL, + INFORMATION_LEVEL +}; + enum cache_type { READ_CACHE,WRITE_CACHE, diff --git a/innobase/buf/buf0rea.c b/innobase/buf/buf0rea.c index 71e885ff439..11107d777c8 100644 --- a/innobase/buf/buf0rea.c +++ b/innobase/buf/buf0rea.c @@ -629,6 +629,8 @@ buf_read_ibuf_merge_pages( } } + os_aio_simulated_wake_handler_threads(); + /* Flush pages from the end of the LRU list if necessary */ buf_flush_free_margin(); diff --git a/isam/isamchk.c b/isam/isamchk.c index 5dd20c14063..c0ba810ef64 100644 --- a/isam/isamchk.c +++ b/isam/isamchk.c @@ -671,7 +671,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))) + if ((ho_error=handle_options(argc, argv, my_long_options, get_one_option, NULL))) exit(ho_error); if (*argc == 0) diff --git a/isam/pack_isam.c b/isam/pack_isam.c index aa83b2b2a96..6e03df100a2 100644 --- a/isam/pack_isam.c +++ b/isam/pack_isam.c @@ -337,7 +337,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))) + if ((ho_error=handle_options(argc, argv, my_long_options, get_one_option, NULL))) exit(ho_error); my_progname= argv[0][0]; diff --git a/myisam/mi_test1.c b/myisam/mi_test1.c index 77c4d3dfbad..5574eaba101 100644 --- a/myisam/mi_test1.c +++ b/myisam/mi_test1.c @@ -644,7 +644,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))) + if ((ho_error=handle_options(&argc, &argv, my_long_options, get_one_option, NULL))) exit(ho_error); return; diff --git a/myisam/myisam_ftdump.c b/myisam/myisam_ftdump.c index eeee96d0ff2..cbc8437da79 100644 --- a/myisam/myisam_ftdump.c +++ b/myisam/myisam_ftdump.c @@ -68,7 +68,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))) + if ((error=handle_options(&argc, &argv, my_long_options, get_one_option, 0))) exit(error); if (count || dump) verbose=0; diff --git a/myisam/myisamchk.c b/myisam/myisamchk.c index 2c44953ccc9..5a6717833c5 100644 --- a/myisam/myisamchk.c +++ b/myisam/myisamchk.c @@ -696,7 +696,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))) + if ((ho_error=handle_options(argc, argv, my_long_options, get_one_option, NULL))) 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 de4bd80805a..d3241467d23 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))) + if ((ho_error=handle_options(argc, argv, my_long_options, get_one_option, NULL))) exit(ho_error); if (!*argc) diff --git a/mysql-test/r/lowercase_table.result b/mysql-test/r/lowercase_table.result index 8bf3db8cad0..2f71e4c2f57 100644 --- a/mysql-test/r/lowercase_table.result +++ b/mysql-test/r/lowercase_table.result @@ -58,3 +58,10 @@ ERROR 42000: Not unique table/alias: 'C' drop table t1, t2; show tables; Tables_in_test +create table t1 (a int); +select TEST.t1.* from TEST.t1; +a +alter table t1 rename to T1; +select TEST.t1.* from TEST.t1; +a +drop table t1; diff --git a/mysql-test/t/lowercase_table.test b/mysql-test/t/lowercase_table.test index db46f3d432d..bdfa8dfc132 100644 --- a/mysql-test/t/lowercase_table.test +++ b/mysql-test/t/lowercase_table.test @@ -54,3 +54,13 @@ select C.a, c.a from t1 c, t2 C; drop table t1, t2; show tables; + +# +# Test all caps database name +# +create table t1 (a int); +select TEST.t1.* from TEST.t1; +alter table t1 rename to T1; +select TEST.t1.* from TEST.t1; +drop table t1; + diff --git a/mysys/my_getopt.c b/mysys/my_getopt.c index d7a9babe5e7..07a8f199b3b 100644 --- a/mysys/my_getopt.c +++ b/mysys/my_getopt.c @@ -17,9 +17,9 @@ #include <my_global.h> #include <m_string.h> #include <stdlib.h> -#include <my_getopt.h> #include <my_sys.h> #include <mysys_err.h> +#include <my_getopt.h> static int findopt(char *optpat, uint length, const struct my_option **opt_res, @@ -56,6 +56,13 @@ char *disabled_my_option= (char*) "0"; my_bool my_getopt_print_errors= 1; +void default_reporter(enum loglevel level, const char *format, ...) +{ + va_list args; + va_start(args, format); + vfprintf(stderr, format, args); + va_end(args); +} /* function: handle_options @@ -76,10 +83,8 @@ void my_getopt_register_get_addr(gptr* (*func_addr)(const char *, uint, } int handle_options(int *argc, char ***argv, - const struct my_option *longopts, - my_bool (*get_one_option)(int, - const struct my_option *, - char *)) + 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, @@ -95,6 +100,8 @@ 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 +125,8 @@ int handle_options(int *argc, char ***argv, if (!*++pos) { if (my_getopt_print_errors) - fprintf(stderr, "%s: Option '-O' requires an argument\n", - my_progname); + reporter(ERROR_LEVEL, "%s: Option '-O' requires an argument\n", + my_progname); return EXIT_ARGUMENT_REQUIRED; } cur_arg= *pos; @@ -135,9 +142,8 @@ int handle_options(int *argc, char ***argv, if (!*cur_arg) { if (my_getopt_print_errors) - fprintf(stderr, - "%s: Option '--set-variable' requires an argument\n", - my_progname); + reporter(ERROR_LEVEL, "%s: Option '--set-variable' requires an argument\n", + my_progname); return EXIT_ARGUMENT_REQUIRED; } } @@ -149,9 +155,8 @@ int handle_options(int *argc, char ***argv, if (!*++pos) { if (my_getopt_print_errors) - fprintf(stderr, - "%s: Option '--set-variable' requires an argument\n", - my_progname); + reporter(ERROR_LEVEL, "%s: Option '--set-variable' requires an argument\n", + my_progname); return EXIT_ARGUMENT_REQUIRED; } cur_arg= *pos; @@ -210,7 +215,7 @@ int handle_options(int *argc, char ***argv, if (opt_found > 1) { if (my_getopt_print_errors) - fprintf(stderr, + reporter(ERROR_LEVEL, "%s: ambiguous option '--%s-%s' (--%s-%s)\n", my_progname, special_opt_prefix[i], opt_str, special_opt_prefix[i], prev_found); @@ -245,18 +250,16 @@ int handle_options(int *argc, char ***argv, if (must_be_var) { if (my_getopt_print_errors) - fprintf(stderr, - "%s: %s: unknown variable '%s'\n", my_progname, - option_is_loose ? "WARNING" : "ERROR", opt_str); + reporter(option_is_loose ? WARNING_LEVEL : ERROR_LEVEL, + "%s: unknown variable '%s'\n", my_progname, cur_arg); if (!option_is_loose) return EXIT_UNKNOWN_VARIABLE; } else { if (my_getopt_print_errors) - fprintf(stderr, - "%s: %s: unknown option '--%s'\n", my_progname, - option_is_loose ? "WARNING" : "ERROR", opt_str); + reporter(option_is_loose ? WARNING_LEVEL : ERROR_LEVEL, + "%s: unknown option '--%s'\n", my_progname, cur_arg); if (!option_is_loose) return EXIT_UNKNOWN_OPTION; } @@ -272,14 +275,14 @@ int handle_options(int *argc, char ***argv, if (must_be_var) { if (my_getopt_print_errors) - fprintf(stderr, "%s: variable prefix '%s' is not unique\n", + reporter(ERROR_LEVEL, "%s: variable prefix '%s' is not unique\n", my_progname, opt_str); return EXIT_VAR_PREFIX_NOT_UNIQUE; } else { if (my_getopt_print_errors) - fprintf(stderr, "%s: ambiguous option '--%s' (%s, %s)\n", + reporter(ERROR_LEVEL, "%s: ambiguous option '--%s' (%s, %s)\n", my_progname, opt_str, prev_found, optp->name); return EXIT_AMBIGUOUS_OPTION; } @@ -300,7 +303,7 @@ int handle_options(int *argc, char ***argv, if (must_be_var && (optp->var_type & GET_TYPE_MASK) == GET_NO_ARG) { if (my_getopt_print_errors) - fprintf(stderr, "%s: option '%s' cannot take an argument\n", + reporter(ERROR_LEVEL, "%s: option '%s' cannot take an argument\n", my_progname, optp->name); return EXIT_NO_ARGUMENT_ALLOWED; } @@ -312,7 +315,7 @@ int handle_options(int *argc, char ***argv, if (optend && (optp->var_type & GET_TYPE_MASK) != GET_BOOL) { if (my_getopt_print_errors) - fprintf(stderr, "%s: option '--%s' cannot take an argument\n", + reporter(ERROR_LEVEL, "%s: option '--%s' cannot take an argument\n", my_progname, optp->name); return EXIT_NO_ARGUMENT_ALLOWED; } @@ -351,7 +354,7 @@ int handle_options(int *argc, char ***argv, if (!*++pos) { if (my_getopt_print_errors) - fprintf(stderr, "%s: option '--%s' requires an argument\n", + reporter(ERROR_LEVEL, "%s: option '--%s' requires an argument\n", my_progname, optp->name); return EXIT_ARGUMENT_REQUIRED; } @@ -410,7 +413,7 @@ int handle_options(int *argc, char ***argv, if (!pos[1]) { if (my_getopt_print_errors) - fprintf(stderr, + reporter(ERROR_LEVEL, "%s: option '-%c' requires an argument\n", my_progname, optp->id); return EXIT_ARGUMENT_REQUIRED; @@ -423,7 +426,7 @@ int handle_options(int *argc, char ***argv, if ((error= setval(optp, optp->value, argument, set_maximum_value))) { - fprintf(stderr, + reporter(ERROR_LEVEL, "%s: Error while setting value '%s' to '%s'\n", my_progname, argument, optp->name); return error; @@ -435,7 +438,7 @@ int handle_options(int *argc, char ***argv, if (!opt_found) { if (my_getopt_print_errors) - fprintf(stderr, + reporter(ERROR_LEVEL, "%s: unknown option '-%c'\n", my_progname, *optend); return EXIT_UNKNOWN_OPTION; } @@ -445,7 +448,7 @@ int handle_options(int *argc, char ***argv, } if ((error= setval(optp, value, argument, set_maximum_value))) { - fprintf(stderr, + reporter(ERROR_LEVEL, "%s: Error while setting value '%s' to '%s'\n", my_progname, argument, optp->name); return error; diff --git a/sql/gen_lex_hash.cc b/sql/gen_lex_hash.cc index 7a445ed8c4d..cb97febea32 100644 --- a/sql/gen_lex_hash.cc +++ b/sql/gen_lex_hash.cc @@ -362,7 +362,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))) + if ((ho_error=handle_options(&argc, &argv, my_long_options, get_one_option, 0))) exit(ho_error); if (argc >= 1) diff --git a/sql/log.cc b/sql/log.cc index 240965fdca3..870242eac31 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -31,12 +31,51 @@ #include <stdarg.h> #include <m_ctype.h> // For test_if_number +#ifdef __NT__ +#include "message.h" +#endif + MYSQL_LOG mysql_log,mysql_update_log,mysql_slow_log,mysql_bin_log; ulong sync_binlog_counter= 0; static bool test_if_number(const char *str, long *res, bool allow_wildcards); +#ifdef __NT__ +static int eventSource = 0; +void setupWindowsEventSource() +{ + if (eventSource) return; + + eventSource = 1; + HKEY hRegKey = NULL; + DWORD dwError = 0; + TCHAR szPath[ MAX_PATH ]; + + // Create the event source registry key + dwError = RegCreateKey(HKEY_LOCAL_MACHINE, + "SYSTEM\\CurrentControlSet\\Services\\EventLog\\Application\\MySQL", + &hRegKey); + + // 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); + + RegCloseKey(hRegKey); +} + +#endif + + /**************************************************************************** ** Find a uniq filename for 'filename.#'. ** Set # to a number as low as possible @@ -230,7 +269,7 @@ bool MYSQL_LOG::open(const char *log_name, enum_log_type log_type_arg, "started with:\nTcp port: %d Unix socket: %s\n", my_progname,server_version,mysqld_port,mysqld_unix_port #endif - ); + ); end=strnmov(buff+len,"Time Id Command Argument\n", sizeof(buff)-len); if (my_b_write(&log_file, (byte*) buff,(uint) (end-buff)) || @@ -1940,41 +1979,33 @@ static bool test_if_number(register const char *str, } /* test_if_number */ -void sql_print_error(const char *format,...) +void print_buffer_to_file(enum loglevel level, const char *buffer) { - va_list args; time_t skr; struct tm tm_tmp; struct tm *start; - va_start(args,format); - DBUG_ENTER("sql_print_error"); + + DBUG_ENTER("print_buffer_to_log"); VOID(pthread_mutex_lock(&LOCK_error_log)); -#ifndef DBUG_OFF - { - char buff[1024]; - my_vsnprintf(buff,sizeof(buff)-1,format,args); - DBUG_PRINT("error",("%s",buff)); - va_end(args); - va_start(args,format); - } -#endif + skr=time(NULL); - localtime_r(&skr,&tm_tmp); + localtime_r(&skr, &tm_tmp); start=&tm_tmp; - fprintf(stderr,"%02d%02d%02d %2d:%02d:%02d ", - start->tm_year % 100, - start->tm_mon+1, + 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); - (void) vfprintf(stderr,format,args); - (void) fputc('\n',stderr); + start->tm_sec, + level == ERROR_LEVEL ? "ERROR" : level == WARNING_LEVEL ? "WARNING" : "INFORMATION", + buffer); + fflush(stderr); - va_end(args); VOID(pthread_mutex_unlock(&LOCK_error_log)); + DBUG_VOID_RETURN; } @@ -2169,5 +2200,124 @@ void MYSQL_LOG::report_pos_in_innodb() my_b_tell(&log_file)); } #endif + +#ifdef __NT__ +void print_buffer_to_nt_eventlog(enum loglevel level, char *buff, int buffLen) +{ + HANDLE event; + char *buffptr; + LPCSTR *buffmsgptr; + + DBUG_ENTER("print_buffer_to_nt_eventlog"); + + buffptr = buff; + if (strlen(buff) > (uint)(buffLen-4)) + { + char *newBuff = new char[ strlen(buff) + 4 ]; + strcpy(newBuff, buff); + buffptr = newBuff; + } + strcat(buffptr, "\r\n\r\n"); + buffmsgptr = (LPCSTR*)&buffptr; + + setupWindowsEventSource(); + if (event = RegisterEventSource(NULL,"MySQL")) + { + switch (level){ + case ERROR_LEVEL: + 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); + break; + case INFORMATION_LEVEL: + 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) + delete[] buffptr; + + + DBUG_VOID_RETURN; +} +#endif + +/* + 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 + + 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. + + RETURN VALUES + void +*/ +void vprint_msg_to_log(enum loglevel level, const char *format, va_list args) +{ + char buff[1024]; + + 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 + +#ifdef __NT__ + print_buffer_to_nt_eventlog(level, buff, sizeof(buff)); +#endif + + DBUG_VOID_RETURN; +} + + +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_VOID_RETURN; +} + +void sql_print_warning(const char *format, ...) +{ + DBUG_ENTER("sql_print_warning"); + + va_list args; + 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"); + + va_list args; + va_start(args, format); + vprint_msg_to_log(INFORMATION_LEVEL, format, args); + va_end(args); + DBUG_VOID_RETURN; } diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 2037cf48616..1949ecf26dc 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -576,7 +576,7 @@ int mysql_insert(THD *thd,TABLE_LIST *table,List<Item> &fields, int mysql_prepare_delete(THD *thd, TABLE_LIST *table_list, Item **conds); int mysql_delete(THD *thd, TABLE_LIST *table, COND *conds, SQL_LIST *order, ha_rows rows, ulong options); -int mysql_truncate(THD *thd, TABLE_LIST *table_list, bool dont_send_ok=0); +int mysql_truncate(THD *thd, TABLE_LIST *table_list, bool dont_send_ok); TABLE *open_ltable(THD *thd, TABLE_LIST *table_list, thr_lock_type update); TABLE *open_table(THD *thd,const char *db,const char *table,const char *alias, bool *refresh); @@ -782,8 +782,14 @@ int key_cmp(KEY_PART_INFO *key_part, const byte *key, uint key_length); bool init_errmessage(void); void sql_perror(const char *message); -void sql_print_error(const char *format,...) - __attribute__ ((format (printf, 1, 2))); + +void vprint_msg_to_log( enum loglevel level, const char *format, va_list args ); +void sql_print_error( const char *format, ... ); +void sql_print_warning( const char *format, ...); +void sql_print_information( const char *format, ...); + + + bool fn_format_relative_to_data_home(my_string to, const char *name, const char *dir, const char *extension); bool open_log(MYSQL_LOG *log, const char *hostname, diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 4ef41e62f32..74f130e6784 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -6078,7 +6078,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), } return 0; } - + /* Initiates DEBUG - but no debugging here ! */ extern "C" gptr * mysql_getopt_value(const char *keyname, uint key_length, @@ -6108,6 +6108,13 @@ mysql_getopt_value(const char *keyname, uint key_length, return option->value; } +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 ); +} static void get_options(int argc,char **argv) { @@ -6116,7 +6123,7 @@ static void get_options(int argc,char **argv) my_getopt_register_get_addr(mysql_getopt_value); strmake(def_ft_boolean_syntax, ft_boolean_syntax, sizeof(ft_boolean_syntax)-1); - 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, option_error_reporter))) exit(ho_error); if (argc > 0) { diff --git a/sql/sql_base.cc b/sql/sql_base.cc index dede280325d..255f04d853b 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -2441,9 +2441,20 @@ bool insert_fields(THD *thd,TABLE_LIST *tables, const char *db_name, const char *table_name, List_iterator<Item> *it) { + char name_buff[NAME_LEN+1]; 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; + } + + found=0; for (; tables ; tables=tables->next) { diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index f9e979d1fdf..3cb356d42c8 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -2740,7 +2740,7 @@ unsent_create_error: send_error(thd,ER_LOCK_OR_ACTIVE_TRANSACTION,NullS); goto error; } - res=mysql_truncate(thd,tables); + res=mysql_truncate(thd, tables, 0); break; case SQLCOM_DELETE: { diff --git a/support-files/mysql.spec.sh b/support-files/mysql.spec.sh index 6ec05433bef..e7f8a035a15 100644 --- a/support-files/mysql.spec.sh +++ b/support-files/mysql.spec.sh @@ -156,7 +156,7 @@ Summary: MySQL - server with Berkeley DB, RAID and UDF support Group: Applications/Databases Provides: mysql-Max Obsoletes: mysql-Max -Requires: MySQL >= 4.0 +Requires: MySQL-server >= 4.0 %description Max Optional MySQL server binary that supports additional features like @@ -594,8 +594,13 @@ fi %attr(644, root, root) %{_libdir}/mysql/libmysqld.a # The spec file changelog only includes changes made to the spec file -# itself +# itself - note that they must be ordered by date (important when +# merging BK trees) %changelog +* Thu Aug 26 2004 Lenz Grimmer <lenz@mysql.com> + +- MySQL-Max now requires MySQL-server instead of MySQL (BUG 3860) + * Fri Aug 20 2004 Lenz Grimmer <lenz@mysql.com> - do not link statically on IA64/AMD64 as these systems do not have diff --git a/tools/mysqlmanager.c b/tools/mysqlmanager.c index bb0a76d6c49..36a8b2f394c 100644 --- a/tools/mysqlmanager.c +++ b/tools/mysqlmanager.c @@ -1335,7 +1335,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))) + if ((ho_error=handle_options(&argc, &argv, my_long_options, get_one_option, NULL))) exit(ho_error); return 0; |