From 767d880f9c641746ed0087c4a2395e2a66d43374 Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 14 Aug 2004 03:38:37 +0200 Subject: [PATCH 01/54] mysql_priv.h: Added declarations for print_msg_to_log and vprint_msg_to_log. sql_print_error are simple functions that wrap calls to print_msg_to_log. Define the different error types with MY_ERROR_TYPE, MY_WARNING_TYPE, and MY_INFORMATION_TYPE gen_lex_hash.cc: Added NULL error reporting parameter to handle_options log.cc: Add print_msg_to_log, print_buffer_to_log, and vprint_msg_to_log. Print_msg_to_log will write the message to the windows event log if on NT. We now have error, warning, and information versions of sql_print_xxxx. T his is a variation of a similar changeset WAX did. mysqld.cc: Added option_error_reporter callback function and pass that into handle_options mysql.cc: Added NULL as error reporter arg to the end of handle_options Many files: Added NULL error reporter parameter as the last paramter to handle_options my_getopt.c: Added second function pointer to server as an error reporting callback. Added local function report_option_error that will either write the error to stderr or to the error reporting callback. changed all calls in handle_options from fprintf(stderr, ... ) to report_option_error my_getopt.h: Changed declaration of handle_options to use typedefs for the two function pointers. added second function pointer to server as an error reporting callback mysqld.dsp: Added custom build step for compiling message file and added message resource file (output of mc) VC++Files/sql/mysqld.dsp: Added custom build step for compiling message file and added message resource file (output of mc) client/mysqladmin.c: Added NULL error reporter parameter as the last paramter to handle_options client/mysqlcheck.c: Added NULL error reporter parameter as the last paramter to handle_options client/mysqldump.c: Added NULL error reporter parameter as the last paramter to handle_options client/mysqlimport.c: Added NULL error reporter parameter as the last paramter to handle_options client/mysqlmanager-pwgen.c: Added NULL error reporter parameter as the last paramter to handle_options client/mysqlmanagerc.c: Added NULL error reporter parameter as the last paramter to handle_options client/mysqlbinlog.cc: Added NULL error reporter parameter as the last paramter to handle_options client/mysqlshow.c: Added NULL error reporter parameter as the last paramter to handle_options client/mysqltest.c: Added NULL error reporter parameter as the last paramter to handle_options extra/my_print_defaults.c: Added NULL error reporter parameter as the last paramter to handle_options extra/mysql_install.c: Added NULL error reporter parameter as the last paramter to handle_options extra/mysql_waitpid.c: Added NULL error reporter parameter as the last paramter to handle_options extra/perror.c: Added NULL error reporter parameter as the last paramter to handle_options extra/resolve_stack_dump.c: Added NULL error reporter parameter as the last paramter to handle_options extra/resolveip.c: Added NULL error reporter parameter as the last paramter to handle_options isam/isamchk.c: Added NULL error reporter parameter as the last paramter to handle_options isam/pack_isam.c: Added NULL error reporter parameter as the last paramter to handle_options myisam/mi_test1.c: Added NULL error reporter parameter as the last paramter to handle_options myisam/myisam_ftdump.c: Added NULL error reporter parameter as the last paramter to handle_options myisam/myisamchk.c: Added NULL error reporter parameter as the last paramter to handle_options myisam/myisampack.c: Added NULL error reporter parameter as the last paramter to handle_options include/my_getopt.h: Changed declaration of handle_options to use typedefs for the two function pointers. added second function pointer to server as an error reporting callback mysys/my_getopt.c: Added second function pointer to server as an error reporting callback. Added local function report_option_error that will either write the error to stderr or to the error reporting callback. changed all calls in handle_options from fprintf(stderr, ... ) to report_option_error tools/mysqlmanager.c: Added NULL error reporter parameter as the last paramter to handle_options client/mysql.cc: Added NULL as error reporter arg to the end of handle_options sql/mysqld.cc: Added option_error_reporter callback function and pass that into handle_options sql/log.cc: Add print_msg_to_log, print_buffer_to_log, and vprint_msg_to_log. Print_msg_to_log will write the message to the windows event log if on NT. We now have error, warning, and information versions of sql_print_xxxx. T his is a variation of a similar changeset WAX did. sql/gen_lex_hash.cc: Added NULL error reporting parameter to handle_options sql/mysql_priv.h: Added declarations for print_msg_to_log and vprint_msg_to_log. sql_print_error are simple functions that wrap calls to print_msg_to_log. Define the different error types with MY_ERROR_TYPE, MY_WARNING_TYPE, and MY_INFORMATION_TYPE BitKeeper/etc/logging_ok: Logging to logging@openlogging.org accepted --- BitKeeper/etc/logging_ok | 1 + VC++Files/sql/mysqld.dsp | 83 ++++++++++++++ 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 | 8 +- 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 | 48 +++++---- sql/gen_lex_hash.cc | 2 +- sql/log.cc | 208 ++++++++++++++++++++++++++++++++---- sql/mysql_priv.h | 22 +++- sql/mysqld.cc | 7 +- tools/mysqlmanager.c | 2 +- 31 files changed, 352 insertions(+), 73 deletions(-) diff --git a/BitKeeper/etc/logging_ok b/BitKeeper/etc/logging_ok index 3ffbead8d68..cdaa06ecb0e 100644 --- a/BitKeeper/etc/logging_ok +++ b/BitKeeper/etc/logging_ok @@ -108,6 +108,7 @@ ram@gw.mysql.r18.ru ram@mysql.r18.ru ram@ram.(none) ranger@regul.home.lan +rburnett@build.mysql.com root@x3.internalnet salle@geopard.(none) salle@geopard.online.bg diff --git a/VC++Files/sql/mysqld.dsp b/VC++Files/sql/mysqld.dsp index 1332b74235f..3198c918a5e 100644 --- a/VC++Files/sql/mysqld.dsp +++ b/VC++Files/sql/mysqld.dsp @@ -900,6 +900,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 66a99bbdf75..72ebfe9cf0c 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -758,7 +758,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 3bc11ec0fb0..e2843685d50 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))) + 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 7c3d22c4900..93e0b98b1e5 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))) + 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 1c5638f3c52..718b92da466 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))) + 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 6dad8182b87..c0ef07a7670 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))) + 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 ca53b74c119..751379591ff 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))) + 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 57d91b52f49..dc845008ce0 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 1a9aec02955..cabe55cd95e 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))) + 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 2ec07692a4d..df54b60dc97 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))) + 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 f8a7995432b..515e816f473 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))) + 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_install.c b/extra/mysql_install.c index e2783f906b9..ab44e1a055b 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))) + if ((ho_error=handle_options(&argc, &argv, my_long_options, get_one_option, NULL))) exit(ho_error); return 0; 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 b4aeaf00671..212b313ade4 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))) + 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 c54f17a186e..8b72ab1d864 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 d3caa9e1d45..23ea34abc42 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 11ecc66fac3..01b21951972 100644 --- a/include/my_getopt.h +++ b/include/my_getopt.h @@ -50,11 +50,11 @@ struct my_option extern char *disabled_my_option; extern my_bool my_getopt_print_errors; +typedef my_bool (* hoGetOneOption) (int, const struct my_option *, char * ); +typedef void (* hoErrorReporter) (const char *format, va_list args ); + 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, hoGetOneOption, hoErrorReporter ); 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 daa9464eb4f..8603b436841 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))) + 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 b2e21afc743..59594ccc929 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))) + 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 8ea97c8e489..88e6c5c89d3 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))) + 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 838f90feae5..35182bc8abb 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)) + if (error=handle_options(&argc, &argv, my_long_options, get_one_option, NULL)) exit(error); if (count || dump) verbose=0; diff --git a/myisam/myisamchk.c b/myisam/myisamchk.c index 5377ecc18a5..e8e85345897 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))) + 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 872fcb49faf..51f8ad1bb11 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/mysys/my_getopt.c b/mysys/my_getopt.c index 694c4685667..7524bbf318d 100644 --- a/mysys/my_getopt.c +++ b/mysys/my_getopt.c @@ -56,6 +56,19 @@ char *disabled_my_option= (char*) "0"; my_bool my_getopt_print_errors= 1; +void report_option_error( hoErrorReporter reporter, const char *format, ... ) +{ + va_list args; + va_start( args, format ); + + + if (reporter != NULL) + reporter( format, args ); + else + vfprintf( stderr, format, args ); + + va_end( args ); +} /* function: handle_options @@ -68,10 +81,7 @@ my_bool my_getopt_print_errors= 1; */ 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, hoGetOneOption get_one_option, hoErrorReporter reporter ) { uint opt_found, argvpos= 0, length, i; my_bool end_of_options= 0, must_be_var, set_maximum_value, special_used, @@ -109,7 +119,7 @@ int handle_options(int *argc, char ***argv, if (!*++pos) { if (my_getopt_print_errors) - fprintf(stderr, "%s: Option '-O' requires an argument\n", + report_option_error(reporter, "%s: Option '-O' requires an argument\n", progname); return EXIT_ARGUMENT_REQUIRED; } @@ -126,7 +136,7 @@ int handle_options(int *argc, char ***argv, if (!*cur_arg) { if (my_getopt_print_errors) - fprintf(stderr, + report_option_error(reporter, "%s: Option '--set-variable' requires an argument\n", progname); return EXIT_ARGUMENT_REQUIRED; @@ -140,7 +150,7 @@ int handle_options(int *argc, char ***argv, if (!*++pos) { if (my_getopt_print_errors) - fprintf(stderr, + report_option_error( reporter, "%s: Option '--set-variable' requires an argument\n", progname); return EXIT_ARGUMENT_REQUIRED; @@ -201,7 +211,7 @@ int handle_options(int *argc, char ***argv, if (opt_found > 1) { if (my_getopt_print_errors) - fprintf(stderr, + report_option_error( reporter, "%s: ambiguous option '--%s-%s' (--%s-%s)\n", progname, special_opt_prefix[i], cur_arg, special_opt_prefix[i], prev_found); @@ -236,7 +246,7 @@ int handle_options(int *argc, char ***argv, if (must_be_var) { if (my_getopt_print_errors) - fprintf(stderr, + report_option_error( reporter, "%s: %s: unknown variable '%s'\n", progname, option_is_loose ? "WARNING" : "ERROR", cur_arg); if (!option_is_loose) @@ -245,7 +255,7 @@ int handle_options(int *argc, char ***argv, else { if (my_getopt_print_errors) - fprintf(stderr, + report_option_error( reporter, "%s: %s: unknown option '--%s'\n", progname, option_is_loose ? "WARNING" : "ERROR", cur_arg); if (!option_is_loose) @@ -263,14 +273,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", + report_option_error( reporter, "%s: variable prefix '%s' is not unique\n", progname, cur_arg); return EXIT_VAR_PREFIX_NOT_UNIQUE; } else { if (my_getopt_print_errors) - fprintf(stderr, "%s: ambiguous option '--%s' (%s, %s)\n", + report_option_error( reporter, "%s: ambiguous option '--%s' (%s, %s)\n", progname, cur_arg, prev_found, optp->name); return EXIT_AMBIGUOUS_OPTION; } @@ -278,7 +288,7 @@ int handle_options(int *argc, char ***argv, if (must_be_var && optp->var_type == GET_NO_ARG) { if (my_getopt_print_errors) - fprintf(stderr, "%s: option '%s' cannot take an argument\n", + report_option_error( reporter, "%s: option '%s' cannot take an argument\n", progname, optp->name); return EXIT_NO_ARGUMENT_ALLOWED; } @@ -287,7 +297,7 @@ int handle_options(int *argc, char ***argv, if (optend && optp->var_type != GET_BOOL) { if (my_getopt_print_errors) - fprintf(stderr, "%s: option '--%s' cannot take an argument\n", + report_option_error( reporter, "%s: option '--%s' cannot take an argument\n", progname, optp->name); return EXIT_NO_ARGUMENT_ALLOWED; } @@ -325,7 +335,7 @@ int handle_options(int *argc, char ***argv, if (!*++pos) { if (my_getopt_print_errors) - fprintf(stderr, "%s: option '--%s' requires an argument\n", + report_option_error( reporter, "%s: option '--%s' requires an argument\n", progname, optp->name); return EXIT_ARGUMENT_REQUIRED; } @@ -375,7 +385,7 @@ int handle_options(int *argc, char ***argv, if (!pos[1]) { if (my_getopt_print_errors) - fprintf(stderr, + report_option_error( reporter, "%s: option '-%c' requires an argument\n", progname, optp->id); return EXIT_ARGUMENT_REQUIRED; @@ -387,7 +397,7 @@ int handle_options(int *argc, char ***argv, } if ((error= setval(optp, argument, set_maximum_value))) { - fprintf(stderr, + report_option_error( reporter, "%s: Error while setting value '%s' to '%s'\n", progname, argument, optp->name); return error; @@ -399,7 +409,7 @@ int handle_options(int *argc, char ***argv, if (!opt_found) { if (my_getopt_print_errors) - fprintf(stderr, + report_option_error( reporter, "%s: unknown option '-%c'\n", progname, *optend); return EXIT_UNKNOWN_OPTION; } @@ -409,7 +419,7 @@ int handle_options(int *argc, char ***argv, } if ((error= setval(optp, argument, set_maximum_value))) { - fprintf(stderr, + report_option_error( reporter, "%s: Error while setting value '%s' to '%s'\n", progname, argument, optp->name); return error; diff --git a/sql/gen_lex_hash.cc b/sql/gen_lex_hash.cc index 1f604659272..72ab1184533 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))) + 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 e031656cc6e..3d76f9d5634 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -31,12 +31,51 @@ #include // For test_if_number #include +#ifdef __NT__ +#include "message.h" +#endif + MYSQL_LOG mysql_log,mysql_update_log,mysql_slow_log,mysql_bin_log; extern I_List binlog_do_db, binlog_ignore_db; 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 @@ -1677,41 +1716,42 @@ static bool test_if_number(register const char *str, } /* test_if_number */ -void sql_print_error(const char *format,...) +void print_buffer_to_log( my_bool timestamp, 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("sql_print_buffer_to_log"); + +#if !defined(__WIN__) && !defined(__NT__) 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); - start=&tm_tmp; - fprintf(stderr,"%02d%02d%02d %2d:%02d:%02d ", - start->tm_year % 100, - start->tm_mon+1, + + if (timestamp) + { + skr=time(NULL); + localtime_r(&skr, &tm_tmp); + start=&tm_tmp; + fprintf( stderr, "%02d%02d%02d %2d:%02d:%02d %s", + 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); - fflush(stderr); - va_end(args); + start->tm_sec, + buffer ); + } + else + fprintf( stderr, "%s", buffer ); + fputc('\n', stderr); + fflush(stderr); + +#if !defined(__WIN__) && !defined(__NT__) VOID(pthread_mutex_unlock(&LOCK_error_log)); +#endif + DBUG_VOID_RETURN; } @@ -1770,3 +1810,125 @@ bool flush_error_log() } return result; } + +/** + * prints a printf style message to the error log and, under NT, to the Windows event log. + * @param event_type type of even to log. + * @param timestamp true to add a timestamp to the entry, false otherwise. + * @param format The printf style format of the message + * @param ... values for the message + * @return void +*/ +void print_msg_to_log( long event_type, my_bool timestamp, const char *format, ... ) +{ + va_list args; + + DBUG_ENTER("startup_print_msg_to_logo"); + + va_start( args, format ); + vprint_msg_to_log( event_type, timestamp, format, args ); + va_end( args ); + + DBUG_VOID_RETURN; +} + +/** + * prints a printf style message to the error log and, under NT, to the Windows event log. + * @param event_type type of even to log. + * @param timestamp true to add a timestamp to the entry, false otherwise. + * @param format The printf style format of the message + * @param args va_list prepped arument list + * @return void +*/ +void vprint_msg_to_log(long event_type, my_bool timestamp, const char *format, va_list args) +{ + char buff[1024]; + + DBUG_ENTER("startup_vprint_msg_to_log"); + + my_vsnprintf( buff, sizeof(buff)-5, format, args ); + + print_buffer_to_log( timestamp, buff ); + +#ifndef DBUG_OFF + DBUG_PRINT("error",("%s",buff)); +#endif + +#ifdef __NT__ + HANDLE event; + LPSTR buffptr; + + strcat( buff, "\r\n\r\n" ); + buffptr = (LPSTR)&buff; + setupWindowsEventSource(); + if (event = RegisterEventSource(NULL,"MySQL")) + { + switch (event_type){ + case MY_ERROR_TYPE: + ReportEvent(event, (WORD)event_type, 0, MSG_DEFAULT, NULL, 1, 0, (LPCSTR*)&buffptr, NULL); + break; + case MY_WARNING_TYPE: + ReportEvent(event, (WORD)event_type, 0, MSG_DEFAULT, NULL, 1, 0, (LPCSTR*)&buffptr, NULL); + break; + case MY_INFORMATION_TYPE: + ReportEvent(event, (WORD)event_type, 0, MSG_DEFAULT, NULL, 1, 0, (LPCSTR*)&buffptr, NULL); + break; + } + DeregisterEventSource(event); + } +#endif + DBUG_VOID_RETURN; +} + +void sql_print_error( const char *format, ... ) +{ + DBUG_ENTER( "startup_sql_print_error" ); + + va_list args; + va_start( args, format ); + print_msg_to_log( MY_ERROR_TYPE, true, format, args ); + va_end( args ); + + DBUG_VOID_RETURN; +} + +void sql_print_warning( const char *format, ... ) +{ + DBUG_ENTER( "startup_sql_print_warning" ); + + va_list args; + va_start( args, format ); + print_msg_to_log( MY_WARNING_TYPE, true, format, args ); + va_end( args ); + + DBUG_VOID_RETURN; +} + +void sql_print_information( const char *format, ... ) +{ + DBUG_ENTER( "startup_sql_print_information" ); + + va_list args; + va_start( args, format ); + print_msg_to_log( MY_INFORMATION_TYPE, true, format, args ); + va_end( args ); + + DBUG_VOID_RETURN; +} + +/*void sql_init_fprintf(const char *format,...) +{ + va_list args; + char buff[255]; + buff[0]= 0; + va_start(args,format); + my_vsnprintf(buff,sizeof(buff)-1,format,args); +#ifdef __NT__ + sql_nt_print_error(MY_ERROR_TYPE,buff); +#else + sql_win_print_error(buff); +#endif + va_end(args); +} +*/ + diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 2e893ead407..1bc6544b72e 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -639,9 +639,27 @@ void key_unpack(String *to,TABLE *form,uint index); bool check_if_key_used(TABLE *table, uint idx, List &fields); void init_errmessage(void); +void vprint_msg_to_log( long errType, my_bool timestamp, const char *format, va_list args ); +void print_msg_to_log( long errType, my_bool timestamp, const char *format, ... ); void sql_perror(const char *message); -void sql_print_error(const char *format,...) - __attribute__ ((format (printf, 1, 2))); + /* __attribute__ ((format (printf, 1, 2))); +*/ + +#define MY_ERROR_TYPE 0x0001 +#define MY_WARNING_TYPE 0x0002 +#define MY_INFORMATION_TYPE 0x0004 + +/*void sql_init_perror(const char *message);*/ +/*void sql_fprintf(const char *format,...) + __attribute__ ((format (printf, 1, 2)));*/ + +/*#define sql_fprintf(format, args...) fprintf (stderr, format, ##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 3f7c187ccdd..9191759b2d2 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -5095,11 +5095,16 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), } /* Initiates DEBUG - but no debugging here ! */ +void option_error_reporter( const char *format, va_list args ) +{ + vprint_msg_to_log( MY_ERROR_TYPE, false, format, args ); +} + 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, option_error_reporter ))) exit(ho_error); #if defined(HAVE_BROKEN_REALPATH) diff --git a/tools/mysqlmanager.c b/tools/mysqlmanager.c index ade6da895c6..12b5519ae9c 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))) + if ((ho_error=handle_options(&argc, &argv, my_long_options, get_one_option, NULL))) exit(ho_error); return 0; From 4736e7d4bdcde029923518826db33da6a38a6c01 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 18 Aug 2004 22:31:01 +0200 Subject: [PATCH 02/54] BUG# 4466 - Nothing in .err when mysql service ends because of malformed my.ini options mysqld.cc: Changed option_error_reporter to match new function header that includes LOGLEVEL enum mysql_priv.h: Removed the MY_ERROR style bitmask. Changed function headers to use new LOGLEVEL enum log.cc: Changed print_buffer_to_log to print_buffer_to_file. Remove the timestamp bool and now all log entries written to stderr are timestamped. Removed some unused commented code. changed to use the new LOGLEVEL enum. my_getopt.c: Changed functions to use the new LOGLEVEL enum and changed the included error reporter to be default_reporter. This reporter is used in handle_options if a reporter is not given my_getopt.h: changed typedefs to use better naming convention. Moved error bitmask into the LOGLEVEL enum and included it here. include/my_getopt.h: changed typedefs to use better naming convention. Moved error bitmask into the LOGLEVEL enum and included it here. mysys/my_getopt.c: Changed functions to use the new LOGLEVEL enum and changed the included error reporter to be default_reporter. This reporter is used in handle_options if a reporter is not given sql/log.cc: Changed print_buffer_to_log to print_buffer_to_file. Remove the timestamp bool and now all log entries written to stderr are timestamped. Removed some unused commented code. changed to use the new LOGLEVEL enum. sql/mysql_priv.h: Removed the MY_ERROR style bitmask. Changed function headers to use new LOGLEVEL enum sql/mysqld.cc: Changed option_error_reporter to match new function header that includes LOGLEVEL enum --- include/my_getopt.h | 20 +++++- mysys/my_getopt.c | 56 +++++++---------- sql/log.cc | 148 +++++++++++++++++++++++--------------------- sql/mysql_priv.h | 16 +---- sql/mysqld.cc | 7 ++- 5 files changed, 127 insertions(+), 120 deletions(-) diff --git a/include/my_getopt.h b/include/my_getopt.h index 01b21951972..9e26b12cb9e 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 @@ -50,14 +53,25 @@ struct my_option extern char *disabled_my_option; extern my_bool my_getopt_print_errors; -typedef my_bool (* hoGetOneOption) (int, const struct my_option *, char * ); -typedef void (* hoErrorReporter) (const char *format, va_list args ); +enum LOGLEVEL { + ERROR_LEVEL, + WARNING_LEVEL, + INFORMATION_LEVEL +}; + +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, hoGetOneOption, hoErrorReporter ); + 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); 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/mysys/my_getopt.c b/mysys/my_getopt.c index 7524bbf318d..4bb9a79e299 100644 --- a/mysys/my_getopt.c +++ b/mysys/my_getopt.c @@ -56,17 +56,11 @@ char *disabled_my_option= (char*) "0"; my_bool my_getopt_print_errors= 1; -void report_option_error( hoErrorReporter reporter, const char *format, ... ) +void default_reporter( enum LOGLEVEL level, const char *format, ... ) { va_list args; va_start( args, format ); - - - if (reporter != NULL) - reporter( format, args ); - else - vfprintf( stderr, format, args ); - + vfprintf( stderr, format, args ); va_end( args ); } @@ -81,7 +75,8 @@ void report_option_error( hoErrorReporter reporter, const char *format, ... ) */ int handle_options(int *argc, char ***argv, - const struct my_option *longopts, hoGetOneOption get_one_option, hoErrorReporter 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, @@ -95,6 +90,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; @@ -119,8 +116,7 @@ int handle_options(int *argc, char ***argv, if (!*++pos) { if (my_getopt_print_errors) - report_option_error(reporter, "%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; @@ -136,9 +132,7 @@ int handle_options(int *argc, char ***argv, if (!*cur_arg) { if (my_getopt_print_errors) - report_option_error(reporter, - "%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; } } @@ -150,9 +144,7 @@ int handle_options(int *argc, char ***argv, if (!*++pos) { if (my_getopt_print_errors) - report_option_error( reporter, - "%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; @@ -211,7 +203,7 @@ int handle_options(int *argc, char ***argv, if (opt_found > 1) { if (my_getopt_print_errors) - report_option_error( reporter, + reporter( ERROR_LEVEL, "%s: ambiguous option '--%s-%s' (--%s-%s)\n", progname, special_opt_prefix[i], cur_arg, special_opt_prefix[i], prev_found); @@ -246,18 +238,16 @@ int handle_options(int *argc, char ***argv, if (must_be_var) { if (my_getopt_print_errors) - report_option_error( reporter, - "%s: %s: unknown variable '%s'\n", progname, - option_is_loose ? "WARNING" : "ERROR", 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) - report_option_error( reporter, - "%s: %s: unknown option '--%s'\n", progname, - option_is_loose ? "WARNING" : "ERROR", 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; } @@ -273,14 +263,14 @@ int handle_options(int *argc, char ***argv, if (must_be_var) { if (my_getopt_print_errors) - report_option_error( reporter, "%s: variable prefix '%s' is not unique\n", + 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) - report_option_error( reporter, "%s: ambiguous option '--%s' (%s, %s)\n", + reporter( ERROR_LEVEL, "%s: ambiguous option '--%s' (%s, %s)\n", progname, cur_arg, prev_found, optp->name); return EXIT_AMBIGUOUS_OPTION; } @@ -288,7 +278,7 @@ int handle_options(int *argc, char ***argv, if (must_be_var && optp->var_type == GET_NO_ARG) { if (my_getopt_print_errors) - report_option_error( reporter, "%s: option '%s' cannot take an argument\n", + reporter( ERROR_LEVEL, "%s: option '%s' cannot take an argument\n", progname, optp->name); return EXIT_NO_ARGUMENT_ALLOWED; } @@ -297,7 +287,7 @@ int handle_options(int *argc, char ***argv, if (optend && optp->var_type != GET_BOOL) { if (my_getopt_print_errors) - report_option_error( reporter, "%s: option '--%s' cannot take an argument\n", + reporter( ERROR_LEVEL, "%s: option '--%s' cannot take an argument\n", progname, optp->name); return EXIT_NO_ARGUMENT_ALLOWED; } @@ -335,7 +325,7 @@ int handle_options(int *argc, char ***argv, if (!*++pos) { if (my_getopt_print_errors) - report_option_error( reporter, "%s: option '--%s' requires an argument\n", + reporter( ERROR_LEVEL, "%s: option '--%s' requires an argument\n", progname, optp->name); return EXIT_ARGUMENT_REQUIRED; } @@ -385,7 +375,7 @@ int handle_options(int *argc, char ***argv, if (!pos[1]) { if (my_getopt_print_errors) - report_option_error( reporter, + reporter( ERROR_LEVEL, "%s: option '-%c' requires an argument\n", progname, optp->id); return EXIT_ARGUMENT_REQUIRED; @@ -397,7 +387,7 @@ int handle_options(int *argc, char ***argv, } if ((error= setval(optp, argument, set_maximum_value))) { - report_option_error( reporter, + reporter( ERROR_LEVEL, "%s: Error while setting value '%s' to '%s'\n", progname, argument, optp->name); return error; @@ -409,7 +399,7 @@ int handle_options(int *argc, char ***argv, if (!opt_found) { if (my_getopt_print_errors) - report_option_error( reporter, + reporter( ERROR_LEVEL, "%s: unknown option '-%c'\n", progname, *optend); return EXIT_UNKNOWN_OPTION; } @@ -419,7 +409,7 @@ int handle_options(int *argc, char ***argv, } if ((error= setval(optp, argument, set_maximum_value))) { - report_option_error( reporter, + reporter( ERROR_LEVEL, "%s: Error while setting value '%s' to '%s'\n", progname, argument, optp->name); return error; diff --git a/sql/log.cc b/sql/log.cc index 3d76f9d5634..a487de250db 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -1716,41 +1716,32 @@ static bool test_if_number(register const char *str, } /* test_if_number */ -void print_buffer_to_log( my_bool timestamp, 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("sql_print_buffer_to_log"); + DBUG_ENTER("startup_print_buffer_to_log"); -#if !defined(__WIN__) && !defined(__NT__) VOID(pthread_mutex_lock(&LOCK_error_log)); -#endif - if (timestamp) - { - skr=time(NULL); - localtime_r(&skr, &tm_tmp); - start=&tm_tmp; - fprintf( stderr, "%02d%02d%02d %2d:%02d:%02d %s", + skr=time(NULL); + localtime_r(&skr, &tm_tmp); + start=&tm_tmp; + 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 ); - } - else - fprintf( stderr, "%s", buffer ); - fputc('\n', stderr); fflush(stderr); -#if !defined(__WIN__) && !defined(__NT__) VOID(pthread_mutex_unlock(&LOCK_error_log)); -#endif DBUG_VOID_RETURN; } @@ -1819,28 +1810,82 @@ bool flush_error_log() * @param ... values for the message * @return void */ -void print_msg_to_log( long event_type, my_bool timestamp, const char *format, ... ) +void print_msg_to_log( LOGLEVEL level, const char *format, ... ) { va_list args; - DBUG_ENTER("startup_print_msg_to_logo"); + DBUG_ENTER("startup_print_msg_to_log"); va_start( args, format ); - vprint_msg_to_log( event_type, timestamp, format, args ); + vprint_msg_to_log( level, format, args ); va_end( args ); DBUG_VOID_RETURN; } -/** - * prints a printf style message to the error log and, under NT, to the Windows event log. - * @param event_type type of even to log. - * @param timestamp true to add a timestamp to the entry, false otherwise. - * @param format The printf style format of the message - * @param args va_list prepped arument list - * @return void + +#ifdef __NT__ +void print_buffer_to_nt_eventlog( enum LOGLEVEL level, char *buff, int buffLen ) +{ + HANDLE event; + char *buffptr; + LPCSTR *buffmsgptr; + + 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(long event_type, my_bool timestamp, const char *format, va_list args) +void vprint_msg_to_log(enum LOGLEVEL level, const char *format, va_list args) { char buff[1024]; @@ -1848,45 +1893,27 @@ void vprint_msg_to_log(long event_type, my_bool timestamp, const char *format, v my_vsnprintf( buff, sizeof(buff)-5, format, args ); - print_buffer_to_log( timestamp, buff ); + print_buffer_to_file( level, buff ); #ifndef DBUG_OFF DBUG_PRINT("error",("%s",buff)); #endif #ifdef __NT__ - HANDLE event; - LPSTR buffptr; - - strcat( buff, "\r\n\r\n" ); - buffptr = (LPSTR)&buff; - setupWindowsEventSource(); - if (event = RegisterEventSource(NULL,"MySQL")) - { - switch (event_type){ - case MY_ERROR_TYPE: - ReportEvent(event, (WORD)event_type, 0, MSG_DEFAULT, NULL, 1, 0, (LPCSTR*)&buffptr, NULL); - break; - case MY_WARNING_TYPE: - ReportEvent(event, (WORD)event_type, 0, MSG_DEFAULT, NULL, 1, 0, (LPCSTR*)&buffptr, NULL); - break; - case MY_INFORMATION_TYPE: - ReportEvent(event, (WORD)event_type, 0, MSG_DEFAULT, NULL, 1, 0, (LPCSTR*)&buffptr, NULL); - break; - } - DeregisterEventSource(event); - } + print_buffer_to_nt_eventlog( level, buff, sizeof(buff) ); #endif + DBUG_VOID_RETURN; } + void sql_print_error( const char *format, ... ) { DBUG_ENTER( "startup_sql_print_error" ); va_list args; va_start( args, format ); - print_msg_to_log( MY_ERROR_TYPE, true, format, args ); + print_msg_to_log( ERROR_LEVEL, format, args ); va_end( args ); DBUG_VOID_RETURN; @@ -1898,7 +1925,7 @@ void sql_print_warning( const char *format, ... ) va_list args; va_start( args, format ); - print_msg_to_log( MY_WARNING_TYPE, true, format, args ); + print_msg_to_log( WARNING_LEVEL, format, args ); va_end( args ); DBUG_VOID_RETURN; @@ -1910,25 +1937,8 @@ void sql_print_information( const char *format, ... ) va_list args; va_start( args, format ); - print_msg_to_log( MY_INFORMATION_TYPE, true, format, args ); + print_msg_to_log( INFORMATION_LEVEL, format, args ); va_end( args ); DBUG_VOID_RETURN; } - -/*void sql_init_fprintf(const char *format,...) -{ - va_list args; - char buff[255]; - buff[0]= 0; - va_start(args,format); - my_vsnprintf(buff,sizeof(buff)-1,format,args); -#ifdef __NT__ - sql_nt_print_error(MY_ERROR_TYPE,buff); -#else - sql_win_print_error(buff); -#endif - va_end(args); -} -*/ - diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 1bc6544b72e..ed8b4bd2457 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -24,6 +24,7 @@ #include #include /* Needed by field.h */ #include +#include #ifdef __EMX__ #undef write /* remove pthread.h macro definition for EMX */ @@ -639,21 +640,10 @@ void key_unpack(String *to,TABLE *form,uint index); bool check_if_key_used(TABLE *table, uint idx, List &fields); void init_errmessage(void); -void vprint_msg_to_log( long errType, my_bool timestamp, const char *format, va_list args ); -void print_msg_to_log( long errType, my_bool timestamp, const char *format, ... ); +void vprint_msg_to_log( enum LOGLEVEL level, const char *format, va_list args ); +void print_msg_to_log( enum LOGLEVEL level, const char *format, ... ); void sql_perror(const char *message); - /* __attribute__ ((format (printf, 1, 2))); -*/ -#define MY_ERROR_TYPE 0x0001 -#define MY_WARNING_TYPE 0x0002 -#define MY_INFORMATION_TYPE 0x0004 - -/*void sql_init_perror(const char *message);*/ -/*void sql_fprintf(const char *format,...) - __attribute__ ((format (printf, 1, 2)));*/ - -/*#define sql_fprintf(format, args...) fprintf (stderr, format, ##args) */ void sql_print_error( const char *format, ... ); void sql_print_warning( const char *format, ...); void sql_print_information( const char *format, ...); diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 9191759b2d2..d70f61c5c22 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -5095,9 +5095,12 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), } /* Initiates DEBUG - but no debugging here ! */ -void option_error_reporter( const char *format, va_list args ) +void option_error_reporter( enum LOGLEVEL level, const char *format, ... ) { - vprint_msg_to_log( MY_ERROR_TYPE, false, format, args ); + 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) From 87bce8540c7c38cb88ce8743b8efcb0a51f53bfe Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 19 Aug 2004 17:56:32 +0200 Subject: [PATCH 03/54] Bug #4466 Nothing in .err when mysql service ends because of malformed my.ini options mysqld.cc: Changed LOGLEVEL enum to loglevel mysql_priv.h, log.cc: Changed LOGLEVEL to loglevel. Removed startup_ from some of the DBUG_ENTER macros. Removed the print_msg_to_log function as it was unused. my_getopt.c, my_getopt.h: Renamed LOGLEVEL to loglevel to match coding standards include/my_getopt.h: Renamed LOGLEVEL to loglevel to match coding standards mysys/my_getopt.c: Renamed LOGLEVEL to loglevel to match coding standards sql/log.cc: Changed LOGLEVEL to loglevel. Removed startup_ from some of the DBUG_ENTER macros. Removed the print_msg_to_log function as it was unused. sql/mysql_priv.h: Changed LOGLEVEL to loglevel. Removed startup_ from some of the DBUG_ENTER macros. Removed the print_msg_to_log function as it was unused. sql/mysqld.cc: Changed LOGLEVEL enum to loglevel --- include/my_getopt.h | 4 ++-- mysys/my_getopt.c | 2 +- sql/log.cc | 45 +++++++++++++-------------------------------- sql/mysql_priv.h | 3 +-- sql/mysqld.cc | 2 +- 5 files changed, 18 insertions(+), 38 deletions(-) diff --git a/include/my_getopt.h b/include/my_getopt.h index 9e26b12cb9e..f3db2a70a92 100644 --- a/include/my_getopt.h +++ b/include/my_getopt.h @@ -53,14 +53,14 @@ struct my_option extern char *disabled_my_option; extern my_bool my_getopt_print_errors; -enum LOGLEVEL { +enum loglevel { ERROR_LEVEL, WARNING_LEVEL, INFORMATION_LEVEL }; typedef my_bool (* my_get_one_option) (int, const struct my_option *, char * ); -typedef void (* my_error_reporter) (enum LOGLEVEL level, const char *format, ... ); +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_get_one_option, diff --git a/mysys/my_getopt.c b/mysys/my_getopt.c index 4bb9a79e299..91671fcff5b 100644 --- a/mysys/my_getopt.c +++ b/mysys/my_getopt.c @@ -56,7 +56,7 @@ 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 ); diff --git a/sql/log.cc b/sql/log.cc index a487de250db..9743fdf8a37 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -1716,13 +1716,13 @@ 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("startup_print_buffer_to_log"); + DBUG_ENTER("print_buffer_to_log"); VOID(pthread_mutex_lock(&LOCK_error_log)); @@ -1802,35 +1802,16 @@ bool flush_error_log() return result; } -/** - * prints a printf style message to the error log and, under NT, to the Windows event log. - * @param event_type type of even to log. - * @param timestamp true to add a timestamp to the entry, false otherwise. - * @param format The printf style format of the message - * @param ... values for the message - * @return void -*/ -void print_msg_to_log( LOGLEVEL level, const char *format, ... ) -{ - va_list args; - - DBUG_ENTER("startup_print_msg_to_log"); - - va_start( args, format ); - vprint_msg_to_log( level, format, args ); - va_end( args ); - - DBUG_VOID_RETURN; -} - #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, int buffLen ) { HANDLE event; char *buffptr; LPCSTR *buffmsgptr; + DBUG_ENTER( "print_buffer_to_nt_eventlog" ); + buffptr = buff; if (strlen(buff) > (uint)(buffLen-4)) { @@ -1885,11 +1866,11 @@ void print_buffer_to_nt_eventlog( enum LOGLEVEL level, char *buff, int buffLen ) RETURN VALUES void */ -void vprint_msg_to_log(enum LOGLEVEL level, const char *format, va_list args) +void vprint_msg_to_log(enum loglevel level, const char *format, va_list args) { char buff[1024]; - DBUG_ENTER("startup_vprint_msg_to_log"); + DBUG_ENTER("vprint_msg_to_log"); my_vsnprintf( buff, sizeof(buff)-5, format, args ); @@ -1909,11 +1890,11 @@ void vprint_msg_to_log(enum LOGLEVEL level, const char *format, va_list args) void sql_print_error( const char *format, ... ) { - DBUG_ENTER( "startup_sql_print_error" ); + DBUG_ENTER( "sql_print_error" ); va_list args; va_start( args, format ); - print_msg_to_log( ERROR_LEVEL, format, args ); + vprint_msg_to_log( ERROR_LEVEL, format, args ); va_end( args ); DBUG_VOID_RETURN; @@ -1921,11 +1902,11 @@ void sql_print_error( const char *format, ... ) void sql_print_warning( const char *format, ... ) { - DBUG_ENTER( "startup_sql_print_warning" ); + DBUG_ENTER( "sql_print_warning" ); va_list args; va_start( args, format ); - print_msg_to_log( WARNING_LEVEL, format, args ); + vprint_msg_to_log( WARNING_LEVEL, format, args ); va_end( args ); DBUG_VOID_RETURN; @@ -1933,11 +1914,11 @@ void sql_print_warning( const char *format, ... ) void sql_print_information( const char *format, ... ) { - DBUG_ENTER( "startup_sql_print_information" ); + DBUG_ENTER( "sql_print_information" ); va_list args; va_start( args, format ); - print_msg_to_log( INFORMATION_LEVEL, format, args ); + 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 ed8b4bd2457..e86604df659 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -640,10 +640,9 @@ void key_unpack(String *to,TABLE *form,uint index); bool check_if_key_used(TABLE *table, uint idx, List &fields); void init_errmessage(void); -void vprint_msg_to_log( enum LOGLEVEL level, const char *format, va_list args ); -void print_msg_to_log( enum LOGLEVEL level, const char *format, ... ); void sql_perror(const char *message); +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, ...); diff --git a/sql/mysqld.cc b/sql/mysqld.cc index d70f61c5c22..a27298c254c 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -5095,7 +5095,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), } /* 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 ); From f2ef3d162eaf16bac68b7bc602be83cc7acf4f74 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 19 Aug 2004 20:26:00 +0200 Subject: [PATCH 04/54] Bug #4466 Nothing in .err when mysql service ends because of malformed my.ini options my_getopt.c: Moved the inclusion of my_getopt.h down below the inclusion of my_sys.h so that enum loglevel definition would be available my_sys.h, my_getopt.h: moved definition of enum loglevel from my_getopt.h to my_sys.h include/my_getopt.h: moved definition of enum loglevel from my_getopt.h to my_sys.h include/my_sys.h: moved definition of enum loglevel from my_getopt.h to my_sys.h mysys/my_getopt.c: Moved the inclusion of my_getopt.h down below the inclusion of my_sys.h so that enum loglevel definition would be available --- include/my_getopt.h | 6 ------ include/my_sys.h | 6 ++++++ mysys/my_getopt.c | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/include/my_getopt.h b/include/my_getopt.h index f3db2a70a92..f5b847f7dda 100644 --- a/include/my_getopt.h +++ b/include/my_getopt.h @@ -53,12 +53,6 @@ struct my_option extern char *disabled_my_option; extern my_bool my_getopt_print_errors; -enum loglevel { - ERROR_LEVEL, - WARNING_LEVEL, - INFORMATION_LEVEL -}; - typedef my_bool (* my_get_one_option) (int, const struct my_option *, char * ); typedef void (* my_error_reporter) (enum loglevel level, const char *format, ... ); diff --git a/include/my_sys.h b/include/my_sys.h index 4934df3c4e5..9e43889d0e0 100644 --- a/include/my_sys.h +++ b/include/my_sys.h @@ -261,6 +261,12 @@ typedef struct st_typelib { /* Different types saved here */ const char **type_names; } TYPELIB; +enum loglevel { + ERROR_LEVEL, + WARNING_LEVEL, + INFORMATION_LEVEL +}; + enum cache_type { READ_CACHE,WRITE_CACHE, diff --git a/mysys/my_getopt.c b/mysys/my_getopt.c index 91671fcff5b..c471a30eb35 100644 --- a/mysys/my_getopt.c +++ b/mysys/my_getopt.c @@ -17,10 +17,10 @@ #include #include #include -#include #include #include #include +#include static int findopt(char *optpat, uint length, const struct my_option **opt_res, From 47d87c639c9b8150bda20da8e22992121285fe1c Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 24 Aug 2004 19:05:42 +0200 Subject: [PATCH 05/54] All 'Makefile's must use '$(AR)' (not just 'ar') because the variable may contain options. libmysqld/Makefile.am: Always use 'make' variable '$(AR)' so that options (AIX 64 bit!) are included. BitKeeper/etc/logging_ok: Logging to logging@openlogging.org accepted --- BitKeeper/etc/logging_ok | 1 + libmysqld/Makefile.am | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/BitKeeper/etc/logging_ok b/BitKeeper/etc/logging_ok index d16de3077f3..441e8a1f1c1 100644 --- a/BitKeeper/etc/logging_ok +++ b/BitKeeper/etc/logging_ok @@ -57,6 +57,7 @@ jcole@main.burghcom.com jcole@mugatu.spaceapes.com jcole@sarvik.tfr.cafe.ee jcole@tetra.spaceapes.com +joerg@mysql.com jorge@linux.jorge.mysql.com kaj@work.mysql.com konstantin@mysql.com diff --git a/libmysqld/Makefile.am b/libmysqld/Makefile.am index 54c7ada4a85..ef0f61b4234 100644 --- a/libmysqld/Makefile.am +++ b/libmysqld/Makefile.am @@ -89,9 +89,9 @@ libmysqld.a: libmysqld_int.a $(INC_LIB) cd tmp ; \ for file in *.a ; do \ bfile=`basename $$file .a` ; \ - ar x $$file; \ + $(AR) x $$file; \ for obj in *.o ; do mv $$obj $${bfile}_$$obj ; done ; \ - ar q ../libmysqld_int2.a *.o ; \ + $(AR) q ../libmysqld_int2.a *.o ; \ rm -f *.o ; \ done ; \ cd .. ; \ From 73fe243d43067860295148ed6eac1f742d16de26 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 24 Aug 2004 20:17:23 +0300 Subject: [PATCH 06/54] buf0rea.c: Fix bug: if there was little file I/O in InnoDB, but the insert buffer was used, it could happen that 'Pending normal aio reads' was bigger than 0, but the I/O handler thread did not get waken up in 600 seconds. This resulted in a hang, and crashing of InnoDB. innobase/buf/buf0rea.c: Fix bug: if there was little file I/O in InnoDB, but the insert buffer was used, it could happen that 'Pending normal aio reads' was bigger than 0, but the I/O handler thread did not get waken up in 600 seconds. This resulted in a hang, and crashing of InnoDB. --- innobase/buf/buf0rea.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/innobase/buf/buf0rea.c b/innobase/buf/buf0rea.c index 83397c9c7fa..a808c282934 100644 --- a/innobase/buf/buf0rea.c +++ b/innobase/buf/buf0rea.c @@ -546,6 +546,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(); From 335a791aba38d53f61f2f0ee1d98cc5a992dd70a Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 25 Aug 2004 02:04:45 -0300 Subject: [PATCH 07/54] Adding binary version information for debug/release version of libmysqld.dll This was a customer request for to get the XP Logo Certification. Note for LenZ: Adding to the project libmysqld.dsp the file libmysqld.rc at compilation time will be created the libmysqld.res and this linked. For every release edit the libmysqld.rc version number. --- libmysqld/libmysqld.rc | 125 +++++++++++++++++++++++++++++++++++++++++ libmysqld/resource.h | 15 +++++ 2 files changed, 140 insertions(+) create mode 100755 libmysqld/libmysqld.rc create mode 100755 libmysqld/resource.h diff --git a/libmysqld/libmysqld.rc b/libmysqld/libmysqld.rc new file mode 100755 index 00000000000..5b6142faddf --- /dev/null +++ b/libmysqld/libmysqld.rc @@ -0,0 +1,125 @@ +//Microsoft Developer Studio generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include "afxres.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (U.S.) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +#ifdef _WIN32 +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US +#pragma code_page(1252) +#endif //_WIN32 + + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE DISCARDABLE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE DISCARDABLE +BEGIN + "#include ""afxres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE DISCARDABLE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + + +#ifndef _MAC +///////////////////////////////////////////////////////////////////////////// +// +// Version +// + +VS_VERSION_INFO VERSIONINFO + FILEVERSION 4,0,20,0 + PRODUCTVERSION 4,0,20,0 + FILEFLAGSMASK 0x3fL +#ifdef _DEBUG + FILEFLAGS 0x9L +#else + FILEFLAGS 0x8L +#endif + FILEOS 0x40004L + FILETYPE 0x2L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN +#ifdef _DEBUG + VALUE "Comments", "Embedded Server\0" + VALUE "CompanyName", "MySQL AB\0" + VALUE "FileDescription", "Embedded Server\0" + VALUE "FileVersion", "4.0.20\0" + VALUE "InternalName", "Embedded Server\0" + VALUE "LegalCopyright", "Copyright © 2004\0" + VALUE "LegalTrademarks", "MySQL and MySQL AB\0" + VALUE "OriginalFilename", "libmysqld.dll debug\0" + VALUE "PrivateBuild", "libmysqld.dll debug \0" + VALUE "ProductName", "libmysqld.dll debug\0" + VALUE "ProductVersion", "4.0.20\0" + VALUE "SpecialBuild", "\0" +#else + VALUE "Comments", "Embedded Server\0" + VALUE "CompanyName", "MySQL AB\0" + VALUE "FileDescription", "Embedded Server\0" + VALUE "FileVersion", "4.0.20\0" + VALUE "InternalName", "Embedded Server\0" + VALUE "LegalCopyright", "Copyright © 2004\0" + VALUE "LegalTrademarks", "MySQL and MySQL AB\0" + VALUE "OriginalFilename", "libmysqld.dll release\0" + VALUE "PrivateBuild", "libmysqld.dll release \0" + VALUE "ProductName", "libmysqld.dll release\0" + VALUE "ProductVersion", "4.0.20\0" + VALUE "SpecialBuild", "\0" +#endif + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END +END + +#endif // !_MAC + +#endif // English (U.S.) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/libmysqld/resource.h b/libmysqld/resource.h new file mode 100755 index 00000000000..f770fe490a6 --- /dev/null +++ b/libmysqld/resource.h @@ -0,0 +1,15 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Developer Studio generated include file. +// Used by libmysqld.rc +// + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 101 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1000 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif From ca59bf47466bb50148315bb82af23db11aaab003 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 25 Aug 2004 15:12:31 +0200 Subject: [PATCH 08/54] Bug #4792 lower_case_table_names does not resolve db.tbl.column in SELECT list sql_base.cc: Added code to lowercase database name in insert_fields when lower_case_table_names=1. This fixes bug# 4792 sql/sql_base.cc: Added code to lowercase database name in insert_fields when lower_case_table_names=1. This fixes bug# 4792 --- sql/sql_base.cc | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 7b1b3cc1b7a..26ce394ec37 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -2062,9 +2062,20 @@ bool insert_fields(THD *thd,TABLE_LIST *tables, const char *db_name, const char *table_name, List_iterator *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) { From 7dfdfa9fa397927963b4754d86fcf77ae3f036c5 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 25 Aug 2004 17:20:12 +0400 Subject: [PATCH 09/54] Cleanup. --- libmysql/libmysql.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c index cea8ce3a499..2ddbaa0b693 100644 --- a/libmysql/libmysql.c +++ b/libmysql/libmysql.c @@ -3393,7 +3393,7 @@ static void fetch_long_with_conversion(MYSQL_BIND *param, MYSQL_FIELD *field, longlong value) { char *buffer= (char *)param->buffer; - uint field_is_unsigned= (field->flags & UNSIGNED_FLAG); + uint field_is_unsigned= field->flags & UNSIGNED_FLAG; switch (param->buffer_type) { case MYSQL_TYPE_NULL: /* do nothing */ @@ -3590,14 +3590,14 @@ static void fetch_result_with_conversion(MYSQL_BIND *param, MYSQL_FIELD *field, { ulong length; enum enum_field_types field_type= field->type; + uint field_is_unsigned= field->flags & UNSIGNED_FLAG; switch (field_type) { case MYSQL_TYPE_TINY: { char value= (char) **row; - uint field_is_unsigned= (field->flags & UNSIGNED_FLAG); - longlong data= (field_is_unsigned) ? (longlong) (unsigned char) value: - (longlong) value; + longlong data= field_is_unsigned ? (longlong) (unsigned char) value : + (longlong) value; fetch_long_with_conversion(param, field, data); length= 1; break; @@ -3606,9 +3606,8 @@ static void fetch_result_with_conversion(MYSQL_BIND *param, MYSQL_FIELD *field, case MYSQL_TYPE_YEAR: { short value= sint2korr(*row); - uint field_is_unsigned= (field->flags & UNSIGNED_FLAG); - longlong data= ((field_is_unsigned) ? (longlong) (unsigned short) value: - (longlong) value); + longlong data= field_is_unsigned ? (longlong) (unsigned short) value : + (longlong) value; fetch_long_with_conversion(param, field, data); length= 2; break; @@ -3616,9 +3615,8 @@ static void fetch_result_with_conversion(MYSQL_BIND *param, MYSQL_FIELD *field, case MYSQL_TYPE_LONG: { long value= sint4korr(*row); - uint field_is_unsigned= (field->flags & UNSIGNED_FLAG); - longlong data= ((field_is_unsigned) ? (longlong) (unsigned long) value: - (longlong) value); + longlong data= field_is_unsigned ? (longlong) (unsigned long) value : + (longlong) value; fetch_long_with_conversion(param, field, data); length= 4; break; From 3b55c6f394280835b193f2cb272faabeccbb06dd Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 25 Aug 2004 17:25:38 +0200 Subject: [PATCH 10/54] Test case for Bug #4792 lower_case_table_names does not resolve db.tbl.column in SELECT list lowercase_table.result: New results for modified lowercase_table test lowercase_table.test: Added test case for all uppercase database when running under lower_case_table_names. This really only failed under Windows. Bug# 4792 mysql-test/t/lowercase_table.test: Added test case for all uppercase database when running under lower_case_table_names. This really only failed under Windows. Bug# 4792 mysql-test/r/lowercase_table.result: New results for modified lowercase_table test --- mysql-test/r/lowercase_table.result | 9 +++++++++ mysql-test/t/lowercase_table.test | 11 +++++++++++ 2 files changed, 20 insertions(+) diff --git a/mysql-test/r/lowercase_table.result b/mysql-test/r/lowercase_table.result index 16bc92cb711..5acab254511 100644 --- a/mysql-test/r/lowercase_table.result +++ b/mysql-test/r/lowercase_table.result @@ -39,3 +39,12 @@ 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 table t1 (a int); +select FOO.t1.* from FOO.t1; +a +alter table t1 rename to T1; +select FOO.t1.* from FOO.t1; +a +drop database FOO; diff --git a/mysql-test/t/lowercase_table.test b/mysql-test/t/lowercase_table.test index 5bc19f26c0e..d52c60baea7 100644 --- a/mysql-test/t/lowercase_table.test +++ b/mysql-test/t/lowercase_table.test @@ -30,3 +30,14 @@ select count(T1.a) from t1; --error 1109 select count(bags.a) from t1 as Bags; drop table t1; + +# +# Test all caps database name +# +create database foo; +use foo; +create table t1 (a int); +select FOO.t1.* from FOO.t1; +alter table t1 rename to T1; +select FOO.t1.* from FOO.t1; +drop database FOO; From 3818b0d3b3b77d118ce569ecac5f57ca92599d79 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 25 Aug 2004 12:52:19 -0500 Subject: [PATCH 11/54] mysql.h: Fix a misleading plural that should be singular. Fix other typos while I'm at it. include/mysql.h: Fix a misleading plural that should be singular. Fix other typos while I'm at it. --- include/mysql.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/mysql.h b/include/mysql.h index e2ed3ab59af..cf5af6ce189 100644 --- a/include/mysql.h +++ b/include/mysql.h @@ -99,7 +99,7 @@ typedef struct st_mysql_field { unsigned int flags; /* Div flags */ unsigned int decimals; /* Number of decimals in field */ unsigned int charsetnr; /* Character set */ - enum enum_field_types type; /* Type of field. Se mysql_com.h for types */ + enum enum_field_types type; /* Type of field. See mysql_com.h for types */ } MYSQL_FIELD; typedef char **MYSQL_ROW; /* return data as array of strings */ @@ -175,7 +175,7 @@ struct st_mysql_options { */ my_bool rpl_parse; /* - If set, never read from a master,only from slave, when doing + If set, never read from a master, only from slave, when doing a read that is replication-aware */ my_bool no_master_reads; @@ -538,7 +538,7 @@ enum enum_mysql_stmt_state typedef struct st_mysql_bind { unsigned long *length; /* output length pointer */ - my_bool *is_null; /* Pointer to null indicators */ + my_bool *is_null; /* Pointer to null indicator */ void *buffer; /* buffer to get/put data */ enum enum_field_types buffer_type; /* buffer type */ unsigned long buffer_length; /* buffer length, must be set for str/binary */ @@ -581,7 +581,7 @@ typedef struct st_mysql_stmt unsigned char **row); unsigned long stmt_id; /* Id for prepared statement */ unsigned int last_errno; /* error code */ - unsigned int param_count; /* inpute parameters count */ + unsigned int param_count; /* input parameter count */ unsigned int field_count; /* number of columns in result set */ enum enum_mysql_stmt_state state; /* statement state */ char last_error[MYSQL_ERRMSG_SIZE]; /* error message */ From 8ed5952a86b75f3c68faf3c039a59fbde51209f8 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 26 Aug 2004 00:37:25 +0300 Subject: [PATCH 12/54] Remove default argument to mysql_truncate() Update to new valgrind mysql-test/mysql-test-run.sh: Update for new valgrind sql/mysql_priv.h: Remove default argument to mysql_truncate() sql/sql_parse.cc: Remove default argument to mysql_truncate() --- mysql-test/mysql-test-run.sh | 2 +- sql/mysql_priv.h | 2 +- sql/sql_parse.cc | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/mysql-test/mysql-test-run.sh b/mysql-test/mysql-test-run.sh index 449b7015188..fedb2ea89b4 100644 --- a/mysql-test/mysql-test-run.sh +++ b/mysql-test/mysql-test-run.sh @@ -352,7 +352,7 @@ while test $# -gt 0; do $ECHO "You need to have the 'valgrind' program in your PATH to run mysql-test-run with option --valgrind. Valgrind's home page is http://developer.kde.org/~sewardj ." exit 1 fi - VALGRIND="$VALGRIND --alignment=8 --leak-check=yes --num-callers=16" + VALGRIND="$VALGRIND --tool=memcheck --alignment=8 --leak-check=yes --num-callers=16" EXTRA_MASTER_MYSQLD_OPT="$EXTRA_MASTER_MYSQLD_OPT --skip-safemalloc --skip-bdb" EXTRA_SLAVE_MYSQLD_OPT="$EXTRA_SLAVE_MYSQLD_OPT --skip-safemalloc --skip-bdb" SLEEP_TIME_AFTER_RESTART=10 diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 2e893ead407..3fba75d7140 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -477,7 +477,7 @@ int mysql_insert(THD *thd,TABLE_LIST *table,List &fields, void kill_delayed_threads(void); int mysql_delete(THD *thd, TABLE_LIST *table, COND *conds, ORDER *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); diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 1f0af05a460..7b0924ff108 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -2046,7 +2046,7 @@ mysql_execute_command(void) send_error(&thd->net,ER_LOCK_OR_ACTIVE_TRANSACTION,NullS); goto error; } - res=mysql_truncate(thd,tables); + res=mysql_truncate(thd, tables, 0); break; case SQLCOM_DELETE: { From b6425bc22c73e1869e3e7b71fb1bf2d90a229927 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 26 Aug 2004 12:02:11 +0500 Subject: [PATCH 13/54] ctype-latin1.c: Revert this change, it was done in a mistake. strings/ctype-latin1.c: Revert this change, it was done in a mistake. --- strings/ctype-latin1.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/strings/ctype-latin1.c b/strings/ctype-latin1.c index 614717998fb..aea517811ab 100644 --- a/strings/ctype-latin1.c +++ b/strings/ctype-latin1.c @@ -701,7 +701,7 @@ CHARSET_INFO my_charset_latin1_german2_ci= ctype_latin1, to_lower_latin1, to_upper_latin1, - NULL, + sort_order_latin1_de, NULL, /* contractions */ NULL, /* sort_order_big*/ cs_to_uni, /* tab_to_uni */ From c1825f208cafe972f69517c2b164de5ccfb2ab92 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 26 Aug 2004 12:10:32 +0200 Subject: [PATCH 14/54] Fix ndb home path --- ndb/src/common/mgmcommon/NdbConfig.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ndb/src/common/mgmcommon/NdbConfig.c b/ndb/src/common/mgmcommon/NdbConfig.c index 26eb6b5af34..6b609b22fa4 100644 --- a/ndb/src/common/mgmcommon/NdbConfig.c +++ b/ndb/src/common/mgmcommon/NdbConfig.c @@ -32,7 +32,7 @@ NdbConfig_AllocHomePath(int _len) len+= path_len; buf= malloc(len); if (path_len > 0) - snprintf(buf, len, "%s%c", path, DIR_SEPARATOR); + snprintf(buf, len, "%s%s", path, DIR_SEPARATOR); else buf[0]= 0; From 0830992f2d2dc469f02296e338974e324929c4ba Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 26 Aug 2004 12:25:14 +0200 Subject: [PATCH 15/54] - Updated RPM spec file: MySQL-Max now requires MySQL-server instead of MySQL (BUG#3860) --- support-files/mysql.spec.sh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/support-files/mysql.spec.sh b/support-files/mysql.spec.sh index b6243cbd4ad..eb5b469c8da 100644 --- a/support-files/mysql.spec.sh +++ b/support-files/mysql.spec.sh @@ -153,7 +153,7 @@ Summary: MySQL - server with Berkeley BD, 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 @@ -588,8 +588,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 + +- MySQL-Max now requires MySQL-server instead of MySQL (BUG 3860) + * Tue Aug 10 2004 Lenz Grimmer - Added libmygcc.a to the devel subpackage (required to link applications From 08595c46e71a253aa41c5937c69970003ebd1ff4 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 26 Aug 2004 13:25:09 +0200 Subject: [PATCH 16/54] sco compile fix: MAXPATHLEN --- ndb/src/common/logger/FileLogHandler.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ndb/src/common/logger/FileLogHandler.cpp b/ndb/src/common/logger/FileLogHandler.cpp index d13dd7b2a78..1b5e8f8d8ca 100644 --- a/ndb/src/common/logger/FileLogHandler.cpp +++ b/ndb/src/common/logger/FileLogHandler.cpp @@ -18,6 +18,11 @@ #include +// alt use PATH_MAX +#ifndef MAXPATHLEN +#define MAXPATHLEN 1024 +#endif + // // PUBLIC // From 42771f9877c17050a230cdaf8a26afc5d077a712 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 26 Aug 2004 16:31:37 +0500 Subject: [PATCH 17/54] "SELECT BINARY x" now means "SELECT CAST(x AS BINARY)". --- mysql-test/r/binary.result | 4 ++-- mysql-test/r/ctype_cp1251.result | 4 ++-- mysql-test/r/endspace.result | 2 +- mysql-test/r/func_if.result | 2 +- mysql-test/r/func_str.result | 2 +- mysql-test/r/myisam.result | 1 - mysql-test/r/type_ranges.result | 2 +- sql/sql_yacc.yy | 3 +-- 8 files changed, 9 insertions(+), 11 deletions(-) diff --git a/mysql-test/r/binary.result b/mysql-test/r/binary.result index 68b507d1089..405de1158d6 100644 --- a/mysql-test/r/binary.result +++ b/mysql-test/r/binary.result @@ -111,10 +111,10 @@ a b aaa bbb select charset(a), charset(b), charset(binary 'ccc') from t1 limit 1; charset(a) charset(b) charset(binary 'ccc') -latin1 binary latin1 +latin1 binary binary select collation(a), collation(b), collation(binary 'ccc') from t1 limit 1; collation(a) collation(b) collation(binary 'ccc') -latin1_bin binary latin1_bin +latin1_bin binary binary drop table t1; create table t1( firstname char(20), lastname char(20)); insert into t1 values ("john","doe"),("John","Doe"); diff --git a/mysql-test/r/ctype_cp1251.result b/mysql-test/r/ctype_cp1251.result index 2a59f976156..3793e962d40 100644 --- a/mysql-test/r/ctype_cp1251.result +++ b/mysql-test/r/ctype_cp1251.result @@ -49,8 +49,8 @@ a b aaa bbb select charset(a), charset(b), charset(binary 'ccc') from t1 limit 1; charset(a) charset(b) charset(binary 'ccc') -cp1251 binary cp1251 +cp1251 binary binary select collation(a), collation(b), collation(binary 'ccc') from t1 limit 1; collation(a) collation(b) collation(binary 'ccc') -cp1251_bin binary cp1251_bin +cp1251_bin binary binary drop table t1; diff --git a/mysql-test/r/endspace.result b/mysql-test/r/endspace.result index 167adea6674..4800bbf4ecb 100644 --- a/mysql-test/r/endspace.result +++ b/mysql-test/r/endspace.result @@ -19,7 +19,7 @@ select 'a a' > 'a', 'a \0' < 'a'; 1 1 select binary 'a a' > 'a', binary 'a \0' > 'a', binary 'a\0' > 'a'; binary 'a a' > 'a' binary 'a \0' > 'a' binary 'a\0' > 'a' -1 0 0 +1 1 1 create table t1 (text1 varchar(32) not NULL, KEY key1 (text1)); insert into t1 values ('teststring'), ('nothing'), ('teststring\t'); check table t1; diff --git a/mysql-test/r/func_if.result b/mysql-test/r/func_if.result index 4c8a0561b0a..dd916d06372 100644 --- a/mysql-test/r/func_if.result +++ b/mysql-test/r/func_if.result @@ -43,7 +43,7 @@ explain extended select if(u=1,st,binary st) s from t1 where st like "%a%" order id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 7 Using where; Using filesort Warnings: -Note 1003 select if((test.t1.u = 1),test.t1.st,(test.t1.st collate _latin1'BINARY')) AS `s` from test.t1 where (test.t1.st like _latin1'%a%') order by if((test.t1.u = 1),test.t1.st,(test.t1.st collate _latin1'BINARY')) +Note 1003 select if((test.t1.u = 1),test.t1.st,cast(test.t1.st as char charset binary)) AS `s` from test.t1 where (test.t1.st like _latin1'%a%') order by if((test.t1.u = 1),test.t1.st,cast(test.t1.st as char charset binary)) select nullif(u=0, 'test') from t1; nullif(u=0, 'test') NULL diff --git a/mysql-test/r/func_str.result b/mysql-test/r/func_str.result index 345832387bd..7b2fc4b21a5 100644 --- a/mysql-test/r/func_str.result +++ b/mysql-test/r/func_str.result @@ -638,7 +638,7 @@ explain extended select md5('hello'), sha('abc'), sha1('abc'), soundex(''), 'moo id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No tables used Warnings: -Note 1003 select md5(_latin1'hello') AS `md5('hello')`,sha(_latin1'abc') AS `sha('abc')`,sha(_latin1'abc') AS `sha1('abc')`,soundex(_latin1'') AS `soundex('')`,(soundex(_latin1'mood') = soundex(_latin1'mud')) AS `'mood' sounds like 'mud'`,aes_decrypt(aes_encrypt(_latin1'abc',_latin1'1'),_latin1'1') AS `aes_decrypt(aes_encrypt('abc','1'),'1')`,concat(_latin1'*',repeat(_latin1' ',5),_latin1'*') AS `concat('*',space(5),'*')`,reverse(_latin1'abc') AS `reverse('abc')`,rpad(_latin1'a',4,_latin1'1') AS `rpad('a',4,'1')`,lpad(_latin1'a',4,_latin1'1') AS `lpad('a',4,'1')`,concat_ws(_latin1',',_latin1'',NULL,_latin1'a') AS `concat_ws(',','',NULL,'a')`,make_set(255,_latin2'a',_latin2'b',_latin2'c') AS `make_set(255,_latin2'a',_latin2'b',_latin2'c')`,elt(2,1) AS `elt(2,1)`,locate(_latin1'a',_latin1'b',2) AS `locate("a","b",2)`,format(130,10) AS `format(130,10)`,char(0) AS `char(0)`,conv(130,16,10) AS `conv(130,16,10)`,hex(130) AS `hex(130)`,(_latin1'HE' collate _latin1'BINARY') AS `binary 'HE'`,export_set(255,_latin2'y',_latin2'n',_latin2' ') AS `export_set(255,_latin2'y',_latin2'n',_latin2' ')`,field((_latin1'b' collate _latin1'latin1_bin'),_latin1'A',_latin1'B') AS `FIELD('b' COLLATE latin1_bin,'A','B')`,find_in_set(_latin1'B',_latin1'a,b,c,d') AS `FIND_IN_SET(_latin1'B',_latin1'a,b,c,d')`,collation(conv(130,16,10)) AS `collation(conv(130,16,10))`,coercibility(conv(130,16,10)) AS `coercibility(conv(130,16,10))`,length(_latin1'\n \r\0\\_\\%\\') AS `length('\n\t\r\b\0\_\%\\')`,bit_length(_latin1'\n \r\0\\_\\%\\') AS `bit_length('\n\t\r\b\0\_\%\\')`,bit_length(_latin1'\n \r\0\\_\\%\\') AS `bit_length('\n\t\r\b\0\_\%\\')`,concat(_latin1'monty',_latin1' was here ',_latin1'again') AS `concat('monty',' was here ','again')`,length(_latin1'hello') AS `length('hello')`,char(ascii(_latin1'h')) AS `char(ascii('h'))`,ord(_latin1'h') AS `ord('h')`,quote((1 / 0)) AS `quote(1/0)`,crc32(_latin1'123') AS `crc32("123")`,replace(_latin1'aaaa',_latin1'a',_latin1'b') AS `replace('aaaa','a','b')`,insert(_latin1'txs',2,1,_latin1'hi') AS `insert('txs',2,1,'hi')`,left(_latin2'a',1) AS `left(_latin2'a',1)`,right(_latin2'a',1) AS `right(_latin2'a',1)`,lcase(_latin2'a') AS `lcase(_latin2'a')`,ucase(_latin2'a') AS `ucase(_latin2'a')`,substr(_latin1'abcdefg',3,2) AS `SUBSTR('abcdefg',3,2)`,substr_index(_latin1'1abcd;2abcd;3abcd;4abcd',_latin1';',2) AS `substring_index("1abcd;2abcd;3abcd;4abcd", ';', 2)`,trim(_latin2' a ') AS `trim(_latin2' a ')`,ltrim(_latin2' a ') AS `ltrim(_latin2' a ')`,rtrim(_latin2' a ') AS `rtrim(_latin2' a ')`,decode(encode(repeat(_latin1'a',100000))) AS `decode(encode(repeat("a",100000),"monty"),"monty")` +Note 1003 select md5(_latin1'hello') AS `md5('hello')`,sha(_latin1'abc') AS `sha('abc')`,sha(_latin1'abc') AS `sha1('abc')`,soundex(_latin1'') AS `soundex('')`,(soundex(_latin1'mood') = soundex(_latin1'mud')) AS `'mood' sounds like 'mud'`,aes_decrypt(aes_encrypt(_latin1'abc',_latin1'1'),_latin1'1') AS `aes_decrypt(aes_encrypt('abc','1'),'1')`,concat(_latin1'*',repeat(_latin1' ',5),_latin1'*') AS `concat('*',space(5),'*')`,reverse(_latin1'abc') AS `reverse('abc')`,rpad(_latin1'a',4,_latin1'1') AS `rpad('a',4,'1')`,lpad(_latin1'a',4,_latin1'1') AS `lpad('a',4,'1')`,concat_ws(_latin1',',_latin1'',NULL,_latin1'a') AS `concat_ws(',','',NULL,'a')`,make_set(255,_latin2'a',_latin2'b',_latin2'c') AS `make_set(255,_latin2'a',_latin2'b',_latin2'c')`,elt(2,1) AS `elt(2,1)`,locate(_latin1'a',_latin1'b',2) AS `locate("a","b",2)`,format(130,10) AS `format(130,10)`,char(0) AS `char(0)`,conv(130,16,10) AS `conv(130,16,10)`,hex(130) AS `hex(130)`,cast(_latin1'HE' as char charset binary) AS `binary 'HE'`,export_set(255,_latin2'y',_latin2'n',_latin2' ') AS `export_set(255,_latin2'y',_latin2'n',_latin2' ')`,field((_latin1'b' collate _latin1'latin1_bin'),_latin1'A',_latin1'B') AS `FIELD('b' COLLATE latin1_bin,'A','B')`,find_in_set(_latin1'B',_latin1'a,b,c,d') AS `FIND_IN_SET(_latin1'B',_latin1'a,b,c,d')`,collation(conv(130,16,10)) AS `collation(conv(130,16,10))`,coercibility(conv(130,16,10)) AS `coercibility(conv(130,16,10))`,length(_latin1'\n \r\0\\_\\%\\') AS `length('\n\t\r\b\0\_\%\\')`,bit_length(_latin1'\n \r\0\\_\\%\\') AS `bit_length('\n\t\r\b\0\_\%\\')`,bit_length(_latin1'\n \r\0\\_\\%\\') AS `bit_length('\n\t\r\b\0\_\%\\')`,concat(_latin1'monty',_latin1' was here ',_latin1'again') AS `concat('monty',' was here ','again')`,length(_latin1'hello') AS `length('hello')`,char(ascii(_latin1'h')) AS `char(ascii('h'))`,ord(_latin1'h') AS `ord('h')`,quote((1 / 0)) AS `quote(1/0)`,crc32(_latin1'123') AS `crc32("123")`,replace(_latin1'aaaa',_latin1'a',_latin1'b') AS `replace('aaaa','a','b')`,insert(_latin1'txs',2,1,_latin1'hi') AS `insert('txs',2,1,'hi')`,left(_latin2'a',1) AS `left(_latin2'a',1)`,right(_latin2'a',1) AS `right(_latin2'a',1)`,lcase(_latin2'a') AS `lcase(_latin2'a')`,ucase(_latin2'a') AS `ucase(_latin2'a')`,substr(_latin1'abcdefg',3,2) AS `SUBSTR('abcdefg',3,2)`,substr_index(_latin1'1abcd;2abcd;3abcd;4abcd',_latin1';',2) AS `substring_index("1abcd;2abcd;3abcd;4abcd", ';', 2)`,trim(_latin2' a ') AS `trim(_latin2' a ')`,ltrim(_latin2' a ') AS `ltrim(_latin2' a ')`,rtrim(_latin2' a ') AS `rtrim(_latin2' a ')`,decode(encode(repeat(_latin1'a',100000))) AS `decode(encode(repeat("a",100000),"monty"),"monty")` SELECT lpad(12345, 5, "#"); lpad(12345, 5, "#") 12345 diff --git a/mysql-test/r/myisam.result b/mysql-test/r/myisam.result index 0109097d3a1..354675cd4d4 100644 --- a/mysql-test/r/myisam.result +++ b/mysql-test/r/myisam.result @@ -412,7 +412,6 @@ aaa. aaa . select concat(a,'.') from t1 where binary a='aaa'; concat(a,'.') -aaa . aaa. update t1 set a='bbb' where a='aaa'; select concat(a,'.') from t1; diff --git a/mysql-test/r/type_ranges.result b/mysql-test/r/type_ranges.result index e803fde14a6..5a65c90c5c7 100644 --- a/mysql-test/r/type_ranges.result +++ b/mysql-test/r/type_ranges.result @@ -272,7 +272,7 @@ auto bigint(17) unsigned NULL PRI 0 select,insert,update,references t1 bigint(1) NULL 0 select,insert,update,references t2 char(1) latin1_swedish_ci select,insert,update,references t3 longtext latin1_swedish_ci select,insert,update,references -t4 longtext latin1_bin select,insert,update,references +t4 longblob NULL select,insert,update,references select * from t2; auto t1 t2 t3 t4 11 1 a aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 9cc39fe5104..4eca7359023 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -2745,8 +2745,7 @@ simple_expr: | ASCII_SYM '(' expr ')' { $$= new Item_func_ascii($3); } | BINARY expr %prec NEG { - $$= new Item_func_set_collation($2,new Item_string(binary_keyword, - 6, &my_charset_latin1)); + $$= create_func_cast($2, ITEM_CAST_CHAR, -1, &my_charset_bin); } | CAST_SYM '(' expr AS cast_type ')' { From 45f49c60cd124315e2d70905f3a01d6f738123f6 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 26 Aug 2004 16:51:26 +0500 Subject: [PATCH 18/54] A fix (Bug#5219: Cannot use '||' with MBRContains(..)). --- mysql-test/r/gis.result | 19 +++++++++++++++++++ mysql-test/t/gis.test | 18 ++++++++++++++++++ sql/opt_range.cc | 17 ++++++++++++----- 3 files changed, 49 insertions(+), 5 deletions(-) diff --git a/mysql-test/r/gis.result b/mysql-test/r/gis.result index c2fd7855c85..9f5dd286cf9 100644 --- a/mysql-test/r/gis.result +++ b/mysql-test/r/gis.result @@ -466,3 +466,22 @@ insert IGNORE into t1 values ('Garbage'); ERROR HY000: Unknown error alter table t1 add spatial index(a); drop table t1; +create table t1(a geometry not null, spatial index(a)); +insert into t1 values +(GeomFromText('POINT(1 1)')), (GeomFromText('POINT(3 3)')), +(GeomFromText('POINT(4 4)')), (GeomFromText('POINT(6 6)')); +select AsText(a) from t1 where +MBRContains(GeomFromText('Polygon((0 0, 0 2, 2 2, 2 0, 0 0))'), a) +or +MBRContains(GeomFromText('Polygon((2 2, 2 5, 5 5, 5 2, 2 2))'), a); +AsText(a) +POINT(1 1) +POINT(3 3) +POINT(4 4) +select AsText(a) from t1 where +MBRContains(GeomFromText('Polygon((0 0, 0 2, 2 2, 2 0, 0 0))'), a) +and +MBRContains(GeomFromText('Polygon((0 0, 0 7, 7 7, 7 0, 0 0))'), a); +AsText(a) +POINT(1 1) +drop table t1; diff --git a/mysql-test/t/gis.test b/mysql-test/t/gis.test index 590007caba1..e35b9996a44 100644 --- a/mysql-test/t/gis.test +++ b/mysql-test/t/gis.test @@ -172,3 +172,21 @@ insert IGNORE into t1 values ('Garbage'); alter table t1 add spatial index(a); drop table t1; + +# +# Bug #5219: problem with range optimizer +# + +create table t1(a geometry not null, spatial index(a)); +insert into t1 values +(GeomFromText('POINT(1 1)')), (GeomFromText('POINT(3 3)')), +(GeomFromText('POINT(4 4)')), (GeomFromText('POINT(6 6)')); +select AsText(a) from t1 where + MBRContains(GeomFromText('Polygon((0 0, 0 2, 2 2, 2 0, 0 0))'), a) + or + MBRContains(GeomFromText('Polygon((2 2, 2 5, 5 5, 5 2, 2 2))'), a); +select AsText(a) from t1 where + MBRContains(GeomFromText('Polygon((0 0, 0 2, 2 2, 2 0, 0 0))'), a) + and + MBRContains(GeomFromText('Polygon((0 0, 0 7, 7 7, 7 0, 0 0))'), a); +drop table t1; diff --git a/sql/opt_range.cc b/sql/opt_range.cc index 40e3ffebe56..02947e58a9e 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -1302,14 +1302,14 @@ tree_and(PARAM *param,SEL_TREE *tree1,SEL_TREE *tree2) if (*key2 && !(*key2)->simple_key()) flag|=CLONE_KEY2_MAYBE; *key1=key_and(*key1,*key2,flag); - if ((*key1)->type == SEL_ARG::IMPOSSIBLE) + if (*key1 && (*key1)->type == SEL_ARG::IMPOSSIBLE) { tree1->type= SEL_TREE::IMPOSSIBLE; +#ifdef EXTRA_DEBUG + (*key1)->test_use_count(*key1); +#endif break; } -#ifdef EXTRA_DEBUG - (*key1)->test_use_count(*key1); -#endif } } DBUG_RETURN(tree1); @@ -1401,6 +1401,12 @@ key_and(SEL_ARG *key1,SEL_ARG *key2,uint clone_flag) return key2; if (!key2) return key1; + if ((key1->min_flag | key2->min_flag) & GEOM_FLAG) + { + key1->free_tree(); + key2->free_tree(); + return 0; // Can't optimize this + } if (key1->part != key2->part) { if (key1->part > key2->part) @@ -1538,7 +1544,8 @@ key_or(SEL_ARG *key1,SEL_ARG *key2) key1->use_count--; key2->use_count--; - if (key1->part != key2->part) + if (key1->part != key2->part || + (key1->min_flag | key2->min_flag) & GEOM_FLAG) { key1->free_tree(); key2->free_tree(); From 536ce70814b71ddef63bfeda81e81a97ce13023b Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 26 Aug 2004 14:06:39 +0200 Subject: [PATCH 19/54] FileLogHandler.cpp, ndb_global.h: sco and others: use PATH_MAX always ndb/include/ndb_global.h: sco and others: use PATH_MAX always ndb/src/common/logger/FileLogHandler.cpp: sco and others: use PATH_MAX always --- ndb/include/ndb_global.h | 8 ++++++++ ndb/src/common/logger/FileLogHandler.cpp | 9 ++------- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/ndb/include/ndb_global.h b/ndb/include/ndb_global.h index 038950a7a32..b8fcca6dbb1 100644 --- a/ndb/include/ndb_global.h +++ b/ndb/include/ndb_global.h @@ -94,6 +94,14 @@ extern int strcasecmp(const char *s1, const char *s2); extern int strncasecmp(const char *s1, const char *s2, size_t n); #endif +#ifdef SCO + +#ifndef PATH_MAX +#define PATH_MAX 1024 +#endif + +#endif /* SCO */ + #ifdef __cplusplus } #endif diff --git a/ndb/src/common/logger/FileLogHandler.cpp b/ndb/src/common/logger/FileLogHandler.cpp index 1b5e8f8d8ca..632db71db15 100644 --- a/ndb/src/common/logger/FileLogHandler.cpp +++ b/ndb/src/common/logger/FileLogHandler.cpp @@ -14,15 +14,10 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include #include - #include -// alt use PATH_MAX -#ifndef MAXPATHLEN -#define MAXPATHLEN 1024 -#endif - // // PUBLIC // @@ -151,7 +146,7 @@ FileLogHandler::createNewFile() { bool rc = true; int fileNo = 1; - char newName[MAXPATHLEN]; + char newName[PATH_MAX]; do { From 11612dd3b428b24b5a47a257ae5f01b03e688e59 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 26 Aug 2004 17:43:08 +0500 Subject: [PATCH 20/54] Should check for GEOM_FLAG later because keyX may be partly initialized (min_flag is not set). --- sql/opt_range.cc | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/sql/opt_range.cc b/sql/opt_range.cc index 02947e58a9e..f11ed31950a 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -1401,12 +1401,6 @@ key_and(SEL_ARG *key1,SEL_ARG *key2,uint clone_flag) return key2; if (!key2) return key1; - if ((key1->min_flag | key2->min_flag) & GEOM_FLAG) - { - key1->free_tree(); - key2->free_tree(); - return 0; // Can't optimize this - } if (key1->part != key2->part) { if (key1->part > key2->part) @@ -1462,6 +1456,13 @@ key_and(SEL_ARG *key1,SEL_ARG *key2,uint clone_flag) return key1; } + if ((key1->min_flag | key2->min_flag) & GEOM_FLAG) + { + key1->free_tree(); + key2->free_tree(); + return 0; // Can't optimize this + } + key1->use_count--; key2->use_count--; SEL_ARG *e1=key1->first(), *e2=key2->first(), *new_tree=0; From c75e4dfed14e0f96e3458e2a8764ef570bf3b744 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 26 Aug 2004 16:15:36 +0300 Subject: [PATCH 21/54] Fixed a bug in mysql.cc. Overriding password prompting by giving password as an argument later did not work. --- client/mysql.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/client/mysql.cc b/client/mysql.cc index dd472041b34..98a6c69d0cd 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -44,7 +44,7 @@ #include #endif -const char *VER= "14.5"; +const char *VER= "14.6"; /* Don't try to make a nice table if the data is too big */ #define MAX_COLUMN_LENGTH 1024 @@ -792,6 +792,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), while (*argument) *argument++= 'x'; // Destroy argument if (*start) start[1]=0 ; + tty_password= 0; } else tty_password= 1; From e188532610931e911308e0edb3668fdff2cf684d Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 26 Aug 2004 15:32:57 +0200 Subject: [PATCH 22/54] remove warning --- extra/mysql_waitpid.c | 1 + 1 file changed, 1 insertion(+) diff --git a/extra/mysql_waitpid.c b/extra/mysql_waitpid.c index 9fcabfbb53e..0894d81a5ae 100644 --- a/extra/mysql_waitpid.c +++ b/extra/mysql_waitpid.c @@ -20,6 +20,7 @@ #include #include +#include #include #include #include From c42ce28591de77a01c200cbd2c6cb4ed8be18764 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 26 Aug 2004 14:35:33 +0000 Subject: [PATCH 23/54] ndb cluster config fixes, se respective files mysql-test/ndb/ndb_config_2_node.ini: added new config parameter datadir ndb/include/mgmapi/mgmapi_config_parameters.h: added new config parameter datadir and backup data dir ndb/include/mgmcommon/ConfigRetriever.hpp: changed verify config so that it can be used by mgmt srvr ndb/include/mgmcommon/NdbConfig.h: added option to set path for ndb files ndb/src/common/mgmcommon/ConfigInfo.cpp: changed token names for DB, MGM and API added config parametsers for datadir and backup data dir ndb/src/common/mgmcommon/ConfigRetriever.cpp: changed verify config so that it can be used by mgmt srvr ndb/src/common/mgmcommon/InitConfigFileParser.cpp: no need anymore to make uppercase ndb/src/common/mgmcommon/NdbConfig.c: bugfix+ added method to set datadir ndb/src/kernel/Makefile.am: added debug libs to ndbd ndb/src/kernel/vm/Configuration.cpp: added debug libs to ndbd ndb/src/mgmsrv/MgmtSrvr.cpp: added verify config to mgmt srvr ndb/src/mgmsrv/main.cpp: . --- mysql-test/ndb/ndb_config_2_node.ini | 7 +- ndb/include/mgmapi/mgmapi_config_parameters.h | 3 + ndb/include/mgmcommon/ConfigRetriever.hpp | 10 +- ndb/include/mgmcommon/NdbConfig.h | 1 + ndb/src/common/mgmcommon/ConfigInfo.cpp | 381 +++++++++++------- ndb/src/common/mgmcommon/ConfigRetriever.cpp | 21 +- .../common/mgmcommon/InitConfigFileParser.cpp | 4 - ndb/src/common/mgmcommon/NdbConfig.c | 12 +- ndb/src/kernel/Makefile.am | 5 +- ndb/src/kernel/vm/Configuration.cpp | 26 +- ndb/src/mgmsrv/MgmtSrvr.cpp | 73 ++-- ndb/src/mgmsrv/main.cpp | 4 +- 12 files changed, 339 insertions(+), 208 deletions(-) diff --git a/mysql-test/ndb/ndb_config_2_node.ini b/mysql-test/ndb/ndb_config_2_node.ini index a395b300df4..cc0f940efe3 100644 --- a/mysql-test/ndb/ndb_config_2_node.ini +++ b/mysql-test/ndb/ndb_config_2_node.ini @@ -5,15 +5,16 @@ DataMemory= CHOOSE_DataMemory IndexMemory= CHOOSE_IndexMemory Diskless= CHOOSE_Diskless TimeBetweenWatchDogCheck= 30000 -FileSystemPath= CHOOSE_FILESYSTEM +DataDir= CHOOSE_FILESYSTEM [ndbd] -HostName: CHOOSE_HOSTNAME_1 +HostName= CHOOSE_HOSTNAME_1 [ndbd] -HostName: CHOOSE_HOSTNAME_2 +HostName= CHOOSE_HOSTNAME_2 [ndb_mgmd] +DataDir= CHOOSE_FILESYSTEM PortNumber= CHOOSE_PORT_MGM [mysqld] diff --git a/ndb/include/mgmapi/mgmapi_config_parameters.h b/ndb/include/mgmapi/mgmapi_config_parameters.h index c0be3d6f03a..07d0aa87380 100644 --- a/ndb/include/mgmapi/mgmapi_config_parameters.h +++ b/ndb/include/mgmapi/mgmapi_config_parameters.h @@ -12,6 +12,7 @@ #define CFG_NODE_BYTE_ORDER 4 #define CFG_NODE_HOST 5 #define CFG_NODE_SYSTEM 6 +#define CFG_NODE_DATADIR 7 /** * DB config parameters @@ -89,6 +90,8 @@ #define CFG_DB_LONG_SIGNAL_BUFFER 157 +#define CFG_DB_BACKUP_DATA_PATH 158 + #define CFG_NODE_ARBIT_RANK 200 #define CFG_NODE_ARBIT_DELAY 201 diff --git a/ndb/include/mgmcommon/ConfigRetriever.hpp b/ndb/include/mgmcommon/ConfigRetriever.hpp index 396ce24308c..dd34eb0cfbb 100644 --- a/ndb/include/mgmcommon/ConfigRetriever.hpp +++ b/ndb/include/mgmcommon/ConfigRetriever.hpp @@ -78,6 +78,11 @@ public: * Get config from file */ struct ndb_mgm_configuration * getConfig(const char * file); + + /** + * Verify config + */ + bool verifyConfig(const struct ndb_mgm_configuration *, Uint32 nodeid); private: BaseString errorString; enum ErrorType { @@ -97,11 +102,6 @@ private: Uint32 m_version; Uint32 m_node_type; NdbMgmHandle m_handle; - - /** - * Verify config - */ - bool verifyConfig(const struct ndb_mgm_configuration *); }; #endif diff --git a/ndb/include/mgmcommon/NdbConfig.h b/ndb/include/mgmcommon/NdbConfig.h index 5c83a348df2..eb90f5e7c78 100644 --- a/ndb/include/mgmcommon/NdbConfig.h +++ b/ndb/include/mgmcommon/NdbConfig.h @@ -21,6 +21,7 @@ extern "C" { #endif +void NdbConfig_SetPath(const char *path); char* NdbConfig_NdbCfgName(int with_ndb_home); char* NdbConfig_ErrorFileName(int node_id); char* NdbConfig_ClusterLogFileName(int node_id); diff --git a/ndb/src/common/mgmcommon/ConfigInfo.cpp b/ndb/src/common/mgmcommon/ConfigInfo.cpp index 95646e4899e..769fc707c2a 100644 --- a/ndb/src/common/mgmcommon/ConfigInfo.cpp +++ b/ndb/src/common/mgmcommon/ConfigInfo.cpp @@ -33,11 +33,15 @@ * Section names ****************************************************************************/ +#define DB_TOKEN "NDBD" +#define MGM_TOKEN "NDB_MGMD" +#define API_TOKEN "MYSQLD" + const ConfigInfo::AliasPair ConfigInfo::m_sectionNameAliases[]={ - {"API", "MYSQLD"}, - {"DB", "NDBD"}, - {"MGM", "NDB_MGMD"}, + {API_TOKEN, "API"}, + {DB_TOKEN, "DB"}, + {MGM_TOKEN, "MGM"}, {0, 0} }; @@ -47,9 +51,9 @@ ConfigInfo::m_sectionNames[]={ "EXTERNAL SYSTEM", "COMPUTER", - "DB", - "MGM", - "API", + DB_TOKEN, + MGM_TOKEN, + API_TOKEN, "REP", "EXTERNAL REP", @@ -84,6 +88,8 @@ static bool fixNodeId(InitConfigFileParser::Context & ctx, const char * data); static bool fixExtConnection(InitConfigFileParser::Context & ctx, const char * data); static bool fixDepricated(InitConfigFileParser::Context & ctx, const char *); static bool saveInConfigValues(InitConfigFileParser::Context & ctx, const char *); +static bool fixFileSystemPath(InitConfigFileParser::Context & ctx, const char * data); +static bool fixBackupDataPath(InitConfigFileParser::Context & ctx, const char * data); const ConfigInfo::SectionRule ConfigInfo::m_SectionRules[] = { @@ -91,9 +97,9 @@ ConfigInfo::m_SectionRules[] = { { "EXTERNAL SYSTEM", transformExternalSystem, 0 }, { "COMPUTER", transformComputer, 0 }, - { "DB", transformNode, 0 }, - { "API", transformNode, 0 }, - { "MGM", transformNode, 0 }, + { DB_TOKEN, transformNode, 0 }, + { API_TOKEN, transformNode, 0 }, + { MGM_TOKEN, transformNode, 0 }, { "REP", transformNode, 0 }, { "EXTERNAL REP", transformExtNode, 0 }, @@ -102,9 +108,9 @@ ConfigInfo::m_SectionRules[] = { { "SCI", transformConnection, 0 }, { "OSE", transformConnection, 0 }, - { "DB", fixNodeHostname, 0 }, - { "API", fixNodeHostname, 0 }, - { "MGM", fixNodeHostname, 0 }, + { DB_TOKEN, fixNodeHostname, 0 }, + { API_TOKEN, fixNodeHostname, 0 }, + { MGM_TOKEN, fixNodeHostname, 0 }, { "REP", fixNodeHostname, 0 }, //{ "EXTERNAL REP", fixNodeHostname, 0 }, @@ -138,7 +144,10 @@ ConfigInfo::m_SectionRules[] = { { "*", fixDepricated, 0 }, { "*", applyDefaultValues, "system" }, - { "DB", checkDbConstraints, 0 }, + { DB_TOKEN, fixFileSystemPath, 0 }, + { DB_TOKEN, fixBackupDataPath, 0 }, + + { DB_TOKEN, checkDbConstraints, 0 }, /** * checkConnectionConstraints must be after fixExtConnection @@ -153,9 +162,9 @@ ConfigInfo::m_SectionRules[] = { { "*", checkMandatory, 0 }, - { "DB", saveInConfigValues, 0 }, - { "API", saveInConfigValues, 0 }, - { "MGM", saveInConfigValues, 0 }, + { DB_TOKEN, saveInConfigValues, 0 }, + { API_TOKEN, saveInConfigValues, 0 }, + { MGM_TOKEN, saveInConfigValues, 0 }, { "REP", saveInConfigValues, 0 }, { "TCP", saveInConfigValues, 0 }, @@ -196,7 +205,7 @@ struct DepricationTransform { static const DepricationTransform f_deprication[] = { - { "DB", "Discless", "Diskless", 0, 1 }, + { DB_TOKEN, "Discless", "Diskless", 0, 1 }, { 0, 0, 0, 0, 0} }; @@ -302,7 +311,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { CFG_SYS_PRIMARY_MGM_NODE, "PrimaryMGMNode", "SYSTEM", - "Node id of Primary MGM node", + "Node id of Primary "MGM_TOKEN" node", ConfigInfo::USED, false, ConfigInfo::INT, @@ -327,8 +336,8 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { ***************************************************************************/ { CFG_SECTION_NODE, - "DB", - "DB", + DB_TOKEN, + DB_TOKEN, "Node section", ConfigInfo::USED, false, @@ -340,7 +349,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { { CFG_NODE_HOST, "HostName", - "DB", + DB_TOKEN, "Name of computer for this node", ConfigInfo::INTERNAL, false, @@ -351,7 +360,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { { CFG_NODE_SYSTEM, "System", - "DB", + DB_TOKEN, "Name of system for this node", ConfigInfo::INTERNAL, false, @@ -362,8 +371,8 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { { CFG_NODE_ID, "Id", - "DB", - "Number identifying the database node (DB)", + DB_TOKEN, + "Number identifying the database node ("DB_TOKEN")", ConfigInfo::USED, false, ConfigInfo::INT, @@ -374,7 +383,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { { KEY_INTERNAL, "ServerPort", - "DB", + DB_TOKEN, "Port used to setup transporter", ConfigInfo::USED, false, @@ -386,7 +395,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { { CFG_DB_NO_REPLICAS, "NoOfReplicas", - "DB", + DB_TOKEN, "Number of copies of all data in the database (1-4)", ConfigInfo::USED, false, @@ -398,7 +407,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { { CFG_DB_NO_ATTRIBUTES, "MaxNoOfAttributes", - "DB", + DB_TOKEN, "Total number of attributes stored in database. I.e. sum over all tables", ConfigInfo::USED, false, @@ -410,7 +419,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { { CFG_DB_NO_TABLES, "MaxNoOfTables", - "DB", + DB_TOKEN, "Total number of tables stored in the database", ConfigInfo::USED, false, @@ -422,7 +431,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { { CFG_DB_NO_ORDERED_INDEXES, "MaxNoOfOrderedIndexes", - "DB", + DB_TOKEN, "Total number of ordered indexes that can be defined in the system", ConfigInfo::USED, false, @@ -434,7 +443,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { { CFG_DB_NO_UNIQUE_HASH_INDEXES, "MaxNoOfUniqueHashIndexes", - "DB", + DB_TOKEN, "Total number of unique hash indexes that can be defined in the system", ConfigInfo::USED, false, @@ -446,7 +455,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { { CFG_DB_NO_INDEXES, "MaxNoOfIndexes", - "DB", + DB_TOKEN, "Total number of indexes that can be defined in the system", ConfigInfo::DEPRICATED, false, @@ -458,8 +467,8 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { { CFG_DB_NO_INDEX_OPS, "MaxNoOfConcurrentIndexOperations", - "DB", - "Total number of index operations that can execute simultaneously on one DB node", + DB_TOKEN, + "Total number of index operations that can execute simultaneously on one "DB_TOKEN" node", ConfigInfo::USED, false, ConfigInfo::INT, @@ -471,7 +480,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { { CFG_DB_NO_TRIGGERS, "MaxNoOfTriggers", - "DB", + DB_TOKEN, "Total number of triggers that can be defined in the system", ConfigInfo::USED, false, @@ -483,8 +492,8 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { { CFG_DB_NO_TRIGGER_OPS, "MaxNoOfFiredTriggers", - "DB", - "Total number of triggers that can fire simultaneously in one DB node", + DB_TOKEN, + "Total number of triggers that can fire simultaneously in one "DB_TOKEN" node", ConfigInfo::USED, false, ConfigInfo::INT, @@ -495,7 +504,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { { KEY_INTERNAL, "ExecuteOnComputer", - "DB", + DB_TOKEN, "String referencing an earlier defined COMPUTER", ConfigInfo::USED, false, @@ -506,7 +515,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { { CFG_DB_NO_SAVE_MSGS, "MaxNoOfSavedMessages", - "DB", + DB_TOKEN, "Max number of error messages in error log and max number of trace files", ConfigInfo::USED, true, @@ -518,7 +527,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { { CFG_DB_MEMLOCK, "LockPagesInMainMemory", - "DB", + DB_TOKEN, "If set to yes, then NDB Cluster data will not be swapped out to disk", ConfigInfo::USED, true, @@ -530,7 +539,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { { CFG_DB_WATCHDOG_INTERVAL, "TimeBetweenWatchDogCheck", - "DB", + DB_TOKEN, "Time between execution checks inside a database node", ConfigInfo::USED, true, @@ -542,8 +551,8 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { { CFG_DB_STOP_ON_ERROR, "StopOnError", - "DB", - "If set to N, the DB automatically restarts/recovers in case of node failure", + DB_TOKEN, + "If set to N, "DB_TOKEN" automatically restarts/recovers in case of node failure", ConfigInfo::USED, true, ConfigInfo::BOOL, @@ -554,7 +563,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { { CFG_DB_STOP_ON_ERROR_INSERT, "RestartOnErrorInsert", - "DB", + DB_TOKEN, "See src/kernel/vm/Emulator.hpp NdbRestartType for details", ConfigInfo::INTERNAL, true, @@ -566,7 +575,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { { CFG_DB_NO_OPS, "MaxNoOfConcurrentOperations", - "DB", + DB_TOKEN, "Max number of operation records in transaction coordinator", ConfigInfo::USED, false, @@ -578,7 +587,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { { CFG_DB_NO_LOCAL_OPS, "MaxNoOfLocalOperations", - "DB", + DB_TOKEN, "Max number of operation records defined in the local storage node", ConfigInfo::USED, false, @@ -590,7 +599,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { { CFG_DB_NO_LOCAL_SCANS, "MaxNoOfLocalScans", - "DB", + DB_TOKEN, "Max number of fragment scans in parallel in the local storage node", ConfigInfo::USED, false, @@ -602,7 +611,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { { CFG_DB_BATCH_SIZE, "BatchSizePerLocalScan", - "DB", + DB_TOKEN, "Used to calculate the number of lock records for scan with hold lock", ConfigInfo::USED, false, @@ -614,8 +623,8 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { { CFG_DB_NO_TRANSACTIONS, "MaxNoOfConcurrentTransactions", - "DB", - "Max number of transaction executing concurrently on the DB node", + DB_TOKEN, + "Max number of transaction executing concurrently on the "DB_TOKEN" node", ConfigInfo::USED, false, ConfigInfo::INT, @@ -626,8 +635,8 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { { CFG_DB_NO_SCANS, "MaxNoOfConcurrentScans", - "DB", - "Max number of scans executing concurrently on the DB node", + DB_TOKEN, + "Max number of scans executing concurrently on the "DB_TOKEN" node", ConfigInfo::USED, false, ConfigInfo::INT, @@ -638,8 +647,8 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { { CFG_DB_TRANS_BUFFER_MEM, "TransactionBufferMemory", - "DB", - "Dynamic buffer space (in bytes) for key and attribute data allocated for each DB node", + DB_TOKEN, + "Dynamic buffer space (in bytes) for key and attribute data allocated for each "DB_TOKEN" node", ConfigInfo::USED, false, ConfigInfo::INT, @@ -650,8 +659,8 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { { CFG_DB_INDEX_MEM, "IndexMemory", - "DB", - "Number bytes on each DB node allocated for storing indexes", + DB_TOKEN, + "Number bytes on each "DB_TOKEN" node allocated for storing indexes", ConfigInfo::USED, false, ConfigInfo::INT64, @@ -662,8 +671,8 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { { CFG_DB_DATA_MEM, "DataMemory", - "DB", - "Number bytes on each DB node allocated for storing data", + DB_TOKEN, + "Number bytes on each "DB_TOKEN" node allocated for storing data", ConfigInfo::USED, false, ConfigInfo::INT64, @@ -674,8 +683,8 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { { CFG_DB_UNDO_INDEX_BUFFER, "UndoIndexBuffer", - "DB", - "Number bytes on each DB node allocated for writing UNDO logs for index part", + DB_TOKEN, + "Number bytes on each "DB_TOKEN" node allocated for writing UNDO logs for index part", ConfigInfo::USED, false, ConfigInfo::INT, @@ -686,8 +695,8 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { { CFG_DB_UNDO_DATA_BUFFER, "UndoDataBuffer", - "DB", - "Number bytes on each DB node allocated for writing UNDO logs for data part", + DB_TOKEN, + "Number bytes on each "DB_TOKEN" node allocated for writing UNDO logs for data part", ConfigInfo::USED, false, ConfigInfo::INT, @@ -698,8 +707,8 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { { CFG_DB_REDO_BUFFER, "RedoBuffer", - "DB", - "Number bytes on each DB node allocated for writing REDO logs", + DB_TOKEN, + "Number bytes on each "DB_TOKEN" node allocated for writing REDO logs", ConfigInfo::USED, false, ConfigInfo::INT, @@ -710,8 +719,8 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { { CFG_DB_LONG_SIGNAL_BUFFER, "LongMessageBuffer", - "DB", - "Number bytes on each DB node allocated for internal long messages", + DB_TOKEN, + "Number bytes on each "DB_TOKEN" node allocated for internal long messages", ConfigInfo::USED, false, ConfigInfo::INT, @@ -722,7 +731,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { { CFG_DB_START_PARTIAL_TIMEOUT, "StartPartialTimeout", - "DB", + DB_TOKEN, "Time to wait before trying to start wo/ all nodes. 0=Wait forever", ConfigInfo::USED, true, @@ -734,7 +743,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { { CFG_DB_START_PARTITION_TIMEOUT, "StartPartitionedTimeout", - "DB", + DB_TOKEN, "Time to wait before trying to start partitioned. 0=Wait forever", ConfigInfo::USED, true, @@ -746,7 +755,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { { CFG_DB_START_FAILURE_TIMEOUT, "StartFailureTimeout", - "DB", + DB_TOKEN, "Time to wait before terminating. 0=Wait forever", ConfigInfo::USED, true, @@ -758,8 +767,8 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { { CFG_DB_HEARTBEAT_INTERVAL, "HeartbeatIntervalDbDb", - "DB", - "Time between DB-DB heartbeats. DB considered dead after 3 missed HBs", + DB_TOKEN, + "Time between "DB_TOKEN"-"DB_TOKEN" heartbeats. "DB_TOKEN" considered dead after 3 missed HBs", ConfigInfo::USED, true, ConfigInfo::INT, @@ -770,8 +779,8 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { { CFG_DB_API_HEARTBEAT_INTERVAL, "HeartbeatIntervalDbApi", - "DB", - "Time between API-DB heartbeats. API connection closed after 3 missed HBs", + DB_TOKEN, + "Time between "API_TOKEN"-"DB_TOKEN" heartbeats. "API_TOKEN" connection closed after 3 missed HBs", ConfigInfo::USED, true, ConfigInfo::INT, @@ -782,7 +791,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { { CFG_DB_LCP_INTERVAL, "TimeBetweenLocalCheckpoints", - "DB", + DB_TOKEN, "Time between taking snapshots of the database (expressed in 2log of bytes)", ConfigInfo::USED, true, @@ -794,7 +803,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { { CFG_DB_GCP_INTERVAL, "TimeBetweenGlobalCheckpoints", - "DB", + DB_TOKEN, "Time between doing group commit of transactions to disk", ConfigInfo::USED, true, @@ -806,8 +815,8 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { { CFG_DB_NO_REDOLOG_FILES, "NoOfFragmentLogFiles", - "DB", - "No of 16 Mbyte Redo log files in each of 4 file sets belonging to DB node", + DB_TOKEN, + "No of 16 Mbyte Redo log files in each of 4 file sets belonging to "DB_TOKEN" node", ConfigInfo::USED, false, ConfigInfo::INT, @@ -818,8 +827,8 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { { KEY_INTERNAL, "MaxNoOfOpenFiles", - "DB", - "Max number of files open per DB node.(One thread is created per file)", + DB_TOKEN, + "Max number of files open per "DB_TOKEN" node.(One thread is created per file)", ConfigInfo::USED, false, ConfigInfo::INT, @@ -831,7 +840,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { { CFG_DB_TRANSACTION_CHECK_INTERVAL, "TimeBetweenInactiveTransactionAbortCheck", - "DB", + DB_TOKEN, "Time between inactive transaction checks", ConfigInfo::USED, true, @@ -843,7 +852,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { { CFG_DB_TRANSACTION_INACTIVE_TIMEOUT, "TransactionInactiveTimeout", - "DB", + DB_TOKEN, "Time application can wait before executing another transaction part (ms).\n" "This is the time the transaction coordinator waits for the application\n" "to execute or send another part (query, statement) of the transaction.\n" @@ -859,7 +868,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { { CFG_DB_TRANSACTION_DEADLOCK_TIMEOUT, "TransactionDeadlockDetectionTimeout", - "DB", + DB_TOKEN, "Time transaction can be executing in a DB node (ms).\n" "This is the time the transaction coordinator waits for each database node\n" "of the transaction to execute a request. If the database node takes too\n" @@ -874,7 +883,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { { KEY_INTERNAL, "NoOfDiskPagesToDiskDuringRestartTUP", - "DB", + DB_TOKEN, "?", ConfigInfo::USED, true, @@ -886,7 +895,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { { KEY_INTERNAL, "NoOfDiskPagesToDiskAfterRestartTUP", - "DB", + DB_TOKEN, "?", ConfigInfo::USED, true, @@ -898,7 +907,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { { KEY_INTERNAL, "NoOfDiskPagesToDiskDuringRestartACC", - "DB", + DB_TOKEN, "?", ConfigInfo::USED, true, @@ -910,7 +919,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { { KEY_INTERNAL, "NoOfDiskPagesToDiskAfterRestartACC", - "DB", + DB_TOKEN, "?", ConfigInfo::USED, true, @@ -923,7 +932,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { { CFG_DB_DISCLESS, "Diskless", - "DB", + DB_TOKEN, "Run wo/ disk", ConfigInfo::USED, true, @@ -935,7 +944,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { { KEY_INTERNAL, "Discless", - "DB", + DB_TOKEN, "Diskless", ConfigInfo::DEPRICATED, true, @@ -949,7 +958,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { { CFG_DB_ARBIT_TIMEOUT, "ArbitrationTimeout", - "DB", + DB_TOKEN, "Max time (milliseconds) database partion waits for arbitration signal", ConfigInfo::USED, false, @@ -959,20 +968,31 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { MAX_INT_RNIL_STRING }, { - CFG_DB_FILESYSTEM_PATH, - "FileSystemPath", - "DB", - "Path to directory where the DB node stores its data (directory must exist)", + CFG_NODE_DATADIR, + "DataDir", + DB_TOKEN, + "Data directory for this node", ConfigInfo::USED, false, ConfigInfo::STRING, DATADIR, 0, 0 }, + { + CFG_DB_FILESYSTEM_PATH, + "FileSystemPath", + DB_TOKEN, + "Path to directory where the "DB_TOKEN" node stores its data (directory must exist)", + ConfigInfo::USED, + false, + ConfigInfo::STRING, + UNDEFINED, + 0, 0 }, + { CFG_LOGLEVEL_STARTUP, "LogLevelStartup", - "DB", + DB_TOKEN, "Node startup info printed on stdout", ConfigInfo::USED, false, @@ -984,7 +1004,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { { CFG_LOGLEVEL_SHUTDOWN, "LogLevelShutdown", - "DB", + DB_TOKEN, "Node shutdown info printed on stdout", ConfigInfo::USED, false, @@ -996,7 +1016,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { { CFG_LOGLEVEL_STATISTICS, "LogLevelStatistic", - "DB", + DB_TOKEN, "Transaction, operation, transporter info printed on stdout", ConfigInfo::USED, false, @@ -1008,7 +1028,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { { CFG_LOGLEVEL_CHECKPOINT, "LogLevelCheckpoint", - "DB", + DB_TOKEN, "Local and Global checkpoint info printed on stdout", ConfigInfo::USED, false, @@ -1020,7 +1040,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { { CFG_LOGLEVEL_NODERESTART, "LogLevelNodeRestart", - "DB", + DB_TOKEN, "Node restart, node failure info printed on stdout", ConfigInfo::USED, false, @@ -1032,7 +1052,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { { CFG_LOGLEVEL_CONNECTION, "LogLevelConnection", - "DB", + DB_TOKEN, "Node connect/disconnect info printed on stdout", ConfigInfo::USED, false, @@ -1044,7 +1064,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { { CFG_LOGLEVEL_ERROR, "LogLevelError", - "DB", + DB_TOKEN, "Transporter, heartbeat errors printed on stdout", ConfigInfo::USED, false, @@ -1056,7 +1076,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { { CFG_LOGLEVEL_INFO, "LogLevelInfo", - "DB", + DB_TOKEN, "Heartbeat and log info printed on stdout", ConfigInfo::USED, false, @@ -1071,7 +1091,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { { CFG_DB_PARALLEL_BACKUPS, "ParallelBackups", - "DB", + DB_TOKEN, "Maximum number of parallel backups", ConfigInfo::NOTIMPLEMENTED, false, @@ -1080,10 +1100,21 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "1", "1" }, + { + CFG_DB_BACKUP_DATA_PATH, + "BackupDataPath", + DB_TOKEN, + "Path to where to store backups", + ConfigInfo::USED, + false, + ConfigInfo::STRING, + UNDEFINED, + 0, 0 }, + { CFG_DB_BACKUP_MEM, "BackupMemory", - "DB", + DB_TOKEN, "Total memory allocated for backups per node (in bytes)", ConfigInfo::USED, false, @@ -1095,7 +1126,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { { CFG_DB_BACKUP_DATA_BUFFER_MEM, "BackupDataBufferSize", - "DB", + DB_TOKEN, "Default size of databuffer for a backup (in bytes)", ConfigInfo::USED, false, @@ -1107,7 +1138,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { { CFG_DB_BACKUP_LOG_BUFFER_MEM, "BackupLogBufferSize", - "DB", + DB_TOKEN, "Default size of logbuffer for a backup (in bytes)", ConfigInfo::USED, false, @@ -1119,7 +1150,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { { CFG_DB_BACKUP_WRITE_SIZE, "BackupWriteSize", - "DB", + DB_TOKEN, "Default size of filesystem writes made by backup (in bytes)", ConfigInfo::USED, false, @@ -1205,8 +1236,8 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { ***************************************************************************/ { CFG_SECTION_NODE, - "API", - "API", + API_TOKEN, + API_TOKEN, "Node section", ConfigInfo::USED, false, @@ -1218,7 +1249,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { { CFG_NODE_HOST, "HostName", - "API", + API_TOKEN, "Name of computer for this node", ConfigInfo::INTERNAL, false, @@ -1229,7 +1260,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { { CFG_NODE_SYSTEM, "System", - "API", + API_TOKEN, "Name of system for this node", ConfigInfo::INTERNAL, false, @@ -1240,8 +1271,8 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { { CFG_NODE_ID, "Id", - "API", - "Number identifying application node (API)", + API_TOKEN, + "Number identifying application node ("API_TOKEN")", ConfigInfo::USED, false, ConfigInfo::INT, @@ -1252,7 +1283,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { { KEY_INTERNAL, "ExecuteOnComputer", - "API", + API_TOKEN, "String referencing an earlier defined COMPUTER", ConfigInfo::USED, false, @@ -1263,8 +1294,8 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { { CFG_NODE_ARBIT_RANK, "ArbitrationRank", - "API", - "If 0, then API is not arbitrator. Kernel selects arbitrators in order 1, 2", + API_TOKEN, + "If 0, then "API_TOKEN" is not arbitrator. Kernel selects arbitrators in order 1, 2", ConfigInfo::USED, false, ConfigInfo::INT, @@ -1275,7 +1306,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { { CFG_NODE_ARBIT_DELAY, "ArbitrationDelay", - "API", + API_TOKEN, "When asked to arbitrate, arbitrator waits this long before voting (msec)", ConfigInfo::USED, false, @@ -1289,8 +1320,8 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { ***************************************************************************/ { CFG_SECTION_NODE, - "MGM", - "MGM", + MGM_TOKEN, + MGM_TOKEN, "Node section", ConfigInfo::USED, false, @@ -1302,7 +1333,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { { CFG_NODE_HOST, "HostName", - "MGM", + MGM_TOKEN, "Name of computer for this node", ConfigInfo::INTERNAL, false, @@ -1310,10 +1341,21 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { UNDEFINED, 0, 0 }, + { + CFG_NODE_DATADIR, + "DataDir", + MGM_TOKEN, + "Data directory for this node", + ConfigInfo::USED, + false, + ConfigInfo::STRING, + DATADIR, + 0, 0 }, + { CFG_NODE_SYSTEM, "System", - "MGM", + MGM_TOKEN, "Name of system for this node", ConfigInfo::INTERNAL, false, @@ -1324,8 +1366,8 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { { CFG_NODE_ID, "Id", - "MGM", - "Number identifying the management server node (MGM)", + MGM_TOKEN, + "Number identifying the management server node ("MGM_TOKEN")", ConfigInfo::USED, false, ConfigInfo::INT, @@ -1336,7 +1378,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { { CFG_LOG_DESTINATION, "LogDestination", - "MGM", + MGM_TOKEN, "String describing where logmessages are sent", ConfigInfo::USED, false, @@ -1347,7 +1389,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { { KEY_INTERNAL, "ExecuteOnComputer", - "MGM", + MGM_TOKEN, "String referencing an earlier defined COMPUTER", ConfigInfo::USED, false, @@ -1358,7 +1400,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { { KEY_INTERNAL, "MaxNoOfSavedEvents", - "MGM", + MGM_TOKEN, "", ConfigInfo::USED, false, @@ -1370,7 +1412,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { { CFG_MGM_PORT, "PortNumber", - "MGM", + MGM_TOKEN, "Port number to give commands to/fetch configurations from management server", ConfigInfo::USED, false, @@ -1382,7 +1424,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { { KEY_INTERNAL, "PortNumberStats", - "MGM", + MGM_TOKEN, "Port number used to get statistical information from a management server", ConfigInfo::USED, false, @@ -1394,8 +1436,8 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { { CFG_NODE_ARBIT_RANK, "ArbitrationRank", - "MGM", - "If 0, then MGM is not arbitrator. Kernel selects arbitrators in order 1, 2", + MGM_TOKEN, + "If 0, then "MGM_TOKEN" is not arbitrator. Kernel selects arbitrators in order 1, 2", ConfigInfo::USED, false, ConfigInfo::INT, @@ -1406,7 +1448,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { { CFG_NODE_ARBIT_DELAY, "ArbitrationDelay", - "MGM", + MGM_TOKEN, "", ConfigInfo::USED, false, @@ -1456,7 +1498,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { CFG_CONNECTION_NODE_1, "NodeId1", "TCP", - "Id of node (DB, API or MGM) on one side of the connection", + "Id of node ("DB_TOKEN", "API_TOKEN" or "MGM_TOKEN") on one side of the connection", ConfigInfo::USED, false, ConfigInfo::STRING, @@ -1467,7 +1509,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { CFG_CONNECTION_NODE_2, "NodeId2", "TCP", - "Id of node (DB, API or MGM) on one side of the connection", + "Id of node ("DB_TOKEN", "API_TOKEN" or "MGM_TOKEN") on one side of the connection", ConfigInfo::USED, false, ConfigInfo::STRING, @@ -1587,7 +1629,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { CFG_CONNECTION_NODE_1, "NodeId1", "SHM", - "Id of node (DB, API or MGM) on one side of the connection", + "Id of node ("DB_TOKEN", "API_TOKEN" or "MGM_TOKEN") on one side of the connection", ConfigInfo::USED, false, ConfigInfo::STRING, @@ -1610,7 +1652,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { CFG_CONNECTION_NODE_2, "NodeId2", "SHM", - "Id of node (DB, API or MGM) on one side of the connection", + "Id of node ("DB_TOKEN", "API_TOKEN" or "MGM_TOKEN") on one side of the connection", ConfigInfo::USED, false, ConfigInfo::STRING, @@ -1707,7 +1749,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { CFG_CONNECTION_NODE_1, "NodeId1", "SCI", - "Id of node (DB, API or MGM) on one side of the connection", + "Id of node ("DB_TOKEN", "API_TOKEN" or "MGM_TOKEN") on one side of the connection", ConfigInfo::USED, false, ConfigInfo::INT, @@ -1719,7 +1761,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { CFG_CONNECTION_NODE_2, "NodeId2", "SCI", - "Id of node (DB, API or MGM) on one side of the connection", + "Id of node ("DB_TOKEN", "API_TOKEN" or "MGM_TOKEN") on one side of the connection", ConfigInfo::USED, false, ConfigInfo::INT, @@ -1862,7 +1904,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { CFG_CONNECTION_NODE_1, "NodeId1", "OSE", - "Id of node (DB, API or MGM) on one side of the connection", + "Id of node ("DB_TOKEN", "API_TOKEN" or "MGM_TOKEN") on one side of the connection", ConfigInfo::USED, false, ConfigInfo::INT, @@ -1874,7 +1916,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { CFG_CONNECTION_NODE_2, "NodeId2", "OSE", - "Id of node (DB, API or MGM) on one side of the connection", + "Id of node ("DB_TOKEN", "API_TOKEN" or "MGM_TOKEN") on one side of the connection", ConfigInfo::USED, false, ConfigInfo::INT, @@ -2206,7 +2248,7 @@ ConfigInfo::getDescription(const Properties * section, bool ConfigInfo::isSection(const char * section) const { for (int i = 0; iget("ExecuteOnComputer", &compId)){ const char * type; - if(ctx.m_currentSection->get("Type", &type) && strcmp(type,"DB") == 0) + if(ctx.m_currentSection->get("Type", &type) && strcmp(type,DB_TOKEN) == 0) require(ctx.m_currentSection->put("HostName", "localhost")); else require(ctx.m_currentSection->put("HostName", "")); @@ -2437,6 +2479,39 @@ fixNodeHostname(InitConfigFileParser::Context & ctx, const char * data){ return checkLocalhostHostnameMix(ctx); } +bool +fixFileSystemPath(InitConfigFileParser::Context & ctx, const char * data){ + DBUG_ENTER("fixFileSystemPath"); + + const char * path; + if (ctx.m_currentSection->get("FileSystemPath", &path)) + DBUG_RETURN(true); + + if (ctx.m_currentSection->get("DataDir", &path)) { + require(ctx.m_currentSection->put("FileSystemPath", path)); + DBUG_RETURN(true); + } + + require(false); + DBUG_RETURN(false); +} + +bool +fixBackupDataPath(InitConfigFileParser::Context & ctx, const char * data){ + + const char * path; + if (ctx.m_currentSection->get("BackupDataPath", &path)) + return true; + + if (ctx.m_currentSection->get("FileSystemPath", &path)) { + require(ctx.m_currentSection->put("BackupDataPath", path)); + return true; + } + + require(false); + return false; +} + bool transformExtNode(InitConfigFileParser::Context & ctx, const char * data){ @@ -2778,10 +2853,16 @@ fixHostname(InitConfigFileParser::Context & ctx, const char * data){ static bool fixPortNumber(InitConfigFileParser::Context & ctx, const char * data){ + DBUG_ENTER("fixPortNumber"); + Uint32 id1= 0, id2= 0; require(ctx.m_currentSection->get("NodeId1", &id1)); require(ctx.m_currentSection->get("NodeId2", &id2)); - id1 = id1 < id2 ? id1 : id2; + if (id1 > id2) { + Uint32 tmp= id1; + id1= id2; + id2= tmp; + } const Properties * node; require(ctx.m_config->get("Node", id1, &node)); @@ -2790,7 +2871,7 @@ fixPortNumber(InitConfigFileParser::Context & ctx, const char * data){ if (hostname.c_str()[0] == 0) { ctx.reportError("Hostname required on nodeid %d since it will act as server.", id1); - return false; + DBUG_RETURN(false); } Uint32 port= 0; @@ -2823,7 +2904,9 @@ fixPortNumber(InitConfigFileParser::Context & ctx, const char * data){ } else ctx.m_currentSection->put("PortNumber", port); - return true; + DBUG_PRINT("info", ("connection %d-%d port %d host %s", id1, id2, port, hostname.c_str())); + + DBUG_RETURN(true); } /** @@ -2908,8 +2991,8 @@ checkConnectionConstraints(InitConfigFileParser::Context & ctx, const char *){ * -# Not both of them are MGMs * -# None of them contain a "SystemX" name */ - if((strcmp(type1, "DB") != 0 && strcmp(type2, "DB") != 0) && - !(strcmp(type1, "MGM") == 0 && strcmp(type2, "MGM") == 0) && + if((strcmp(type1, DB_TOKEN) != 0 && strcmp(type2, DB_TOKEN) != 0) && + !(strcmp(type1, MGM_TOKEN) == 0 && strcmp(type2, MGM_TOKEN) == 0) && !ctx.m_currentSection->contains("System1") && !ctx.m_currentSection->contains("System2")){ ctx.reportError("Invalid connection between node %d (%s) and node %d (%s)" @@ -3157,10 +3240,10 @@ add_node_connections(Vector§ions, const char * type; if(!tmp->get("Type", &type)) continue; - if (strcmp(type,"DB") == 0) + if (strcmp(type,DB_TOKEN) == 0) p_db_nodes.put("", i_db++, i); - else if (strcmp(type,"API") == 0 || - strcmp(type,"MGM") == 0) + else if (strcmp(type,API_TOKEN) == 0 || + strcmp(type,MGM_TOKEN) == 0) p_api_mgm_nodes.put("", i_api_mgm++, i); } @@ -3233,7 +3316,7 @@ static bool add_server_ports(Vector§ions, Uint32 adder= 0; computers.get("",computer, &adder); - if (strcmp(type,"DB") == 0) { + if (strcmp(type,DB_TOKEN) == 0) { adder++; tmp->put("ServerPort", port_base+adder); computers.put("",computer, adder); @@ -3250,7 +3333,7 @@ check_node_vs_replicas(Vector§ions, { Uint32 db_nodes = 0; Uint32 replicas = 0; - ctx.m_userProperties.get("DB", &db_nodes); + ctx.m_userProperties.get(DB_TOKEN, &db_nodes); ctx.m_userProperties.get("NoOfReplicas", &replicas); if((db_nodes % replicas) != 0){ ctx.reportError("Invalid no of db nodes wrt no of replicas.\n" diff --git a/ndb/src/common/mgmcommon/ConfigRetriever.cpp b/ndb/src/common/mgmcommon/ConfigRetriever.cpp index 2e809907058..afee135d793 100644 --- a/ndb/src/common/mgmcommon/ConfigRetriever.cpp +++ b/ndb/src/common/mgmcommon/ConfigRetriever.cpp @@ -154,7 +154,7 @@ ConfigRetriever::getConfig() { if(p == 0) return 0; - if(!verifyConfig(p)){ + if(!verifyConfig(p, _ownNodeId)){ free(p); p= 0; } @@ -239,7 +239,7 @@ ConfigRetriever::setConnectString(const char * connectString) { } bool -ConfigRetriever::verifyConfig(const struct ndb_mgm_configuration * conf){ +ConfigRetriever::verifyConfig(const struct ndb_mgm_configuration * conf, Uint32 nodeid){ char buf[255]; ndb_mgm_configuration_iterator * it; @@ -253,8 +253,8 @@ ConfigRetriever::verifyConfig(const struct ndb_mgm_configuration * conf){ } NdbAutoPtr ptr(it); - if(ndb_mgm_find(it, CFG_NODE_ID, _ownNodeId) != 0){ - snprintf(buf, 255, "Unable to find node with id: %d", _ownNodeId); + if(ndb_mgm_find(it, CFG_NODE_ID, nodeid) != 0){ + snprintf(buf, 255, "Unable to find node with id: %d", nodeid); setError(CR_ERROR, buf); return false; } @@ -266,6 +266,11 @@ ConfigRetriever::verifyConfig(const struct ndb_mgm_configuration * conf){ return false; } + const char * datadir; + if(!ndb_mgm_get_string_parameter(it, CFG_NODE_DATADIR, &datadir)){ + NdbConfig_SetPath(datadir); + } + char localhost[MAXHOSTNAMELEN]; if(NdbHost_GetHostName(localhost) != 0){ snprintf(buf, 255, "Unable to get own hostname"); @@ -332,8 +337,8 @@ ConfigRetriever::verifyConfig(const struct ndb_mgm_configuration * conf){ if(iter.get(CFG_CONNECTION_NODE_1, &nodeId1)) continue; if(iter.get(CFG_CONNECTION_NODE_2, &nodeId2)) continue; - if(nodeId1 != _ownNodeId && nodeId2 != _ownNodeId) continue; - remoteNodeId = (_ownNodeId == nodeId1 ? nodeId2 : nodeId1); + if(nodeId1 != nodeid && nodeId2 != nodeid) continue; + remoteNodeId = (nodeid == nodeId1 ? nodeId2 : nodeId1); const char * name; struct in_addr addr; @@ -342,7 +347,7 @@ ConfigRetriever::verifyConfig(const struct ndb_mgm_configuration * conf){ if(Ndb_getInAddr(&addr, name) != 0){ tmp.assfmt("Unable to lookup/illegal hostname %s, " "connection from node %d to node %d", - name, _ownNodeId, remoteNodeId); + name, nodeid, remoteNodeId); setError(CR_ERROR, tmp.c_str()); return false; } @@ -352,7 +357,7 @@ ConfigRetriever::verifyConfig(const struct ndb_mgm_configuration * conf){ if(Ndb_getInAddr(&addr, name) != 0){ tmp.assfmt("Unable to lookup/illegal hostname %s, " "connection from node %d to node %d", - name, _ownNodeId, remoteNodeId); + name, nodeid, remoteNodeId); setError(CR_ERROR, tmp.c_str()); return false; } diff --git a/ndb/src/common/mgmcommon/InitConfigFileParser.cpp b/ndb/src/common/mgmcommon/InitConfigFileParser.cpp index 833a2efab9d..652e0f96190 100644 --- a/ndb/src/common/mgmcommon/InitConfigFileParser.cpp +++ b/ndb/src/common/mgmcommon/InitConfigFileParser.cpp @@ -480,10 +480,6 @@ InitConfigFileParser::parseSectionHeader(const char* line) const { tmp[0] = ' '; trim(tmp); - // Convert section header to upper - for(int i= strlen(tmp)-1; i >= 0; i--) - tmp[i]= toupper(tmp[i]); - // Get the correct header name if an alias { const char *tmp_alias= m_info->getAlias(tmp); diff --git a/ndb/src/common/mgmcommon/NdbConfig.c b/ndb/src/common/mgmcommon/NdbConfig.c index baf25033b6f..c3f4abf61a7 100644 --- a/ndb/src/common/mgmcommon/NdbConfig.c +++ b/ndb/src/common/mgmcommon/NdbConfig.c @@ -19,6 +19,8 @@ #include #include +static char *datadir_path= 0; + static char* NdbConfig_AllocHomePath(int _len) { @@ -27,19 +29,27 @@ NdbConfig_AllocHomePath(int _len) int path_len= 0; char *buf; + if (path == 0) + path= datadir_path; + if (path) path_len= strlen(path); len+= path_len; buf= NdbMem_Allocate(len); if (path_len > 0) - snprintf(buf, len, "%s%c", path, DIR_SEPARATOR); + snprintf(buf, len, "%s%s", path, DIR_SEPARATOR); else buf[0]= 0; return buf; } +void +NdbConfig_SetPath(const char* path){ + datadir_path= path; +} + char* NdbConfig_NdbCfgName(int with_ndb_home){ char *buf; diff --git a/ndb/src/kernel/Makefile.am b/ndb/src/kernel/Makefile.am index 60284f6a369..a6be3244b41 100644 --- a/ndb/src/kernel/Makefile.am +++ b/ndb/src/kernel/Makefile.am @@ -52,7 +52,10 @@ LDADD += \ $(top_builddir)/ndb/src/common/mgmcommon/libmgmsrvcommon.la \ $(top_builddir)/ndb/src/mgmapi/libmgmapi.la \ $(top_builddir)/ndb/src/common/portlib/libportlib.la \ - $(top_builddir)/ndb/src/common/util/libgeneral.la + $(top_builddir)/ndb/src/common/util/libgeneral.la \ + $(top_builddir)/dbug/libdbug.a \ + $(top_builddir)/mysys/libmysys.a \ + $(top_builddir)/strings/libmystrings.a # Don't update the files from bitkeeper %::SCCS/s.% diff --git a/ndb/src/kernel/vm/Configuration.cpp b/ndb/src/kernel/vm/Configuration.cpp index 9469a39a6f5..1acc5d59f97 100644 --- a/ndb/src/kernel/vm/Configuration.cpp +++ b/ndb/src/kernel/vm/Configuration.cpp @@ -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 */ +#include +#include + #include "Configuration.hpp" #include #include "GlobalData.hpp" @@ -56,6 +59,9 @@ Configuration::init(int argc, const char** argv){ int _deamon = 0; int _help = 0; int _print_version = 0; +#ifndef DBUG_OFF + const char *debug_option= 0; +#endif /** * Arguments to NDB process @@ -66,6 +72,10 @@ Configuration::init(int argc, const char** argv){ { "nostart", 'n', arg_flag, &_no_start, "Don't start ndbd immediately. Ndbd will await command from ndb_mgmd", "" }, { "daemon", 'd', arg_flag, &_deamon, "Start ndbd as daemon", "" }, +#ifndef DBUG_OFF + { "debug", 0, arg_string, &debug_option, + "Specify debug options e.g. d:t:i:o,out.trace", "options" }, +#endif { "initial", 'i', arg_flag, &_initial, "Perform initial start of ndbd, including cleaning the file system. Consult documentation before using this", "" }, @@ -84,15 +94,17 @@ Configuration::init(int argc, const char** argv){ return false; } -#if 0 - ndbout << "no_start=" <<_no_start<< endl; - ndbout << "initial=" <<_initial<< endl; - ndbout << "deamon=" <<_deamon<< endl; - ndbout << "connect_str="<<_connect_str< #include #include @@ -512,6 +513,8 @@ MgmtSrvr::MgmtSrvr(NodeId nodeId, theConfCount(0), m_allocated_resources(*this) { + DBUG_ENTER("MgmtSrvr::MgmtSrvr"); + _config = NULL; _isStatPortActive = false; _isClusterLogStatActive = false; @@ -543,37 +546,39 @@ MgmtSrvr::MgmtSrvr(NodeId nodeId, for(Uint32 i = 0; im_configValues, CFG_SECTION_NODE); - for(ndb_mgm_first(iter); ndb_mgm_valid(iter); ndb_mgm_next(iter)){ - unsigned type, id; - if(ndb_mgm_get_int_parameter(iter, CFG_TYPE_OF_SECTION, &type) != 0) - continue; - - if(ndb_mgm_get_int_parameter(iter, CFG_NODE_ID, &id) != 0) - continue; - - MGM_REQUIRE(id < MAX_NODES); + { + ndb_mgm_configuration_iterator * iter = ndb_mgm_create_configuration_iterator + (config->m_configValues, CFG_SECTION_NODE); + for(ndb_mgm_first(iter); ndb_mgm_valid(iter); ndb_mgm_next(iter)){ + unsigned type, id; + if(ndb_mgm_get_int_parameter(iter, CFG_TYPE_OF_SECTION, &type) != 0) + continue; - switch(type){ - case NODE_TYPE_DB: - nodeTypes[id] = NDB_MGM_NODE_TYPE_NDB; - break; - case NODE_TYPE_API: - nodeTypes[id] = NDB_MGM_NODE_TYPE_API; - break; - case NODE_TYPE_MGM: - nodeTypes[id] = NDB_MGM_NODE_TYPE_MGM; - break; - case NODE_TYPE_REP: - nodeTypes[id] = NDB_MGM_NODE_TYPE_REP; - break; - case NODE_TYPE_EXT_REP: - default: - break; + if(ndb_mgm_get_int_parameter(iter, CFG_NODE_ID, &id) != 0) + continue; + + MGM_REQUIRE(id < MAX_NODES); + + switch(type){ + case NODE_TYPE_DB: + nodeTypes[id] = NDB_MGM_NODE_TYPE_NDB; + break; + case NODE_TYPE_API: + nodeTypes[id] = NDB_MGM_NODE_TYPE_API; + break; + case NODE_TYPE_MGM: + nodeTypes[id] = NDB_MGM_NODE_TYPE_MGM; + break; + case NODE_TYPE_REP: + nodeTypes[id] = NDB_MGM_NODE_TYPE_REP; + break; + case NODE_TYPE_EXT_REP: + default: + break; + } } + ndb_mgm_destroy_iterator(iter); } - ndb_mgm_destroy_iterator(iter); m_statisticsListner = NULL; @@ -589,6 +594,18 @@ MgmtSrvr::MgmtSrvr(NodeId nodeId, exit(-1); } _ownNodeId = tmp; + + + { + DBUG_PRINT("info", ("verifyConfig")); + ConfigRetriever cr(NDB_VERSION, NDB_MGM_NODE_TYPE_MGM); + if (!cr.verifyConfig(config->m_configValues, _ownNodeId)) { + ndbout << cr.getErrorString() << endl; + exit(-1); + } + } + + DBUG_VOID_RETURN; } diff --git a/ndb/src/mgmsrv/main.cpp b/ndb/src/mgmsrv/main.cpp index 511043e62c9..8e031e42ada 100644 --- a/ndb/src/mgmsrv/main.cpp +++ b/ndb/src/mgmsrv/main.cpp @@ -109,7 +109,7 @@ struct getargs args[] = { "Specify cluster configuration file", "filename" }, #ifndef DBUG_OFF { "debug", 0, arg_string, &debug_option, - "Specify debug option e.d. d:t:i:o,out.trace", "options" }, + "Specify debug options e.g. d:t:i:o,out.trace", "options" }, #endif { "daemon", 'd', arg_flag, &glob.daemon, "Run ndb_mgmd in daemon mode" }, @@ -143,8 +143,8 @@ NDB_MAIN(mgmsrv){ exit(1); } - my_init(); #ifndef DBUG_OFF + my_init(); if (debug_option) DBUG_PUSH(debug_option); #endif From 44b2807e4bb2383525c3abfd9ad896114dec0796 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 26 Aug 2004 18:26:38 +0300 Subject: [PATCH 24/54] Portability fixes Fixed bug in end space handle for WHERE text_column="constant" heap/hp_hash.c: Optimzations (no change of logic) libmysql/libmysql.c: Added missing casts (portability fix) myisam/mi_key.c: Changed macro to take arguments and not depend on local variables Simple indentation fixes ? mysql-test/r/connect.result: Added test for setting empty password mysql-test/r/create_select_tmp.result: TYPE -> ENGINE mysql-test/r/ctype_utf8.result: Combine drop's mysql-test/r/endspace.result: Added more tests to test end space behaviour mysql-test/r/having.result: Added missing DROP TABLE mysql-test/r/type_blob.result: Added more tests to ensure that fix for BLOB usage is correct mysql-test/r/type_timestamp.result: Add test from 4.0 mysql-test/t/connect.test: Added test for setting empty password mysql-test/t/create_select_tmp.test: TYPE -> ENGINE mysql-test/t/ctype_utf8.test: Combine drop's mysql-test/t/endspace.test: Added more tests to test end space behaviour mysql-test/t/having.test: Added missing DROP TABLE mysql-test/t/type_blob.test: Added more tests to ensure that fix for BLOB usage is correct mysql-test/t/type_timestamp.test: Add test from 4.0 sql/field.cc: Removed not used variable Portability fix (cast) Simplified Field_str::double() Simple indentation cleanups sql/field.h: Removed not needed class variable sql/item_cmpfunc.cc: Indentation fix sql/item_strfunc.cc: Use on stack variable for Item_str_func::val() instead of str_value. This makes it safe to use str_value inside the Item's val function. Cleaned up LEFT() usage, thanks to the above change sql/item_sum.cc: Indentation cleanups sql/protocol.cc: Added missing cast sql/sql_acl.cc: Indentatin cleanups. Added missing cast Simple optimization of get_sort() sql/sql_select.cc: Don't use 'ref' to search on text field that is not of type BINARY (use 'range' instead). The reson is that for 'ref' we use 'index_next_same' to read the next possible row. For text fields, rows in a ref may not come in order, like for 'x', 'x\t' 'x ' (stored in this order) which causes a search for 'column='x ' to fail sql/tztime.cc: Simple cleanup strings/ctype-bin.c: Comment fixes strings/ctype-mb.c: Changed variable names for arguments --- heap/hp_hash.c | 67 +++++++++++++++------------ libmysql/libmysql.c | 4 +- myisam/mi_key.c | 23 ++++----- mysql-test/r/connect.result | 1 + mysql-test/r/create_select_tmp.result | 8 ++-- mysql-test/r/ctype_utf8.result | 3 +- mysql-test/r/endspace.result | 43 ++++++++++++----- mysql-test/r/having.result | 1 + mysql-test/r/type_blob.result | 20 +++++++- mysql-test/r/type_timestamp.result | 12 +++++ mysql-test/t/connect.test | 1 + mysql-test/t/create_select_tmp.test | 8 ++-- mysql-test/t/ctype_utf8.test | 3 +- mysql-test/t/endspace.test | 12 +++-- mysql-test/t/having.test | 1 + mysql-test/t/type_blob.test | 7 +++ mysql-test/t/type_timestamp.test | 10 ++++ sql/field.cc | 38 ++++++--------- sql/field.h | 3 +- sql/item_cmpfunc.cc | 4 +- sql/item_strfunc.cc | 21 +++++---- sql/item_sum.cc | 8 ++-- sql/protocol.cc | 2 +- sql/sql_acl.cc | 10 ++-- sql/sql_select.cc | 51 +++++++++++--------- sql/tztime.cc | 11 +++-- strings/ctype-bin.c | 5 +- strings/ctype-mb.c | 41 +++++++++------- 28 files changed, 254 insertions(+), 164 deletions(-) diff --git a/heap/hp_hash.c b/heap/hp_hash.c index 8feae19a480..71eecc8bdf2 100644 --- a/heap/hp_hash.c +++ b/heap/hp_hash.c @@ -246,12 +246,12 @@ ulong hp_hashnr(register HP_KEYDEF *keydef, register const byte *key) if (seg->type == HA_KEYTYPE_TEXT) { CHARSET_INFO *cs= seg->charset; - uint length= ((uchar*)key) - pos; - uint char_length= length / cs->mbmaxlen; - if (length > char_length) + uint char_length= (uint) ((uchar*) key - pos); + if (cs->mbmaxlen > 1) { - char_length= my_charpos(cs, pos, pos + length, char_length); - set_if_smaller(char_length, length); + uint length= char_length; + char_length= my_charpos(cs, pos, pos + length, length/cs->mbmaxlen); + set_if_smaller(char_length, length); /* QQ: ok to remove? */ } cs->coll->hash_sort(cs, pos, char_length, &nr, &nr2); } @@ -289,11 +289,12 @@ ulong hp_rec_hashnr(register HP_KEYDEF *keydef, register const byte *rec) if (seg->type == HA_KEYTYPE_TEXT) { CHARSET_INFO *cs= seg->charset; - uint char_length= seg->length / cs->mbmaxlen; - if (seg->length > char_length) + uint char_length= seg->length; + if (cs->mbmaxlen > 1) { - char_length= my_charpos(cs, pos, pos + seg->length, char_length); - set_if_smaller(char_length, seg->length); + char_length= my_charpos(cs, pos, pos + char_length, + char_length / cs->mbmaxlen); + set_if_smaller(char_length, seg->length); /* QQ: ok to remove? */ } cs->coll->hash_sort(cs, pos, char_length, &nr, &nr2); } @@ -417,17 +418,17 @@ int hp_rec_key_cmp(HP_KEYDEF *keydef, const byte *rec1, const byte *rec2) if (seg->type == HA_KEYTYPE_TEXT) { CHARSET_INFO *cs= seg->charset; - uint char_length= seg->length / cs->mbmaxlen; uint char_length1; uint char_length2; uchar *pos1= (uchar*)rec1 + seg->start; uchar *pos2= (uchar*)rec2 + seg->start; - if (seg->length > char_length) + if (cs->mbmaxlen > 1) { + uint char_length= seg->length / cs->mbmaxlen; char_length1= my_charpos(cs, pos1, pos1 + seg->length, char_length); - set_if_smaller(char_length1, seg->length); + set_if_smaller(char_length1, seg->length); /* QQ: ok to remove? */ char_length2= my_charpos(cs, pos2, pos2 + seg->length, char_length); - set_if_smaller(char_length2, seg->length); + set_if_smaller(char_length2, seg->length); /* QQ: ok to remove? */ } else { @@ -468,12 +469,12 @@ int hp_key_cmp(HP_KEYDEF *keydef, const byte *rec, const byte *key) if (seg->type == HA_KEYTYPE_TEXT) { CHARSET_INFO *cs= seg->charset; - uint char_length= seg->length / cs->mbmaxlen; uint char_length_key; uint char_length_rec; uchar *pos= (uchar*) rec + seg->start; - if (seg->length > char_length) + if (cs->mbmaxlen > 1) { + uint char_length= seg->length / cs->mbmaxlen; char_length_key= my_charpos(cs, key, key + seg->length, char_length); set_if_smaller(char_length_key, seg->length); char_length_rec= my_charpos(cs, pos, pos + seg->length, char_length); @@ -509,21 +510,22 @@ void hp_make_key(HP_KEYDEF *keydef, byte *key, const byte *rec) for (seg=keydef->seg,endseg=seg+keydef->keysegs ; seg < endseg ; seg++) { CHARSET_INFO *cs= seg->charset; - uint char_length= (cs && cs->mbmaxlen > 1) ? seg->length / cs->mbmaxlen : - seg->length; + uint char_length= seg->length; uchar *pos= (uchar*) rec + seg->start; if (seg->null_bit) *key++= test(rec[seg->null_pos] & seg->null_bit); - if (seg->length > char_length) + if (cs->mbmaxlen > 1) { - char_length= my_charpos(cs, pos, pos + seg->length, char_length); - set_if_smaller(char_length, seg->length); + char_length= my_charpos(cs, pos, pos + seg->length, + char_length / cs->mbmaxlen); + set_if_smaller(char_length, seg->length); /* QQ: ok to remove? */ } memcpy(key,rec+seg->start,(size_t) char_length); key+= char_length; } } + uint hp_rb_make_key(HP_KEYDEF *keydef, byte *key, const byte *rec, byte *recpos) { @@ -575,13 +577,13 @@ uint hp_rb_make_key(HP_KEYDEF *keydef, byte *key, } continue; } - char_length= seg->length / (seg->charset ? seg->charset->mbmaxlen : 1); - if (seg->length > char_length) + char_length= seg->length; + if (seg->charset->mbmaxlen > 1) { char_length= my_charpos(seg->charset, - rec + seg->start, rec + seg->start + seg->length, - char_length); - set_if_smaller(char_length, seg->length); + rec + seg->start, rec + seg->start + char_length, + char_length / seg->charset->mbmaxlen); + set_if_smaller(char_length, seg->length); /* QQ: ok to remove? */ if (char_length < seg->length) seg->charset->cset->fill(seg->charset, key + char_length, seg->length - char_length, ' '); @@ -593,7 +595,9 @@ uint hp_rb_make_key(HP_KEYDEF *keydef, byte *key, return key - start_key; } -uint hp_rb_pack_key(HP_KEYDEF *keydef, uchar *key, const uchar *old, uint k_len) + +uint hp_rb_pack_key(HP_KEYDEF *keydef, uchar *key, const uchar *old, + uint k_len) { HA_KEYSEG *seg, *endseg; uchar *start_key= key; @@ -623,11 +627,12 @@ uint hp_rb_pack_key(HP_KEYDEF *keydef, uchar *key, const uchar *old, uint k_len) } continue; } - char_length= seg->length / (seg->charset ? seg->charset->mbmaxlen : 1); - if (seg->length > char_length) + char_length= seg->length; + if (seg->charset->mbmaxlen > 1) { - char_length= my_charpos(seg->charset, old, old+seg->length, char_length); - set_if_smaller(char_length, seg->length); + char_length= my_charpos(seg->charset, old, old+char_length, + char_length / seg->charset->mbmaxlen); + set_if_smaller(char_length, seg->length); /* QQ: ok to remove? */ if (char_length < seg->length) seg->charset->cset->fill(seg->charset, key + char_length, seg->length - char_length, ' '); @@ -639,12 +644,14 @@ uint hp_rb_pack_key(HP_KEYDEF *keydef, uchar *key, const uchar *old, uint k_len) return key - start_key; } + uint hp_rb_key_length(HP_KEYDEF *keydef, const byte *key __attribute__((unused))) { return keydef->length; } + uint hp_rb_null_key_length(HP_KEYDEF *keydef, const byte *key) { const byte *start_key= key; diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c index cea8ce3a499..8780718666d 100644 --- a/libmysql/libmysql.c +++ b/libmysql/libmysql.c @@ -3429,7 +3429,7 @@ static void fetch_long_with_conversion(MYSQL_BIND *param, MYSQL_FIELD *field, char buff[22]; /* Enough for longlong */ char *end= longlong10_to_str(value, buff, field_is_unsigned ? 10: -10); /* Resort to string conversion which supports all typecodes */ - fetch_string_with_conversion(param, buff, end - buff); + fetch_string_with_conversion(param, buff, (uint) (end - buff)); break; } } @@ -3505,7 +3505,7 @@ static void fetch_float_with_conversion(MYSQL_BIND *param, MYSQL_FIELD *field, sprintf(buff, "%.*f", (int) field->decimals, value); end= strend(buff); } - fetch_string_with_conversion(param, buff, end - buff); + fetch_string_with_conversion(param, buff, (uint) (end - buff)); break; } } diff --git a/myisam/mi_key.c b/myisam/mi_key.c index 043dd7c6884..3545756779f 100644 --- a/myisam/mi_key.c +++ b/myisam/mi_key.c @@ -23,9 +23,9 @@ #include #endif -#define CHECK_KEYS +#define CHECK_KEYS /* Enable safety checks */ -#define FIX_LENGTH \ +#define FIX_LENGTH(cs, pos, length, char_length) \ do { \ if (length > char_length) \ char_length= my_charpos(cs, pos, pos+length, char_length); \ @@ -48,7 +48,7 @@ uint _mi_make_key(register MI_INFO *info, uint keynr, uchar *key, my_bool is_ft= info->s->keyinfo[keynr].flag & HA_FULLTEXT; DBUG_ENTER("_mi_make_key"); - if(info->s->keyinfo[keynr].flag & HA_SPATIAL) + if (info->s->keyinfo[keynr].flag & HA_SPATIAL) { /* TODO: nulls processing @@ -78,7 +78,8 @@ uint _mi_make_key(register MI_INFO *info, uint keynr, uchar *key, *key++=1; /* Not NULL */ } - char_length= (!is_ft && cs && cs->mbmaxlen > 1) ? length/cs->mbmaxlen : length; + char_length= ((!is_ft && cs && cs->mbmaxlen > 1) ? length/cs->mbmaxlen : + length); pos= (byte*) record+keyseg->start; if (keyseg->flag & HA_SPACE_PACK) @@ -95,7 +96,7 @@ uint _mi_make_key(register MI_INFO *info, uint keynr, uchar *key, pos++; } length=(uint) (end-pos); - FIX_LENGTH; + FIX_LENGTH(cs, pos, length, char_length); store_key_length_inc(key,char_length); memcpy((byte*) key,(byte*) pos,(size_t) char_length); key+=char_length; @@ -106,7 +107,7 @@ uint _mi_make_key(register MI_INFO *info, uint keynr, uchar *key, uint tmp_length=uint2korr(pos); pos+=2; /* Skip VARCHAR length */ set_if_smaller(length,tmp_length); - FIX_LENGTH; + FIX_LENGTH(cs, pos, length, char_length); store_key_length_inc(key,char_length); memcpy((byte*) key,(byte*) pos,(size_t) char_length); key+= char_length; @@ -117,7 +118,7 @@ uint _mi_make_key(register MI_INFO *info, uint keynr, uchar *key, uint tmp_length=_mi_calc_blob_length(keyseg->bit_start,pos); memcpy_fixed((byte*) &pos,pos+keyseg->bit_start,sizeof(char*)); set_if_smaller(length,tmp_length); - FIX_LENGTH; + FIX_LENGTH(cs, pos, length, char_length); store_key_length_inc(key,char_length); memcpy((byte*) key,(byte*) pos,(size_t) char_length); key+= char_length; @@ -157,7 +158,7 @@ uint _mi_make_key(register MI_INFO *info, uint keynr, uchar *key, } continue; } - FIX_LENGTH; + FIX_LENGTH(cs, pos, length, char_length); memcpy((byte*) key, pos, char_length); if (length > char_length) cs->cset->fill(cs, key+char_length, length-char_length, ' '); @@ -237,7 +238,7 @@ uint _mi_pack_key(register MI_INFO *info, uint keynr, uchar *key, uchar *old, } k_length-=length; length=(uint) (end-pos); - FIX_LENGTH; + FIX_LENGTH(cs, pos, length, char_length); store_key_length_inc(key,char_length); memcpy((byte*) key,pos,(size_t) char_length); key+= char_length; @@ -250,7 +251,7 @@ uint _mi_pack_key(register MI_INFO *info, uint keynr, uchar *key, uchar *old, k_length-= 2+length; pos+=2; set_if_smaller(length,tmp_length); /* Safety */ - FIX_LENGTH; + FIX_LENGTH(cs, pos, length, char_length); store_key_length_inc(key,char_length); old+=2; /* Skip length */ memcpy((byte*) key, pos,(size_t) char_length); @@ -267,7 +268,7 @@ uint _mi_pack_key(register MI_INFO *info, uint keynr, uchar *key, uchar *old, } continue; } - FIX_LENGTH; + FIX_LENGTH(cs, pos, length, char_length); memcpy((byte*) key, pos, char_length); if (length > char_length) cs->cset->fill(cs,key+char_length, length-char_length, ' '); diff --git a/mysql-test/r/connect.result b/mysql-test/r/connect.result index ae0def02399..edf30e7f6e4 100644 --- a/mysql-test/r/connect.result +++ b/mysql-test/r/connect.result @@ -40,6 +40,7 @@ show tables; Tables_in_test update mysql.user set password=old_password("gambling2") where user=_binary"test"; flush privileges; +set password=""; set password='gambling3'; ERROR HY000: Password hash should be a 41-digit hexadecimal number set password=old_password('gambling3'); diff --git a/mysql-test/r/create_select_tmp.result b/mysql-test/r/create_select_tmp.result index 09ffc9013c7..b99bf3e3591 100644 --- a/mysql-test/r/create_select_tmp.result +++ b/mysql-test/r/create_select_tmp.result @@ -1,19 +1,19 @@ drop table if exists t1, t2; CREATE TABLE t1 ( a int ); INSERT INTO t1 VALUES (1),(2),(1); -CREATE TABLE t2 ( PRIMARY KEY (a) ) TYPE=INNODB SELECT a FROM t1; +CREATE TABLE t2 ( PRIMARY KEY (a) ) ENGINE=INNODB SELECT a FROM t1; ERROR 23000: Duplicate entry '1' for key 1 select * from t2; ERROR 42S02: Table 'test.t2' doesn't exist -CREATE TEMPORARY TABLE t2 ( PRIMARY KEY (a) ) TYPE=INNODB SELECT a FROM t1; +CREATE TEMPORARY TABLE t2 ( PRIMARY KEY (a) ) ENGINE=INNODB SELECT a FROM t1; ERROR 23000: Duplicate entry '1' for key 1 select * from t2; ERROR 42S02: Table 'test.t2' doesn't exist -CREATE TABLE t2 ( PRIMARY KEY (a) ) TYPE=MYISAM SELECT a FROM t1; +CREATE TABLE t2 ( PRIMARY KEY (a) ) ENGINE=MYISAM SELECT a FROM t1; ERROR 23000: Duplicate entry '1' for key 1 select * from t2; ERROR 42S02: Table 'test.t2' doesn't exist -CREATE TEMPORARY TABLE t2 ( PRIMARY KEY (a) ) TYPE=MYISAM SELECT a FROM t1; +CREATE TEMPORARY TABLE t2 ( PRIMARY KEY (a) ) ENGINE=MYISAM SELECT a FROM t1; ERROR 23000: Duplicate entry '1' for key 1 select * from t2; ERROR 42S02: Table 'test.t2' doesn't exist diff --git a/mysql-test/r/ctype_utf8.result b/mysql-test/r/ctype_utf8.result index 38fc8e17d14..f3be539251a 100644 --- a/mysql-test/r/ctype_utf8.result +++ b/mysql-test/r/ctype_utf8.result @@ -1,5 +1,4 @@ -drop table if exists t1; -drop table if exists t2; +drop table if exists t1,t2; set names utf8; select left(_utf8 0xD0B0D0B1D0B2,1); left(_utf8 0xD0B0D0B1D0B2,1) diff --git a/mysql-test/r/endspace.result b/mysql-test/r/endspace.result index 167adea6674..bca1717eeba 100644 --- a/mysql-test/r/endspace.result +++ b/mysql-test/r/endspace.result @@ -52,13 +52,13 @@ select * from t1 ignore key (key1) where text1='teststring' or text1 like 'tests text1 teststring teststring -select * from t1 where text1='teststring' or text1 like 'teststring_%'; -text1 -teststring -teststring -select * from t1 where text1='teststring' or text1 > 'teststring\t'; -text1 -teststring +select concat('|', text1, '|') from t1 where text1='teststring' or text1 like 'teststring_%'; +concat('|', text1, '|') +|teststring | +|teststring| +select concat('|', text1, '|') from t1 where text1='teststring' or text1 > 'teststring\t'; +concat('|', text1, '|') +|teststring| select text1, length(text1) from t1 order by text1; text1 length(text1) nothing 7 @@ -77,7 +77,28 @@ concat('|', text1, '|') |teststring| |teststring | |teststring | +select concat('|', text1, '|') from t1 where text1='teststring' or text1 > 'teststring\t'; +concat('|', text1, '|') +|teststring| +|teststring | +select concat('|', text1, '|') from t1 where text1='teststring'; +concat('|', text1, '|') +|teststring| +select concat('|', text1, '|') from t1 where text1='teststring '; +concat('|', text1, '|') +|teststring | alter table t1 modify text1 text not null, pack_keys=1; +select concat('|', text1, '|') from t1 where text1='teststring'; +concat('|', text1, '|') +|teststring| +|teststring | +select concat('|', text1, '|') from t1 where text1='teststring '; +concat('|', text1, '|') +|teststring| +|teststring | +explain select concat('|', text1, '|') from t1 where text1='teststring '; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range key1 key1 22 NULL 2 Using where select * from t1 where text1 like 'teststring_%'; text1 teststring @@ -87,10 +108,10 @@ text1 teststring teststring teststring -select * from t1 where text1='teststring' or text1 > 'teststring\t'; -text1 -teststring -teststring +select concat('|', text1, '|') from t1 where text1='teststring' or text1 > 'teststring\t'; +concat('|', text1, '|') +|teststring| +|teststring | select concat('|', text1, '|') from t1 order by text1; concat('|', text1, '|') |nothing| diff --git a/mysql-test/r/having.result b/mysql-test/r/having.result index f7e0bbf3e2c..218276406b1 100644 --- a/mysql-test/r/having.result +++ b/mysql-test/r/having.result @@ -127,3 +127,4 @@ having (a.description is not null) and (c=0); id description c 1 test 0 2 test2 0 +drop table t1,t2,t3; diff --git a/mysql-test/r/type_blob.result b/mysql-test/r/type_blob.result index 580fc9a8d0b..95bba1d4ec7 100644 --- a/mysql-test/r/type_blob.result +++ b/mysql-test/r/type_blob.result @@ -593,9 +593,12 @@ create table t1 (id integer primary key auto_increment, txt text, unique index t insert into t1 (txt) values ('Chevy'), ('Chevy '), (NULL); select * from t1 where txt='Chevy' or txt is NULL; id txt +3 NULL 1 Chevy 2 Chevy -3 NULL +explain select * from t1 where txt='Chevy' or txt is NULL; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range txt_index txt_index 23 NULL 2 Using where select * from t1 where txt='Chevy '; id txt 1 Chevy @@ -663,6 +666,21 @@ id txt 1 Chevy 2 Chevy 4 Ford +alter table t1 modify column txt blob; +explain select * from t1 where txt='Chevy' or txt is NULL; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ref_or_null txt_index txt_index 23 const 2 Using where +select * from t1 where txt='Chevy' or txt is NULL; +id txt +1 Chevy +3 NULL +explain select * from t1 where txt='Chevy' or txt is NULL order by txt; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ref_or_null txt_index txt_index 23 const 2 Using where; Using filesort +select * from t1 where txt='Chevy' or txt is NULL order by txt; +id txt +3 NULL +1 Chevy drop table t1; CREATE TABLE t1 ( i int(11) NOT NULL default '0', c text NOT NULL, PRIMARY KEY (i), KEY (c(1),c(1))); INSERT t1 VALUES (1,''),(2,''),(3,'asdfh'),(4,''); diff --git a/mysql-test/r/type_timestamp.result b/mysql-test/r/type_timestamp.result index aa8c0903558..425e4a05586 100644 --- a/mysql-test/r/type_timestamp.result +++ b/mysql-test/r/type_timestamp.result @@ -365,3 +365,15 @@ select * from t1; t1 i 2004-04-01 00:00:00 10 drop table t1; +create table t1 (ts timestamp(19)); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `ts` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +set TIMESTAMP=1000000000; +insert into t1 values (); +select * from t1; +ts +2001-09-09 04:46:40 +drop table t1; diff --git a/mysql-test/t/connect.test b/mysql-test/t/connect.test index c1ecf176470..4598ca5ea15 100644 --- a/mysql-test/t/connect.test +++ b/mysql-test/t/connect.test @@ -48,6 +48,7 @@ flush privileges; #connect (con1,localhost,test,gambling2,""); #show tables; connect (con1,localhost,test,gambling2,mysql); +set password=""; --error 1105 set password='gambling3'; set password=old_password('gambling3'); diff --git a/mysql-test/t/create_select_tmp.test b/mysql-test/t/create_select_tmp.test index 166d32fb17c..d81a3799d98 100644 --- a/mysql-test/t/create_select_tmp.test +++ b/mysql-test/t/create_select_tmp.test @@ -12,18 +12,18 @@ drop table if exists t1, t2; CREATE TABLE t1 ( a int ); INSERT INTO t1 VALUES (1),(2),(1); --error 1062; -CREATE TABLE t2 ( PRIMARY KEY (a) ) TYPE=INNODB SELECT a FROM t1; +CREATE TABLE t2 ( PRIMARY KEY (a) ) ENGINE=INNODB SELECT a FROM t1; --error 1146; select * from t2; --error 1062; -CREATE TEMPORARY TABLE t2 ( PRIMARY KEY (a) ) TYPE=INNODB SELECT a FROM t1; +CREATE TEMPORARY TABLE t2 ( PRIMARY KEY (a) ) ENGINE=INNODB SELECT a FROM t1; --error 1146; select * from t2; --error 1062; -CREATE TABLE t2 ( PRIMARY KEY (a) ) TYPE=MYISAM SELECT a FROM t1; +CREATE TABLE t2 ( PRIMARY KEY (a) ) ENGINE=MYISAM SELECT a FROM t1; --error 1146; select * from t2; --error 1062; -CREATE TEMPORARY TABLE t2 ( PRIMARY KEY (a) ) TYPE=MYISAM SELECT a FROM t1; +CREATE TEMPORARY TABLE t2 ( PRIMARY KEY (a) ) ENGINE=MYISAM SELECT a FROM t1; --error 1146; select * from t2; diff --git a/mysql-test/t/ctype_utf8.test b/mysql-test/t/ctype_utf8.test index 4624f2ec78c..2c531d4e5d2 100644 --- a/mysql-test/t/ctype_utf8.test +++ b/mysql-test/t/ctype_utf8.test @@ -3,8 +3,7 @@ # --disable_warnings -drop table if exists t1; -drop table if exists t2; +drop table if exists t1,t2; --enable_warnings set names utf8; diff --git a/mysql-test/t/endspace.test b/mysql-test/t/endspace.test index a9933ff93b5..9ee5e32967a 100644 --- a/mysql-test/t/endspace.test +++ b/mysql-test/t/endspace.test @@ -31,19 +31,25 @@ explain select * from t1 order by text1; alter table t1 modify text1 char(32) binary not null; check table t1; select * from t1 ignore key (key1) where text1='teststring' or text1 like 'teststring_%'; -select * from t1 where text1='teststring' or text1 like 'teststring_%'; -select * from t1 where text1='teststring' or text1 > 'teststring\t'; +select concat('|', text1, '|') from t1 where text1='teststring' or text1 like 'teststring_%'; +select concat('|', text1, '|') from t1 where text1='teststring' or text1 > 'teststring\t'; select text1, length(text1) from t1 order by text1; select text1, length(text1) from t1 order by binary text1; alter table t1 modify text1 blob not null, drop key key1, add key key1 (text1(20)); insert into t1 values ('teststring '); select concat('|', text1, '|') from t1 order by text1; +select concat('|', text1, '|') from t1 where text1='teststring' or text1 > 'teststring\t'; +select concat('|', text1, '|') from t1 where text1='teststring'; +select concat('|', text1, '|') from t1 where text1='teststring '; alter table t1 modify text1 text not null, pack_keys=1; +select concat('|', text1, '|') from t1 where text1='teststring'; +select concat('|', text1, '|') from t1 where text1='teststring '; +explain select concat('|', text1, '|') from t1 where text1='teststring '; select * from t1 where text1 like 'teststring_%'; select * from t1 where text1='teststring' or text1 like 'teststring_%'; -select * from t1 where text1='teststring' or text1 > 'teststring\t'; +select concat('|', text1, '|') from t1 where text1='teststring' or text1 > 'teststring\t'; select concat('|', text1, '|') from t1 order by text1; drop table t1; diff --git a/mysql-test/t/having.test b/mysql-test/t/having.test index 870f57a4483..12a44fd75dc 100644 --- a/mysql-test/t/having.test +++ b/mysql-test/t/having.test @@ -121,3 +121,4 @@ select from t1 a left join t3 b on a.id=b.order_id group by a.id, a.description having (a.description is not null) and (c=0); +drop table t1,t2,t3; diff --git a/mysql-test/t/type_blob.test b/mysql-test/t/type_blob.test index 8c6cabd997b..bd571deff49 100644 --- a/mysql-test/t/type_blob.test +++ b/mysql-test/t/type_blob.test @@ -340,6 +340,7 @@ drop table t1; create table t1 (id integer primary key auto_increment, txt text, unique index txt_index (txt (20))); insert into t1 (txt) values ('Chevy'), ('Chevy '), (NULL); select * from t1 where txt='Chevy' or txt is NULL; +explain select * from t1 where txt='Chevy' or txt is NULL; select * from t1 where txt='Chevy '; select * from t1 where txt='Chevy ' or txt='Chevy'; select * from t1 where txt='Chevy' or txt='Chevy '; @@ -358,7 +359,13 @@ select * from t1 where txt < 'Chevy ' or txt is NULL; select * from t1 where txt <= 'Chevy'; select * from t1 where txt > 'Chevy'; select * from t1 where txt >= 'Chevy'; +alter table t1 modify column txt blob; +explain select * from t1 where txt='Chevy' or txt is NULL; +select * from t1 where txt='Chevy' or txt is NULL; +explain select * from t1 where txt='Chevy' or txt is NULL order by txt; +select * from t1 where txt='Chevy' or txt is NULL order by txt; drop table t1; + CREATE TABLE t1 ( i int(11) NOT NULL default '0', c text NOT NULL, PRIMARY KEY (i), KEY (c(1),c(1))); INSERT t1 VALUES (1,''),(2,''),(3,'asdfh'),(4,''); select max(i) from t1 where c = ''; diff --git a/mysql-test/t/type_timestamp.test b/mysql-test/t/type_timestamp.test index 9b3abc9f155..a644197f757 100644 --- a/mysql-test/t/type_timestamp.test +++ b/mysql-test/t/type_timestamp.test @@ -234,3 +234,13 @@ alter table t1 add i int default 10; select * from t1; drop table t1; + +# Test for bug #4491, TIMESTAMP(19) should be possible to create and not +# only read in 4.0 +# +create table t1 (ts timestamp(19)); +show create table t1; +set TIMESTAMP=1000000000; +insert into t1 values (); +select * from t1; +drop table t1; diff --git a/sql/field.cc b/sql/field.cc index bbb91fc534d..5356fbc773a 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -1753,7 +1753,7 @@ void Field_medium::sql_type(String &res) const int Field_long::store(const char *from,uint len,CHARSET_INFO *cs) { long tmp; - int error= 0, cuted_fields= 0; + int error= 0; char *end; tmp= cs->cset->scan(cs, from, from+len, MY_SEQ_SPACES); @@ -1781,7 +1781,7 @@ int Field_long::store(const char *from,uint len,CHARSET_INFO *cs) #if SIZEOF_LONG > 4 if (unsigned_flag) { - if (tmp > UINT_MAX32) + if ((ulong) tmp > UINT_MAX32) { tmp= UINT_MAX32; error= 1; @@ -4277,27 +4277,17 @@ int Field_string::store(const char *from,uint length,CHARSET_INFO *cs) int Field_str::store(double nr) { - bool use_scientific_notation=TRUE; char buff[DOUBLE_TO_STRING_CONVERSION_BUFFER_SIZE]; uint length; - if (field_length < 32 && nr > 1) // TODO: negative numbers - { - if (ceiling == 0) - { - static double e[]= {1e1, 1e2, 1e4, 1e8, 1e16 }; - double p= 1; - for (int i= sizeof(e)/sizeof(e[0]), j= 1<>= 1 ) - { - if (field_length & j) - p*= e[i]; - } - ceiling= p-1; - } - use_scientific_notation= (ceiling < nr); - } - length= (uint)sprintf(buff, "%-.*g", - use_scientific_notation ? max(0,(int)field_length-5) : field_length, - nr); + bool use_scientific_notation= TRUE; + use_scientific_notation= TRUE; +if (field_length < 32 && fabs(nr) < log_10[field_length]-1) + use_scientific_notation= FALSE; + length= (uint) my_sprintf(buff, (buff, "%-.*g", + (use_scientific_notation ? + max(0, (int)field_length-5) : + field_length), + nr)); /* +1 below is because "precision" in %g above means the max. number of significant digits, not the output width. @@ -4310,6 +4300,7 @@ int Field_str::store(double nr) return store((const char *)buff, min(length, field_length), charset()); } + int Field_string::store(longlong nr) { char buff[64]; @@ -4403,9 +4394,8 @@ char *Field_string::pack(char *to, const char *from, uint max_length) char *Field_string::pack_key(char *to, const char *from, uint max_length) { - int length=min(field_length,max_length); - uint char_length= (field_charset->mbmaxlen > 1) ? - max_length/field_charset->mbmaxlen : max_length; + uint length= min(field_length,max_length); + uint char_length= max_length/field_charset->mbmaxlen; if (length > char_length) char_length= my_charpos(field_charset, from, from+length, char_length); set_if_smaller(length, char_length); diff --git a/sql/field.h b/sql/field.h index eaf90ddc0ff..9cce7b9541b 100644 --- a/sql/field.h +++ b/sql/field.h @@ -336,14 +336,13 @@ public: class Field_str :public Field { protected: CHARSET_INFO *field_charset; - double ceiling; // for ::store(double nr) public: Field_str(char *ptr_arg,uint32 len_arg, uchar *null_ptr_arg, uchar null_bit_arg, utype unireg_check_arg, const char *field_name_arg, struct st_table *table_arg,CHARSET_INFO *charset) :Field(ptr_arg, len_arg, null_ptr_arg, null_bit_arg, - unireg_check_arg, field_name_arg, table_arg), ceiling(0.0) + unireg_check_arg, field_name_arg, table_arg) { field_charset=charset; if (charset->state & MY_CS_BINSORT) diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index 5ad4cf92959..bf7813eb9ba 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -1732,8 +1732,8 @@ bool Item_func_in::nulls_in_row() static int srtcmp_in(CHARSET_INFO *cs, const String *x,const String *y) { return cs->coll->strnncollsp(cs, - (unsigned char *) x->ptr(),x->length(), - (unsigned char *) y->ptr(),y->length()); + (uchar *) x->ptr(),x->length(), + (uchar *) y->ptr(),y->length()); } diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index ecfeff02cac..fac73a1a759 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -39,7 +39,8 @@ C_MODE_END String my_empty_string("",default_charset_info); -static void my_coll_agg_error(DTCollation &c1, DTCollation &c2, const char *fname) +static void my_coll_agg_error(DTCollation &c1, DTCollation &c2, + const char *fname) { my_error(ER_CANT_AGGREGATE_2COLLATIONS,MYF(0), c1.collation->name,c1.derivation_name(), @@ -62,8 +63,9 @@ double Item_str_func::val() { DBUG_ASSERT(fixed == 1); int err; - String *res; - res=val_str(&str_value); + char buff[64]; + String *res, tmp(buff,sizeof(buff), &my_charset_bin); + res= val_str(&tmp); return res ? my_strntod(res->charset(), (char*) res->ptr(),res->length(), NULL, &err) : 0.0; } @@ -72,8 +74,9 @@ longlong Item_str_func::val_int() { DBUG_ASSERT(fixed == 1); int err; - String *res; - res=val_str(&str_value); + char buff[22]; + String *res, tmp(buff,sizeof(buff), &my_charset_bin); + res= val_str(&tmp); return (res ? my_strntoll(res->charset(), res->ptr(), res->length(), 10, NULL, &err) : @@ -986,10 +989,7 @@ String *Item_func_left::val_str(String *str) if (res->length() <= (uint) length || res->length() <= (char_pos= res->charpos(length))) return res; - if (&str_value == res) - str_value.length(char_pos); - else - str_value.set(*res, 0, char_pos); + str_value.set(*res, 0, char_pos); return &str_value; } @@ -2200,7 +2200,8 @@ String *Item_func_conv_charset::val_str(String *str) null_value=1; return 0; } - null_value= str_value.copy(arg->ptr(),arg->length(),arg->charset(),conv_charset); + null_value= str_value.copy(arg->ptr(),arg->length(),arg->charset(), + conv_charset); return null_value ? 0 : &str_value; } diff --git a/sql/item_sum.cc b/sql/item_sum.cc index cbb4cd41046..0ec8baf97bb 100644 --- a/sql/item_sum.cc +++ b/sql/item_sum.cc @@ -1945,13 +1945,12 @@ void Item_func_group_concat::reset_field() bool Item_func_group_concat::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref) { + uint i; /* for loop variable */ DBUG_ASSERT(fixed == 0); if (save_args_for_prepared_statement(thd)) return 1; - uint i; /* for loop variable */ - if (!thd->allow_sum_func) { my_error(ER_INVALID_GROUP_FUNC_USE,MYF(0)); @@ -1971,7 +1970,7 @@ Item_func_group_concat::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref) if (args[i]->fix_fields(thd, tables, args + i) || args[i]->check_cols(1)) return 1; if (i < arg_count_field) - maybe_null |= args[i]->maybe_null; + maybe_null|= args[i]->maybe_null; } result_field= 0; @@ -2048,7 +2047,8 @@ bool Item_func_group_concat::setup(THD *thd) of a record instead of a pointer of one. */ if (!(table=create_tmp_table(thd, tmp_table_param, all_fields, - (ORDER*) 0, 0, TRUE,select_lex->options | thd->options, + (ORDER*) 0, 0, TRUE, + select_lex->options | thd->options, HA_POS_ERROR,(char *) ""))) DBUG_RETURN(1); table->file->extra(HA_EXTRA_NO_ROWS); diff --git a/sql/protocol.cc b/sql/protocol.cc index 7c4b09ac3e3..da2a285fffc 100644 --- a/sql/protocol.cc +++ b/sql/protocol.cc @@ -200,7 +200,7 @@ net_printf(THD *thd, uint errcode, ...) 2+SQLSTATE_LENGTH+1 : 2) : 0); #ifndef EMBEDDED_LIBRARY text_pos=(char*) net->buff + head_length + offset + 1; - length=(char*)net->buff_end-text_pos; + length= (uint) ((char*)net->buff_end - text_pos); #else length=sizeof(text_pos)-1; #endif diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index f60897bf62b..fd3d27099ed 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -551,21 +551,19 @@ static ulong get_sort(uint count,...) uint chars= 0; uint wild_pos= 0; /* first wildcard position */ - if (start= str) + if ((start= str)) { for (; *str ; str++) { if (*str == wild_many || *str == wild_one || *str == wild_prefix) { - wild_pos= str - start + 1; + wild_pos= (uint) (str - start) + 1; break; } - else - chars++; + chars= 128; // Marker that chars existed } } - sort= (sort << 8) + (wild_pos ? (wild_pos > 127 ? 127 : wild_pos) : - (chars ? 128 : 0)); + sort= (sort << 8) + (wild_pos ? min(wild_pos, 127) : chars); } va_end(args); return sort; diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 6fdc1c2bfc3..4ca8008c518 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -833,7 +833,8 @@ JOIN::optimize() ((group_list && const_tables != tables && (!simple_group || !test_if_skip_sort_order(&join_tab[const_tables], group_list, - unit->select_limit_cnt, 0))) || select_distinct) && + unit->select_limit_cnt, 0))) || + select_distinct) && tmp_table_param.quick_group && !procedure) { need_tmp=1; simple_order=simple_group=0; // Force tmp table without sort @@ -2163,22 +2164,32 @@ add_key_field(KEY_FIELD **key_fields,uint and_level, COND *cond, number. cmp_type() is checked to allow compare of dates to numbers. eq_func is NEVER true when num_values > 1 */ - if (!eq_func || - field->result_type() == STRING_RESULT && - (*value)->result_type() != STRING_RESULT && - field->cmp_type() != (*value)->result_type()) - return; - - /* - We can't use indexes if the effective collation - of the operation differ from the field collation. - */ - if (field->result_type() == STRING_RESULT && - (*value)->result_type() == STRING_RESULT && - field->cmp_type() == STRING_RESULT && - ((Field_str*)field)->charset() != cond->compare_collation()) - return; + if (!eq_func) + return; + if (field->result_type() == STRING_RESULT) + { + if ((*value)->result_type() != STRING_RESULT) + { + if (field->cmp_type() != (*value)->result_type()) + return; + } + else + { + /* + We can't use indexes if the effective collation + of the operation differ from the field collation. + We can also not used index on a text column, as the column may + contain 'x' 'x\t' 'x ' and 'read_next_same' will stop after + 'x' when searching for WHERE col='x ' + */ + if (field->cmp_type() == STRING_RESULT && + (((Field_str*)field)->charset() != cond->compare_collation() || + ((*value)->type() != Item::NULL_ITEM && + (field->flags & BLOB_FLAG) && !field->binary()))) + return; + } + } } } DBUG_ASSERT(num_values == 1); @@ -5564,9 +5575,7 @@ bool create_myisam_from_heap(THD *thd, TABLE *table, TMP_TABLE_PARAM *param, table->file->info(HA_STATUS_VARIABLE); /* update table->file->records */ new_table.file->start_bulk_insert(table->file->records); #else - /* - HA_EXTRA_WRITE_CACHE can stay until close, no need to disable it explicitly. - */ + /* HA_EXTRA_WRITE_CACHE can stay until close, no need to disable it */ new_table.file->extra(HA_EXTRA_WRITE_CACHE); #endif @@ -7234,9 +7243,9 @@ test_if_skip_sort_order(JOIN_TAB *tab,ORDER *order,ha_rows select_limit, keys.merge(table->used_keys); /* - We are adding here also the index speified in FORCE INDEX clause, + We are adding here also the index specified in FORCE INDEX clause, if any. - This is to allow users to use index in ORDER BY. + This is to allow users to use index in ORDER BY. */ if (table->force_index) keys.merge(table->keys_in_use_for_query); diff --git a/sql/tztime.cc b/sql/tztime.cc index 757272d332f..610f75f1643 100644 --- a/sql/tztime.cc +++ b/sql/tztime.cc @@ -2158,20 +2158,21 @@ my_tz_find(const String * name, TABLE_LIST *tz_tables) if (!(result_tz= new (&tz_storage) Time_zone_offset(offset)) || my_hash_insert(&offset_tzs, (const byte *) result_tz)) { + result_tz= 0; sql_print_error("Fatal error: Out of memory " "while setting new time zone"); - result_tz= 0; } } - } else { + } + else + { + result_tz= 0; if ((tmp_tzname= (TZ_NAMES_ENTRY *)hash_search(&tz_names, (const byte *)name->ptr(), name->length()))) result_tz= tmp_tzname->tz; - else if(time_zone_tables_exist) + else if (time_zone_tables_exist) result_tz= tz_load_from_open_tables(name, tz_tables); - else - result_tz= 0; } VOID(pthread_mutex_unlock(&tz_LOCK)); diff --git a/strings/ctype-bin.c b/strings/ctype-bin.c index e759a5654f1..a33398fa6fa 100644 --- a/strings/ctype-bin.c +++ b/strings/ctype-bin.c @@ -93,7 +93,7 @@ static int my_strnncoll_binary(CHARSET_INFO * cs __attribute__((unused)), NOTE This function is used for real binary strings, i.e. for BLOB, BINARY(N) and VARBINARY(N). - It does not ignore trailing spaces. + It compares trailing spaces as spaces. RETURN < 0 s < t @@ -133,7 +133,8 @@ static int my_strnncoll_8bit_bin(CHARSET_INFO * cs __attribute__((unused)), NOTE This function is used for character strings with binary collations. - It ignores trailing spaces. + The shorter string is extended with end space to be as long as the longer + one. RETURN < 0 s < t diff --git a/strings/ctype-mb.c b/strings/ctype-mb.c index ecafa6356d5..34c2d887247 100644 --- a/strings/ctype-mb.c +++ b/strings/ctype-mb.c @@ -237,7 +237,8 @@ int my_wildcmp_mb(CHARSET_INFO *cs, if (str++ == str_end) return (-1); } { - int tmp=my_wildcmp_mb(cs,str,str_end,wildstr,wildend,escape,w_one,w_many); + int tmp=my_wildcmp_mb(cs,str,str_end,wildstr,wildend,escape,w_one, + w_many); if (tmp <= 0) return (tmp); } @@ -248,41 +249,46 @@ int my_wildcmp_mb(CHARSET_INFO *cs, return (str != str_end ? 1 : 0); } + uint my_numchars_mb(CHARSET_INFO *cs __attribute__((unused)), - const char *b, const char *e) + const char *pos, const char *end) { - register uint32 n=0,mblen; - while (b < e) + register uint32 count=0; + while (pos < end) { - b+= (mblen= my_ismbchar(cs,b,e)) ? mblen : 1; - ++n; + uint mblen; + pos+= (mblen= my_ismbchar(cs,pos,end)) ? mblen : 1; + count++; } - return n; + return count; } + uint my_charpos_mb(CHARSET_INFO *cs __attribute__((unused)), - const char *b, const char *e, uint pos) + const char *pos, const char *end, uint length) { - uint mblen; - const char *b0=b; + const char *start= pos; - while (pos && bcset->mb_wc(cs, &wc, (uchar*) b, (uchar*) e)) <0) break; b+= mblen; @@ -374,7 +380,8 @@ static int my_strnncoll_mb_bin(CHARSET_INFO * cs __attribute__((unused)), NOTE This function is used for character strings with binary collations. - It ignores trailing spaces. + The shorter string is extended with end space to be as long as the longer + one. RETURN A negative number if s < t From 1275b4c51314db24615efd7996a1d5266a03d2ba Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 26 Aug 2004 17:30:53 +0200 Subject: [PATCH 25/54] 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. include/m_string.h: Extend the "fake" approach from 'strtoull()' onto 'strtoll()'. strings/strto.c: Ensure that calling file has included necessary headers, as these are needed at the upper level already. strings/strtol.c: Cleanup/alignment with the "long long" functions. strings/strtoll.c: When "long" is 64 bit already, system function 'strtol()' can be used. Header files 'my_global.h' and 'm_string.h' will manage that, if they are included early enough. strings/strtoul.c: Cleanup/alignment with the "long long" functions. strings/strtoull.c: When "long" is 64 bit already, system function 'strtoul()' can be used. Header files 'my_global.h' and 'm_string.h' will manage that, if they are included early enough. BitKeeper/etc/logging_ok: Logging to logging@openlogging.org accepted --- BitKeeper/etc/logging_ok | 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 ++++++++++++- 7 files changed, 49 insertions(+), 7 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/include/m_string.h b/include/m_string.h index 0709dbaffb4..97d34421537 100644 --- a/include/m_string.h +++ b/include/m_string.h @@ -238,6 +238,9 @@ longlong my_strtoll10(const char *nptr, char **endptr, int *error); #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 52efec6e087..9e10b935834 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..32a7bc62298 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 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_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 82257f94f411b678da753b3ccb7e883621189eb1 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 26 Aug 2004 18:22:22 +0200 Subject: [PATCH 26/54] after merge sql/item_row.cc: ds20 compat fix --- sql/item_row.cc | 3 ++- sql/log.cc | 38 +++++++++++++++++++------------------- sql/sql_base.cc | 4 ++-- tests/client_test.c | 2 +- 4 files changed, 24 insertions(+), 23 deletions(-) diff --git a/sql/item_row.cc b/sql/item_row.cc index c7e4bc0acf4..f6623e80734 100644 --- a/sql/item_row.cc +++ b/sql/item_row.cc @@ -66,7 +66,8 @@ bool Item_row::fix_fields(THD *thd, TABLE_LIST *tabl, Item **ref) // we can't assign 'item' before, because fix_fields() can change arg Item *item= *arg; used_tables_cache |= item->used_tables(); - if (const_item_cache&= item->const_item() && !with_null) + const_item_cache&= item->const_item() && !with_null; + if (const_item_cache) { if (item->cols() > 1) with_null|= item->null_inside(); diff --git a/sql/log.cc b/sql/log.cc index 870242eac31..f4ec5d9c731 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -1,15 +1,15 @@ /* Copyright (C) 2000-2003 MySQL AB - + This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ @@ -43,31 +43,31 @@ static bool test_if_number(const char *str, #ifdef __NT__ static int eventSource = 0; -void setupWindowsEventSource() +void setupWindowsEventSource() { if (eventSource) return; eventSource = 1; - HKEY hRegKey = NULL; + 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", + 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); - + 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, + DWORD dwTypes = EVENTLOG_ERROR_TYPE | EVENTLOG_WARNING_TYPE | EVENTLOG_INFORMATION_TYPE; + dwError = RegSetValueEx(hRegKey, "TypesSupported", 0, REG_DWORD, (LPBYTE) &dwTypes, sizeof dwTypes); RegCloseKey(hRegKey); @@ -2200,6 +2200,8 @@ void MYSQL_LOG::report_pos_in_innodb() my_b_tell(&log_file)); } #endif + DBUG_VOID_RETURN; +} #ifdef __NT__ void print_buffer_to_nt_eventlog(enum loglevel level, char *buff, int buffLen) @@ -2241,7 +2243,6 @@ void print_buffer_to_nt_eventlog(enum loglevel level, char *buff, int buffLen) if (buffptr != buff) delete[] buffptr; - DBUG_VOID_RETURN; } #endif @@ -2253,7 +2254,7 @@ void print_buffer_to_nt_eventlog(enum loglevel level, char *buff, int buffLen) 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 + args va_list list of arguments for the message NOTE @@ -2267,7 +2268,6 @@ void print_buffer_to_nt_eventlog(enum loglevel level, char *buff, int buffLen) 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); @@ -2286,7 +2286,7 @@ void vprint_msg_to_log(enum loglevel level, const char *format, va_list args) } -void sql_print_error(const char *format, ...) +void sql_print_error(const char *format, ...) { DBUG_ENTER("sql_print_error"); @@ -2298,7 +2298,7 @@ void sql_print_error(const char *format, ...) DBUG_VOID_RETURN; } -void sql_print_warning(const char *format, ...) +void sql_print_warning(const char *format, ...) { DBUG_ENTER("sql_print_warning"); @@ -2310,7 +2310,7 @@ void sql_print_warning(const char *format, ...) DBUG_VOID_RETURN; } -void sql_print_information(const char *format, ...) +void sql_print_information(const char *format, ...) { DBUG_ENTER("sql_print_information"); diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 255f04d853b..ea7b4521247 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -2449,8 +2449,8 @@ insert_fields(THD *thd,TABLE_LIST *tables, const char *db_name, 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 ); + strmake(name_buff, db_name, sizeof(name_buff)-1); + my_casedn_str(system_charset_info,name_buff); db_name = name_buff; } diff --git a/tests/client_test.c b/tests/client_test.c index de77d4517dd..825e866315e 100644 --- a/tests/client_test.c +++ b/tests/client_test.c @@ -10142,7 +10142,7 @@ static void get_options(int argc, char **argv) int ho_error; if ((ho_error= handle_options(&argc, &argv, client_test_long_options, - get_one_option))) + get_one_option, 0))) exit(ho_error); if (tty_password) From 68750ccfda19440a2a844dc92872b969539cdf06 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 26 Aug 2004 18:25:48 +0200 Subject: [PATCH 27/54] Fixed wrong number of fragment records in DIH Fixed bug in failed create table Fixed new test case for failed create table using new ERROR_INSERT ndb/src/kernel/blocks/ERROR_codes.txt: Added new error insert for test of failed create table ndb/src/kernel/blocks/dbdih/DbdihMain.cpp: Added new error insert for test of failed create table Fixed bug in handling failed create table Moved some constants to pc.hpp ndb/src/kernel/vm/Configuration.cpp: Added new error insert for test of failed create table Fixed bug in handling failed create table Moved some constants to pc.hpp ndb/src/kernel/vm/pc.hpp: Constants moved here from DIH ndb/test/ndbapi/testDict.cpp: New test case for failed create table --- ndb/src/kernel/blocks/ERROR_codes.txt | 7 ++++- ndb/src/kernel/blocks/dbdih/DbdihMain.cpp | 23 ++++++++------ ndb/src/kernel/vm/Configuration.cpp | 8 +++-- ndb/src/kernel/vm/pc.hpp | 7 +++++ ndb/test/ndbapi/testDict.cpp | 38 +++++++++++++---------- 5 files changed, 54 insertions(+), 29 deletions(-) diff --git a/ndb/src/kernel/blocks/ERROR_codes.txt b/ndb/src/kernel/blocks/ERROR_codes.txt index af575de4f62..43532a973f9 100644 --- a/ndb/src/kernel/blocks/ERROR_codes.txt +++ b/ndb/src/kernel/blocks/ERROR_codes.txt @@ -5,7 +5,7 @@ Next DBACC 3001 Next DBTUP 4007 Next DBLQH 5040 Next DBDICT 6006 -Next DBDIH 7173 +Next DBDIH 7174 Next DBTC 8035 Next CMVMI 9000 Next BACKUP 10022 @@ -387,6 +387,11 @@ Backup Stuff: 5028: Crash when receiving LQHKEYREQ (in non-master) +Failed Create Table: +-------------------- +7173: Create table failed due to not sufficient number of fragment or + replica records. + Drop Table/Index: ----------------- 4001: Crash on REL_TABMEMREQ in TUP diff --git a/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp b/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp index a49c27e7b08..9498f3f41d5 100644 --- a/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp +++ b/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp @@ -6425,6 +6425,10 @@ void Dbdih::execDIADDTABREQ(Signal* signal) tabPtr.p->totalfragments = noFragments; ndbrequire(noReplicas == cnoReplicas); // Only allowed + if (ERROR_INSERTED(7173)) { + addtabrefuseLab(signal, connectPtr, ZREPLERROR1); + return; + } if ((noReplicas * noFragments) > cnoFreeReplicaRec) { jam(); addtabrefuseLab(signal, connectPtr, ZREPLERROR1); @@ -6736,13 +6740,15 @@ void Dbdih::tableDeleteLab(Signal* signal, FileRecordPtr filePtr) void Dbdih::releaseTable(TabRecordPtr tabPtr) { FragmentstorePtr fragPtr; - for (Uint32 fragId = 0; fragId < tabPtr.p->totalfragments; fragId++) { - jam(); - getFragstore(tabPtr.p, fragId, fragPtr); - releaseReplicas(fragPtr.p->storedReplicas); - releaseReplicas(fragPtr.p->oldStoredReplicas); - }//for - releaseFragments(tabPtr); + if (tabPtr.p->noOfFragChunks > 0) { + for (Uint32 fragId = 0; fragId < tabPtr.p->totalfragments; fragId++) { + jam(); + getFragstore(tabPtr.p, fragId, fragPtr); + releaseReplicas(fragPtr.p->storedReplicas); + releaseReplicas(fragPtr.p->oldStoredReplicas); + }//for + releaseFragments(tabPtr); + } if (tabPtr.p->tabFile[0] != RNIL) { jam(); releaseFile(tabPtr.p->tabFile[0]); @@ -6875,9 +6881,6 @@ Uint32 Dbdih::extractNodeInfo(const Fragmentstore * fragPtr, Uint32 nodes[]) return nodeCount; }//Dbdih::extractNodeInfo() -#define NO_OF_FRAGS_PER_CHUNK 16 -#define LOG_NO_OF_FRAGS_PER_CHUNK 4 - void Dbdih::getFragstore(TabRecord * tab, //In parameter Uint32 fragNo, //In parameter diff --git a/ndb/src/kernel/vm/Configuration.cpp b/ndb/src/kernel/vm/Configuration.cpp index 9469a39a6f5..956c11c44d5 100644 --- a/ndb/src/kernel/vm/Configuration.cpp +++ b/ndb/src/kernel/vm/Configuration.cpp @@ -599,8 +599,12 @@ Configuration::calcSizeAlt(ConfigValues * ownConfig){ cfg.put(CFG_DIH_CONNECT, noOfOperations + noOfTransactions + 46); + Uint32 noFragPerTable= ((noOfDBNodes + NO_OF_FRAGS_PER_CHUNK - 1) >> + LOG_NO_OF_FRAGS_PER_CHUNK) << + LOG_NO_OF_FRAGS_PER_CHUNK; + cfg.put(CFG_DIH_FRAG_CONNECT, - NO_OF_FRAG_PER_NODE * noOfMetaTables * noOfDBNodes); + noFragPerTable * noOfMetaTables); int temp; temp = noOfReplicas - 2; @@ -611,7 +615,7 @@ Configuration::calcSizeAlt(ConfigValues * ownConfig){ cfg.put(CFG_DIH_MORE_NODES, temp * NO_OF_FRAG_PER_NODE * noOfMetaTables * noOfDBNodes); - + cfg.put(CFG_DIH_REPLICAS, NO_OF_FRAG_PER_NODE * noOfMetaTables * noOfDBNodes * noOfReplicas); diff --git a/ndb/src/kernel/vm/pc.hpp b/ndb/src/kernel/vm/pc.hpp index 5ac95d661a4..6ef7be30f94 100644 --- a/ndb/src/kernel/vm/pc.hpp +++ b/ndb/src/kernel/vm/pc.hpp @@ -150,6 +150,13 @@ #define NO_OF_FRAG_PER_NODE 1 #define MAX_FRAG_PER_NODE 8 +/** +* DIH allocates fragments in chunk for fast find of fragment record. +* These parameters define chunk size and log of chunk size. +*/ +#define NO_OF_FRAGS_PER_CHUNK 8 +#define LOG_NO_OF_FRAGS_PER_CHUNK 3 + /* ---------------------------------------------------------------- */ // To avoid synching too big chunks at a time we synch after writing // a certain number of data/UNDO pages. (e.g. 2 MBytes). diff --git a/ndb/test/ndbapi/testDict.cpp b/ndb/test/ndbapi/testDict.cpp index e7597c26960..c527bbd655b 100644 --- a/ndb/test/ndbapi/testDict.cpp +++ b/ndb/test/ndbapi/testDict.cpp @@ -1002,11 +1002,13 @@ int runGetPrimaryKey(NDBT_Context* ctx, NDBT_Step* step){ return result; } -int +struct ErrorCodes { int error_id; bool crash;}; +ErrorCodes NF_codes[] = { - 6003 - ,6004 - //,6005 + {6003, true}, + {6004, true}, + //,6005, true, + {7173, false} }; int @@ -1042,7 +1044,9 @@ runNF1(NDBT_Context* ctx, NDBT_Step* step){ for(int i = 0; i 50){ - CHECK2(restarter.startNodes(&nodeId, 1) == 0, + if(myRandom48(100) > 50){ + CHECK2(restarter.startNodes(&nodeId, 1) == 0, "failed to start node"); - CHECK2(restarter.waitClusterStarted() == 0, + CHECK2(restarter.waitClusterStarted() == 0, "waitClusterStarted failed"); - CHECK2(dict->dropTable(pTab->getName()) == 0, + CHECK2(dict->dropTable(pTab->getName()) == 0, "drop table failed"); - } else { - CHECK2(dict->dropTable(pTab->getName()) == 0, + } else { + CHECK2(dict->dropTable(pTab->getName()) == 0, "drop table failed"); - CHECK2(restarter.startNodes(&nodeId, 1) == 0, + CHECK2(restarter.startNodes(&nodeId, 1) == 0, "failed to start node"); - CHECK2(restarter.waitClusterStarted() == 0, + CHECK2(restarter.waitClusterStarted() == 0, "waitClusterStarted failed"); - } + } - CHECK2(restarter.dumpStateOneNode(nodeId, &val, 1) == 0, + CHECK2(restarter.dumpStateOneNode(nodeId, &val, 1) == 0, "Failed to set LCP to min value"); + } } } end: From 4b47cc97aaff047f62866f7f3521e618725b2ee6 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 26 Aug 2004 19:46:11 +0200 Subject: [PATCH 28/54] - typo fix - make sure to include an existing file in the source distribution... --- 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 3b43f7b7911..7ae1071f9ec 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 ce91cbb8676fd75a2a44ac0db989c6a29f827425 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 26 Aug 2004 22:47:34 +0400 Subject: [PATCH 29/54] A short fix and test case for Bug#5126 "Mediumint and PS problem": just treat mediumint as long. libmysql/libmysql.c: A short fix for bug #5126 "Mediumint and PS problem": just treat mediumint as long, as it's sent just like long. tests/client_test.c: A test case for bug#5126 --- libmysql/libmysql.c | 2 ++ tests/client_test.c | 48 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c index e9961ed11e3..380e53d7d47 100644 --- a/libmysql/libmysql.c +++ b/libmysql/libmysql.c @@ -3339,6 +3339,7 @@ static void fetch_string_with_conversion(MYSQL_BIND *param, char *value, } case MYSQL_TYPE_DATE: case MYSQL_TYPE_DATETIME: + case MYSQL_TYPE_TIMESTAMP: { MYSQL_TIME *tm= (MYSQL_TIME *)buffer; str_to_datetime(value, length, tm, 0, &err); @@ -3612,6 +3613,7 @@ static void fetch_result_with_conversion(MYSQL_BIND *param, MYSQL_FIELD *field, length= 2; break; } + case MYSQL_TYPE_INT24: /* mediumint is sent as 4 bytes int */ case MYSQL_TYPE_LONG: { long value= sint4korr(*row); diff --git a/tests/client_test.c b/tests/client_test.c index 825e866315e..ed186837d28 100644 --- a/tests/client_test.c +++ b/tests/client_test.c @@ -10044,6 +10044,53 @@ static void test_bug4030() } +static void test_bug5126() +{ + MYSQL_STMT *stmt; + MYSQL_BIND bind[2]; + long c1, c2; + const char *stmt_text; + int rc; + + myheader("test_bug5126"); + + stmt_text= "DROP TABLE IF EXISTS t1"; + rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text)); + myquery(rc); + + stmt_text= "CREATE TABLE t1 (a mediumint, b int)"; + rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text)); + myquery(rc); + + stmt_text= "INSERT INTO t1 VALUES (8386608, 1)"; + rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text)); + myquery(rc); + + stmt= mysql_stmt_init(mysql); + stmt_text= "SELECT a, b FROM t1"; + rc= mysql_stmt_prepare(stmt, stmt_text, strlen(stmt_text)); + check_execute(stmt, rc); + rc= mysql_stmt_execute(stmt); + check_execute(stmt, rc); + + /* Bind output buffers */ + bzero(bind, sizeof(bind)); + + bind[0].buffer_type= MYSQL_TYPE_LONG; + bind[0].buffer= &c1; + bind[1].buffer_type= MYSQL_TYPE_LONG; + bind[1].buffer= &c2; + + mysql_stmt_bind_result(stmt, bind); + + rc= mysql_stmt_fetch(stmt); + assert(rc == 0); + assert(c1 == 8386608 && c2 == 1); + printf("%ld, %ld\n", c1, c2); + mysql_stmt_close(stmt); +} + + /* Read and parse arguments and MySQL options from my.cnf */ @@ -10341,6 +10388,7 @@ int main(int argc, char **argv) test_bug4236(); /* init -> execute */ test_bug4030(); /* test conversion string -> time types in libmysql */ + test_bug5126(); /* support for mediumint type in libmysql */ /* XXX: PLEASE RUN THIS PROGRAM UNDER VALGRIND AND VERIFY THAT YOUR TEST DOESN'T CONTAIN WARNINGS/ERRORS BEFORE YOU PUSH. From 3212cc473d55f4489ac6a1acf9f5b6b7693fa92d Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 26 Aug 2004 21:43:07 +0000 Subject: [PATCH 30/54] new parameter BackupDataDir --- ndb/include/mgmapi/mgmapi_config_parameters.h | 2 +- ndb/src/common/mgmcommon/ConfigInfo.cpp | 14 ++-- ndb/src/kernel/blocks/ndbfs/AsyncFile.cpp | 6 +- ndb/src/kernel/blocks/ndbfs/AsyncFile.hpp | 2 +- ndb/src/kernel/blocks/ndbfs/Filename.cpp | 54 ++++++------- ndb/src/kernel/blocks/ndbfs/Filename.hpp | 9 ++- ndb/src/kernel/blocks/ndbfs/Ndbfs.cpp | 4 +- ndb/src/kernel/blocks/ndbfs/Ndbfs.hpp | 1 + ndb/src/kernel/vm/Configuration.cpp | 76 +++++++++++++------ ndb/src/kernel/vm/Configuration.hpp | 8 ++ 10 files changed, 109 insertions(+), 67 deletions(-) diff --git a/ndb/include/mgmapi/mgmapi_config_parameters.h b/ndb/include/mgmapi/mgmapi_config_parameters.h index 07d0aa87380..faa1851c09d 100644 --- a/ndb/include/mgmapi/mgmapi_config_parameters.h +++ b/ndb/include/mgmapi/mgmapi_config_parameters.h @@ -90,7 +90,7 @@ #define CFG_DB_LONG_SIGNAL_BUFFER 157 -#define CFG_DB_BACKUP_DATA_PATH 158 +#define CFG_DB_BACKUP_DATADIR 158 #define CFG_NODE_ARBIT_RANK 200 #define CFG_NODE_ARBIT_DELAY 201 diff --git a/ndb/src/common/mgmcommon/ConfigInfo.cpp b/ndb/src/common/mgmcommon/ConfigInfo.cpp index 769fc707c2a..52023fe4619 100644 --- a/ndb/src/common/mgmcommon/ConfigInfo.cpp +++ b/ndb/src/common/mgmcommon/ConfigInfo.cpp @@ -89,7 +89,7 @@ static bool fixExtConnection(InitConfigFileParser::Context & ctx, const char * d static bool fixDepricated(InitConfigFileParser::Context & ctx, const char *); static bool saveInConfigValues(InitConfigFileParser::Context & ctx, const char *); static bool fixFileSystemPath(InitConfigFileParser::Context & ctx, const char * data); -static bool fixBackupDataPath(InitConfigFileParser::Context & ctx, const char * data); +static bool fixBackupDataDir(InitConfigFileParser::Context & ctx, const char * data); const ConfigInfo::SectionRule ConfigInfo::m_SectionRules[] = { @@ -145,7 +145,7 @@ ConfigInfo::m_SectionRules[] = { { "*", applyDefaultValues, "system" }, { DB_TOKEN, fixFileSystemPath, 0 }, - { DB_TOKEN, fixBackupDataPath, 0 }, + { DB_TOKEN, fixBackupDataDir, 0 }, { DB_TOKEN, checkDbConstraints, 0 }, @@ -1101,8 +1101,8 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "1" }, { - CFG_DB_BACKUP_DATA_PATH, - "BackupDataPath", + CFG_DB_BACKUP_DATADIR, + "BackupDataDir", DB_TOKEN, "Path to where to store backups", ConfigInfo::USED, @@ -2497,14 +2497,14 @@ fixFileSystemPath(InitConfigFileParser::Context & ctx, const char * data){ } bool -fixBackupDataPath(InitConfigFileParser::Context & ctx, const char * data){ +fixBackupDataDir(InitConfigFileParser::Context & ctx, const char * data){ const char * path; - if (ctx.m_currentSection->get("BackupDataPath", &path)) + if (ctx.m_currentSection->get("BackupDataDir", &path)) return true; if (ctx.m_currentSection->get("FileSystemPath", &path)) { - require(ctx.m_currentSection->put("BackupDataPath", path)); + require(ctx.m_currentSection->put("BackupDataDir", path)); return true; } diff --git a/ndb/src/kernel/blocks/ndbfs/AsyncFile.cpp b/ndb/src/kernel/blocks/ndbfs/AsyncFile.cpp index c2b8cc80a44..c61fccad22a 100644 --- a/ndb/src/kernel/blocks/ndbfs/AsyncFile.cpp +++ b/ndb/src/kernel/blocks/ndbfs/AsyncFile.cpp @@ -108,8 +108,10 @@ AsyncFile::AsyncFile() : } void -AsyncFile::doStart(Uint32 nodeId, const char * filesystemPath) { - theFileName.init(nodeId, filesystemPath); +AsyncFile::doStart(Uint32 nodeId, + const char * filesystemPath, + const char * backup_path) { + theFileName.init(nodeId, filesystemPath, backup_path); // Stacksize for filesystem threads // An 8k stack should be enough diff --git a/ndb/src/kernel/blocks/ndbfs/AsyncFile.hpp b/ndb/src/kernel/blocks/ndbfs/AsyncFile.hpp index 9a405bc1580..2176c93c5d5 100644 --- a/ndb/src/kernel/blocks/ndbfs/AsyncFile.hpp +++ b/ndb/src/kernel/blocks/ndbfs/AsyncFile.hpp @@ -181,7 +181,7 @@ public: void execute( Request* request ); - void doStart(Uint32 nodeId, const char * fspath); + void doStart(Uint32 nodeId, const char * fspath, const char * backup_path); // its a thread so its always running void run(); diff --git a/ndb/src/kernel/blocks/ndbfs/Filename.cpp b/ndb/src/kernel/blocks/ndbfs/Filename.cpp index 660fe6eee94..28aa1d23df4 100644 --- a/ndb/src/kernel/blocks/ndbfs/Filename.cpp +++ b/ndb/src/kernel/blocks/ndbfs/Filename.cpp @@ -46,43 +46,31 @@ Filename::Filename() : } void -Filename::init(Uint32 nodeid, const char * pFileSystemPath){ +Filename::init(Uint32 nodeid, + const char * pFileSystemPath, + const char * pBackupDirPath){ + DBUG_ENTER("Filename::init"); + if (pFileSystemPath == NULL) { ERROR_SET(fatal, AFS_ERROR_NOPATH, ""," Filename::init()"); return; } - strncpy(theBaseDirectory, pFileSystemPath, PATH_MAX); - - // the environment variable is set, - // check that it is pointing on a valid directory - // - char buf2[PATH_MAX]; memset(buf2, 0,sizeof(buf2)); -#ifdef NDB_WIN32 - char* szFilePart; - if(!GetFullPathName(theBaseDirectory, sizeof(buf2), buf2, &szFilePart) - || (::GetFileAttributes(theBaseDirectory)&FILE_ATTRIBUTE_READONLY)) -#else - if((::realpath(theBaseDirectory, buf2) == NULL)|| - (::access(theBaseDirectory, W_OK) != 0)) -#endif - { - ERROR_SET(fatal, AFS_ERROR_INVALIDPATH, pFileSystemPath, " Filename::init()"); - } - strncpy(theBaseDirectory, buf2, sizeof(theBaseDirectory)); - // path seems ok, add delimiter if missing - if (strcmp(&theBaseDirectory[strlen(theBaseDirectory) - 1], - DIR_SEPARATOR) != 0) - strcat(theBaseDirectory, DIR_SEPARATOR); - - snprintf(buf2, sizeof(buf2), "ndb_%u_fs%s", nodeid, DIR_SEPARATOR); - strcat(theBaseDirectory, buf2); + snprintf(theFileSystemDirectory, sizeof(theFileSystemDirectory), + "%sndb_%u_fs%s", pFileSystemPath, nodeid, DIR_SEPARATOR); + strncpy(theBackupDirectory, pBackupDirPath, sizeof(theBackupDirectory)); + + DBUG_PRINT("info", ("theFileSystemDirectory=%s", theFileSystemDirectory)); + DBUG_PRINT("info", ("theBackupDirectory=%s", theBackupDirectory)); #ifdef NDB_WIN32 - CreateDirectory(theBaseDirectory, 0); + CreateDirectory(theFileSystemDirectory, 0); #else - mkdir(theBaseDirectory, S_IRUSR | S_IWUSR | S_IXUSR | S_IXGRP | S_IRGRP); + mkdir(theFileSystemDirectory, S_IRUSR | S_IWUSR | S_IXUSR | S_IXGRP | S_IRGRP); #endif + theBaseDirectory= 0; + + DBUG_VOID_RETURN; } Filename::~Filename(){ @@ -94,10 +82,16 @@ Filename::set(BlockReference blockReference, { char buf[PATH_MAX]; theLevelDepth = 0; - strncpy(theName, theBaseDirectory, PATH_MAX); - + const Uint32 type = FsOpenReq::getSuffix(filenumber); const Uint32 version = FsOpenReq::getVersion(filenumber); + + if (version == 2) + theBaseDirectory= theBackupDirectory; + else + theBaseDirectory= theFileSystemDirectory; + strncpy(theName, theBaseDirectory, PATH_MAX); + switch(version){ case 1 :{ const Uint32 diskNo = FsOpenReq::v1_getDisk(filenumber); diff --git a/ndb/src/kernel/blocks/ndbfs/Filename.hpp b/ndb/src/kernel/blocks/ndbfs/Filename.hpp index 25c06092436..249c1b1ca10 100644 --- a/ndb/src/kernel/blocks/ndbfs/Filename.hpp +++ b/ndb/src/kernel/blocks/ndbfs/Filename.hpp @@ -67,13 +67,16 @@ public: const char* directory(int level); int levels() const; const char* c_str() const; - - void init(Uint32 nodeid, const char * fileSystemPath); + + void init(Uint32 nodeid, const char * fileSystemPath, + const char * backupDirPath); private: int theLevelDepth; char theName[PATH_MAX]; - char theBaseDirectory[PATH_MAX]; + char theFileSystemDirectory[PATH_MAX]; + char theBackupDirectory[PATH_MAX]; + char *theBaseDirectory; char theDirectory[PATH_MAX]; }; diff --git a/ndb/src/kernel/blocks/ndbfs/Ndbfs.cpp b/ndb/src/kernel/blocks/ndbfs/Ndbfs.cpp index c7ef1a91099..56e3d3abbed 100644 --- a/ndb/src/kernel/blocks/ndbfs/Ndbfs.cpp +++ b/ndb/src/kernel/blocks/ndbfs/Ndbfs.cpp @@ -58,6 +58,8 @@ Ndbfs::Ndbfs(const Configuration & conf) : m_maxOpenedFiles(0) { theFileSystemPath = conf.fileSystemPath(); + theBackupFilePath = conf.backupFilePath(); + theRequestPool = new Pool; const ndb_mgm_configuration_iterator * p = conf.getOwnConfigIterator(); @@ -559,7 +561,7 @@ Ndbfs::createAsyncFile(){ } AsyncFile* file = new AsyncFile; - file->doStart(getOwnNodeId(), theFileSystemPath); + file->doStart(getOwnNodeId(), theFileSystemPath, theBackupFilePath); // Put the file in list of all files theFiles.push_back(file); diff --git a/ndb/src/kernel/blocks/ndbfs/Ndbfs.hpp b/ndb/src/kernel/blocks/ndbfs/Ndbfs.hpp index 080196a9ea5..c5aaa4e5c49 100644 --- a/ndb/src/kernel/blocks/ndbfs/Ndbfs.hpp +++ b/ndb/src/kernel/blocks/ndbfs/Ndbfs.hpp @@ -80,6 +80,7 @@ private: Vector theIdleFiles; // List of idle AsyncFiles OpenFiles theOpenFiles; // List of open AsyncFiles const char * theFileSystemPath; + const char * theBackupFilePath; // Statistics variables Uint32 m_maxOpenedFiles; diff --git a/ndb/src/kernel/vm/Configuration.cpp b/ndb/src/kernel/vm/Configuration.cpp index 1acc5d59f97..d91d720b18a 100644 --- a/ndb/src/kernel/vm/Configuration.cpp +++ b/ndb/src/kernel/vm/Configuration.cpp @@ -144,6 +144,7 @@ Configuration::Configuration() _programName = 0; _connectString = 0; _fsPath = 0; + _backupPath = 0; _initialStart = false; _daemonMode = false; m_config_retriever= 0; @@ -156,6 +157,9 @@ Configuration::~Configuration(){ if(_fsPath != NULL) free(_fsPath); + if(_backupPath != NULL) + free(_backupPath); + if (m_config_retriever) { delete m_config_retriever; } @@ -237,8 +241,48 @@ Configuration::fetch_configuration(){ } } +static char * get_and_validate_path(ndb_mgm_configuration_iterator &iter, + Uint32 param, const char *param_string) +{ + const char* path = NULL; + if(iter.get(param, &path)){ + ERROR_SET(fatal, ERR_INVALID_CONFIG, "Invalid configuration fetched missing ", + param_string); + } + + if(path == 0 || strlen(path) == 0){ + ERROR_SET(fatal, ERR_INVALID_CONFIG, + "Invalid configuration fetched. Configuration does not contain valid ", + param_string); + } + + // check that it is pointing on a valid directory + // + char buf2[PATH_MAX]; + memset(buf2, 0,sizeof(buf2)); +#ifdef NDB_WIN32 + char* szFilePart; + if(!GetFullPathName(path, sizeof(buf2), buf2, &szFilePart) + || (::GetFileAttributes(alloc_path)&FILE_ATTRIBUTE_READONLY)) +#else + if((::realpath(path, buf2) == NULL)|| + (::access(buf2, W_OK) != 0)) +#endif + { + ERROR_SET(fatal, AFS_ERROR_INVALIDPATH, path, " Filename::init()"); + } + + if (strcmp(&buf2[strlen(buf2) - 1], DIR_SEPARATOR)) + strcat(buf2, DIR_SEPARATOR); + + return strdup(buf2); +} + void Configuration::setupConfiguration(){ + + DBUG_ENTER("Configuration::setupConfiguration"); + ndb_mgm_configuration * p = m_clusterConfig; /** @@ -284,29 +328,15 @@ Configuration::setupConfiguration(){ } /** - * Get filesystem path + * Get paths */ - { - const char* pFileSystemPath = NULL; - if(iter.get(CFG_DB_FILESYSTEM_PATH, &pFileSystemPath)){ - ERROR_SET(fatal, ERR_INVALID_CONFIG, "Invalid configuration fetched", - "FileSystemPath missing"); - } - - if(pFileSystemPath == 0 || strlen(pFileSystemPath) == 0){ - ERROR_SET(fatal, ERR_INVALID_CONFIG, "Invalid configuration fetched", - "Configuration does not contain valid filesystem path"); - } - - if(pFileSystemPath[strlen(pFileSystemPath) - 1] == '/') - _fsPath = strdup(pFileSystemPath); - else { - _fsPath = (char *)NdbMem_Allocate(strlen(pFileSystemPath) + 2); - strcpy(_fsPath, pFileSystemPath); - strcat(_fsPath, "/"); - } - } - + if (_fsPath) + free(_fsPath); + _fsPath= get_and_validate_path(iter, CFG_DB_FILESYSTEM_PATH, "FileSystemPath"); + if (_backupPath) + free(_backupPath); + _backupPath= get_and_validate_path(iter, CFG_DB_BACKUP_DATADIR, "BackupDataDir"); + if(iter.get(CFG_DB_STOP_ON_ERROR_INSERT, &m_restartOnErrorInsert)){ ERROR_SET(fatal, ERR_INVALID_CONFIG, "Invalid configuration fetched", "RestartOnErrorInsert missing"); @@ -327,6 +357,8 @@ Configuration::setupConfiguration(){ (p, CFG_SECTION_NODE); calcSizeAlt(cf); + + DBUG_VOID_RETURN; } bool diff --git a/ndb/src/kernel/vm/Configuration.hpp b/ndb/src/kernel/vm/Configuration.hpp index bd91f3fa74b..e84ff8d9193 100644 --- a/ndb/src/kernel/vm/Configuration.hpp +++ b/ndb/src/kernel/vm/Configuration.hpp @@ -53,6 +53,7 @@ public: // Cluster configuration const char * programName() const; const char * fileSystemPath() const; + const char * backupFilePath() const; char * getConnectStringCopy() const; /** @@ -89,6 +90,7 @@ private: */ char * _programName; char * _fsPath; + char * _backupPath; bool _initialStart; char * _connectString; bool _daemonMode; @@ -108,6 +110,12 @@ Configuration::fileSystemPath() const { return _fsPath; } +inline +const char * +Configuration::backupFilePath() const { + return _backupPath; +} + inline bool Configuration::getInitialStart() const { From 1b0dee296d2623c48229ce930f6dba84d40fc393 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 26 Aug 2004 16:44:01 -0500 Subject: [PATCH 31/54] 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: 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 c17995f5779..f3c20c81a9f 100755 --- a/Build-tools/Do-compile +++ b/Build-tools/Do-compile @@ -376,7 +376,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 $flags --warnings --tmpdir=$bench_tmpdir --master_port=$mysql_tcp_port --slave_port=$slave_port --ndbcluster_port=$ndbcluster_port --manager-port=$manager_port --no-manager --sleep=10", "tests were successful"); + check_system("./mysql-test-run $flags --tmpdir=$bench_tmpdir --master_port=$mysql_tcp_port --slave_port=$slave_port --ndbcluster_port=$ndbcluster_port --manager-port=$manager_port --no-manager --sleep=10", "tests were successful"); } # From b5ebc0f259de7d3ed8a13adaf161d499f6596b6c Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 27 Aug 2004 00:59:16 +0200 Subject: [PATCH 32/54] Fix ordered index scan with partially specified key --- mysql-test/r/ndb_index_ordered.result | 6 ++++++ mysql-test/t/ndb_index_ordered.test | 3 +++ ndb/src/ndbapi/NdbScanOperation.cpp | 11 ++++------- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/mysql-test/r/ndb_index_ordered.result b/mysql-test/r/ndb_index_ordered.result index 75de1ac4a7f..1441e53e935 100644 --- a/mysql-test/r/ndb_index_ordered.result +++ b/mysql-test/r/ndb_index_ordered.result @@ -205,4 +205,10 @@ a b c select * from t1 where b<=5 and c=0 or b<=5 and c=2; a b c 19 4 0 +select count(*) from t1 where b = 0; +count(*) +0 +select count(*) from t1 where b = 1; +count(*) +1 drop table t1; diff --git a/mysql-test/t/ndb_index_ordered.test b/mysql-test/t/ndb_index_ordered.test index 3def52e865c..cffe9236fb5 100644 --- a/mysql-test/t/ndb_index_ordered.test +++ b/mysql-test/t/ndb_index_ordered.test @@ -113,6 +113,9 @@ select * from t1 where b<=5 and c=0; select * from t1 where b=4 and c<=5 order by a; select * from t1 where b<=4 and c<=5 order by a; select * from t1 where b<=5 and c=0 or b<=5 and c=2; + +select count(*) from t1 where b = 0; +select count(*) from t1 where b = 1; drop table t1; # diff --git a/ndb/src/ndbapi/NdbScanOperation.cpp b/ndb/src/ndbapi/NdbScanOperation.cpp index 52cb4cecb02..0aa40f968bb 100644 --- a/ndb/src/ndbapi/NdbScanOperation.cpp +++ b/ndb/src/ndbapi/NdbScanOperation.cpp @@ -1188,13 +1188,11 @@ NdbIndexScanOperation::fix_get_values(){ for(Uint32 i = 0; im_columns[i]; - NdbColumnImpl * col = tab->getColumn(key->m_keyInfoPos); - curr->setup(col, 0); - } - break; + case FAKE_PTR: + curr->setup(curr->m_column, 0); case API_PTR: + curr = curr->next(); + break; case SETBOUND_EQ: break; #ifdef VM_TRACE @@ -1202,7 +1200,6 @@ NdbIndexScanOperation::fix_get_values(){ abort(); #endif } - curr = curr->next(); } } From f87f890eff42f7200d0167d1ca61854f69740d13 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 27 Aug 2004 03:27:16 +0400 Subject: [PATCH 33/54] Adding the file needed for windows build (on behalf of Reggie) --- 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 3e4ba63de1b7735e0ce22bb2e0987a48475fc692 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 27 Aug 2004 08:25:02 +0200 Subject: [PATCH 34/54] compile ERROR!! --- ndb/test/ndbapi/testDict.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ndb/test/ndbapi/testDict.cpp b/ndb/test/ndbapi/testDict.cpp index c527bbd655b..a0c7bb1414b 100644 --- a/ndb/test/ndbapi/testDict.cpp +++ b/ndb/test/ndbapi/testDict.cpp @@ -1305,7 +1305,7 @@ runTableRenameNF(NDBT_Context* ctx, NDBT_Step* step){ const int numNodes = restarter.getNumDbNodes(); for(int i = 0; i Abort backup\n" +"SHUTDOWN Shutdown all processed in cluster and quit\n" "CLUSTERLOG ON Enable Cluster logging\n" "CLUSTERLOG OFF Disable Cluster logging\n" "CLUSTERLOG FILTER Toggle severity filter on/off\n" @@ -62,7 +65,9 @@ static const char* helpText = "EXIT SINGLE USER MODE Exit single user mode\n" " STATUS Print status\n" " CLUSTERLOG {=}+ Set log level for cluster log\n" +#ifdef HAVE_GLOBAL_REPLICATION "REP CONNECT Connect to REP server on host:port\n" +#endif "QUIT Quit management client\n" ; @@ -299,6 +304,10 @@ CommandInterpreter::readAndExecute(int _try_reconnect) executeShow(allAfterFirstToken); return true; } + else if (strcmp(firstToken, "SHUTDOWN") == 0) { + executeShutdown(allAfterFirstToken); + return true; + } else if (strcmp(firstToken, "CLUSTERLOG") == 0){ executeClusterLog(allAfterFirstToken); return true; @@ -628,6 +637,57 @@ CommandInterpreter::executeHelp(char* parameters) } +/***************************************************************************** + * SHUTDOWN + *****************************************************************************/ + +void +CommandInterpreter::executeShutdown(char* parameters) +{ + connect(); + + ndb_mgm_cluster_state *state = ndb_mgm_get_status(m_mgmsrv); + if(state == NULL) { + ndbout_c("Could not get status"); + printError(); + return; + } + + int result = 0; + result = ndb_mgm_stop(m_mgmsrv, 0, 0); + if (result <= 0) { + ndbout << "Shutdown failed." << endl; + printError(); + return; + } + + ndbout << "NDB Cluster storage node(s) have shutdown." << endl; + + int mgm_id= 0; + for(int i=0; i < state->no_of_nodes; i++) { + if(state->node_states[i].node_type == NDB_MGM_NODE_TYPE_MGM && + state->node_states[i].version != 0){ + if (mgm_id == 0) + mgm_id= state->node_states[i].node_id; + else { + ndbout << "Unable to locate management server, shutdown manually with #STOP" + << endl; + } + } + } + + result = 0; + result = ndb_mgm_stop(m_mgmsrv, 1, &mgm_id); + if (result <= 0) { + ndbout << "Shutdown failed." << endl; + printError(); + return; + } + + ndbout << "NDB Cluster management server shutdown." << endl; + exit(0); +} + /***************************************************************************** * SHOW *****************************************************************************/ diff --git a/ndb/src/mgmclient/CommandInterpreter.hpp b/ndb/src/mgmclient/CommandInterpreter.hpp index 478e03d129a..eecc48a739e 100644 --- a/ndb/src/mgmclient/CommandInterpreter.hpp +++ b/ndb/src/mgmclient/CommandInterpreter.hpp @@ -127,6 +127,7 @@ private: */ void executeHelp(char* parameters); void executeShow(char* parameters); + void executeShutdown(char* parameters); void executeRun(char* parameters); void executeInfo(char* parameters); void executeClusterLog(char* parameters); diff --git a/ndb/src/common/mgmcommon/Config.cpp b/ndb/src/mgmsrv/Config.cpp similarity index 99% rename from ndb/src/common/mgmcommon/Config.cpp rename to ndb/src/mgmsrv/Config.cpp index c0819b9f463..b8a494cb759 100644 --- a/ndb/src/common/mgmcommon/Config.cpp +++ b/ndb/src/mgmsrv/Config.cpp @@ -19,7 +19,6 @@ #include #include "MgmtErrorReporter.hpp" #include -#include "ConfigInfo.hpp" //***************************************************************************** // Ctor / Dtor diff --git a/ndb/src/common/mgmcommon/Config.hpp b/ndb/src/mgmsrv/Config.hpp similarity index 98% rename from ndb/src/common/mgmcommon/Config.hpp rename to ndb/src/mgmsrv/Config.hpp index 26fd53dbed2..b5e1e17b027 100644 --- a/ndb/src/common/mgmcommon/Config.hpp +++ b/ndb/src/mgmsrv/Config.hpp @@ -24,7 +24,7 @@ #include #include #include -#include "ConfigInfo.hpp" +#include class ConfigInfo; diff --git a/ndb/src/common/mgmcommon/ConfigInfo.cpp b/ndb/src/mgmsrv/ConfigInfo.cpp similarity index 99% rename from ndb/src/common/mgmcommon/ConfigInfo.cpp rename to ndb/src/mgmsrv/ConfigInfo.cpp index 52023fe4619..7bbd26581e2 100644 --- a/ndb/src/common/mgmcommon/ConfigInfo.cpp +++ b/ndb/src/mgmsrv/ConfigInfo.cpp @@ -33,15 +33,15 @@ * Section names ****************************************************************************/ -#define DB_TOKEN "NDBD" -#define MGM_TOKEN "NDB_MGMD" -#define API_TOKEN "MYSQLD" +#define DB_TOKEN "DB" +#define MGM_TOKEN "MGM" +#define API_TOKEN "API" const ConfigInfo::AliasPair ConfigInfo::m_sectionNameAliases[]={ - {API_TOKEN, "API"}, - {DB_TOKEN, "DB"}, - {MGM_TOKEN, "MGM"}, + {API_TOKEN, "MYSQLD"}, + {DB_TOKEN, "NDBD"}, + {MGM_TOKEN, "NDB_MGMD"}, {0, 0} }; @@ -975,7 +975,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { ConfigInfo::USED, false, ConfigInfo::STRING, - DATADIR, + MYSQLCLUSTERDIR, 0, 0 }, { @@ -1349,7 +1349,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { ConfigInfo::USED, false, ConfigInfo::STRING, - DATADIR, + MYSQLCLUSTERDIR, 0, 0 }, { diff --git a/ndb/src/common/mgmcommon/ConfigInfo.hpp b/ndb/src/mgmsrv/ConfigInfo.hpp similarity index 100% rename from ndb/src/common/mgmcommon/ConfigInfo.hpp rename to ndb/src/mgmsrv/ConfigInfo.hpp diff --git a/ndb/src/common/mgmcommon/InitConfigFileParser.cpp b/ndb/src/mgmsrv/InitConfigFileParser.cpp similarity index 100% rename from ndb/src/common/mgmcommon/InitConfigFileParser.cpp rename to ndb/src/mgmsrv/InitConfigFileParser.cpp diff --git a/ndb/src/common/mgmcommon/InitConfigFileParser.hpp b/ndb/src/mgmsrv/InitConfigFileParser.hpp similarity index 100% rename from ndb/src/common/mgmcommon/InitConfigFileParser.hpp rename to ndb/src/mgmsrv/InitConfigFileParser.hpp diff --git a/ndb/src/mgmsrv/Makefile.am b/ndb/src/mgmsrv/Makefile.am index 630a19e0356..60b579d18e1 100644 --- a/ndb/src/mgmsrv/Makefile.am +++ b/ndb/src/mgmsrv/Makefile.am @@ -1,3 +1,7 @@ +MYSQLDATAdir = $(localstatedir) +MYSQLSHAREdir = $(pkgdatadir) +MYSQLBASEdir= $(prefix) +MYSQLCLUSTERdir= $(prefix)/mysql-cluster ndbbin_PROGRAMS = ndb_mgmd @@ -11,6 +15,9 @@ ndb_mgmd_SOURCES = \ NodeLogLevelList.cpp \ SignalQueue.cpp \ MgmtSrvrConfig.cpp \ + ConfigInfo.cpp \ + InitConfigFileParser.cpp \ + Config.cpp \ CommandInterpreter.cpp INCLUDES_LOC = -I$(top_srcdir)/ndb/src/ndbapi \ @@ -24,6 +31,12 @@ LDADD_LOC = $(top_builddir)/ndb/src/libndbclient.la \ $(top_builddir)/strings/libmystrings.a @TERMCAP_LIB@ +DEFS_LOC = -DDEFAULT_MYSQL_HOME="\"$(MYSQLBASEdir)\"" \ + -DDATADIR="\"$(MYSQLDATAdir)\"" \ + -DSHAREDIR="\"$(MYSQLSHAREdir)\"" \ + -DMYSQLCLUSTERDIR="\"$(MYSQLCLUSTERdir)\"" \ + -DNDB_BASE_PORT="\"@ndb_port_base@\"" + include $(top_srcdir)/ndb/config/common.mk.am include $(top_srcdir)/ndb/config/type_ndbapi.mk.am diff --git a/ndb/test/include/NdbBackup.hpp b/ndb/test/include/NdbBackup.hpp index 0a372eca7df..e2e672b8a72 100644 --- a/ndb/test/include/NdbBackup.hpp +++ b/ndb/test/include/NdbBackup.hpp @@ -47,7 +47,7 @@ private: int _node_id, unsigned _backup_id); - const char * getFileSystemPathForNode(int _node_id); + const char * getBackupDataDirForNode(int _node_id); }; diff --git a/ndb/test/ndbapi/testDict.cpp b/ndb/test/ndbapi/testDict.cpp index c527bbd655b..a0c7bb1414b 100644 --- a/ndb/test/ndbapi/testDict.cpp +++ b/ndb/test/ndbapi/testDict.cpp @@ -1305,7 +1305,7 @@ runTableRenameNF(NDBT_Context* ctx, NDBT_Step* step){ const int numNodes = restarter.getNumDbNodes(); for(int i = 0; i Date: Fri, 27 Aug 2004 12:11:49 +0000 Subject: [PATCH 38/54] small fixes mysql-test/ndb/ndbcluster.sh: use new shutdown command ndb/src/common/mgmcommon/Makefile.am: compile error fix --- mysql-test/ndb/ndbcluster.sh | 3 +-- ndb/src/common/mgmcommon/Makefile.am | 2 ++ 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/mysql-test/ndb/ndbcluster.sh b/mysql-test/ndb/ndbcluster.sh index bbd3fa3257a..e04e22f1434 100644 --- a/mysql-test/ndb/ndbcluster.sh +++ b/mysql-test/ndb/ndbcluster.sh @@ -193,8 +193,7 @@ stop_default_ndbcluster() { exec_mgmtclient="$exec_mgmtclient --try-reconnect=1" -echo "all stop" | $exec_mgmtclient 2>&1 | cat > /dev/null -echo "3 stop" | $exec_mgmtclient 2>&1 | cat > /dev/null +echo "shutdown" | $exec_mgmtclient 2>&1 | cat > /dev/null if [ -f "$fs_ndb/$pidfile" ] ; then kill -9 `cat "$fs_ndb/$pidfile"` 2> /dev/null diff --git a/ndb/src/common/mgmcommon/Makefile.am b/ndb/src/common/mgmcommon/Makefile.am index 29cfa47482a..ed6a526eb47 100644 --- a/ndb/src/common/mgmcommon/Makefile.am +++ b/ndb/src/common/mgmcommon/Makefile.am @@ -7,6 +7,8 @@ libmgmsrvcommon_la_SOURCES = \ INCLUDES_LOC = -I$(top_srcdir)/ndb/src/mgmapi -I$(top_srcdir)/ndb/src/mgmsrv +DEFS_LOC = -DNDB_BASE_PORT="\"@ndb_port_base@\"" + include $(top_srcdir)/ndb/config/common.mk.am include $(top_srcdir)/ndb/config/type_ndbapi.mk.am include $(top_srcdir)/ndb/config/type_mgmapiclient.mk.am From c0c6513864055e9e71f1012e683b7eb7dca664ab Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 27 Aug 2004 14:15:47 +0200 Subject: [PATCH 39/54] Fix order by --- mysql-test/r/ndb_autodiscover.result | 4 ++-- mysql-test/t/ndb_autodiscover.test | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/mysql-test/r/ndb_autodiscover.result b/mysql-test/r/ndb_autodiscover.result index b0e2aa04f3e..f5b908c39e2 100644 --- a/mysql-test/r/ndb_autodiscover.result +++ b/mysql-test/r/ndb_autodiscover.result @@ -35,10 +35,10 @@ update t1 set name="Autodiscover" where id = 2; show status like 'handler_discover%'; Variable_name Value Handler_discover 4 -select * from t1 order by name; +select * from t1 order by id; id name -2 Autodiscover 1 Autodiscover +2 Autodiscover 3 Discover 3 show status like 'handler_discover%'; Variable_name Value diff --git a/mysql-test/t/ndb_autodiscover.test b/mysql-test/t/ndb_autodiscover.test index d04599f223e..371a130291b 100644 --- a/mysql-test/t/ndb_autodiscover.test +++ b/mysql-test/t/ndb_autodiscover.test @@ -50,7 +50,7 @@ flush tables; system rm var/master-data/test/t1.frm ; update t1 set name="Autodiscover" where id = 2; show status like 'handler_discover%'; -select * from t1 order by name; +select * from t1 order by id; show status like 'handler_discover%'; # From aa243adb8fbdbfe5527e433d847480f797ad8591 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 27 Aug 2004 15:10:53 +0200 Subject: [PATCH 40/54] bug-5252 fix (tinyblob) ndb/src/ndbapi/NdbBlob.cpp: theBlobTable is NULL for tinyblob --- ndb/src/ndbapi/NdbBlob.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/ndb/src/ndbapi/NdbBlob.cpp b/ndb/src/ndbapi/NdbBlob.cpp index 65e1aeedda7..7939f54d846 100644 --- a/ndb/src/ndbapi/NdbBlob.cpp +++ b/ndb/src/ndbapi/NdbBlob.cpp @@ -145,6 +145,7 @@ NdbBlob::init() theNdbOp = NULL; theTable = NULL; theAccessTable = NULL; + theBlobTable = NULL; theColumn = NULL; theFillChar = 0; theInlineSize = 0; @@ -1028,9 +1029,9 @@ NdbBlob::atPrepare(NdbConnection* aCon, NdbOperation* anOp, const NdbColumnImpl* // sanity check assert((NDB_BLOB_HEAD_SIZE << 2) == sizeof(Head)); assert(theColumn->m_attrSize * theColumn->m_arraySize == sizeof(Head) + theInlineSize); - const NdbDictionary::Table* bt; - const NdbDictionary::Column* bc; if (thePartSize > 0) { + const NdbDictionary::Table* bt = NULL; + const NdbDictionary::Column* bc = NULL; if (theStripeSize == 0 || (bt = theColumn->getBlobTable()) == NULL || (bc = bt->getColumn("DATA")) == NULL || @@ -1039,8 +1040,8 @@ NdbBlob::atPrepare(NdbConnection* aCon, NdbOperation* anOp, const NdbColumnImpl* setErrorCode(ErrTable); return -1; } + theBlobTable = &NdbTableImpl::getImpl(*bt); } - theBlobTable = & NdbTableImpl::getImpl(*bt); // buffers theKeyBuf.alloc(theTable->m_sizeOfKeysInWords << 2); theAccessKeyBuf.alloc(theAccessTable->m_sizeOfKeysInWords << 2); From 0f194e61b49bf02ff5251f44d47a779d3dd20dfa Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 27 Aug 2004 13:37:00 +0000 Subject: [PATCH 41/54] added debug to ndb test --- ndb/test/src/NDBT_Test.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/ndb/test/src/NDBT_Test.cpp b/ndb/test/src/NDBT_Test.cpp index b1691c379a9..7ccc9e5588f 100644 --- a/ndb/test/src/NDBT_Test.cpp +++ b/ndb/test/src/NDBT_Test.cpp @@ -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 */ +#include +#include + #include "NDBT.hpp" #include "NDBT_Test.hpp" @@ -953,6 +956,9 @@ int NDBT_TestSuite::execute(int argc, const char** argv){ int _print_cases = false; int _verbose = false; +#ifndef DBUG_OFF + const char *debug_option= 0; +#endif struct getargs args[] = { { "print", '\0', arg_flag, &_print, "Print execution tree", "" }, @@ -964,6 +970,10 @@ int NDBT_TestSuite::execute(int argc, const char** argv){ { "remote_mgm", 'm', arg_string, &_remote_mgm, "host:port to mgmsrv of remote cluster", "host:port" }, { "timer", 't', arg_flag, &_timer, "Print execution time", "time" }, +#ifndef DBUG_OFF + { "debug", 0, arg_string, &debug_option, + "Specify debug options e.g. d:t:i:o,out.trace", "options" }, +#endif { "verbose", 'v', arg_flag, &_verbose, "Print verbose status", "verbose" } }; int num_args = sizeof(args) / sizeof(args[0]); @@ -973,6 +983,13 @@ int NDBT_TestSuite::execute(int argc, const char** argv){ arg_printusage(args, num_args, argv[0], "tabname1 tabname2 ... tabnameN\n"); return NDBT_WRONGARGS; } + +#ifndef DBUG_OFF + my_init(); + if (debug_option) + DBUG_PUSH(debug_option); +#endif + // Check if table name is supplied if (argv[optind] != NULL) _tabname = argv[optind]; From f4abefe36a16931c1d88219fad1c3248be01ef82 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 27 Aug 2004 20:32:28 +0500 Subject: [PATCH 42/54] fixed format of history of new libedit for compatibility with old libedit and readline 1. discarded reading and writting of hist_cookie as the begin of the file 2. skip strvis for string before saving cmd-line-utils/libedit/history.c: fixed format of history for compatibility with old libedit and readline 1. discarded reading and writting of hist_cookie as the begin of file 2. skip strvis for string before saving --- cmd-line-utils/libedit/history.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/cmd-line-utils/libedit/history.c b/cmd-line-utils/libedit/history.c index 0294734b9a3..53648203bf0 100644 --- a/cmd-line-utils/libedit/history.c +++ b/cmd-line-utils/libedit/history.c @@ -661,12 +661,6 @@ history_load(History *h, const char *fname) if ((fp = fopen(fname, "r")) == NULL) return (i); - if ((line = fgetln(fp, &sz)) == NULL) - goto done; - - if (strncmp(line, hist_cookie, sz) != 0) - goto done; - ptr = h_malloc(max_size = 1024); if (ptr == NULL) goto done; @@ -720,8 +714,6 @@ history_save(History *h, const char *fname) if (fchmod(fileno(fp), S_IRUSR|S_IWUSR) == -1) goto done; - if (fputs(hist_cookie, fp) == EOF) - goto done; ptr = h_malloc(max_size = 1024); if (ptr == NULL) goto done; @@ -740,7 +732,7 @@ history_save(History *h, const char *fname) ptr = nptr; } (void) strvis(ptr, ev.str, VIS_WHITE); - (void) fprintf(fp, "%s\n", ptr); + (void) fprintf(fp, "%s\n", ev.str); } oomem: h_free((ptr_t)ptr); From 3d2e2ddd120e513d6f4aa9cd309f96de92bf903d Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 27 Aug 2004 20:48:18 +0500 Subject: [PATCH 43/54] grant.result: Forgot to push in the previous changeset mysql-test/r/grant.result: Forgot to push in the previous changeset --- mysql-test/r/grant.result | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mysql-test/r/grant.result b/mysql-test/r/grant.result index 37b2747a9a1..35b90349804 100644 --- a/mysql-test/r/grant.result +++ b/mysql-test/r/grant.result @@ -228,7 +228,7 @@ GRANT USAGE ON *.* TO ' GRANT SELECT (ËÏÌ) ON `ÂÄ`.`ÔÁÂ` TO 'ÀÚÅÒ'@'localhost' REVOKE SELECT (ËÏÌ) ON ÂÄ.ÔÁÂ FROM ÀÚÅÒ@localhost; DROP DATABASE ÂÄ; -SET NAMES binary; +SET NAMES latin1; insert into mysql.user (host, user) values ('localhost', 'test11'); insert into mysql.db (host, db, user, select_priv) values ('localhost', 'a%', 'test11', 'Y'), ('localhost', 'ab%', 'test11', 'Y'); From f71662695d424aad8f0de3af3044cabc7da72c88 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 27 Aug 2004 20:48:19 +0500 Subject: [PATCH 44/54] Bug#2451 ALTER doesn't result in an error on CHARACTER SET and COLLATION conflict --- include/mysqld_error.h | 3 +- mysql-test/r/ctype_create.result | 8 ++++ mysql-test/t/ctype_create.test | 12 ++++++ sql/share/czech/errmsg.txt | 1 + sql/share/danish/errmsg.txt | 1 + sql/share/dutch/errmsg.txt | 1 + sql/share/english/errmsg.txt | 1 + sql/share/estonian/errmsg.txt | 1 + sql/share/french/errmsg.txt | 1 + sql/share/german/errmsg.txt | 1 + sql/share/greek/errmsg.txt | 1 + sql/share/hungarian/errmsg.txt | 1 + sql/share/italian/errmsg.txt | 1 + sql/share/japanese/errmsg.txt | 1 + sql/share/korean/errmsg.txt | 1 + sql/share/norwegian-ny/errmsg.txt | 1 + sql/share/norwegian/errmsg.txt | 1 + sql/share/polish/errmsg.txt | 1 + sql/share/portuguese/errmsg.txt | 1 + sql/share/romanian/errmsg.txt | 1 + sql/share/russian/errmsg.txt | 1 + sql/share/serbian/errmsg.txt | 1 + sql/share/slovak/errmsg.txt | 1 + sql/share/spanish/errmsg.txt | 1 + sql/share/swedish/errmsg.txt | 1 + sql/share/ukrainian/errmsg.txt | 1 + sql/sql_yacc.yy | 67 +++++++++++++++++++++++-------- 27 files changed, 95 insertions(+), 18 deletions(-) diff --git a/include/mysqld_error.h b/include/mysqld_error.h index 4d65515d6ce..776869ff045 100644 --- a/include/mysqld_error.h +++ b/include/mysqld_error.h @@ -318,4 +318,5 @@ #define ER_WARN_INVALID_TIMESTAMP 1299 #define ER_INVALID_CHARACTER_STRING 1300 #define ER_WARN_ALLOWED_PACKET_OVERFLOWED 1301 -#define ER_ERROR_MESSAGES 302 +#define ER_CONFLICTING_DECLARATIONS 1302 +#define ER_ERROR_MESSAGES 303 diff --git a/mysql-test/r/ctype_create.result b/mysql-test/r/ctype_create.result index 0da76c556e2..b35131f62a4 100644 --- a/mysql-test/r/ctype_create.result +++ b/mysql-test/r/ctype_create.result @@ -54,4 +54,12 @@ t1 CREATE TABLE `t1` ( `a` char(10) collate latin1_german1_ci default NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_german1_ci DROP TABLE t1; +create table t1 (a char) character set latin1 character set latin2; +ERROR HY000: Conflicting declarations: 'CHARACTER SET latin1' and 'CHARACTER SET latin2' +create table t1 (a char) character set latin1 collate latin2_bin; +ERROR 42000: COLLATION 'latin2_bin' is not valid for CHARACTER SET 'latin1' +create database d1 default character set latin1 character set latin2; +ERROR HY000: Conflicting declarations: 'CHARACTER SET latin1' and 'CHARACTER SET latin2' +create database d1 default character set latin1 collate latin2_bin; +ERROR 42000: COLLATION 'latin2_bin' is not valid for CHARACTER SET 'latin1' DROP DATABASE mysqltest1; diff --git a/mysql-test/t/ctype_create.test b/mysql-test/t/ctype_create.test index 6d7ed6fc205..9a5cb025474 100644 --- a/mysql-test/t/ctype_create.test +++ b/mysql-test/t/ctype_create.test @@ -71,6 +71,18 @@ SHOW CREATE TABLE t1; DROP TABLE t1; # +# Bug# +# CREATE TABLE and CREATE DATABASE didn't fail in some cases +# +--error 1302 +create table t1 (a char) character set latin1 character set latin2; +--error 1253 +create table t1 (a char) character set latin1 collate latin2_bin; +--error 1302 +create database d1 default character set latin1 character set latin2; +--error 1253 +create database d1 default character set latin1 collate latin2_bin; + # # DROP DATABASE mysqltest1; diff --git a/sql/share/czech/errmsg.txt b/sql/share/czech/errmsg.txt index ee75210d4fe..9769ec1a55d 100644 --- a/sql/share/czech/errmsg.txt +++ b/sql/share/czech/errmsg.txt @@ -314,3 +314,4 @@ character-set=latin2 "Invalid TIMESTAMP value in column '%s' at row %ld", "Invalid %s character string: '%.64s'", "Result of %s() was larger than max_allowed_packet (%ld) - truncated" +"Conflicting declarations: '%s' and '%s'" diff --git a/sql/share/danish/errmsg.txt b/sql/share/danish/errmsg.txt index 408f86b0445..31715354101 100644 --- a/sql/share/danish/errmsg.txt +++ b/sql/share/danish/errmsg.txt @@ -308,3 +308,4 @@ character-set=latin1 "Invalid TIMESTAMP value in column '%s' at row %ld", "Invalid %s character string: '%.64s'", "Result of %s() was larger than max_allowed_packet (%ld) - truncated" +"Conflicting declarations: '%s' and '%s'" diff --git a/sql/share/dutch/errmsg.txt b/sql/share/dutch/errmsg.txt index 95af6aaa01f..06e47e006f5 100644 --- a/sql/share/dutch/errmsg.txt +++ b/sql/share/dutch/errmsg.txt @@ -316,3 +316,4 @@ character-set=latin1 "Invalid TIMESTAMP value in column '%s' at row %ld", "Invalid %s character string: '%.64s'", "Result of %s() was larger than max_allowed_packet (%ld) - truncated" +"Conflicting declarations: '%s' and '%s'" diff --git a/sql/share/english/errmsg.txt b/sql/share/english/errmsg.txt index 5ad23b92a5a..a2e74460380 100644 --- a/sql/share/english/errmsg.txt +++ b/sql/share/english/errmsg.txt @@ -305,3 +305,4 @@ character-set=latin1 "Invalid TIMESTAMP value in column '%s' at row %ld", "Invalid %s character string: '%.64s'", "Result of %s() was larger than max_allowed_packet (%ld) - truncated" +"Conflicting declarations: '%s' and '%s'" diff --git a/sql/share/estonian/errmsg.txt b/sql/share/estonian/errmsg.txt index 36e0b8409e9..df29f08e752 100644 --- a/sql/share/estonian/errmsg.txt +++ b/sql/share/estonian/errmsg.txt @@ -310,3 +310,4 @@ character-set=latin7 "Invalid TIMESTAMP value in column '%s' at row %ld", "Invalid %s character string: '%.64s'", "Result of %s() was larger than max_allowed_packet (%ld) - truncated" +"Conflicting declarations: '%s' and '%s'" diff --git a/sql/share/french/errmsg.txt b/sql/share/french/errmsg.txt index 3bd6835908e..f0435278440 100644 --- a/sql/share/french/errmsg.txt +++ b/sql/share/french/errmsg.txt @@ -305,3 +305,4 @@ character-set=latin1 "Invalid TIMESTAMP value in column '%s' at row %ld", "Invalid %s character string: '%.64s'", "Result of %s() was larger than max_allowed_packet (%ld) - truncated" +"Conflicting declarations: '%s' and '%s'" diff --git a/sql/share/german/errmsg.txt b/sql/share/german/errmsg.txt index bf5a36a887a..af11e09f2f6 100644 --- a/sql/share/german/errmsg.txt +++ b/sql/share/german/errmsg.txt @@ -317,3 +317,4 @@ character-set=latin1 "Invalid TIMESTAMP value in column '%s' at row %ld", "Invalid %s character string: '%.64s'", "Result of %s() was larger than max_allowed_packet (%ld) - truncated" +"Conflicting declarations: '%s' and '%s'" diff --git a/sql/share/greek/errmsg.txt b/sql/share/greek/errmsg.txt index 9703bad11a1..7c921beba75 100644 --- a/sql/share/greek/errmsg.txt +++ b/sql/share/greek/errmsg.txt @@ -305,3 +305,4 @@ character-set=greek "Invalid TIMESTAMP value in column '%s' at row %ld", "Invalid %s character string: '%.64s'", "Result of %s() was larger than max_allowed_packet (%ld) - truncated" +"Conflicting declarations: '%s' and '%s'" diff --git a/sql/share/hungarian/errmsg.txt b/sql/share/hungarian/errmsg.txt index 1f71086ff69..e961b72a38e 100644 --- a/sql/share/hungarian/errmsg.txt +++ b/sql/share/hungarian/errmsg.txt @@ -307,3 +307,4 @@ character-set=latin2 "Invalid TIMESTAMP value in column '%s' at row %ld", "Invalid %s character string: '%.64s'", "Result of %s() was larger than max_allowed_packet (%ld) - truncated" +"Conflicting declarations: '%s' and '%s'" diff --git a/sql/share/italian/errmsg.txt b/sql/share/italian/errmsg.txt index 21158fcb567..02c719fd7c0 100644 --- a/sql/share/italian/errmsg.txt +++ b/sql/share/italian/errmsg.txt @@ -305,3 +305,4 @@ character-set=latin1 "Invalid TIMESTAMP value in column '%s' at row %ld", "Invalid %s character string: '%.64s'", "Result of %s() was larger than max_allowed_packet (%ld) - truncated" +"Conflicting declarations: '%s' and '%s'" diff --git a/sql/share/japanese/errmsg.txt b/sql/share/japanese/errmsg.txt index 3a6dd644d8b..9674f690183 100644 --- a/sql/share/japanese/errmsg.txt +++ b/sql/share/japanese/errmsg.txt @@ -307,3 +307,4 @@ character-set=ujis "Invalid TIMESTAMP value in column '%s' at row %ld", "Invalid %s character string: '%.64s'", "Result of %s() was larger than max_allowed_packet (%ld) - truncated" +"Conflicting declarations: '%s' and '%s'" diff --git a/sql/share/korean/errmsg.txt b/sql/share/korean/errmsg.txt index 356f0a63540..417d9976b7c 100644 --- a/sql/share/korean/errmsg.txt +++ b/sql/share/korean/errmsg.txt @@ -305,3 +305,4 @@ character-set=euckr "Invalid TIMESTAMP value in column '%s' at row %ld", "Invalid %s character string: '%.64s'", "Result of %s() was larger than max_allowed_packet (%ld) - truncated" +"Conflicting declarations: '%s' and '%s'" diff --git a/sql/share/norwegian-ny/errmsg.txt b/sql/share/norwegian-ny/errmsg.txt index b5564cb264e..ae0b307439d 100644 --- a/sql/share/norwegian-ny/errmsg.txt +++ b/sql/share/norwegian-ny/errmsg.txt @@ -307,3 +307,4 @@ character-set=latin1 "Invalid TIMESTAMP value in column '%s' at row %ld", "Invalid %s character string: '%.64s'", "Result of %s() was larger than max_allowed_packet (%ld) - truncated" +"Conflicting declarations: '%s' and '%s'" diff --git a/sql/share/norwegian/errmsg.txt b/sql/share/norwegian/errmsg.txt index fcea45b06ac..246333af497 100644 --- a/sql/share/norwegian/errmsg.txt +++ b/sql/share/norwegian/errmsg.txt @@ -307,3 +307,4 @@ character-set=latin1 "Invalid TIMESTAMP value in column '%s' at row %ld", "Invalid %s character string: '%.64s'", "Result of %s() was larger than max_allowed_packet (%ld) - truncated" +"Conflicting declarations: '%s' and '%s'" diff --git a/sql/share/polish/errmsg.txt b/sql/share/polish/errmsg.txt index 2a18e4de020..417757b2aea 100644 --- a/sql/share/polish/errmsg.txt +++ b/sql/share/polish/errmsg.txt @@ -309,3 +309,4 @@ character-set=latin2 "Invalid TIMESTAMP value in column '%s' at row %ld", "Invalid %s character string: '%.64s'", "Result of %s() was larger than max_allowed_packet (%ld) - truncated" +"Conflicting declarations: '%s' and '%s'" diff --git a/sql/share/portuguese/errmsg.txt b/sql/share/portuguese/errmsg.txt index 6ba0fbca014..344860280cb 100644 --- a/sql/share/portuguese/errmsg.txt +++ b/sql/share/portuguese/errmsg.txt @@ -306,3 +306,4 @@ character-set=latin1 "Invalid TIMESTAMP value in column '%s' at row %ld", "Invalid %s character string: '%.64s'", "Result of %s() was larger than max_allowed_packet (%ld) - truncated" +"Conflicting declarations: '%s' and '%s'" diff --git a/sql/share/romanian/errmsg.txt b/sql/share/romanian/errmsg.txt index 50b2b36c959..6b64d103e61 100644 --- a/sql/share/romanian/errmsg.txt +++ b/sql/share/romanian/errmsg.txt @@ -309,3 +309,4 @@ character-set=latin2 "Invalid TIMESTAMP value in column '%s' at row %ld", "Invalid %s character string: '%.64s'", "Result of %s() was larger than max_allowed_packet (%ld) - truncated" +"Conflicting declarations: '%s' and '%s'" diff --git a/sql/share/russian/errmsg.txt b/sql/share/russian/errmsg.txt index d8641d1dd14..642b792a24f 100644 --- a/sql/share/russian/errmsg.txt +++ b/sql/share/russian/errmsg.txt @@ -307,3 +307,4 @@ character-set=koi8r "Invalid TIMESTAMP value in column '%s' at row %ld", "Invalid %s character string: '%.64s'", "Result of %s() was larger than max_allowed_packet (%ld) - truncated" +"Conflicting declarations: '%s' and '%s'" diff --git a/sql/share/serbian/errmsg.txt b/sql/share/serbian/errmsg.txt index a8cde5a56b1..8c8bc6e9729 100644 --- a/sql/share/serbian/errmsg.txt +++ b/sql/share/serbian/errmsg.txt @@ -311,3 +311,4 @@ character-set=cp1250 "Invalid TIMESTAMP value in column '%s' at row %ld", "Invalid %s character string: '%.64s'", "Result of %s() was larger than max_allowed_packet (%ld) - truncated" +"Conflicting declarations: '%s' and '%s'" diff --git a/sql/share/slovak/errmsg.txt b/sql/share/slovak/errmsg.txt index 42ef7f62076..23814b2cbc2 100644 --- a/sql/share/slovak/errmsg.txt +++ b/sql/share/slovak/errmsg.txt @@ -313,3 +313,4 @@ character-set=latin2 "Invalid TIMESTAMP value in column '%s' at row %ld", "Invalid %s character string: '%.64s'", "Result of %s() was larger than max_allowed_packet (%ld) - truncated" +"Conflicting declarations: '%s' and '%s'" diff --git a/sql/share/spanish/errmsg.txt b/sql/share/spanish/errmsg.txt index b82712be350..113157858ad 100644 --- a/sql/share/spanish/errmsg.txt +++ b/sql/share/spanish/errmsg.txt @@ -307,3 +307,4 @@ character-set=latin1 "Invalid TIMESTAMP value in column '%s' at row %ld", "Invalid %s character string: '%.64s'", "Result of %s() was larger than max_allowed_packet (%ld) - truncated" +"Conflicting declarations: '%s' and '%s'" diff --git a/sql/share/swedish/errmsg.txt b/sql/share/swedish/errmsg.txt index 78620b28a2f..8b43ea8ed0e 100644 --- a/sql/share/swedish/errmsg.txt +++ b/sql/share/swedish/errmsg.txt @@ -305,3 +305,4 @@ character-set=latin1 "Invalid TIMESTAMP value in column '%s' at row %ld", "Invalid %s character string: '%.64s'", "Result of %s() was larger than max_allowed_packet (%ld) - truncated" +"Conflicting declarations: '%s' and '%s'" diff --git a/sql/share/ukrainian/errmsg.txt b/sql/share/ukrainian/errmsg.txt index 6d07eb1a656..4c762bf5313 100644 --- a/sql/share/ukrainian/errmsg.txt +++ b/sql/share/ukrainian/errmsg.txt @@ -310,3 +310,4 @@ character-set=koi8u "Invalid TIMESTAMP value in column '%s' at row %ld", "Invalid %s character string: '%.64s'", "Result of %s() was larger than max_allowed_packet (%ld) - truncated" +"Conflicting declarations: '%s' and '%s'" diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 4eca7359023..1c057e03a11 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -1049,7 +1049,10 @@ create: lex->col_list.empty(); } | CREATE DATABASE opt_if_not_exists ident - { Lex->create_info.default_table_charset=NULL; } + { + Lex->create_info.default_table_charset= NULL; + Lex->create_info.used_fields= 0; + } opt_create_database_options { LEX *lex=Lex; @@ -1136,11 +1139,8 @@ create_database_options: | create_database_options create_database_option {}; create_database_option: - opt_default COLLATE_SYM collation_name_or_default - { Lex->create_info.default_table_charset=$3; } - | opt_default charset charset_name_or_default - { Lex->create_info.default_table_charset=$3; } - ; + default_collation {} + | default_charset {}; opt_table_options: /* empty */ { $$= 0; } @@ -1200,21 +1200,49 @@ create_table_option: table_list->next=0; lex->create_info.used_fields|= HA_CREATE_USED_UNION; } - | opt_default charset opt_equal charset_name_or_default - { - Lex->create_info.default_table_charset= $4; - Lex->create_info.used_fields|= HA_CREATE_USED_DEFAULT_CHARSET; - } - | opt_default COLLATE_SYM opt_equal collation_name_or_default - { - Lex->create_info.default_table_charset= $4; - Lex->create_info.used_fields|= HA_CREATE_USED_DEFAULT_CHARSET; - } + | default_charset + | default_collation | INSERT_METHOD opt_equal merge_insert_types { Lex->create_info.merge_insert_method= $3; Lex->create_info.used_fields|= HA_CREATE_USED_INSERT_METHOD;} | DATA_SYM DIRECTORY_SYM opt_equal TEXT_STRING_sys { Lex->create_info.data_file_name= $4.str; } | INDEX_SYM DIRECTORY_SYM opt_equal TEXT_STRING_sys { Lex->create_info.index_file_name= $4.str; }; +default_charset: + opt_default charset opt_equal charset_name_or_default + { + HA_CREATE_INFO *cinfo= &Lex->create_info; + if ((cinfo->used_fields & HA_CREATE_USED_DEFAULT_CHARSET) && + cinfo->default_table_charset && $4 && + !my_charset_same(cinfo->default_table_charset,$4)) + { + char cs1[32]; + char cs2[32]; + my_snprintf(cs1, sizeof(cs1), "CHARACTER SET %s", + cinfo->default_table_charset->csname); + my_snprintf(cs2, sizeof(cs2), "CHARACTER SET %s", $4->csname); + net_printf(YYTHD, ER_CONFLICTING_DECLARATIONS, cs1, cs2); + YYABORT; + } + Lex->create_info.default_table_charset= $4; + Lex->create_info.used_fields|= HA_CREATE_USED_DEFAULT_CHARSET; + }; + +default_collation: + opt_default COLLATE_SYM opt_equal collation_name_or_default + { + HA_CREATE_INFO *cinfo= &Lex->create_info; + if ((cinfo->used_fields & HA_CREATE_USED_DEFAULT_CHARSET) && + cinfo->default_table_charset && $4 && + !my_charset_same(cinfo->default_table_charset,$4)) + { + net_printf(YYTHD,ER_COLLATION_CHARSET_MISMATCH, + $4->name, cinfo->default_table_charset->csname); + YYABORT; + } + Lex->create_info.default_table_charset= $4; + Lex->create_info.used_fields|= HA_CREATE_USED_DEFAULT_CHARSET; + }; + storage_engines: ident_or_text { @@ -1824,7 +1852,12 @@ alter: } alter_list {} - | ALTER DATABASE ident opt_create_database_options + | ALTER DATABASE ident + { + Lex->create_info.default_table_charset= NULL; + Lex->create_info.used_fields= 0; + } + opt_create_database_options { LEX *lex=Lex; lex->sql_command=SQLCOM_ALTER_DB; From d393ff72b60e1154244c10cf66f79576f3a2bbe4 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 27 Aug 2004 21:12:53 +0500 Subject: [PATCH 45/54] Bu#4526 building with utf8_bin collation causes help to be case sensitive --- scripts/mysql_create_system_tables.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/scripts/mysql_create_system_tables.sh b/scripts/mysql_create_system_tables.sh index 7a30bcdbeca..5a6ea6025f2 100644 --- a/scripts/mysql_create_system_tables.sh +++ b/scripts/mysql_create_system_tables.sh @@ -231,11 +231,11 @@ then c_ht="$c_ht CREATE TABLE help_topic (" c_ht="$c_ht help_topic_id int unsigned not null," - c_ht="$c_ht name varchar(64) not null," + c_ht="$c_ht name nvarchar(64) not null," c_ht="$c_ht help_category_id smallint unsigned not null," c_ht="$c_ht description text not null," c_ht="$c_ht example text not null," - c_ht="$c_ht url varchar(128) not null," + c_ht="$c_ht url nvarchar(128) not null," c_ht="$c_ht primary key (help_topic_id)," c_ht="$c_ht unique index (name)" c_ht="$c_ht )" @@ -252,9 +252,9 @@ then c_hc="$c_hc CREATE TABLE help_category (" c_hc="$c_hc help_category_id smallint unsigned not null," - c_hc="$c_hc name varchar(64) not null," + c_hc="$c_hc name nvarchar(64) not null," c_hc="$c_hc parent_category_id smallint unsigned null," - c_hc="$c_hc url varchar(128) not null," + c_hc="$c_hc url nvarchar(128) not null," c_hc="$c_hc primary key (help_category_id)," c_hc="$c_hc unique index (name)" c_hc="$c_hc )" @@ -269,7 +269,7 @@ then c_hk="$c_hk CREATE TABLE help_keyword (" c_hk="$c_hk help_keyword_id int unsigned not null," - c_hk="$c_hk name varchar(64) not null," + c_hk="$c_hk name nvarchar(64) not null," c_hk="$c_hk primary key (help_keyword_id)," c_hk="$c_hk unique index (name)" c_hk="$c_hk )" From f1825699fa64b2edb46913f1e0d513edd3c30c4e Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 27 Aug 2004 12:27:57 -0500 Subject: [PATCH 46/54] mysql.cc: Minor edits to help command messages. client/mysql.cc: Minor edits to help command messages. --- client/mysql.cc | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/client/mysql.cc b/client/mysql.cc index 9d4e5bb9a94..51c84152298 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -1670,15 +1670,15 @@ static int com_server_help(String *buffer __attribute__((unused)), if (num_fields == 2) { put_info("Many help items for your request exist", INFO_INFO); - put_info("For more specific request please type 'help ' where item is one of next", INFO_INFO); + put_info("To make a more specific request, please type 'help ',\nwhere item is one of next", INFO_INFO); num_name= 0; num_cat= 1; last_char= '_'; } else if ((cur= mysql_fetch_row(result))) { - tee_fprintf(PAGER, "You asked help about help category: \"%s\"\n", cur[0]); - put_info("For a more information type 'help ' where item is one of the following", INFO_INFO); + tee_fprintf(PAGER, "You asked for help about help category: \"%s\"\n", cur[0]); + put_info("For more information, type 'help ', where item is one of the following", INFO_INFO); num_name= 1; num_cat= 2; print_help_item(&cur,1,2,&last_char); @@ -1692,7 +1692,7 @@ static int com_server_help(String *buffer __attribute__((unused)), else { put_info("\nNothing found", INFO_INFO); - put_info("Please try to run 'help contents' for list of all accessible topics\n", INFO_INFO); + put_info("Please try to run 'help contents' for a list of all accessible topics\n", INFO_INFO); } } @@ -1711,9 +1711,9 @@ com_help(String *buffer __attribute__((unused)), if (help_arg) return com_server_help(buffer,line,help_arg+1); - put_info("\nFor the complete MySQL Manual online visit:\n http://www.mysql.com/documentation\n", INFO_INFO); - put_info("For info on technical support from MySQL developers visit:\n http://www.mysql.com/support\n", INFO_INFO); - put_info("For info on MySQL books, utilities, consultants, etc. visit:\n http://www.mysql.com/portal\n", INFO_INFO); + put_info("\nFor the complete MySQL Manual online, visit:\n http://www.mysql.com/documentation\n", INFO_INFO); + put_info("For info on technical support from MySQL developers, visit:\n http://www.mysql.com/support\n", INFO_INFO); + put_info("For info on MySQL books, utilities, consultants, etc., visit:\n http://www.mysql.com/portal\n", INFO_INFO); put_info("List of all MySQL commands:", INFO_INFO); if (!named_cmds) put_info("Note that all text commands must be first on line and end with ';'",INFO_INFO); From ff136de460c1f6dd925d451842b54e511a700094 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 27 Aug 2004 19:33:46 +0200 Subject: [PATCH 47/54] Handle drop ordered index with table id > pool size --- ndb/src/kernel/blocks/dbtux/DbtuxMeta.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/ndb/src/kernel/blocks/dbtux/DbtuxMeta.cpp b/ndb/src/kernel/blocks/dbtux/DbtuxMeta.cpp index 9495c487847..803314ae52d 100644 --- a/ndb/src/kernel/blocks/dbtux/DbtuxMeta.cpp +++ b/ndb/src/kernel/blocks/dbtux/DbtuxMeta.cpp @@ -287,6 +287,22 @@ Dbtux::execDROP_TAB_REQ(Signal* signal) const DropTabReq reqCopy = *(const DropTabReq*)signal->getDataPtr(); const DropTabReq* const req = &reqCopy; IndexPtr indexPtr; + + Uint32 tableId = req->tableId; + Uint32 senderRef = req->senderRef; + Uint32 senderData = req->senderData; + if (tableId >= c_indexPool.getSize()) { + jam(); + // reply to sender + DropTabConf* const conf = (DropTabConf*)signal->getDataPtrSend(); + conf->senderRef = reference(); + conf->senderData = senderData; + conf->tableId = tableId; + sendSignal(senderRef, GSN_DROP_TAB_CONF, + signal, DropTabConf::SignalLength, JBB); + return; + } + c_indexPool.getPtr(indexPtr, req->tableId); // drop works regardless of index state #ifdef VM_TRACE From 43acfcae1f944f0aef999674e7671bf1c52a9caa Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 27 Aug 2004 19:41:00 +0200 Subject: [PATCH 48/54] Better handling of transaction ids, make *sure* that no one gets same transid twice (wo/ restarting process) --- ndb/src/ndbapi/NdbDictionaryImpl.cpp | 2 +- ndb/src/ndbapi/Ndbif.cpp | 4 ++-- ndb/src/ndbapi/Ndbinit.cpp | 4 ++-- ndb/src/ndbapi/TransporterFacade.cpp | 7 ++++--- ndb/src/ndbapi/TransporterFacade.hpp | 8 ++++---- 5 files changed, 13 insertions(+), 12 deletions(-) diff --git a/ndb/src/ndbapi/NdbDictionaryImpl.cpp b/ndb/src/ndbapi/NdbDictionaryImpl.cpp index cb5e3b3c821..a4d66a6c6d2 100644 --- a/ndb/src/ndbapi/NdbDictionaryImpl.cpp +++ b/ndb/src/ndbapi/NdbDictionaryImpl.cpp @@ -682,7 +682,7 @@ NdbDictInterface::~NdbDictInterface() { if (m_transporter != NULL){ if (m_blockNumber != -1) - m_transporter->close(m_blockNumber); + m_transporter->close(m_blockNumber, 0); } } diff --git a/ndb/src/ndbapi/Ndbif.cpp b/ndb/src/ndbapi/Ndbif.cpp index 7ad37401b9a..7ad51efdb62 100644 --- a/ndb/src/ndbapi/Ndbif.cpp +++ b/ndb/src/ndbapi/Ndbif.cpp @@ -97,7 +97,7 @@ Ndb::init(int aMaxNoOfTransactions) } theFirstTransId = ((Uint64)theNdbBlockNumber << 52)+((Uint64)theNode << 40); - theFirstTransId += theFacade->m_open_count; + theFirstTransId += theFacade->m_max_trans_id; theFacade->unlock_mutex(); @@ -175,7 +175,7 @@ error_handler: freeOperation(); delete theDictionary; - TransporterFacade::instance()->close(theNdbBlockNumber); + TransporterFacade::instance()->close(theNdbBlockNumber, 0); return -1; } diff --git a/ndb/src/ndbapi/Ndbinit.cpp b/ndb/src/ndbapi/Ndbinit.cpp index be168ddffbe..b09696d5262 100644 --- a/ndb/src/ndbapi/Ndbinit.cpp +++ b/ndb/src/ndbapi/Ndbinit.cpp @@ -195,9 +195,9 @@ Ndb::~Ndb() NdbGlobalEventBuffer_drop(theGlobalEventBufferHandle); if (TransporterFacade::instance() != NULL && theNdbBlockNumber > 0){ - TransporterFacade::instance()->close(theNdbBlockNumber); + TransporterFacade::instance()->close(theNdbBlockNumber, theFirstTransId); } - + NdbMutex_Lock(&createNdbMutex); theNoOfNdbObjects -= 1; diff --git a/ndb/src/ndbapi/TransporterFacade.cpp b/ndb/src/ndbapi/TransporterFacade.cpp index 7ec9a6a55a3..71b0ff02cd9 100644 --- a/ndb/src/ndbapi/TransporterFacade.cpp +++ b/ndb/src/ndbapi/TransporterFacade.cpp @@ -548,7 +548,7 @@ TransporterFacade::TransporterFacade() : theClusterMgr = NULL; theArbitMgr = NULL; theStartNodeId = 1; - m_open_count = 0; + m_max_trans_id = 0; } bool @@ -684,9 +684,11 @@ TransporterFacade::ReportNodeAlive(NodeId tNodeId) } int -TransporterFacade::close(BlockNumber blockNumber) +TransporterFacade::close(BlockNumber blockNumber, Uint64 trans_id) { NdbMutex_Lock(theMutexPtr); + Uint32 low_bits = (Uint32)trans_id; + m_max_trans_id = m_max_trans_id > low_bits ? m_max_trans_id : low_bits; close_local(blockNumber); NdbMutex_Unlock(theMutexPtr); return 0; @@ -703,7 +705,6 @@ TransporterFacade::open(void* objRef, ExecuteFunction fun, NodeStatusFunction statusFun) { - m_open_count++; return m_threads.open(objRef, fun, statusFun); } diff --git a/ndb/src/ndbapi/TransporterFacade.hpp b/ndb/src/ndbapi/TransporterFacade.hpp index 14da4b11aa1..4dee45a1d1c 100644 --- a/ndb/src/ndbapi/TransporterFacade.hpp +++ b/ndb/src/ndbapi/TransporterFacade.hpp @@ -67,7 +67,7 @@ public: int open(void* objRef, ExecuteFunction, NodeStatusFunction); // Close this block number - int close(BlockNumber blockNumber); + int close(BlockNumber blockNumber, Uint64 trans_id); // Only sends to nodes which are alive int sendSignal(NdbApiSignal * signal, NodeId nodeId); @@ -210,9 +210,9 @@ private: return (m_statusNext[index] & (1 << 16)) != 0; } } m_threads; - - Uint32 m_open_count; - + + Uint32 m_max_trans_id; + /** * execute function */ From f0239303b94fac05535672c11213749ecaa6ecc6 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 27 Aug 2004 21:18:51 +0200 Subject: [PATCH 49/54] - add missing file "read.h" to the source distribution --- cmd-line-utils/libedit/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd-line-utils/libedit/Makefile.am b/cmd-line-utils/libedit/Makefile.am index c532884ca7d..75664b471a1 100644 --- a/cmd-line-utils/libedit/Makefile.am +++ b/cmd-line-utils/libedit/Makefile.am @@ -23,7 +23,7 @@ libedit_a_DEPENDENCIES = @LIBEDIT_LOBJECTS@ pkginclude_HEADERS = readline/readline.h noinst_HEADERS = chared.h el.h histedit.h key.h parse.h refresh.h sig.h \ - sys.h tokenizer.h config.h hist.h map.h prompt.h \ + sys.h tokenizer.h config.h hist.h map.h prompt.h read.h \ search.h tty.h EXTRA_DIST = makelist.sh np/unvis.c np/strlcpy.c np/vis.c np/strlcat.c np/fgetln.c From 8165b519e2d1b0001f03932f58cc63f7b2ac0c75 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 27 Aug 2004 22:52:33 +0200 Subject: [PATCH 50/54] - adding more missing libedit files --- cmd-line-utils/libedit/Makefile.am | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmd-line-utils/libedit/Makefile.am b/cmd-line-utils/libedit/Makefile.am index 75664b471a1..625f6431da1 100644 --- a/cmd-line-utils/libedit/Makefile.am +++ b/cmd-line-utils/libedit/Makefile.am @@ -24,9 +24,9 @@ pkginclude_HEADERS = readline/readline.h noinst_HEADERS = chared.h el.h histedit.h key.h parse.h refresh.h sig.h \ sys.h tokenizer.h config.h hist.h map.h prompt.h read.h \ - search.h tty.h + search.h tty.h libedit_term.h term.h -EXTRA_DIST = makelist.sh np/unvis.c np/strlcpy.c np/vis.c np/strlcat.c np/fgetln.c +EXTRA_DIST = makelist.sh np/unvis.c np/strlcpy.c np/vis.c np/vis.h np/strlcat.c np/fgetln.c CLEANFILES = makelist common.h emacs.h vi.h fcns.h help.h fcns.c help.c From ebf4ce0501486f5eba7b69fe77fb1c49bbd22763 Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 28 Aug 2004 13:07:47 -0500 Subject: [PATCH 51/54] Minor edits to error messsage. --- sql/mysqld.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 74f130e6784..11397736555 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -2687,7 +2687,7 @@ static void handle_connections_methods() (!have_tcpip || opt_disable_networking) && !opt_enable_shared_memory) { - sql_print_error("TCP/IP,--shared-memory or --named-pipe should be configured on NT OS"); + sql_print_error("TCP/IP, --shared-memory, or --named-pipe should be configured on NT OS"); unireg_abort(1); // Will not return } #endif From 7776439c7b28a35bd4f133eb5225a07166170462 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 30 Aug 2004 08:25:17 +0000 Subject: [PATCH 52/54] fixed so that error handler is only invoked once --- ndb/src/kernel/main.cpp | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/ndb/src/kernel/main.cpp b/ndb/src/kernel/main.cpp index 4d3a0afe6ed..79177e57be0 100644 --- a/ndb/src/kernel/main.cpp +++ b/ndb/src/kernel/main.cpp @@ -15,6 +15,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include +#include #include #include "Configuration.hpp" @@ -26,6 +27,7 @@ #include #include #include +#include #include #include @@ -39,6 +41,7 @@ #endif extern EventLogger g_eventLogger; +extern NdbMutex * theShutdownMutex; void catchsigs(bool ignore); // for process signal handling @@ -328,16 +331,18 @@ handler_shutdown(int signum){ extern "C" void handler_error(int signum){ + // only let one thread run shutdown + static long thread_id= 0; + + if (thread_id != 0 && thread_id == my_thread_id()) + ; // Shutdown thread received signal + if(theShutdownMutex && NdbMutex_Trylock(theShutdownMutex) != 0) + while(true) + NdbSleep_MilliSleep(10); + thread_id= my_thread_id(); g_eventLogger.info("Received signal %d. Running error handler.", signum); // restart the system char errorData[40]; snprintf(errorData, 40, "Signal %d received", signum); ERROR_SET(fatal, 0, errorData, __FILE__); } - - - - - - - From 42a7e96adb650e1db4da0049c06bbf140c6728da Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 30 Aug 2004 10:13:09 +0000 Subject: [PATCH 53/54] see resp. file ndb/src/kernel/blocks/cmvmi/Cmvmi.cpp: adder error insert for error during shutdown ndb/src/kernel/error/ErrorHandlingMacros.hpp: seeror set method for signal handler ndb/src/kernel/main.cpp: adder error insert for error during shutdown ndb/src/kernel/vm/Emulator.cpp: adder error insert for error during shutdown + check for error handler invoked by signal handler ndb/src/kernel/vm/Emulator.hpp: enum so signal that Shatdown is invoked by signal handler --- ndb/src/kernel/blocks/cmvmi/Cmvmi.cpp | 11 +++++++++++ ndb/src/kernel/error/ErrorHandlingMacros.hpp | 2 ++ ndb/src/kernel/main.cpp | 10 ++++++++-- ndb/src/kernel/vm/Emulator.cpp | 13 ++++++++++++- ndb/src/kernel/vm/Emulator.hpp | 1 + 5 files changed, 34 insertions(+), 3 deletions(-) diff --git a/ndb/src/kernel/blocks/cmvmi/Cmvmi.cpp b/ndb/src/kernel/blocks/cmvmi/Cmvmi.cpp index e1f199ac411..e2085eb612c 100644 --- a/ndb/src/kernel/blocks/cmvmi/Cmvmi.cpp +++ b/ndb/src/kernel/blocks/cmvmi/Cmvmi.cpp @@ -46,6 +46,7 @@ // Used here only to print event reports on stdout/console. EventLogger g_eventLogger; +extern int simulate_error_during_shutdown; Cmvmi::Cmvmi(const Configuration & conf) : SimulatedBlock(CMVMI, conf) @@ -148,6 +149,16 @@ void Cmvmi::execNDB_TAMPER(Signal* signal) if(ERROR_INSERTED(9997)){ ndbrequire(false); } + + if(ERROR_INSERTED(9996)){ + simulate_error_during_shutdown= SIGSEGV; + ndbrequire(false); + } + + if(ERROR_INSERTED(9995)){ + simulate_error_during_shutdown= SIGSEGV; + kill(getpid(), SIGABRT); + } }//execNDB_TAMPER() void Cmvmi::execSET_LOGLEVELORD(Signal* signal) diff --git a/ndb/src/kernel/error/ErrorHandlingMacros.hpp b/ndb/src/kernel/error/ErrorHandlingMacros.hpp index 416507fee23..d8bb7ff759b 100644 --- a/ndb/src/kernel/error/ErrorHandlingMacros.hpp +++ b/ndb/src/kernel/error/ErrorHandlingMacros.hpp @@ -22,6 +22,8 @@ extern const char programName[]; +#define ERROR_SET_SIGNAL(messageCategory, messageID, problemData, objectRef) \ + ErrorReporter::handleError(messageCategory, messageID, problemData, objectRef, NST_ErrorHandlerSignal) #define ERROR_SET(messageCategory, messageID, problemData, objectRef) \ ErrorReporter::handleError(messageCategory, messageID, problemData, objectRef) // Description: diff --git a/ndb/src/kernel/main.cpp b/ndb/src/kernel/main.cpp index 79177e57be0..1f080b003bc 100644 --- a/ndb/src/kernel/main.cpp +++ b/ndb/src/kernel/main.cpp @@ -335,7 +335,13 @@ handler_error(int signum){ static long thread_id= 0; if (thread_id != 0 && thread_id == my_thread_id()) - ; // Shutdown thread received signal + { + // Shutdown thread received signal + signal(signum, SIG_DFL); + kill(getpid(), signum); + while(true) + NdbSleep_MilliSleep(10); + } if(theShutdownMutex && NdbMutex_Trylock(theShutdownMutex) != 0) while(true) NdbSleep_MilliSleep(10); @@ -344,5 +350,5 @@ handler_error(int signum){ // restart the system char errorData[40]; snprintf(errorData, 40, "Signal %d received", signum); - ERROR_SET(fatal, 0, errorData, __FILE__); + ERROR_SET_SIGNAL(fatal, 0, errorData, __FILE__); } diff --git a/ndb/src/kernel/vm/Emulator.cpp b/ndb/src/kernel/vm/Emulator.cpp index 75aea2bda7f..202c6547a81 100644 --- a/ndb/src/kernel/vm/Emulator.cpp +++ b/ndb/src/kernel/vm/Emulator.cpp @@ -61,6 +61,7 @@ Uint32 theEmulatedJamBlockNumber = 0; EmulatorData globalEmulatorData; NdbMutex * theShutdownMutex = 0; +int simulate_error_during_shutdown= 0; EmulatorData::EmulatorData(){ theConfiguration = 0; @@ -117,7 +118,8 @@ NdbShutdown(NdbShutdownType type, } } - if(NdbMutex_Trylock(theShutdownMutex) == 0){ + if((type == NST_ErrorHandlerSignal) || // Signal handler has already locked mutex + (NdbMutex_Trylock(theShutdownMutex) == 0)){ globalData.theRestartFlag = perform_stop; bool restart = false; @@ -145,6 +147,9 @@ NdbShutdown(NdbShutdownType type, case NST_ErrorHandler: ndbout << "Error handler " << shutting << " system" << endl; break; + case NST_ErrorHandlerSignal: + ndbout << "Error handler signal " << shutting << " system" << endl; + break; case NST_Restart: ndbout << "Restarting system" << endl; break; @@ -175,6 +180,12 @@ NdbShutdown(NdbShutdownType type, #endif } + if (simulate_error_during_shutdown) { + kill(getpid(), simulate_error_during_shutdown); + while(true) + NdbSleep_MilliSleep(10); + } + globalEmulatorData.theWatchDog->doStop(); #ifdef VM_TRACE diff --git a/ndb/src/kernel/vm/Emulator.hpp b/ndb/src/kernel/vm/Emulator.hpp index 8c4504b9ba7..bd240f8679b 100644 --- a/ndb/src/kernel/vm/Emulator.hpp +++ b/ndb/src/kernel/vm/Emulator.hpp @@ -79,6 +79,7 @@ enum NdbShutdownType { NST_Normal, NST_Watchdog, NST_ErrorHandler, + NST_ErrorHandlerSignal, NST_Restart, NST_ErrorInsert }; From 89dd83db35f2c003e9590c4583dd8a9f6ec12c90 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 30 Aug 2004 12:13:10 +0200 Subject: [PATCH 54/54] ndb table locks Removed errornous hupp, which made handler commit same transid several times (which is checked when running in debug mode) sql/ha_ndbcluster.cc: Removed errornous hupp, which made handler commit same transid several times (which is checked when running in debug mode) --- sql/ha_ndbcluster.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index 80b8c21fa0c..8146426fed0 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -2559,6 +2559,8 @@ int ha_ndbcluster::external_lock(THD *thd, int lock_type) When using LOCK TABLE's external_lock is only called when the actual TABLE LOCK is done. Under LOCK TABLES, each used tables will force a call to start_stmt. + Ndb doesn't currently support table locks, and will do ordinary + startTransaction for each transaction/statement. */ int ha_ndbcluster::start_stmt(THD *thd) @@ -2574,7 +2576,9 @@ int ha_ndbcluster::start_stmt(THD *thd) NdbConnection *tablock_trans= (NdbConnection*)thd->transaction.all.ndb_tid; DBUG_PRINT("info", ("tablock_trans: %x", (uint)tablock_trans)); - DBUG_ASSERT(tablock_trans); trans= m_ndb->hupp(tablock_trans); + DBUG_ASSERT(tablock_trans); +// trans= m_ndb->hupp(tablock_trans); + trans= m_ndb->startTransaction(); if (trans == NULL) ERR_RETURN(m_ndb->getNdbError()); thd->transaction.stmt.ndb_tid= trans;