diff options
author | monty@mysql.com <> | 2004-05-25 22:54:00 +0300 |
---|---|---|
committer | monty@mysql.com <> | 2004-05-25 22:54:00 +0300 |
commit | 390d9898f9adb21c9794b8161749d8e3fcab7820 (patch) | |
tree | b258dbd41e0b45f70adf8c42ee94cce74cd0232f /client | |
parent | 96b6f0a68661a62ba4c92620dac457ad39fc6f0d (diff) | |
parent | 2397f7081af8d5b42b6ec124e68e5279dae2f05a (diff) | |
download | mariadb-git-390d9898f9adb21c9794b8161749d8e3fcab7820.tar.gz |
merge with 4.0 to get Netware patches and fixes for libmysqld.dll
Diffstat (limited to 'client')
-rw-r--r-- | client/mysql.cc | 25 | ||||
-rw-r--r-- | client/mysqladmin.c | 4 | ||||
-rw-r--r-- | client/mysqlbinlog.cc | 5 | ||||
-rw-r--r-- | client/mysqlcheck.c | 4 | ||||
-rw-r--r-- | client/mysqldump.c | 8 | ||||
-rw-r--r-- | client/mysqlimport.c | 5 | ||||
-rw-r--r-- | client/mysqlshow.c | 6 | ||||
-rw-r--r-- | client/mysqltest.c | 112 |
8 files changed, 161 insertions, 8 deletions
diff --git a/client/mysql.cc b/client/mysql.cc index d3885645124..01d867cca07 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -669,6 +669,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) @@ -681,8 +685,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) @@ -916,6 +925,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) @@ -931,7 +941,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 @@ -2384,10 +2398,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; } @@ -2993,6 +3005,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 @@ -3006,6 +3019,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); @@ -3017,6 +3031,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 a2cce3782d6..e6e90fc628c 100644 --- a/client/mysqladmin.c +++ b/client/mysqladmin.c @@ -874,11 +874,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); } @@ -921,6 +923,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 f8993004467..221015f8c7d 100644 --- a/client/mysqlbinlog.cc +++ b/client/mysqlbinlog.cc @@ -490,9 +490,12 @@ static void die(const char* fmt, ...) exit(1); } +#include <help_start.h> + static void print_version() { printf("%s Ver 3.0 for %s at %s\n", my_progname, SYSTEM_TYPE, MACHINE_TYPE); + NETWARE_SET_SCREEN_MODE(1); } @@ -511,6 +514,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 aa4c1282cc1..78e82e670f8 100644 --- a/client/mysqlcheck.c +++ b/client/mysqlcheck.c @@ -172,10 +172,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 */ @@ -206,6 +209,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 97ae0070e04..0366e0da87f 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -332,11 +332,13 @@ static int dump_all_databases(); static char *quote_name(const char *name, char *buff, my_bool force); 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 */ @@ -346,8 +348,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(); @@ -367,6 +371,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 d47ae48b1ac..ccf7fd9880d 100644 --- a/client/mysqlimport.c +++ b/client/mysqlimport.c @@ -147,14 +147,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(); @@ -173,6 +175,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 9dc5c0a30f4..d9e2a1fa92a 100644 --- a/client/mysqlshow.c +++ b/client/mysqlshow.c @@ -209,12 +209,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(); @@ -234,6 +238,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 303473ef558..be2270850fa 100644 --- a/client/mysqltest.c +++ b/client/mysqltest.c @@ -180,6 +180,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; @@ -906,7 +917,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(); @@ -929,6 +940,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)); @@ -3674,3 +3686,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__ */ |