summaryrefslogtreecommitdiff
path: root/client/mysqlimport.c
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/mysqlimport.c
parent5b178e9a2af23226828f9c71fa6b1b82db319a9e (diff)
parentf8e24020847fe98660c15b03258d3a4f6453d819 (diff)
downloadmariadb-git-bd0a44fba279633bbbe19c904103ea06644061bb.tar.gz
Merge in bug fixes for client tools
Diffstat (limited to 'client/mysqlimport.c')
-rw-r--r--client/mysqlimport.c17
1 files changed, 14 insertions, 3 deletions
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");