Bug #52499 mysql.exe -e "source filename" fails for some file names
Submitted: 31 Mar 2010 12:10 Modified: 1 Apr 2010 8:49
Reporter: Ravi Thati Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server: Command-line Clients Severity:S2 (Serious)
Version:any latest version (tried on 5.1.45 also OS:Windows (windows 2003/3008R2)
Assigned to: CPU Architecture:Any
Tags: restore logs, source options

[31 Mar 2010 12:10] Ravi Thati
Description:
Hi All,

We are facing some interesting problem in restore database dumps/log files with names starting with small case letter 'g'.

Description:
Assume i have database dump "gotcha.sql" under c:/dumps location.
i want to apply that dump to the mysql server,
like : mysql.exe -u root -ppwd -e"source c:\dumps\gotcha.sql"\

this fails with the errors:

C:\>mysql -u root -p -e "source C:\dumps\gotcha.sql"
Enter password: ******
ERROR 1064 (42000) at line 1: You have an error in your SQL syntax; check the ma
nual that corresponds to your MySQL server version for the right syntax to use n
ear 'source C:' at line 1

SOMETIMES i also get

ERROR 1064 (42000) at line 1: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'source c:tagedata' at line 1

--------------

C:\Program Files\MySQL\MySQL Server 5.1\bin\mysql.exe  Ver 14.14 Distrib 5.1.40sp1, for Win64 (unknown)

Connection id:                                      25
SSL:                                                               Not in use
Using delimiter:           ;
Server version:                                     5.1.40sp1-enterprise-pl-advanced-log MySQL Enterprise Server - Advanced Edition (GPL)
Protocol version:        10
Connection:                                            localhost via TCP/IP
Client characterset:  utf8
Server characterset: utf8
TCP port:                           3306
Uptime:                                                     13 min 34 sec

I have tried several combination of filename & also renaming the file for which it failed. 

After this observation what i concluded is :

Such type of source'ing fails for all files starting with 'g' letter in its name provided we mention the absolute path to that file (If i got that directory and run the same command with simple file name it does have any problem).

We would appreciate if mysql devs can verify and fix this bug. 

NOTE**: only seen on Windows platforms.

How to repeat:
1.create database gotcha
2.create some tables and insert rows
3.take dump (mysqldump -u root -ppwd gotcha>c:\dumps\gotcha.sql)
4.drop database from mysql server
5.now try applying the dump file to server 
   mysql.exe -u root -ppwd -e "source c:\dumps\gotcha.sql"

(fails for only files with name starting small letter 'g'. Capital letter 'G' it does not complain.

Suggested fix:
Allow any filename to source to database server using mysql client program.
[31 Mar 2010 12:56] MySQL Verification Team
Please try:

mysql -u root -p -e "source C:/dumps/gotcha.sql"

using / instead of \

Thanks in advance.
[31 Mar 2010 13:07] Ravi Thati
Thank you Miguel Solorzano.
That does the trick.

But why is that Windows slash giving the error ?
[31 Mar 2010 13:09] Ravi Thati
And what is special about character 'g' and windows slash?
[31 Mar 2010 13:21] Valeriy Kravchuk
Please, check the manual, http://dev.mysql.com/doc/refman/5.0/en/mysql-commands.html:

"source file_name, \. file_name

Read the named file and executes the statements contained therein. On Windows, you can specify path name separators as / or \\."

So, please, check if you'll get the same problem with the same filename starting with 'g', but with '/' or '\\' in full pathname, like this:

mysql.exe -u root -ppwd -e"source c:/dumps/gotcha.sql"

or this:

mysql.exe -u root -ppwd -e"source c:\\dumps\\gotcha.sql"
[31 Mar 2010 13:49] Ravi Thati
with UNIX style separator it works :
mysql -u root -p -e "source C:/dumps/gotcha.sql"

double slash gives the following error
C:\dumps>mysql -u root -ppwd -e "source C:\\dumps\\gotcha.sql"
ERROR at line 1: Unknown command '\\'.
[1 Apr 2010 8:06] Sveta Smirnova
Thank you for the feedback.

Closing as "Not a Bug"  because last comment.
[1 Apr 2010 8:49] Ravi Thati
Hi Sveta,

I am not happy to use UNIX style separator and want to use Windows one only.
And nobody have not suggested a fix for file starting with 'g' when using Windows separators.

An alternate way of doing is suggested and i am agreed for that. But what about the actual problem??