Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions client/mysqlimport.c
Original file line number Diff line number Diff line change
Expand Up @@ -431,16 +431,22 @@ static void lock_table(MYSQL *mysql, int tablecount, char **raw_tablename)
{
DYNAMIC_STRING query;
int i;
char tablename[FN_REFLEN];
char tablename[FN_REFLEN], *pos;

if (verbose)
fprintf(stdout, "Locking tables for write\n");
init_dynamic_string(&query, "LOCK TABLES ", 256, 1024);
for (i=0 ; i < tablecount ; i++)
{
fn_format(tablename, raw_tablename[i], "", "", 1 | 2);
dynstr_append(&query, tablename);
dynstr_append(&query, " WRITE,");
dynstr_append(&query, "`");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest you use the new mysql_real_escape_string_quote() API here instead of trying to do the escaping yourself.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for (pos= tablename; *pos; pos++)
{
if (*pos == '`')
dynstr_append(&query, "`");
dynstr_append_mem(&query, pos, 1);
}
dynstr_append(&query, "` WRITE,");
}
if (mysql_real_query(mysql, query.str, (ulong)(query.length-1)))
db_error(mysql); /* We shall countinue here, if --force was given */
Expand Down