summaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
authorJim Winstead <jimw@mysql.com>2009-07-14 10:08:38 -0700
committerJim Winstead <jimw@mysql.com>2009-07-14 10:08:38 -0700
commitbd0a44fba279633bbbe19c904103ea06644061bb (patch)
tree621df211e8838b5cbacf88d7e41019a2401d4f4f /client
parent5b178e9a2af23226828f9c71fa6b1b82db319a9e (diff)
parentf8e24020847fe98660c15b03258d3a4f6453d819 (diff)
downloadmariadb-git-bd0a44fba279633bbbe19c904103ea06644061bb.tar.gz
Merge in bug fixes for client tools
Diffstat (limited to 'client')
-rw-r--r--client/mysql.cc22
-rw-r--r--client/mysql_upgrade.c6
-rw-r--r--client/mysqladmin.cc11
-rw-r--r--client/mysqlcheck.c4
-rw-r--r--client/mysqldump.c3
-rw-r--r--client/mysqlimport.c17
-rw-r--r--client/mysqlslap.c8
7 files changed, 57 insertions, 14 deletions
diff --git a/client/mysql.cc b/client/mysql.cc
index 5afbc2e960b..05f15e3267a 100644
--- a/client/mysql.cc
+++ b/client/mysql.cc
@@ -2302,8 +2302,10 @@ extern "C" char **new_mysql_completion (const char *text, int start, int end);
*/
#if defined(USE_NEW_READLINE_INTERFACE)
+static int fake_magic_space(int, int);
extern "C" char *no_completion(const char*,int)
#elif defined(USE_LIBEDIT_INTERFACE)
+static int fake_magic_space(const char *, int);
extern "C" int no_completion(const char*,int)
#else
extern "C" char *no_completion()
@@ -2380,6 +2382,18 @@ static int not_in_history(const char *line)
return 1;
}
+
+#if defined(USE_NEW_READLINE_INTERFACE)
+static int fake_magic_space(int, int)
+#else
+static int fake_magic_space(const char *, int)
+#endif
+{
+ rl_insert(1, ' ');
+ return 0;
+}
+
+
static void initialize_readline (char *name)
{
/* Allow conditional parsing of the ~/.inputrc file. */
@@ -2389,12 +2403,15 @@ static void initialize_readline (char *name)
#if defined(USE_NEW_READLINE_INTERFACE)
rl_attempted_completion_function= (rl_completion_func_t*)&new_mysql_completion;
rl_completion_entry_function= (rl_compentry_func_t*)&no_completion;
+
+ rl_add_defun("magic-space", (rl_command_func_t *)&fake_magic_space, -1);
#elif defined(USE_LIBEDIT_INTERFACE)
#ifdef HAVE_LOCALE_H
setlocale(LC_ALL,""); /* so as libedit use isprint */
#endif
rl_attempted_completion_function= (CPPFunction*)&new_mysql_completion;
rl_completion_entry_function= &no_completion;
+ rl_add_defun("magic-space", (Function*)&fake_magic_space, -1);
#else
rl_attempted_completion_function= (CPPFunction*)&new_mysql_completion;
rl_completion_entry_function= &no_completion;
@@ -3308,6 +3325,9 @@ print_table_data(MYSQL_RES *result)
uint visible_length;
uint extra_padding;
+ if (off)
+ (void) tee_fputs(" ", PAGER);
+
if (cur[off] == NULL)
{
buffer= "NULL";
@@ -3342,7 +3362,7 @@ print_table_data(MYSQL_RES *result)
else
tee_print_sized_data(buffer, data_length, field_max_length+extra_padding, FALSE);
}
- tee_fputs(" | ", PAGER);
+ tee_fputs(" |", PAGER);
}
(void) tee_fputs("\n", PAGER);
}
diff --git a/client/mysql_upgrade.c b/client/mysql_upgrade.c
index 641d4a38d16..645fb037647 100644
--- a/client/mysql_upgrade.c
+++ b/client/mysql_upgrade.c
@@ -253,8 +253,12 @@ get_one_option(int optid, const struct my_option *opt,
break;
case 'b': /* --basedir */
- case 'v': /* --verbose */
case 'd': /* --datadir */
+ fprintf(stderr, "%s: the '--%s' option is always ignored\n",
+ my_progname, optid == 'b' ? "basedir" : "datadir");
+ /* FALLTHROUGH */
+
+ case 'v': /* --verbose */
case 'f': /* --force */
add_option= FALSE;
break;
diff --git a/client/mysqladmin.cc b/client/mysqladmin.cc
index 9865b67bb3b..a4e7c5ad0c9 100644
--- a/client/mysqladmin.cc
+++ b/client/mysqladmin.cc
@@ -24,7 +24,7 @@
#include <mysql.h>
#define ADMIN_VERSION "8.42"
-#define MAX_MYSQL_VAR 256
+#define MAX_MYSQL_VAR 512
#define SHUTDOWN_DEF_TIMEOUT 3600 /* Wait for shutdown */
#define MAX_TRUNC_LENGTH 3
@@ -371,7 +371,7 @@ int main(int argc,char *argv[])
}
else
{
- while (!interrupted && (!opt_count_iterations || nr_iterations))
+ while (!interrupted)
{
new_line = 0;
if ((error=execute_commands(&mysql,argc,commands)))
@@ -395,11 +395,11 @@ int main(int argc,char *argv[])
}
if (interval)
{
+ if (opt_count_iterations && --nr_iterations == 0)
+ break;
sleep(interval);
if (new_line)
puts("");
- if (opt_count_iterations)
- nr_iterations--;
}
else
break;
@@ -743,6 +743,9 @@ static int execute_commands(MYSQL *mysql,int argc, char **argv)
mysql_error(mysql));
return -1;
}
+
+ DBUG_ASSERT(mysql_num_rows(res) < MAX_MYSQL_VAR);
+
if (!opt_vertical)
print_header(res);
else
diff --git a/client/mysqlcheck.c b/client/mysqlcheck.c
index c59049d8b72..82aabd77b24 100644
--- a/client/mysqlcheck.c
+++ b/client/mysqlcheck.c
@@ -442,7 +442,7 @@ static int process_selected_tables(char *db, char **table_names, int tables)
{
if (use_db(db))
return 1;
- if (opt_all_in_1)
+ if (opt_all_in_1 && what_to_do != DO_UPGRADE)
{
/*
We need table list in form `a`, `b`, `c`
@@ -536,7 +536,7 @@ static int process_all_tables_in_db(char *database)
num_columns= mysql_num_fields(res);
- if (opt_all_in_1)
+ if (opt_all_in_1 && what_to_do != DO_UPGRADE)
{
/*
We need table list in form `a`, `b`, `c`
diff --git a/client/mysqldump.c b/client/mysqldump.c
index 6d45d901b33..193652b88ff 100644
--- a/client/mysqldump.c
+++ b/client/mysqldump.c
@@ -4810,7 +4810,8 @@ static my_bool get_view_structure(char *table, char* db)
result_table);
check_io(sql_file);
}
- fprintf(sql_file, "/*!50001 DROP TABLE %s*/;\n", opt_quoted_table);
+ /* Table might not exist if this view was dumped with --tab. */
+ fprintf(sql_file, "/*!50001 DROP TABLE IF EXISTS %s*/;\n", opt_quoted_table);
if (opt_drop)
{
fprintf(sql_file, "/*!50001 DROP VIEW IF EXISTS %s*/;\n",
diff --git a/client/mysqlimport.c b/client/mysqlimport.c
index 57aee7379f2..92e9702aea0 100644
--- a/client/mysqlimport.c
+++ b/client/mysqlimport.c
@@ -303,7 +303,8 @@ static int get_options(int *argc, char ***argv)
static int write_to_table(char *filename, MYSQL *mysql)
{
char tablename[FN_REFLEN], hard_path[FN_REFLEN],
- sql_statement[FN_REFLEN*16+256], *end;
+ escaped_name[FN_REFLEN * 2 + 1],
+ sql_statement[FN_REFLEN*16+256], *end, *pos;
DBUG_ENTER("write_to_table");
DBUG_PRINT("enter",("filename: %s",filename));
@@ -338,15 +339,25 @@ static int write_to_table(char *filename, MYSQL *mysql)
fprintf(stdout, "Loading data from SERVER file: %s into %s\n",
hard_path, tablename);
}
+ mysql_real_escape_string(mysql, escaped_name, hard_path,
+ (unsigned long) strlen(hard_path));
sprintf(sql_statement, "LOAD DATA %s %s INFILE '%s'",
opt_low_priority ? "LOW_PRIORITY" : "",
- opt_local_file ? "LOCAL" : "", hard_path);
+ opt_local_file ? "LOCAL" : "", escaped_name);
end= strend(sql_statement);
if (replace)
end= strmov(end, " REPLACE");
if (ignore)
end= strmov(end, " IGNORE");
- end= strmov(strmov(end, " INTO TABLE "), tablename);
+ end= strmov(end, " INTO TABLE `");
+ /* Turn any ` into `` in table name. */
+ for (pos= tablename; *pos; pos++)
+ {
+ if (*pos == '`')
+ *end++= '`';
+ *end++= *pos;
+ }
+ end= strmov(end, "`");
if (fields_terminated || enclosed || opt_enclosed || escaped)
end= strmov(end, " FIELDS");
diff --git a/client/mysqlslap.c b/client/mysqlslap.c
index 316fb6a9da3..70abfbb7136 100644
--- a/client/mysqlslap.c
+++ b/client/mysqlslap.c
@@ -565,8 +565,7 @@ static struct my_option my_long_options[] =
REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"csv", OPT_SLAP_CSV,
"Generate CSV output to named file or to stdout if no file is named.",
- (uchar**) &opt_csv_str, (uchar**) &opt_csv_str, 0, GET_STR,
- OPT_ARG, 0, 0, 0, 0, 0, 0},
+ NULL, NULL, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
#ifdef DBUG_OFF
{"debug", '#', "This is a non-debug version. Catch this and exit.",
0, 0, 0, GET_DISABLED, OPT_ARG, 0, 0, 0, 0, 0, 0},
@@ -740,6 +739,11 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
DBUG_PUSH(argument ? argument : default_dbug_option);
debug_check_flag= 1;
break;
+ case OPT_SLAP_CSV:
+ if (!argument)
+ argument= (char *)"-"; /* use stdout */
+ opt_csv_str= argument;
+ break;
#include <sslopt-case.h>
case 'V':
print_version();