diff options
45 files changed, 778 insertions, 124 deletions
diff --git a/Build-tools/Do-compile b/Build-tools/Do-compile index bd6c89d7ded..c4680d4b7e5 100755 --- a/Build-tools/Do-compile +++ b/Build-tools/Do-compile @@ -237,14 +237,14 @@ if ($opt_stage <= 1) # Only enable InnoDB when requested (required to be able to # build the "Classic" packages that do not include InnoDB) - if ($opt_innodb) - { - $opt_config_options.= " --with-innodb"; - } - else - { - $opt_config_options.= " --without-innodb"; - } + if ($opt_innodb) + { + $opt_config_options.= " --with-innodb"; + } + else + { + $opt_config_options.= " --without-innodb"; + } if ($opt_with_other_libc) { diff --git a/client/mysql.cc b/client/mysql.cc index 46ade3aef26..1fd909a397e 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -590,6 +590,10 @@ static struct my_option my_long_options[] = static void usage(int version) { + /* Divert all help information on NetWare to logger screen. */ +#ifdef __NETWARE__ +#define printf consoleprintf +#endif printf("%s Ver %s Distrib %s, for %s (%s)\n", my_progname, VER, MYSQL_SERVER_VERSION, SYSTEM_TYPE, MACHINE_TYPE); if (version) @@ -602,8 +606,13 @@ and you are welcome to modify and redistribute it under the GPL license\n"); my_print_help(my_long_options); print_defaults("my", load_default_groups); my_print_variables(my_long_options); + NETWARE_SET_SCREEN_MODE(1); +#ifdef __NETWARE__ +#undef printf +#endif } + static my_bool get_one_option(int optid, const struct my_option *opt __attribute__((unused)), char *argument) @@ -812,6 +821,7 @@ static int read_lines(bool execute_commands) #ifdef __NETWARE__ line=fgets(linebuffer, sizeof(linebuffer)-1, stdin); /* Remove the '\n' */ + if (line) { char *p = strrchr(line, '\n'); if (p != NULL) @@ -827,7 +837,11 @@ static int read_lines(bool execute_commands) line= readline(prompt); #endif /* defined( __WIN__) || defined(OS2) || defined(__NETWARE__) */ - if (opt_outfile) + /* + When Ctrl+d or Ctrl+z is pressed, the line may be NULL on some OS + which may cause coredump. + */ + if (opt_outfile && line) fprintf(OUTFILE, "%s\n", line); } if (!line) // End of file @@ -2018,10 +2032,8 @@ static int com_quit(String *buffer __attribute__((unused)), char *line __attribute__((unused))) { -#ifdef __NETWARE__ - // let the screen auto close on a normal shutdown - setscreenmode(SCR_AUTOCLOSE_ON_EXIT); -#endif + /* let the screen auto close on a normal shutdown */ + NETWARE_SET_SCREEN_MODE(SCR_AUTOCLOSE_ON_EXIT); status.exit_status=0; return 1; } @@ -2489,6 +2501,7 @@ void tee_fprintf(FILE *file, const char *fmt, ...) { va_list args; + NETWARE_YIELD; va_start(args, fmt); (void) vfprintf(file, fmt, args); #ifdef OS2 @@ -2502,6 +2515,7 @@ void tee_fprintf(FILE *file, const char *fmt, ...) void tee_fputs(const char *s, FILE *file) { + NETWARE_YIELD; fputs(s, file); #ifdef OS2 fflush( file); @@ -2513,6 +2527,7 @@ void tee_fputs(const char *s, FILE *file) void tee_puts(const char *s, FILE *file) { + NETWARE_YIELD; fputs(s, file); fputs("\n", file); #ifdef OS2 diff --git a/client/mysqladmin.c b/client/mysqladmin.c index 9fbf7e2d64d..3bc11ec0fb0 100644 --- a/client/mysqladmin.c +++ b/client/mysqladmin.c @@ -815,11 +815,13 @@ static int execute_commands(MYSQL *mysql,int argc, char **argv) return 0; } +#include <help_start.h> static void print_version(void) { printf("%s Ver %s Distrib %s, for %s on %s\n",my_progname,ADMIN_VERSION, MYSQL_SERVER_VERSION,SYSTEM_TYPE,MACHINE_TYPE); + NETWARE_SET_SCREEN_MODE(1); } @@ -861,6 +863,8 @@ static void usage(void) version Get version info from server"); } +#include <help_end.h> + static int drop_db(MYSQL *mysql, const char *db) { char name_buff[FN_REFLEN+20], buf[10]; diff --git a/client/mysqlbinlog.cc b/client/mysqlbinlog.cc index 6c6acb750d3..7bceedea4fe 100644 --- a/client/mysqlbinlog.cc +++ b/client/mysqlbinlog.cc @@ -479,9 +479,12 @@ static void die(const char* fmt, ...) exit(1); } +#include <help_start.h> + static void print_version() { printf("%s Ver 2.6 for %s at %s\n", my_progname, SYSTEM_TYPE, MACHINE_TYPE); + NETWARE_SET_SCREEN_MODE(1); } @@ -500,6 +503,8 @@ the mysql command line client\n\n"); my_print_variables(my_long_options); } +#include <help_end.h> + extern "C" my_bool get_one_option(int optid, const struct my_option *opt __attribute__((unused)), char *argument) diff --git a/client/mysqlcheck.c b/client/mysqlcheck.c index 3261ec1577d..1c5638f3c52 100644 --- a/client/mysqlcheck.c +++ b/client/mysqlcheck.c @@ -159,10 +159,13 @@ static void print_result(); static char *fix_table_name(char *dest, char *src); int what_to_do = 0; +#include <help_start.h> + static void print_version(void) { printf("%s Ver %s Distrib %s, for %s (%s)\n", my_progname, CHECK_VERSION, MYSQL_SERVER_VERSION, SYSTEM_TYPE, MACHINE_TYPE); + NETWARE_SET_SCREEN_MODE(1); } /* print_version */ @@ -193,6 +196,7 @@ static void usage(void) my_print_variables(my_long_options); } /* usage */ +#include <help_end.h> static my_bool get_one_option(int optid, const struct my_option *opt __attribute__((unused)), diff --git a/client/mysqldump.c b/client/mysqldump.c index f264b9b61c6..3f3746f2963 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -267,11 +267,13 @@ static char *quote_name(const char *name, char *buff, my_bool force); static void print_quoted_xml(FILE *output, char *fname, char *str, uint len); static const char *check_if_ignore_table(const char *table_name); +#include <help_start.h> static void print_version(void) { printf("%s Ver %s Distrib %s, for %s (%s)\n",my_progname,DUMP_VERSION, - MYSQL_SERVER_VERSION,SYSTEM_TYPE,MACHINE_TYPE); + MYSQL_SERVER_VERSION,SYSTEM_TYPE,MACHINE_TYPE); + NETWARE_SET_SCREEN_MODE(1); } /* print_version */ @@ -281,8 +283,10 @@ static void short_usage_sub(void) printf("OR %s [OPTIONS] --databases [OPTIONS] DB1 [DB2 DB3...]\n", my_progname); printf("OR %s [OPTIONS] --all-databases [OPTIONS]\n", my_progname); + NETWARE_SET_SCREEN_MODE(1); } + static void usage(void) { print_version(); @@ -302,6 +306,8 @@ static void short_usage(void) printf("For more options, use %s --help\n", my_progname); } +#include <help_end.h> + static void write_header(FILE *sql_file, char *db_name) { diff --git a/client/mysqlimport.c b/client/mysqlimport.c index c72e32dd2a7..ca53b74c119 100644 --- a/client/mysqlimport.c +++ b/client/mysqlimport.c @@ -134,14 +134,16 @@ static struct my_option my_long_options[] = static const char *load_default_groups[]= { "mysqlimport","client",0 }; +#include <help_start.h> + static void print_version(void) { printf("%s Ver %s Distrib %s, for %s (%s)\n" ,my_progname, IMPORT_VERSION, MYSQL_SERVER_VERSION,SYSTEM_TYPE,MACHINE_TYPE); + NETWARE_SET_SCREEN_MODE(1); } - static void usage(void) { print_version(); @@ -160,6 +162,7 @@ file. The SQL command 'LOAD DATA INFILE' is used to import the rows.\n"); my_print_variables(my_long_options); } +#include <help_end.h> static my_bool get_one_option(int optid, const struct my_option *opt __attribute__((unused)), diff --git a/client/mysqlshow.c b/client/mysqlshow.c index ccae43e4e27..1a9aec02955 100644 --- a/client/mysqlshow.c +++ b/client/mysqlshow.c @@ -182,12 +182,16 @@ static struct my_option my_long_options[] = }; +#include <help_start.h> + static void print_version(void) { printf("%s Ver %s Distrib %s, for %s (%s)\n",my_progname,SHOW_VERSION, MYSQL_SERVER_VERSION,SYSTEM_TYPE,MACHINE_TYPE); + NETWARE_SET_SCREEN_MODE(1); } + static void usage(void) { print_version(); @@ -207,6 +211,8 @@ are shown"); my_print_variables(my_long_options); } +#include <help_end.h> + static my_bool get_one_option(int optid, const struct my_option *opt __attribute__((unused)), char *argument) diff --git a/client/mysqltest.c b/client/mysqltest.c index 32fb44d178e..638d3ca1d89 100644 --- a/client/mysqltest.c +++ b/client/mysqltest.c @@ -178,6 +178,17 @@ typedef struct int alloced; } VAR; +#ifdef __NETWARE__ +/* + Netware doesn't proved environment variable substitution that is done + by the shell in unix environments. We do this in the following function: +*/ + +static char *subst_env_var(const char *cmd); +static int my_popen(const char *cmd, const char *mode); +#define popen(A,B) my_popen((A),(B)) +#endif /* __NETWARE__ */ + VAR var_reg[10]; /*Perl/shell-like variable registers */ HASH var_hash; @@ -890,7 +901,7 @@ int do_exec(struct st_query* q) while (fgets(buf, sizeof(buf), res_file)) replace_dynstr_append_mem(ds, buf, strlen(buf)); - + if (glob_replace) free_replace(); @@ -913,6 +924,7 @@ int do_exec(struct st_query* q) DBUG_RETURN(error); } + int var_query_set(VAR* v, const char* p, const char** p_end) { char* end = (char*)((p_end && *p_end) ? *p_end : p + strlen(p)); @@ -3458,3 +3470,101 @@ static void get_replace_column(struct st_query *q) } my_free(start, MYF(0)); } + +#ifdef __NETWARE__ + +/* + Substitute environment variables with text. + + SYNOPSIS + subst_env_var() + arg String that should be substitute + + DESCRIPTION + This function takes a string as an input and replaces the + environment variables, that starts with '$' character, with it value. + + NOTES + Return string must be freed with my_free() + + RETURN + String with environment variables replaced. +*/ + +static char *subst_env_var(const char *str) +{ + char *result; + + result= pos= my_malloc(MAX_QUERY, MYF(MY_FAE)); + while (*str) + { + /* + need this only when we want to provide the functionality of + escaping through \ 'backslash' + if ((result == pos && *str=='$') || + (result != pos && *str=='$' && str[-1] !='\\')) + */ + if (*str == '$') + { + char env_var[256], *env_pos= env_var, *subst; + + /* Search for end of environment variable */ + for (str++; + *str && !isspace(*str) && *str != '\\' && *str != '/' && + *str != '$'; + str++) + *env_pos++ *str; + *env_pos= 0; + + if (!(subst= getenv(env_var))) + { + my_free(result, MYF(0)); + die("MYSQLTEST.NLM: Environment variable %s is not defined\n", + env_var); + } + + /* get the string to be substitued for env_var */ + pos= strmov(pos, subst); + /* Process delimiter in *str again */ + } + else + *pos++= *str++; + } + *pos= 0; + return result; +} + + +/* + popen replacement for Netware + + SYNPOSIS + my_popen() + name Command to execute (with possible env variables) + mode Mode for popen. + + NOTES + Environment variable expansion does not take place for popen function + on NetWare, so we use this function to wrap around popen to do this. + + For the moment we ignore 'mode' and always use 'r0' + + RETURN + # >= 0 File handle + -1 Error +*/ + +#undef popen /* Remove wrapper */ + +int my_popen(const char *cmd, const char *mode __attribute__((unused)) t) +{ + char *subst_cmd; + int res_file; + + subst_cmd= subst_env_var(cmd); + res_file= popen(subst_cmd, "r0"); + my_free(subst_cmd, MYF(0)); + return res_file; +} + +#endif /* __NETWARE__ */ diff --git a/configure.in b/configure.in index a50d89c8655..7a1d2228961 100644 --- a/configure.in +++ b/configure.in @@ -4,7 +4,7 @@ dnl Process this file with autoconf to produce a configure script. AC_INIT(sql/mysqld.cc) AC_CANONICAL_SYSTEM # The Docs Makefile.am parses this line! -AM_INIT_AUTOMAKE(mysql, 4.0.19) +AM_INIT_AUTOMAKE(mysql, 4.0.20) AM_CONFIG_HEADER(config.h) PROTOCOL_VERSION=10 @@ -128,8 +128,10 @@ fi # The following hack should ensure that configure doesn't add optimizing # or debugging flags to CFLAGS or CXXFLAGS -CFLAGS="$CFLAGS " -CXXFLAGS="$CXXFLAGS " +# C_EXTRA_FLAGS are flags that are automaticly added to both +# CFLAGS and CXXFLAGS +CFLAGS="$CFLAGS $C_EXTRA_FLAGS " +CXXFLAGS="$CXXFLAGS $C_EXTRA_FLAGS " dnl Checks for programs. AC_PROG_AWK @@ -1119,8 +1121,8 @@ dnl Is this the right match for DEC OSF on alpha? # Add library dependencies to mysqld_DEPENDENCIES lib_DEPENDENCIES="\$(bdb_libs_with_path) \$(innodb_libs) \$(pstack_libs) \$(innodb_system_libs) \$(openssl_libs)" cat > $filesed << EOF -s,\(^.*\$(MAKE) gen_lex_hash\),#\1, -s,\(\./gen_lex_hash\),\1.linux, +s,\(^.*\$(MAKE) gen_lex_hash\)\$(EXEEXT),#\1, +s,\(\./gen_lex_hash\)\$(EXEEXT),\1.linux, s%\(mysqld_DEPENDENCIES = \) %\1$lib_DEPENDENCIES % EOF ;; @@ -2671,6 +2673,7 @@ AC_OUTPUT(Makefile extra/Makefile mysys/Makefile isam/Makefile dnl include/Makefile sql-bench/Makefile tools/Makefile dnl tests/Makefile Docs/Makefile support-files/Makefile dnl support-files/MacOSX/Makefile mysql-test/Makefile dnl + netware/Makefile dnl include/mysql_version.h dnl , , [ test -z "$CONFIG_HEADERS" || echo timestamp > stamp-h diff --git a/extra/perror.c b/extra/perror.c index 6d9744a39da..b4405fdc5dd 100644 --- a/extra/perror.c +++ b/extra/perror.c @@ -16,7 +16,7 @@ /* Return error-text for system error messages and nisam messages */ -#define PERROR_VERSION "2.9" +#define PERROR_VERSION "2.10" #include <my_global.h> #include <my_sys.h> @@ -195,16 +195,30 @@ int main(int argc,char *argv[]) else #endif { + /* + On some system, like NETWARE, strerror(unknown_error) returns a + string 'Unknown Error'. To avoid printing it we try to find the + error string by asking for an impossible big error message. + */ + const char *unknown_error= strerror(10000); + for ( ; argc-- > 0 ; argv++) { found=0; code=atoi(*argv); - msg = strerror(code); - if (msg) + msg= strerror(code); + + /* + Don't print message for not existing error messages or for + unknown errors. We test for 'Uknown Errors' just as an + extra safety for Netware + */ + if (msg && strcmp(msg, "Unknown Error") && + (!unknown_error || strcmp(msg, unknown_error))) { found=1; if (verbose) - printf("Error code %3d: %s\n",code,msg); + printf("System error: %3d = %s\n",code,msg); else puts(msg); } @@ -219,7 +233,7 @@ int main(int argc,char *argv[]) else { if (verbose) - printf("%3d = %s\n",code,msg); + printf("MySql error: %3d = %s\n",code,msg); else puts(msg); } diff --git a/include/config-netware.h b/include/config-netware.h index dab365a7127..c4e63056353 100644 --- a/include/config-netware.h +++ b/include/config-netware.h @@ -14,7 +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 */ -/* Defines for netware compatible with MySQL */ +/* Header for NetWare compatible with MySQL */ + +#ifndef _config_netware_h +#define _config_netware_h /* required headers */ #include <unistd.h> @@ -32,18 +35,28 @@ #include <pthread.h> #include <termios.h> +#ifdef __cplusplus +extern "C" { +#endif + /* required adjustments */ #undef HAVE_READDIR_R #undef HAVE_RWLOCK_INIT #undef HAVE_SCHED_H #undef HAVE_SYS_MMAN_H #undef HAVE_SYNCH_H -#undef HAVE_CRYPT #define HAVE_PTHREAD_ATTR_SETSTACKSIZE 1 #define HAVE_PTHREAD_SIGMASK 1 #define HAVE_PTHREAD_YIELD_ZERO_ARG 1 #define HAVE_BROKEN_REALPATH 1 +/* no libc crypt() function */ +#ifdef HAVE_OPENSSL + #define HAVE_CRYPT 1 +#else + #undef HAVE_CRYPT +#endif /* HAVE_OPENSSL */ + /* include the old function apis */ #define USE_OLD_FUNCTIONS 1 @@ -59,6 +72,9 @@ /* signal by closing the sockets */ #define SIGNAL_WITH_VIO_CLOSE 1 +/* On NetWare, stack grows towards lower address*/ +#define STACK_DIRECTION -1 + /* default directory information */ #define DEFAULT_MYSQL_HOME "sys:/mysql" #define PACKAGE "mysql" @@ -80,6 +96,20 @@ /* do not use the extended time in LibC sys\stat.h */ #define _POSIX_SOURCE +/* Kernel call on NetWare that will only yield if our time slice is up */ +void kYieldIfTimeSliceUp(void); + /* Some macros for portability */ -#define set_timespec(ABSTIME,SEC) { (ABSTIME).tv_sec=(SEC); (ABSTIME).tv_nsec=0; } +#define set_timespec(ABSTIME,SEC) { (ABSTIME).tv_sec=time(NULL)+(SEC); (ABSTIME).tv_nsec=0; } + +/* extra protection against CPU Hogs on NetWare */ +#define NETWARE_YIELD kYieldIfTimeSliceUp() +/* Screen mode for help texts */ +#define NETWARE_SET_SCREEN_MODE(A) setscreenmode(A) + +#ifdef __cplusplus +} +#endif + +#endif /* _config_netware_h */ diff --git a/include/help_end.h b/include/help_end.h new file mode 100644 index 00000000000..a63d9e7ca9f --- /dev/null +++ b/include/help_end.h @@ -0,0 +1,6 @@ +#ifdef __NETWARE__ +#undef printf +#undef puts +#undef fputs +#undef putchar +#endif diff --git a/include/help_start.h b/include/help_start.h new file mode 100644 index 00000000000..38bb91f7655 --- /dev/null +++ b/include/help_start.h @@ -0,0 +1,7 @@ +/* Divert all help information on NetWare to logger screen. */ + +#ifdef __NETWARE__ +#define printf consoleprintf +#define puts(s) consoleprintf("%s\n",s) +#define fputs(s,f) puts(s) +#endif diff --git a/include/my_global.h b/include/my_global.h index e4c0fb44337..30cd1800884 100644 --- a/include/my_global.h +++ b/include/my_global.h @@ -73,6 +73,12 @@ #endif #endif /* _WIN32... */ +/* Some defines to avoid ifdefs in the code */ +#ifndef NETWARE_YIELD +#define NETWARE_YIELD +#define NETWARE_SET_SCREEN_MODE(A) +#endif + /* The macros below are borrowed from include/linux/compiler.h in the Linux kernel. Use them to indicate the likelyhood of the truthfulness diff --git a/include/thr_alarm.h b/include/thr_alarm.h index 0dbb700b4fc..7a10d6886ce 100644 --- a/include/thr_alarm.h +++ b/include/thr_alarm.h @@ -64,7 +64,7 @@ typedef my_bool ALARM; #define init_thr_alarm(A) #define thr_alarm_kill(A) #define resize_thr_alarm(N) -#define end_thr_alarm() +#define end_thr_alarm(A) #else #if defined(__WIN__) diff --git a/isam/isamchk.c b/isam/isamchk.c index 35b4e881962..daa9464eb4f 100644 --- a/isam/isamchk.c +++ b/isam/isamchk.c @@ -333,12 +333,16 @@ static struct my_option my_long_options[] = {0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} }; +#include <help_start.h> + static void print_version(void) { printf("%s Ver 6.01 for %s at %s\n", my_progname, SYSTEM_TYPE, MACHINE_TYPE); + NETWARE_SET_SCREEN_MODE(1); } + static void usage(void) { print_version(); @@ -352,6 +356,8 @@ static void usage(void) my_print_variables(my_long_options); } +#include <help_end.h> + /* Check table */ static int nisamchk(my_string filename) diff --git a/libmysqld/Makefile.am b/libmysqld/Makefile.am index 54bfd6503d4..0bfe1452451 100644 --- a/libmysqld/Makefile.am +++ b/libmysqld/Makefile.am @@ -71,29 +71,35 @@ INC_LIB= $(top_builddir)/regex/libregex.a \ @innodb_libs@ @bdb_libs_with_path@ \ $(top_builddir)/mysys/libmysys.a \ $(top_builddir)/strings/libmystrings.a \ - $(top_builddir)/dbug/libdbug.a \ - $(top_builddir)/regex/libregex.a + $(top_builddir)/dbug/libdbug.a # -# To make it easy for the end user to use the embedded library we -# generate a total libmysqld.a from all library files, +# To make it easy for the end user to use the embedded library we +# generate a total libmysqld.a from all library files, libmysqld.a: libmysqld_int.a $(INC_LIB) - if test ! -d tmp ; then mkdir tmp ; fi - rm -f $@ libmysqld_int2.a tmp/*.o tmp/*.a - cp $(INC_LIB) tmp - cp libmysqld_int.a libmysqld_int2.a ; \ - cd tmp ; \ - for file in *.a ; do \ - bfile=`basename $$file .a` ; \ - ar x $$file; \ - for obj in *.o ; do mv $$obj $${bfile}_$$obj ; done ; \ - ar q ../libmysqld_int2.a *.o ; \ - rm -f *.o ; \ - done - mv libmysqld_int2.a libmysqld.a - rm -f tmp/* - $(RANLIB) libmysqld.a + if test "$(host_os)" = "netware" ; \ + then \ + $(libmysqld_a_AR) libmysqld.a libmysqld_int.a $(INC_LIB) ; \ + else \ + if test ! -d tmp ; then mkdir tmp ; fi ; \ + rm -f $@ libmysqld_int2.a tmp/*.o tmp/*.a ; \ + cp $(INC_LIB) tmp ; \ + cp libmysqld_int.a libmysqld_int2.a ; \ + cd tmp ; \ + for file in *.a ; do \ + bfile=`basename $$file .a` ; \ + ar x $$file; \ + for obj in *.o ; do mv $$obj $${bfile}_$$obj ; done ; \ + ar q ../libmysqld_int2.a *.o ; \ + rm -f *.o ; \ + done ; \ + cd .. ; \ + mv libmysqld_int2.a libmysqld.a ; \ + rm -f tmp/* ; \ + $(RANLIB) libmysqld.a ; \ + fi + ## XXX: any time the client interface changes, we'll need to bump ## the version info for libmysqld; however, it's possible for the diff --git a/myisam/myisam_ftdump.c b/myisam/myisam_ftdump.c index d06cb46bdc1..98548de26a4 100644 --- a/myisam/myisam_ftdump.c +++ b/myisam/myisam_ftdump.c @@ -258,15 +258,18 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), return 0; } +#include <help_start.h> static void usage() { printf("Use: myisam_ftdump <table_name> <index_num>\n"); my_print_help(my_long_options); my_print_variables(my_long_options); + NETWARE_SET_SCREEN_MODE(1); exit(1); } +#include <help_end.h> static void complain(int val) /* Kinda assert :-) */ { diff --git a/myisam/myisamchk.c b/myisam/myisamchk.c index 3df42fb4da7..5377ecc18a5 100644 --- a/myisam/myisamchk.c +++ b/myisam/myisamchk.c @@ -323,10 +323,13 @@ static struct my_option my_long_options[] = }; +#include <help_start.h> + static void print_version(void) { printf("%s Ver 2.6 for %s at %s\n", my_progname, SYSTEM_TYPE, MACHINE_TYPE); + NETWARE_SET_SCREEN_MODE(1); } @@ -433,6 +436,7 @@ static void usage(void) my_print_variables(my_long_options); } +#include <help_end.h> /* Read options */ diff --git a/myisam/myisampack.c b/myisam/myisampack.c index 800203a30e2..872fcb49faf 100644 --- a/myisam/myisampack.c +++ b/myisam/myisampack.c @@ -266,12 +266,15 @@ static struct my_option my_long_options[] = { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} }; +#include <help_start.h> static void print_version(void) { printf("%s Ver 1.22 for %s on %s\n", my_progname, SYSTEM_TYPE, MACHINE_TYPE); + NETWARE_SET_SCREEN_MODE(1); } + static void usage(void) { print_version(); @@ -290,6 +293,7 @@ static void usage(void) my_print_variables(my_long_options); } +#include <help_end.h> static my_bool get_one_option(int optid, const struct my_option *opt __attribute__((unused)), diff --git a/mysys/default.c b/mysys/default.c index a913db2c487..81290322223 100644 --- a/mysys/default.c +++ b/mysys/default.c @@ -471,6 +471,7 @@ static char *remove_end_comment(char *ptr) return ptr; } +#include <help_start.h> void print_defaults(const char *conf_file, const char **groups) { @@ -523,3 +524,5 @@ void print_defaults(const char *conf_file, const char **groups) --defaults-file=# Only read default options from the given file #\n\ --defaults-extra-file=# Read this file after the global files are read"); } + +#include <help_end.h> diff --git a/mysys/my_getopt.c b/mysys/my_getopt.c index da7c0ebd1d2..694c4685667 100644 --- a/mysys/my_getopt.c +++ b/mysys/my_getopt.c @@ -690,6 +690,8 @@ static void init_variables(const struct my_option *options) Print help for all options and variables. */ +#include <help_start.h> + void my_print_help(const struct my_option *options) { uint col, name_space= 22, comment_space= 57; @@ -815,3 +817,5 @@ void my_print_variables(const struct my_option *options) } } } + +#include <help_end.h> diff --git a/mysys/my_init.c b/mysys/my_init.c index 8d4ba2c97b6..dd06ae41dcb 100644 --- a/mysys/my_init.c +++ b/mysys/my_init.c @@ -354,14 +354,16 @@ static my_bool win32_init_tcp_ip() #ifdef __NETWARE__ -/**************************************************************************** - Do basic initialisation for netware needed by most programs -****************************************************************************/ +/* + Basic initialisation for netware +*/ static void netware_init() { char cwd[PATH_MAX], *name; + DBUG_ENTER("netware_init"); + /* init only if we are not a client library */ if (my_progname) { @@ -399,5 +401,7 @@ static void netware_init() } } } + + DBUG_VOID_RETURN; } #endif /* __NETWARE__ */ diff --git a/mysys/my_netware.c b/mysys/my_netware.c index e41dbd0a029..9c604778c2d 100644 --- a/mysys/my_netware.c +++ b/mysys/my_netware.c @@ -15,7 +15,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /* - Function specific to netware + Functions specific to netware */ #include <mysys_priv.h> diff --git a/mysys/my_pthread.c b/mysys/my_pthread.c index 5be38fad734..a8157cc2f91 100644 --- a/mysys/my_pthread.c +++ b/mysys/my_pthread.c @@ -102,16 +102,20 @@ void my_pthread_exit(void *status) NXContext_t ctx; char name[PATH_MAX] = ""; - NXThreadGetContext(tid, &ctx); - NXContextGetName(ctx, name, PATH_MAX); - - /* - "MYSQLD.NLM's LibC Reaper" or "MYSQLD.NLM's main thread" - with a debug build of LibC the reaper can have different names - */ - if (!strindex(name, "\'s")) + /* Do not call pthread_exit if it is not a LibC thread */ + if (tid != 0) { - pthread_exit(status); + NXThreadGetContext(tid, &ctx); + NXContextGetName(ctx, name, PATH_MAX); + + /* + "MYSQLD.NLM's LibC Reaper" or "MYSQLD.NLM's main thread" + with a debug build of LibC the reaper can have different names + */ + if (!strindex(name, "\'s")) + { + pthread_exit(status); + } } } #endif diff --git a/netware/BUILD/compile-netware-all b/netware/BUILD/compile-netware-all index 6baff699e94..dbe64e8f97e 100755 --- a/netware/BUILD/compile-netware-all +++ b/netware/BUILD/compile-netware-all @@ -11,5 +11,5 @@ path=`dirname $0` $path/compile-netware-src $path/compile-netware-standard $path/compile-netware-debug -#$path/compile-netware-max -#$path/compile-netware-max-debug +$path/compile-netware-max +$path/compile-netware-max-debug diff --git a/netware/BUILD/compile-netware-standard b/netware/BUILD/compile-netware-standard index 45f5021862c..a21ea16a445 100755 --- a/netware/BUILD/compile-netware-standard +++ b/netware/BUILD/compile-netware-standard @@ -14,6 +14,7 @@ suffix="standard" extra_configs=" \ --with-innodb \ + --enable-thread-safe-client \ " . $path/compile-netware-END diff --git a/netware/BUILD/mwenv b/netware/BUILD/mwenv index c16ada6552a..22f518bcc0d 100755 --- a/netware/BUILD/mwenv +++ b/netware/BUILD/mwenv @@ -6,9 +6,9 @@ # the default is "F:/mydev" export MYDEV="WINE_BUILD_DIR" -export MWCNWx86Includes="$MYDEV/libc/include;$MYDEV" -export MWNWx86Libraries="$MYDEV/libc/imports;$MYDEV/mw/lib;$MYDEV/mysql-VERSION/netware/BUILD" -export MWNWx86LibraryFiles="libcpre.o;libc.imp;netware.imp;mwcrtl.lib;mwcpp.lib;knetware.imp" +export MWCNWx86Includes="$MYDEV/libc/include;$MYDEV/fs64/headers;$MYDEV" +export MWNWx86Libraries="$MYDEV/libc/imports;$MYDEV/mw/lib;$MYDEV/fs64/imports;$MYDEV/mysql-VERSION/netware/BUILD" +export MWNWx86LibraryFiles="libcpre.o;libc.imp;netware.imp;mwcrtl.lib;mwcpp.lib;neb.imp;zPublics.imp;knetware.imp" export WINEPATH="$MYDEV/mw/bin" diff --git a/netware/Makefile.am b/netware/Makefile.am index 0f5e862c579..8d7efec8e3c 100644 --- a/netware/Makefile.am +++ b/netware/Makefile.am @@ -33,7 +33,8 @@ netware_build_files = client/mysql.def client/mysqladmin.def \ isam/isamlog.def isam/pack_isam.def \ libmysqld/libmysqld.def myisam/myisamchk.def \ myisam/myisamlog.def myisam/myisampack.def \ - sql/mysqld.def + sql/mysqld.def extra/mysql_waitpid.def \ + extra/resolve_stack_dump.def myisam/myisam_ftdump.def link_sources: set -x; \ diff --git a/netware/init_db.sql b/netware/init_db.sql index 1e8354e13a1..569c7bd5283 100644 --- a/netware/init_db.sql +++ b/netware/init_db.sql @@ -20,6 +20,6 @@ INSERT INTO user (host,user) values ('%',''); CREATE TABLE func (name char(64) binary DEFAULT '' NOT NULL, ret tinyint(1) DEFAULT '0' NOT NULL, dl char(128) DEFAULT '' NOT NULL, type enum ('function','aggregate') NOT NULL, PRIMARY KEY (name)) comment='User defined functions'; -CREATE TABLE tables_priv (Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL, Table_name char(60) binary DEFAULT '' NOT NULL, Grantor char(77) DEFAULT '' NOT NULL, Timestamp timestamp(14), Table_priv set('Select','Insert','Update','Delete','Create','Drop','Grant','References','Index','Alter') DEFAULT '' NOT NULL, Column_priv set('Select','Insert','Update','References') DEFAULT '' NOT NULL, PRIMARY KEY (Host,Db,User,Table_name), KEY Grantor (Grantor)) comment='Table privileges'; +CREATE TABLE tables_priv (Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL, Table_name char(64) binary DEFAULT '' NOT NULL, Grantor char(77) DEFAULT '' NOT NULL, Timestamp timestamp(14), Table_priv set('Select','Insert','Update','Delete','Create','Drop','Grant','References','Index','Alter') DEFAULT '' NOT NULL, Column_priv set('Select','Insert','Update','References') DEFAULT '' NOT NULL, PRIMARY KEY (Host,Db,User,Table_name), KEY Grantor (Grantor)) comment='Table privileges'; CREATE TABLE columns_priv (Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL, Table_name char(64) binary DEFAULT '' NOT NULL, Column_name char(64) binary DEFAULT '' NOT NULL, Timestamp timestamp(14), Column_priv set('Select','Insert','Update','References') DEFAULT '' NOT NULL, PRIMARY KEY (Host,Db,User,Table_name,Column_name)) comment='Column privileges'; diff --git a/netware/my_manage.c b/netware/my_manage.c index 1c1e75990b4..f5aa3163431 100644 --- a/netware/my_manage.c +++ b/netware/my_manage.c @@ -180,7 +180,7 @@ int sleep_until_file_exists(char *pid_file) Wait for the server on the given port to start. ******************************************************************************/ -int wait_for_server_start(char *bin_dir, char *user, char *password, int port) +int wait_for_server_start(char *bin_dir, char *user, char *password, int port,char *tmp_dir) { arg_list_t al; int err, i; @@ -189,7 +189,7 @@ int wait_for_server_start(char *bin_dir, char *user, char *password, int port) // mysqladmin file snprintf(mysqladmin_file, PATH_MAX, "%s/mysqladmin", bin_dir); - snprintf(trash, PATH_MAX, "/tmp/trash.out"); + snprintf(trash, PATH_MAX, "%s/trash.out",tmp_dir); // args init_args(&al); @@ -283,7 +283,7 @@ int spawn(char *path, arg_list_t *al, int join, char *input, ******************************************************************************/ int stop_server(char *bin_dir, char *user, char *password, int port, - char *pid_file) + char *pid_file,char *tmp_dir) { arg_list_t al; int err, i, argc = 0; @@ -292,7 +292,7 @@ int stop_server(char *bin_dir, char *user, char *password, int port, // mysqladmin file snprintf(mysqladmin_file, PATH_MAX, "%s/mysqladmin", bin_dir); - snprintf(trash, PATH_MAX, "/tmp/trash.out"); + snprintf(trash, PATH_MAX, "%s/trash.out",tmp_dir); // args init_args(&al); diff --git a/netware/my_manage.h b/netware/my_manage.h index b19662c4ee9..ada02378ee4 100644 --- a/netware/my_manage.h +++ b/netware/my_manage.h @@ -71,11 +71,11 @@ void free_args(arg_list_t *); int sleep_until_file_exists(char *); int sleep_until_file_deleted(char *); -int wait_for_server_start(char *, char *, char *, int); +int wait_for_server_start(char *, char *, char *, int,char *); int spawn(char *, arg_list_t *, int, char *, char *, char *); -int stop_server(char *, char *, char *, int, char *); +int stop_server(char *, char *, char *, int, char *,char *); pid_t get_server_pid(char *); void kill_server(pid_t pid); diff --git a/netware/myisam_ftdump.def b/netware/myisam_ftdump.def new file mode 100644 index 00000000000..259d6617445 --- /dev/null +++ b/netware/myisam_ftdump.def @@ -0,0 +1,12 @@ +#------------------------------------------------------------------------------ +# MySQL MyISAM Dump Tool +#------------------------------------------------------------------------------ +MODULE libc.nlm +SCREENNAME "MySQL MyISAM Table Dump Tool" +COPYRIGHT "(c) 2003 Novell, Inc. Portions (c) 2003 MySQL AB. All Rights Reserved." +DESCRIPTION "MySQL MyISAM Table Dump Tool" +VERSION 4, 0 +STACKSIZE 65536 +XDCDATA ../netware/mysql.xdc +#DEBUG + diff --git a/netware/mysql_install_db.c b/netware/mysql_install_db.c index b4060bfdb7e..355e18b819a 100644 --- a/netware/mysql_install_db.c +++ b/netware/mysql_install_db.c @@ -386,7 +386,8 @@ int main(int argc, char **argv) if (!autoclose) setscreenmode(SCR_NO_MODE); // header - printf("MySQL Server %s, for %s (%s)\n\n", VERSION, SYSTEM_TYPE, MACHINE_TYPE); + printf("MySQL Server %s, for %s (%s)\n\n", VERSION, SYSTEM_TYPE, + MACHINE_TYPE); // create paths create_paths(); diff --git a/netware/mysql_test_run.c b/netware/mysql_test_run.c index e1a07baca6c..06d5e5985c1 100644 --- a/netware/mysql_test_run.c +++ b/netware/mysql_test_run.c @@ -53,6 +53,7 @@ #define TEST_SKIP "[ skip ]" #define TEST_FAIL "[ fail ]" #define TEST_BAD "[ bad ]" +#define TEST_IGNORE "[ignore]" /****************************************************************************** @@ -69,7 +70,8 @@ int master_port = 9306; int slave_port = 9307; // comma delimited list of tests to skip or empty string -char skip_test[PATH_MAX] = ""; +char skip_test[PATH_MAX] = " lowercase_table3 , system_mysql_db_fix "; +char ignore_test[PATH_MAX] = ""; char bin_dir[PATH_MAX]; char mysql_test_dir[PATH_MAX]; @@ -107,6 +109,7 @@ int total_pass = 0; int total_fail = 0; int total_test = 0; +int total_ignore = 0; double total_time = 0; int use_openssl = FALSE; @@ -393,7 +396,7 @@ void start_master() { sleep_until_file_exists(master_pid); - if ((err = wait_for_server_start(bin_dir, user, password, master_port)) == 0) + if ((err = wait_for_server_start(bin_dir, user, password, master_port,mysql_tmp_dir)) == 0) { master_running = TRUE; } @@ -582,7 +585,7 @@ void start_slave() { sleep_until_file_exists(slave_pid); - if ((err = wait_for_server_start(bin_dir, user, password, slave_port)) == 0) + if ((err = wait_for_server_start(bin_dir, user, password, slave_port,mysql_tmp_dir)) == 0) { slave_running = TRUE; } @@ -633,7 +636,7 @@ void stop_slave() if (!slave_running) return; // stop - if ((err = stop_server(bin_dir, user, password, slave_port, slave_pid)) == 0) + if ((err = stop_server(bin_dir, user, password, slave_port, slave_pid,mysql_tmp_dir)) == 0) { slave_running = FALSE; } @@ -657,7 +660,7 @@ void stop_master() // running? if (!master_running) return; - if ((err = stop_server(bin_dir, user, password, master_port, master_pid)) == 0) + if ((err = stop_server(bin_dir, user, password, master_port, master_pid,mysql_tmp_dir)) == 0) { master_running = FALSE; } @@ -778,21 +781,31 @@ void run_test(char *test) char temp[PATH_MAX]; char *rstr; double elapsed = 0; - int skip = FALSE; + int skip = FALSE, ignore=FALSE; int restart = FALSE; int flag = FALSE; struct stat info; // single test? - if (!single_test) +// if (!single_test) { // skip tests in the skip list snprintf(temp, PATH_MAX, " %s ", test); skip = (strindex(skip_test, temp) != NULL); + if( skip == FALSE ) + ignore = (strindex(ignore_test, temp) != NULL); } - // skip test? - if (!skip) + if(ignore) + { + // show test + log("%-46s ", test); + + // ignore + rstr = TEST_IGNORE; + ++total_ignore; + } + else if (!skip) // skip test? { char test_file[PATH_MAX]; char master_opt_file[PATH_MAX]; @@ -1148,9 +1161,33 @@ void setup(char *file) ******************************************************************************/ int main(int argc, char **argv) { + int is_ignore_list = 0; // setup setup(argv[0]); + /* The --ignore option is comma saperated list of test cases to skip and should + * be very first command line option to the test suite. + * The usage is now: + * mysql_test_run --ignore=test1,test2 test3 test4 + * where test1 and test2 are test cases to ignore + * and test3 and test4 are test cases to run. */ + if( argc >= 2 && !strnicmp(argv[1], "--ignore=", sizeof("--ignore=")-1) ) + { + char *temp, *token; + temp=strdup(strchr(argv[1],'=') + 1); + for(token=strtok(temp, ","); token != NULL; token=strtok(NULL, ",")) + { + if( strlen(ignore_test) + strlen(token) + 2 <= PATH_MAX-1 ) + sprintf( ignore_test+strlen(ignore_test), " %s ", token); + else + { + free(temp); + die("ignore list too long."); + } + } + free(temp); + is_ignore_list = 1; + } // header log("MySQL Server %s, for %s (%s)\n\n", VERSION, SYSTEM_TYPE, MACHINE_TYPE); @@ -1165,14 +1202,14 @@ int main(int argc, char **argv) log(HEADER); log(DASH); - if (argc > 1) + if ( argc > 1 + is_ignore_list ) { int i; // single test single_test = TRUE; - for (i = 1; i < argc; i++) + for (i = 1 + is_ignore_list; i < argc; i++) { // run given test run_test(argv[i]); diff --git a/netware/mysql_waitpid.def b/netware/mysql_waitpid.def new file mode 100644 index 00000000000..4d56d29c42f --- /dev/null +++ b/netware/mysql_waitpid.def @@ -0,0 +1,12 @@ +#------------------------------------------------------------------------------ +# Wait for a Program to Terminate +#------------------------------------------------------------------------------ +MODULE libc.nlm +#SCREENNAME "MySQL Tool - Wait for a Program to Terminate" +COPYRIGHT "(c) 2003 Novell, Inc. Portions (c) 2003 MySQL AB. All Rights Reserved." +DESCRIPTION "MySQL Tool - Wait for a Program to Terminate" +VERSION 4, 0 +STACKSIZE 65536 +XDCDATA ../netware/mysql.xdc +#DEBUG + diff --git a/netware/resolve_stack_dump.def b/netware/resolve_stack_dump.def new file mode 100644 index 00000000000..21fd177fbc7 --- /dev/null +++ b/netware/resolve_stack_dump.def @@ -0,0 +1,12 @@ +#------------------------------------------------------------------------------ +# Resolve Stack Dump +#------------------------------------------------------------------------------ +MODULE libc.nlm +#SCREENNAME "MySQL Stack Dump Resolve Tool" +COPYRIGHT "(c) 2003 Novell, Inc. Portions (c) 2003 MySQL AB. All Rights Reserved." +DESCRIPTION "MySQL Stack Dump Resolve Tool" +VERSION 4, 0 +STACKSIZE 65536 +XDCDATA ../netware/mysql.xdc +#DEBUG + diff --git a/scripts/make_binary_distribution.sh b/scripts/make_binary_distribution.sh index c7945e31eda..240efbfad75 100644 --- a/scripts/make_binary_distribution.sh +++ b/scripts/make_binary_distribution.sh @@ -85,8 +85,8 @@ do fi done -for i in COPYING README Docs/INSTALL-BINARY \ - MySQLEULA.txt LICENSE.doc README.NW +for i in COPYING COPYING.LIB README Docs/INSTALL-BINARY \ + MySQLEULA.txt LICENSE.doc README.NW do if [ -f $i ] then @@ -151,6 +151,7 @@ done if [ $BASE_SYSTEM = "netware" ] ; then $CP -r netware/*.pl $BASE/scripts + $CP scripts/mysqlhotcopy $BASE/scripts/mysqlhotcopy.pl fi for i in \ @@ -167,7 +168,7 @@ do fi done -# convert the libs to .lib for NetWare +# convert the .a to .lib for NetWare if [ $BASE_SYSTEM = "netware" ] ; then for i in $BASE/lib/*.a do @@ -233,6 +234,16 @@ fi rm -f $BASE/bin/Makefile* $BASE/bin/*.in $BASE/bin/*.sh $BASE/bin/mysql_install_db $BASE/bin/make_binary_distribution $BASE/bin/setsomevars $BASE/support-files/Makefile* $BASE/support-files/*.sh + +# +# Remove system dependent files +# +if [ $BASE_SYSTEM = "netware" ] ; then + rm -f $BASE/MySQLEULA.txt +else + rm -f $BASE/README.NW +fi + # Make safe_mysqld a symlink to mysqld_safe for backwards portability # To be removed in MySQL 4.1 (cd $BASE/bin ; ln -s mysqld_safe safe_mysqld ) @@ -294,29 +305,47 @@ which_1 () exit 1 } -# -# Create the result tar file -# +if [ $BASE_SYSTEM != "netware" ] ; then -tar=`which_1 gnutar gtar` -if test "$?" = "1" -o "$tar" = "" -then - tar=tar -fi + # + # Create the result tar file + # + + tar=`which_1 gnutar gtar` + if test "$?" = "1" -o "$tar" = "" + then + tar=tar + fi + + echo "Using $tar to create archive" + cd $TMP + + OPT=cvf + if [ x$SILENT = x1 ] ; then + OPT=cf + fi + + $tar $OPT $SOURCE/$NEW_NAME.tar $NEW_NAME + cd $SOURCE + echo "Compressing archive" + rm -f $NEW_NAME.tar.gz + gzip -9 $NEW_NAME.tar + echo "Removing temporary directory" + rm -r -f $BASE + + echo "$NEW_NAME.tar.gz created" +else -echo "Using $tar to create archive" -cd $TMP + # + # Create a zip file for NetWare users + # -OPT=cvf -if [ x$SILENT = x1 ] ; then - OPT=cf -fi + cd $TMP + if test -e "$SOURCE/$NEW_NAME.zip"; then rm $SOURCE/$NEW_NAME.zip; fi + zip -r $SOURCE/$NEW_NAME.zip $NEW_NAME + echo "Removing temporary directory" + rm -r -f $BASE -$tar $OPT $SOURCE/$NEW_NAME.tar $NEW_NAME -cd $SOURCE -echo "Compressing archive" -gzip -9 $NEW_NAME.tar -echo "Removing temporary directory" -rm -r -f $BASE + echo "$NEW_NAME.zip created" -echo "$NEW_NAME.tar.gz created" +fi diff --git a/scripts/mysqlhotcopy.sh b/scripts/mysqlhotcopy.sh index ab06215c3ac..6388855eaa6 100644 --- a/scripts/mysqlhotcopy.sh +++ b/scripts/mysqlhotcopy.sh @@ -7,6 +7,7 @@ use File::Basename; use File::Path; use DBI; use Sys::Hostname; +use File::Copy; =head1 NAME @@ -230,6 +231,10 @@ elsif (defined($tgt_name) && ($tgt_name =~ m:/: || $tgt_name eq '.')) { elsif ( $opt{suffix} ) { print "Using copy suffix '$opt{suffix}'\n" unless $opt{quiet}; } +elsif ( ($^O =~ m/^(NetWare)$/) && defined($tgt_name) && ($tgt_name =~ m:\\: || $tgt_name eq '.')) +{ + $tgt_dirname = $tgt_name; +} else { $tgt_name="" if (!defined($tgt_name)); @@ -421,8 +426,11 @@ foreach my $rdb ( @db_desc ) { else { mkdir($tgt_dirpath, 0750) or die "Can't create '$tgt_dirpath': $!\n" unless -d $tgt_dirpath; + if ($^O !~ m/^(NetWare)$/) + { my @f_info= stat "$datadir/$rdb->{src}"; chown $f_info[4], $f_info[5], $tgt_dirpath; + } } } } @@ -578,7 +586,15 @@ sub copy_files { my @cmd; print "Copying ".@$files." files...\n" unless $opt{quiet}; - if ($method =~ /^s?cp\b/) { # cp or scp with optional flags + if ($^O =~ m/^(NetWare)$/) # on NetWare call PERL copy (slower) + { + foreach my $file ( @$files ) + { + copy($file, $target."/".basename($file)); + } + } + elsif ($method =~ /^s?cp\b/) # cp or scp with optional flags + { my $cp = $method; # add option to preserve mod time etc of copied files # not critical, but nice to have @@ -717,7 +733,7 @@ sub retire_directory { if ( -d $tgt_oldpath ) { print "Deleting previous 'old' hotcopy directory ('$tgt_oldpath')\n" unless $opt{quiet}; - rmtree([$tgt_oldpath]) + rmtree([$tgt_oldpath],0,1); } rename($dir, $tgt_oldpath) or die "Can't rename $dir=>$tgt_oldpath: $!\n"; diff --git a/sql/mysqld.cc b/sql/mysqld.cc index c1ea29caa88..23af9f8d23e 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -125,11 +125,28 @@ int deny_severity = LOG_WARNING; #include <nks/vm.h> #include <library.h> #include <monitor.h> - +#include <zOmni.h> //For NEB +#include <neb.h> //For NEB +#include <nebpub.h> //For NEB +#include <zEvent.h> //For NSS event structures +#include <zPublics.h> + +void *neb_consumer_id=NULL; //For storing NEB consumer id +char datavolname[256]={0}; +VolumeID_t datavolid; event_handle_t eh; Report_t ref; +void *refneb=NULL; +int volumeid=-1; + + /* NEB event callback */ +unsigned long neb_event_callback(struct EventBlock *eblock); +void registerwithneb(); +void getvolumename(); +void getvolumeID(BYTE *volumeName); #endif /* __NETWARE__ */ + #ifdef _AIX41 int initgroups(const char *,unsigned int); #endif @@ -1424,6 +1441,7 @@ static void start_signal_handler(void) static void check_data_home(const char *path) {} + #elif defined(__NETWARE__) // down server event callback @@ -1432,27 +1450,196 @@ void mysql_down_server_cb(void *, void *) kill_server(0); } + // destroy callback resources void mysql_cb_destroy(void *) { UnRegisterEventNotification(eh); // cleanup down event notification NX_UNWRAP_INTERFACE(ref); + + /* Deregister NSS volume deactivation event */ + NX_UNWRAP_INTERFACE(refneb); + if (neb_consumer_id) + UnRegisterConsumer(neb_consumer_id, NULL); } + // initialize callbacks void mysql_cb_init() { // register for down server event void *handle = getnlmhandle(); - rtag_t rt = AllocateResourceTag(handle, "MySQL Down Server Callback", - EventSignature); + rtag_t rt= AllocateResourceTag(handle, "MySQL Down Server Callback", + EventSignature); NX_WRAP_INTERFACE((void *)mysql_down_server_cb, 2, (void **)&ref); - eh = RegisterForEventNotification(rt, EVENT_DOWN_SERVER, - EVENT_PRIORITY_APPLICATION, - NULL, ref, NULL); + eh= RegisterForEventNotification(rt, EVENT_PRE_DOWN_SERVER, + EVENT_PRIORITY_APPLICATION, + NULL, ref, NULL); + + /* + Register for volume deactivation event + Wrap the callback function, as it is called by non-LibC thread + */ + (void)NX_WRAP_INTERFACE(neb_event_callback, 1, &refneb); + registerwithneb(); + NXVmRegisterExitHandler(mysql_cb_destroy, NULL); // clean-up } + +/ *To get the name of the NetWare volume having MySQL data folder */ + +void getvolumename() +{ + char *p; + /* + We assume that data path is already set. + If not it won't come here. Terminate after volume name + */ + if ((p= strchr(mysql_real_data_home, ':'))) + strmake(datavolname, mysql_real_data_home, + (uint) (p - mysql_real_data_home)); +} + + +/* + Registering with NEB for NSS Volume Deactivation event +*/ + +void registerwithneb() +{ + + ConsumerRegistrationInfo reg_info; + + /* Clear NEB registration structure */ + bzero((char*) ®_info, sizeof(struct ConsumerRegistrationInfo)); + + /* Fill the NEB consumer information structure */ + reg_info.CRIVersion= 1; // NEB version + /* NEB Consumer name */ + reg_info.CRIConsumerName= (BYTE *) "MySQL Database Server"; + /* Event of interest */ + reg_info.CRIEventName= (BYTE *) "NSS.ChangeVolState.Enter"; + reg_info.CRIUserParameter= NULL; // Consumer Info + reg_info.CRIEventFlags= 0; // Event flags + /* Consumer NLM handle */ + reg_info.CRIOwnerID= (LoadDefinitionStructure *)getnlmhandle(); + reg_info.CRIConsumerESR= NULL; // No consumer ESR required + reg_info.CRISecurityToken= 0; // No security token for the event + reg_info.CRIConsumerFlags= 0; // SMP_ENABLED_BIT; + reg_info.CRIFilterName= 0; // No event filtering + reg_info.CRIFilterDataLength= 0; // No filtering data + reg_info.CRIFilterData= 0; // No filtering data + /* Callback function for the event */ + (void *)reg_info.CRIConsumerCallback= (void *) refneb; + reg_info.CRIOrder= 0; // Event callback order + reg_info.CRIConsumerType= CHECK_CONSUMER; // Consumer type + + /* Register for the event with NEB */ + if (RegisterConsumer(®_info)) + { + consoleprintf("Failed to register for NSS Volume Deactivation event \n"); + return; + } + /* This ID is required for deregistration */ + neb_consumer_id= reg_info.CRIConsumerID; + + /* Get MySQL data volume name, stored in global variable datavolname */ + getvolumename(); + + /* + Get the NSS volume ID of the MySQL Data volume. + Volume ID is stored in a global variable + */ + getvolumeID((BYTE*) datavolname); +} + + +/* + Callback for NSS Volume Deactivation event +*/ +ulong neb_event_callback(struct EventBlock *eblock) +{ + EventChangeVolStateEnter_s *voldata; + voldata= (EventChangeVolStateEnter_s *)eblock->EBEventData; + + /* Deactivation of a volume */ + if ((voldata->oldState == 6 && voldata->newState == 2)) + { + /* + Ensure that we bring down MySQL server only for MySQL data + volume deactivation + */ + if (!memcmp(&voldata->volID, &datavolid, sizeof(VolumeID_t))) + { + consoleprintf("MySQL data volume is deactivated, shutting down MySQL Server \n"); + kill_server(0); + } + } + return 0; +} + + +/* + Function to get NSS volume ID of the MySQL data +*/ + +#define ADMIN_VOL_PATH "_ADMIN:/Volumes/" + +void getvolumeID(BYTE *volumeName) +{ + char path[zMAX_FULL_NAME]; + Key_t rootKey= 0, fileKey= 0; + QUAD getInfoMask; + zInfo_s info; + STATUS status; + + /* Get the root key */ + if ((status= zRootKey(0, &rootKey)) != zOK) + { + consoleprintf("\nGetNSSVolumeProperties - Failed to get root key, status: %d\n.", (int) status); + goto exit; + } + + /* + Get the file key. This is the key to the volume object in the + NSS admin volumes directory. + */ + + strxmov(path, (const char *) ADMIN_VOL_PATH, (const char *) volumeName, + NullS); + if ((status= zOpen(rootKey, zNSS_TASK, zNSPACE_LONG|zMODE_UTF8, + (BYTE *) path, zRR_READ_ACCESS, &fileKey)) != zOK) + { + consoleprintf("\nGetNSSVolumeProperties - Failed to get file, status: %d\n.", (int) status); + goto exit; + } + + getInfoMask= zGET_IDS | zGET_VOLUME_INFO ; + if ((status= zGetInfo(fileKey, getInfoMask, sizeof(info), + zINFO_VERSION_A, &info)) != zOK) + { + consoleprintf("\nGetNSSVolumeProperties - Failed in zGetInfo, status: %d\n.", (int) status); + goto exit; + } + + /* Copy the data to global variable */ + datavolid.timeLow= info.vol.volumeID.timeLow; + datavolid.timeMid= info.vol.volumeID.timeMid; + datavolid.timeHighAndVersion= info.vol.volumeID.timeHighAndVersion; + datavolid.clockSeqHighAndReserved= info.vol.volumeID.clockSeqHighAndReserved; + datavolid.clockSeqLow= info.vol.volumeID.clockSeqLow; + /* This is guranteed to be 6-byte length (but sizeof() would be better) */ + memcpy(datavolid.node, info.vol.volumeID.node, (unsigned int) 6); + +exit: + if (rootKey) + zClose(rootKey); + if (fileKey) + zClose(fileKey); +} + + static void init_signals(void) { int signals[] = {SIGINT,SIGILL,SIGFPE,SIGSEGV,SIGTERM,SIGABRT}; @@ -1462,6 +1649,7 @@ static void init_signals(void) mysql_cb_init(); // initialize callbacks } + static void start_signal_handler(void) { // Save vm id of this process @@ -1471,7 +1659,12 @@ static void start_signal_handler(void) } -/* Warn if the data is on a Traditional volume */ +/* + Warn if the data is on a Traditional volume + + NOTE + Already done by mysqld_safe +*/ static void check_data_home(const char *path) { @@ -1819,7 +2012,7 @@ extern "C" void *signal_hand(void *arg __attribute__((unused))) (REFRESH_LOG | REFRESH_TABLES | REFRESH_FAST | REFRESH_STATUS | REFRESH_GRANT | REFRESH_THREADS | REFRESH_HOSTS), - (TABLE_LIST*) 0); // Flush logs + (TABLE_LIST*) 0); // Flush logs mysql_print_status((THD*) 0); // Send debug some info } break; @@ -1910,6 +2103,7 @@ extern "C" pthread_handler_decl(handle_shutdown,arg) return 0; } + int STDCALL handle_kill(ulong ctrl_type) { if (ctrl_type == CTRL_CLOSE_EVENT || @@ -1922,6 +2116,7 @@ int STDCALL handle_kill(ulong ctrl_type) } #endif + #ifdef OS2 extern "C" pthread_handler_decl(handle_shutdown,arg) { @@ -4662,6 +4857,10 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), opt_specialflag|=SPECIAL_LONG_LOG_FORMAT; break; case (int) OPT_SKIP_NETWORKING: +#if defined(__NETWARE__) + sql_perror("Can't start server: skip-networking option is currently not supported on NetWare"); + exit(1); +#endif opt_disable_networking=1; mysql_port=0; break; diff --git a/tools/mysqlmanager.c b/tools/mysqlmanager.c index 790a5d56b5a..27dfa18e421 100644 --- a/tools/mysqlmanager.c +++ b/tools/mysqlmanager.c @@ -21,6 +21,8 @@ Sasha Pachev <sasha@mysql.com> */ +#ifndef __NETWARE__ + #include <my_global.h> #include <my_pthread.h> #include <mysql.h> @@ -1846,3 +1848,16 @@ int main(int argc, char** argv) else return daemonize(); } + +#else + +#include <stdio.h> + +int main(void) +{ + fprintf(stderr,"This tool has not been ported to NetWare\n"); + return 0; +} + +#endif /* __NETWARE__ */ + diff --git a/vio/test-ssl.c b/vio/test-ssl.c index 84bae5fa0c7..88df6936a1f 100644 --- a/vio/test-ssl.c +++ b/vio/test-ssl.c @@ -15,7 +15,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include <my_global.h> -#ifdef HAVE_OPENSSL +#if defined(HAVE_OPENSSL) && !defined(__NETWARE__) #include <my_sys.h> #include <m_string.h> #include <m_ctype.h> diff --git a/vio/viossl.c b/vio/viossl.c index fafe48b7a84..a489cb98f98 100644 --- a/vio/viossl.c +++ b/vio/viossl.c @@ -25,6 +25,31 @@ #ifdef HAVE_OPENSSL +#ifdef __NETWARE__ +/* + The default OpenSSL implementation on NetWare uses WinSock. + This code allows us to use the BSD sockets. +*/ + +static int SSL_set_fd_bsd(SSL *s, int fd) +{ + int result= -1; + BIO_METHOD *BIO_s_bsdsocket(); + BIO *bio; + + if ((bio= BIO_new(BIO_s_bsdsocket()))) + { + result= BIO_set_fd(bio, fd, BIO_NOCLOSE); + SSL_set_bio(s, bio, bio); + } + return result; +} + +#define SSL_set_fd(A, B) SSL_set_fd_bsd((A), (B)) + +#endif /* __NETWARE__ */ + + static void report_errors() { diff --git a/vio/viosslfactories.c b/vio/viosslfactories.c index 0997e3909db..498d10da0ee 100644 --- a/vio/viosslfactories.c +++ b/vio/viosslfactories.c @@ -172,6 +172,35 @@ vio_verify_callback(int ok, X509_STORE_CTX *ctx) } +#ifdef __NETWARE__ + +/* NetWare SSL cleanup */ +void netware_ssl_cleanup() +{ + /* free memory from SSL_library_init() */ + EVP_cleanup(); + + /* free global X509 method */ + X509_STORE_method_cleanup(); + + /* free the thread_hash error table */ + ERR_free_state_table(); +} + + +/* NetWare SSL initialization */ +static void netware_ssl_init() +{ + /* initialize OpenSSL library */ + SSL_library_init(); + + /* cleanup OpenSSL library */ + NXVmRegisterExitHandler(netware_ssl_cleanup, NULL); +} + +#endif /* __NETWARE__ */ + + /************************ VioSSLConnectorFd **********************************/ /* TODO: @@ -188,7 +217,7 @@ new_VioSSLConnectorFd(const char* key_file, int verify = SSL_VERIFY_NONE; struct st_VioSSLConnectorFd* ptr; int result; - DH *dh=NULL; + DH *dh; DBUG_ENTER("new_VioSSLConnectorFd"); DBUG_PRINT("enter", ("key_file=%s, cert_file=%s, ca_path=%s, ca_file=%s, cipher=%s", @@ -202,6 +231,10 @@ new_VioSSLConnectorFd(const char* key_file, ptr->ssl_method= 0; /* FIXME: constants! */ +#ifdef __NETWARE__ + netware_ssl_init(); +#endif + if (!ssl_algorithms_added) { DBUG_PRINT("info", ("todo: OpenSSL_add_all_algorithms()")); @@ -279,7 +312,7 @@ new_VioSSLAcceptorFd(const char *key_file, SSL_VERIFY_CLIENT_ONCE); struct st_VioSSLAcceptorFd* ptr; int result; - DH *dh=NULL; + DH *dh; DBUG_ENTER("new_VioSSLAcceptorFd"); DBUG_PRINT("enter", ("key_file=%s, cert_file=%s, ca_path=%s, ca_file=%s, cipher=%s", @@ -292,6 +325,10 @@ new_VioSSLAcceptorFd(const char *key_file, /* FIXME: constants! */ ptr->session_id_context= ptr; +#ifdef __NETWARE__ + netware_ssl_init(); +#endif + if (!ssl_algorithms_added) { DBUG_PRINT("info", ("todo: OpenSSL_add_all_algorithms()")); |