diff options
author | unknown <jani@hynda.(none)> | 2003-01-28 23:29:59 +0200 |
---|---|---|
committer | unknown <jani@hynda.(none)> | 2003-01-28 23:29:59 +0200 |
commit | 2ea4eedc15f73bdf93feca1795bc7c3dfd174f56 (patch) | |
tree | c7394867f700e23fadd04b92a53ab1d910d212c3 /client/mysqlcheck.c | |
parent | 8b790656f193a5e321462d5727f1b74841d16667 (diff) | |
download | mariadb-git-2ea4eedc15f73bdf93feca1795bc7c3dfd174f56.tar.gz |
Fixed a bug in --auto-repair.
Diffstat (limited to 'client/mysqlcheck.c')
-rw-r--r-- | client/mysqlcheck.c | 42 |
1 files changed, 36 insertions, 6 deletions
diff --git a/client/mysqlcheck.c b/client/mysqlcheck.c index d8b0e84d3c6..3261ec1577d 100644 --- a/client/mysqlcheck.c +++ b/client/mysqlcheck.c @@ -16,7 +16,7 @@ /* By Jani Tolonen, 2001-04-20, MySQL Development Team */ -#define CHECK_VERSION "2.4.2" +#define CHECK_VERSION "2.4.3" #include "client_priv.h" #include <m_ctype.h> @@ -156,6 +156,7 @@ static void dbDisconnect(char *host); static void DBerror(MYSQL *mysql, const char *when); static void safe_exit(int error); static void print_result(); +static char *fix_table_name(char *dest, char *src); int what_to_do = 0; static void print_version(void) @@ -370,7 +371,8 @@ static int process_selected_tables(char *db, char **table_names, int tables) for (end = table_names_comma_sep + 1; tables > 0; tables--, table_names++) { - end = strxmov(end, " `", *table_names, "`,", NullS); + end= fix_table_name(end, *table_names); + *end++= ','; } *--end = 0; handle_request_for_tables(table_names_comma_sep + 1, tot_length - 1); @@ -383,6 +385,22 @@ static int process_selected_tables(char *db, char **table_names, int tables) } /* process_selected_tables */ +static char *fix_table_name(char *dest, char *src) +{ + char *db_sep; + + *dest++= '`'; + if ((db_sep= strchr(src, '.'))) + { + dest= strmake(dest, src, (uint) (db_sep - src)); + dest= strmov(dest, "`.`"); + src= db_sep + 1; + } + dest= strxmov(dest, src, "`", NullS); + return dest; +} + + static int process_all_tables_in_db(char *database) { MYSQL_RES *res; @@ -417,7 +435,8 @@ static int process_all_tables_in_db(char *database) } for (end = tables + 1; (row = mysql_fetch_row(res)) ;) { - end = strxmov(end, " `", row[0], "`,", NullS); + end= fix_table_name(end, row[0]); + *end++= ','; } *--end = 0; if (tot_length) @@ -448,6 +467,7 @@ static int use_db(char *database) static int handle_request_for_tables(char *tables, uint length) { char *query, *end, options[100], message[100]; + uint query_length= 0; const char *op = 0; options[0] = 0; @@ -478,11 +498,21 @@ static int handle_request_for_tables(char *tables, uint length) if (!(query =(char *) my_malloc((sizeof(char)*(length+110)), MYF(MY_WME)))) return 1; if (opt_all_in_1) + { /* No backticks here as we added them before */ - sprintf(query, "%s TABLE %s %s", op, tables, options); + query_length= my_sprintf(query, + (query, "%s TABLE %s %s", op, tables, options)); + } else - sprintf(query, "%s TABLE `%s` %s", op, tables, options); - if (mysql_query(sock, query)) + { + char *ptr; + + ptr= strmov(strmov(query, op), " TABLE "); + ptr= fix_table_name(ptr, tables); + ptr= strxmov(ptr, " ", options, NullS); + query_length= (uint) (ptr - query); + } + if (mysql_real_query(sock, query, query_length)) { sprintf(message, "when executing '%s TABLE ... %s'", op, options); DBerror(sock, message); |