Bug #5829 mysqlimport garbles path of the file to be imported
Submitted: 30 Sep 2004 17:29 Modified: 1 Nov 2004 16:38
Reporter: Sinisa Milivojevic Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Command-line Clients Severity:S2 (Serious)
Version:4.0 OS:Linux (Linux server, Win /Linux client)
Assigned to: Reggie Burnett

[30 Sep 2004 17:29] Sinisa Milivojevic
Description:
When mysqlimport is run from Windows and it is used to import a file that is on the server, which is another machine running Unix, then this bug occurs.

If a file on the server has a full path of, for example:

  /home/billy/myimport.txt

Then any command for mysqlimport, like:

mysqlimport -uroot -p******* -hebt2k06 --delete test /home/billy/myimport.txt

will fail.

A command will fail if backslashes are used or if any quotes are used.

How to repeat:

mysqlimport -uroot -p******* -hebt2k06 --delete test /home/billy/myimport.txt
[1 Oct 2004 19:52] Miguel Solorzano
The issue here is in the function:

/mysqlimport.c
--241--
 
static int write_to_table(char *filename, MYSQL *sock)
{

The variable: local_file == 1

and  the sql statement is convert to LOCAL:

sprintf(sql_statement, "LOAD DATA %s %s INFILE '%s'",
	  opt_low_priority ? "LOW_PRIORITY" : "",
	  local_file ? "LOCAL" : "", hard_path);

sql_statement	0x0012dc60 "LOAD DATA  LOCAL INFILE '/home/miguel/files/sinisa.txt'"

and then fails. Removing the LOCAL clause:

c:\mysql\bin>mysqlimport -umiguel -p*****  -h192.168.0.77 --delete test /home/miguel/files/sinisa.txt
test.sinisa: Records: 4  Deleted: 0  Skipped: 0  Warnings: 1
[1 Oct 2004 20:30] Miguel Solorzano
This isn't Windows client issue only. Tested also from Debian client against Slackware
server:

miguel@light:~/dbs/4.0$ bin/mysqlimport -umiguel -p****** -h192.168.0.77 --delete test /home/miguel/files/sinisa.txt
bin/mysqlimport: Error: File '/home/miguel/files/sinisa.txt' not found (Errcode: 2), when using table: sinisa

below when removed the LOCAL clause:

miguel@light:~/dbs/4.0$ bin/mysqlimport -umiguel -p******* -h192.168.0.77 --delete test /home/miguel/files/sinisa.txt
test.sinisa: Records: 4  Deleted: 0  Skipped: 0  Warnings: 1
[1 Oct 2004 20:40] Miguel Solorzano
Fixing typo in OS text box.
[7 Oct 2004 11:21] Reggie Burnett
Thank you for your bug report. This issue has been committed to our
source repository of that product and will be incorporated into the
next release.

If necessary, you can access the source repository and build the latest
available version, including the bugfix, yourself. More information 
about accessing the source trees is available at
    http://www.mysql.com/doc/en/Installing_source_tree.html
[1 Nov 2004 15:29] Olivier Müller
This "--local" trick is quite annoying : an update to mysql 4.0.22 broke many things on our servers because of that.

It has been solved by adding 
[mysqlimport]
local           = 1
to the my.cnf, but I would expect such fixes to be better documented, or happing only on
major releases (mysql 4 -> mysql 4.1) or something like that... What do you think?

regards, Olivier
[1 Nov 2004 16:38] Reggie Burnett
You're right and I apologize.  The change should not have happened to MySQL 4.0 since it was not regarded as a critical error.  Do you have things functionally working or are you still having issues?