diff options
Diffstat (limited to 'client/mysql.cc')
-rw-r--r-- | client/mysql.cc | 54 |
1 files changed, 32 insertions, 22 deletions
diff --git a/client/mysql.cc b/client/mysql.cc index c9ee6819a13..0b43f9b80ec 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -44,7 +44,7 @@ #include <locale.h> #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 @@ -294,7 +294,7 @@ static const char *server_default_groups[]= HIST_ENTRY is defined for libedit, but not for the real readline Need to redefine it for real readline to find it */ -#if !defined(USE_LIBEDIT_INTERFACE) +#if !defined(HAVE_HIST_ENTRY) typedef struct _hist_entry { const char *line; const char *data; @@ -607,7 +607,7 @@ static struct my_option my_long_options[] = {"silent", 's', "Be more silent. Print results with a tab as separator, each row on new line.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, #ifdef HAVE_SMEM - {"shared_memory_base_name", OPT_SHARED_MEMORY_BASE_NAME, + {"shared-memory-base-name", OPT_SHARED_MEMORY_BASE_NAME, "Base name of shared memory.", (gptr*) &shared_memory_base_name, (gptr*) &shared_memory_base_name, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, #endif @@ -753,8 +753,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), opt_nopager= 1; case OPT_MYSQL_PROTOCOL: { - if ((opt_protocol = find_type(argument, &sql_protocol_typelib,0)) == - ~(ulong) 0) + if ((opt_protocol= find_type(argument, &sql_protocol_typelib,0)) <= 0) { fprintf(stderr, "Unknown option to protocol: %s\n", argument); exit(1); @@ -793,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; @@ -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 <item>' where item is one of next", INFO_INFO); + put_info("To make a more specific request, please type 'help <item>',\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 <item>' 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 <item>', 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); @@ -2020,21 +2020,27 @@ print_table_data(MYSQL_RES *result) while ((cur= mysql_fetch_row(result))) { + ulong *lengths= mysql_fetch_lengths(result); (void) tee_fputs("|", PAGER); mysql_field_seek(result, 0); for (uint off= 0; off < mysql_num_fields(result); off++) { const char *str= cur[off] ? cur[off] : "NULL"; field= mysql_fetch_field(result); - uint length= field->max_length; - if (length > MAX_COLUMN_LENGTH) + uint maxlength= field->max_length; + if (maxlength > MAX_COLUMN_LENGTH) { tee_fputs(str, PAGER); tee_fputs(" |", PAGER); } else - tee_fprintf(PAGER, num_flag[off] ? "%*s |" : " %-*s|", - length, str); + { + uint currlength= (uint) lengths[off]; + uint numcells= charset_info->cset->numcells(charset_info, + str, str + currlength); + tee_fprintf(PAGER, num_flag[off] ? "%*s |" : " %-*s|", + maxlength + currlength - numcells, str); + } } (void) tee_fputs("\n", PAGER); } @@ -2687,8 +2693,9 @@ char *get_arg(char *line, my_bool get_next_arg) ptr++; if (*ptr == '\\') // short command was used ptr+= 2; - while (*ptr &&!my_isspace(charset_info, *ptr)) // skip command - ptr++; + else + while (*ptr &&!my_isspace(charset_info, *ptr)) // skip command + ptr++; } if (!*ptr) return NullS; @@ -2836,13 +2843,16 @@ com_status(String *buffer __attribute__((unused)), MYSQL_RES *result; LINT_INIT(result); tee_fprintf(stdout, "\nConnection id:\t\t%lu\n",mysql_thread_id(&mysql)); - if (!mysql_query(&mysql,"select DATABASE(),USER()") && + if (!mysql_query(&mysql,"select DATABASE(), USER() limit 1") && (result=mysql_use_result(&mysql))) { MYSQL_ROW cur=mysql_fetch_row(result); - tee_fprintf(stdout, "Current database:\t%s\n", cur[0] ? cur[0] : ""); - tee_fprintf(stdout, "Current user:\t\t%s\n",cur[1]); - (void) mysql_fetch_row(result); // Read eof + if (cur) + { + tee_fprintf(stdout, "Current database:\t%s\n", cur[0] ? cur[0] : ""); + tee_fprintf(stdout, "Current user:\t\t%s\n", cur[1]); + } + mysql_free_result(result); } #ifdef HAVE_OPENSSL if (mysql.net.vio && mysql.net.vio->ssl_arg && |