Bug #5596 mysql \. command doesn't like semicolon
Submitted: 15 Sep 2004 15:53 Modified: 28 Sep 2004 18:55
Reporter: Paul DuBois Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Command-line Clients Severity:S3 (Non-critical)
Version:4.1.4 OS:Any (all)
Assigned to: Paul DuBois CPU Architecture:Any

[15 Sep 2004 15:53] Paul DuBois
Description:
The mysql source and \. command act slightly differently.
source allows a semicolon at the end of the command
but \. does not:

Unix behavior:

mysql> source /dev/null
mysql> source /dev/null;
mysql> \. /dev/null
mysql> \. /dev/null;
ERROR: 
Failed to open file '/dev/null;', error: 2

Windows behavior:

mysql> source nul
mysql> source nul;
mysql> \. nul
mysql> \. nul;
ERROR: 
Failed to open file 'nul;', error: 2

In each case, the semicolon in the final command
is interpreted as part of the filename.

I'm not sure this is actually a bug, although I consider
it such, and it is at least surprising.  If it's designated
as not a bug, we'll need an update to the manual.

Note: I tested this with 4.1.4, but I would guess it
occurs in 3.23 and 4.0 as well.

How to repeat:
See above.
[17 Sep 2004 1:31] Antony Curtis
This may be a documentation issue as none of the \x shorthand commands which 
take an argument currently handle trailing semicolons. 
 
A trailing semicolon can be stripped with the following: 
===== mysql.cc 1.192 vs edited ===== 
--- 1.192/client/mysql.cc	2004-09-15 09:26:26 +01:00 
+++ edited/mysql.cc	2004-09-17 02:26:57 +01:00 
@@ -1089,6 +1089,16 @@ 
 	*out++= (char) inchar; 
 	continue; 
       } 
+      else 
+      { 
+#ifdef USE_MB 
+	char *end= strend; 
+#else	 
+	char *end= strend(pos-1); 
+#endif	 
+	if (end[-1] == ';') 
+	  end[-1]= 0; 
+      }	 
       if ((com=find_command(NullS,(char) inchar))) 
       { 
 	const String tmp(line,(uint) (out-line), charset_info);
[28 Sep 2004 18:55] Paul DuBois
Thank you for your bug report. This issue has been addressed in the
documentation. The updated documentation will appear on our website
shortly, and will be included in the next release of the relevant
product(s).