diff options
Diffstat (limited to 'tools')
-rw-r--r-- | tools/Makefile.am | 23 | ||||
-rw-r--r-- | tools/mysqlmanager.c | 46 |
2 files changed, 45 insertions, 24 deletions
diff --git a/tools/Makefile.am b/tools/Makefile.am index 3c786dc9281..5528df4dd68 100644 --- a/tools/Makefile.am +++ b/tools/Makefile.am @@ -1,6 +1,23 @@ -INCLUDES = @MT_INCLUDES@ -I$(srcdir)/../include \ - $(openssl_includes) -I../include -LDADD= @CLIENT_EXTRA_LDFLAGS@ ../libmysql_r/libmysqlclient_r.la @openssl_libs@ +# Copyright (C) 2004 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 +# Process this file with automake to create Makefile.in + +INCLUDES=@MT_INCLUDES@ -I$(top_srcdir)/include $(openssl_includes) +LDADD= @CLIENT_EXTRA_LDFLAGS@ @openssl_libs@ \ + $(top_builddir)/libmysql_r/libmysqlclient_r.la @ZLIB_LIBS@ bin_PROGRAMS= mysqlmanager mysqlmanager_SOURCES= mysqlmanager.c mysqlmanager_DEPENDENCIES= $(LIBRARIES) $(pkglib_LTLIBRARIES) diff --git a/tools/mysqlmanager.c b/tools/mysqlmanager.c index ade6da895c6..bb0a76d6c49 100644 --- a/tools/mysqlmanager.c +++ b/tools/mysqlmanager.c @@ -91,6 +91,8 @@ #define MAX_LAUNCHER_MSG 256 #endif +static CHARSET_INFO *cs= &my_charset_latin1; + #define MAX_RETRY_COUNT 100 /* @@ -283,7 +285,7 @@ struct manager_cmd commands[] = static struct my_option my_long_options[] = { #ifndef DBUG_OFF - {"debug", '#', "Output debug log. Often this is 'd:t:o,filename'", + {"debug", '#', "Output debug log. Often this is 'd:t:o,filename'.", 0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, #endif {"help", '?', "Display this help and exit.", @@ -299,20 +301,20 @@ static struct my_option my_long_options[] = {"tcp-backlog", 'B', "Size of TCP/IP listen queue.", (gptr*) &manager_back_log, (gptr*) &manager_back_log, 0, GET_INT, REQUIRED_ARG, MANAGER_BACK_LOG, 0, 0, 0, 0, 0}, - {"greeting", 'g', "Set greeting on connect", (gptr*) &manager_greeting, + {"greeting", 'g', "Set greeting on connect.", (gptr*) &manager_greeting, (gptr*) &manager_greeting, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"max-command-len", 'm', "Maximum command length", + {"max-command-len", 'm', "Maximum command length.", (gptr*) &manager_max_cmd_len, (gptr*) &manager_max_cmd_len, 0, GET_UINT, REQUIRED_ARG, MANAGER_MAX_CMD_LEN, 0, 0, 0, 0, 0}, - {"one-thread", 'd', "Use one thread ( for debugging)", (gptr*) &one_thread, + {"one-thread", 'd', "Use one thread ( for debugging).", (gptr*) &one_thread, (gptr*) &one_thread, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"connect-retries", 'C', "Number of attempts to establish MySQL connection", + {"connect-retries", 'C', "Number of attempts to establish MySQL connection.", (gptr*) &manager_connect_retries, (gptr*) &manager_connect_retries, 0, GET_INT, REQUIRED_ARG, MANAGER_CONNECT_RETRIES, 0, 0, 0, 0, 0}, - {"password-file", 'p', "Password file for manager", + {"password-file", 'p', "Password file for manager.", (gptr*) &manager_pw_file, (gptr*) &manager_pw_file, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"pid-file", 'f', "Pid file to use", (gptr*) &pid_file, (gptr*) &pid_file, + {"pid-file", 'f', "Pid file to use.", (gptr*) &pid_file, (gptr*) &pid_file, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"version", 'V', "Output version information and exit.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, @@ -430,8 +432,8 @@ static int exec_line(struct manager_thd* thd,char* buf,char* buf_end) { char* p=buf; struct manager_cmd* cmd; - for (;p<buf_end && !isspace(*p);p++) - *p=tolower(*p); + for (;p<buf_end && !my_isspace(cs,*p);p++) + *p=my_tolower(cs,*p); log_info("Command '%s'", buf); if (!(cmd=lookup_cmd(buf,(int)(p-buf)))) { @@ -441,7 +443,7 @@ static int exec_line(struct manager_thd* thd,char* buf,char* buf_end) thd->fatal=1; return 1; } - for (;p<buf_end && isspace(*p);p++); + for (;p<buf_end && my_isspace(cs,*p);p++); return cmd->handler_func(thd,p,buf_end); } @@ -685,7 +687,7 @@ HANDLE_DECL(handle_stop_exec) error="Process not running"; goto err; } - if (mysql_shutdown(&e->mysql)) + if (mysql_shutdown(&e->mysql, SHUTDOWN_DEFAULT)) { /* e->th=0; */ /* th may be a struct */ pthread_mutex_unlock(&e->lock); @@ -718,7 +720,7 @@ HANDLE_DECL(handle_query) int num_fields,i,ident_len; char* ident,*query; query=ident=args_start; - while (!isspace(*query)) + while (!my_isspace(cs,*query)) query++; if (query == ident) { @@ -726,7 +728,7 @@ HANDLE_DECL(handle_query) goto err; } ident_len=(int)(query-ident); - while (query<args_end && isspace(*query)) + while (query<args_end && my_isspace(cs,*query)) query++; if (query == args_end) { @@ -818,7 +820,7 @@ HANDLE_DECL(handle_def_exec) update_req_len(e); hash_delete(&exec_hash,(byte*)old_e); } - hash_insert(&exec_hash,(byte*)e); + my_hash_insert(&exec_hash,(byte*)e); pthread_mutex_unlock(&lock_exec_hash); client_msg(&thd->net,MANAGER_OK,"Exec definition created"); return 0; @@ -1002,7 +1004,7 @@ static int authenticate(struct manager_thd* thd) for (buf=thd->cmd_buf,p=thd->user,p_end=p+MAX_USER_NAME; buf<buf_end && (c=*buf) && p<p_end; buf++,p++) { - if (isspace(c)) + if (my_isspace(cs,c)) { *p=0; break; @@ -1015,7 +1017,7 @@ static int authenticate(struct manager_thd* thd) if (!(u=(struct manager_user*)hash_search(&user_hash,thd->user, (uint)(p-thd->user)))) return 1; - for (;isspace(*buf) && buf<buf_end;buf++) /* empty */; + for (;my_isspace(cs,*buf) && buf<buf_end;buf++) /* empty */; my_MD5Init(&context); my_MD5Update(&context,(uchar*) buf,(uint)(buf_end-buf)); @@ -1584,9 +1586,9 @@ static void manager_exec_free(void* e) static int hex_val(char c) { - if (isdigit(c)) + if (my_isdigit(cs,c)) return c-'0'; - c=tolower(c); + c=my_tolower(cs,c); return c-'a'+10; } @@ -1643,7 +1645,8 @@ static void init_user_hash() FILE* f; char buf[80]; int line_num=1; - if (hash_init(&user_hash,1024,0,0,get_user_key,manager_user_free,MYF(0))) + if (hash_init(&user_hash,cs,1024,0,0, + get_user_key,manager_user_free,MYF(0))) die("Could not initialize user hash"); if (!(f=my_fopen(manager_pw_file, O_RDONLY | O_BINARY, MYF(MY_WME)))) { @@ -1665,7 +1668,7 @@ static void init_user_hash() } else { - hash_insert(&user_hash,(gptr)u); + my_hash_insert(&user_hash,(gptr)u); } } my_fclose(f, MYF(0)); @@ -1689,7 +1692,8 @@ static void init_pid_file() static void init_globals() { pthread_attr_t thr_attr; - if (hash_init(&exec_hash,1024,0,0,get_exec_key,manager_exec_free,MYF(0))) + if (hash_init(&exec_hash,cs,1024,0,0, + get_exec_key,manager_exec_free,MYF(0))) die("Exec hash initialization failed"); if (!one_thread) { |