Bug #26724 mysql command line client, ignores input to internal cmd after space
Submitted: 28 Feb 2007 15:13 Modified: 13 Mar 2009 20:11
Reporter: Martin Friebe (Gold Quality Contributor) (OCA) Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Command-line Clients Severity:S3 (Non-critical)
Version:5.0.38/5.1BK OS:FreeBSD (freebsd)
Assigned to: Georgi Kodinov CPU Architecture:Any
Tags: client, qc

[28 Feb 2007 15:13] Martin Friebe
Description:
the mysql command line client ignores "additional" arguments to its build in commands. That is after an build in command the argument is read uppon the first unquoted space. The rest of the line is silently ignored, no warning or error caused.

The documentation is not clear on all case
http://dev.mysql.com/doc/refman/5.0/en/mysql-commands.html

I could not find any entry detailing the behaviour of the build in "use" or "charset" command.
I do think it is a bug. It should not be silently ignored. An error or warning should be caused, in order to prevent users from further damage.

on the delimiter the doc is very clear:
> delimiter (\d) Set statement delimiter. NOTE: Takes the rest of the line as
>               new delimiter.

"the rest of the line" not just to the next space. So this is a definitely a bug.

 delimiter x x
should work, and should set the delimiter to x x

 delimiter 'x x'
needs either further documentation, or is a bug too.
the rest of the line is 'x x' with the quotes. 

 delimiter '
does give an error, the wanted behaviour needs to be defined, because you can set it to a quote using 
 delimiter "'"

How to repeat:
# the following changes to the db test
# the "xxx" is ignored
use test xxx
# or the following could get you to drop tables in the wrong db
use test use someotherdb

# the following set the delimiter to just one x
delimiter x x
select 1 x
# sets the delimiter to x x, without the quotes
delimiter 'x x'
select 1 x x
delimiter ;

the following set the charset to latin1, and ignores x
charset latin1 x

# the following works
# help on use
help use
# no help on 'use x'
help use x

Suggested fix:
see description.

delimiter x x
should work without the quotes

delimiter 'x x'
do have the quotes part of the delimiter would be an incompatibility change, so maybe document this
[28 Feb 2007 15:35] MySQL Verification Team
Thank you for the bug report.
[1 Mar 2007 12:02] Martin Friebe
test case for the described items. some are marked as TODO, as the behaviour needs to be decided first

Attachment: client_cmd.test (application/octet-stream, text), 1.79 KiB.

[1 Mar 2007 12:03] Martin Friebe
results for test, (depending on decission on TODO)

Attachment: client_cmd.result (application/octet-stream, text), 483 bytes.

[17 Jan 2008 19:10] Valeriy Kravchuk
Bug #33901 was marked as a duplicate of this one.
[18 Feb 2009 9:44] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/66739

2745 Georgi Kodinov	2009-02-18
      Bug #26724: mysql command line client, ignores input to internal cmd after space
      
      Removed the misleading "NOTE:" from the \h command. 
     @ client/mysql.cc
        Bug #26724: removed the misleading note from the \h command
[18 Feb 2009 9:50] Georgi Kodinov
The logic behind the delimiter parsing is the following (similar to SQL identifiers): 
Delimiter command can take quoted and unquoted strings. Quotation can be done with " or ' (whichever fits). You'll need to quote the quotes with different quotes (e.g. <double quote><single quote><double quote> to get <single quote> as a delimiter) or escape them with a <backslash> (e.g. <single quote><backslash><single quote><single quote> will yield a delimiter of <single quote>),
When non-quoted it takes the string *up to the first space*
When quoted it takes everything up to the matching quote.

Removed the ambiguous and obsolete NOTE from the help file. The rest is for the docs team to update the docs.
[18 Feb 2009 10:20] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/66744

2750 Georgi Kodinov	2009-02-18
      Bug #26724: mysql command line client, ignores input to internal cmd after space
            
      Removed the misleading "NOTE:" from the \h command. 
     @ client/mysql.cc
        Bug #26724: removed the misleading note from the \h command
[19 Feb 2009 13:04] Bugs System
Pushed into 6.0.10-alpha (revid:sergey.glukhov@sun.com-20090218125737-5y5b2xo3duo1wlvo) (version source revid:joro@sun.com-20090218124627-nj1loa1xiznlen4m) (merge vers: 6.0.10-alpha) (pib:6)
[5 Mar 2009 1:34] Paul DuBois
No changelog entry needed.

Added this description of delimiter parsing to:
http://dev.mysql.com/doc/refman/5.1/en/mysql-commands.html

The delimiter can be specified as an unquoted or quoted argument.
Quoting can be done with either single quote (') or douple quote (")
characters. To include a quote within a quoted string, either quote
the string with the other quote character or escape the quote with a
backslash ("\") character. Backslash should be avoided outside of
quoted strings because it is the escape character for MySQL. For an
unquoted argument, the delmiter is read up to the first space or end
of line. For a quoted argument, the delimiter is read up to the
matching quote on the line.

Setting report to NDI pending push into 5.0.x/5.1.x.
[9 Mar 2009 14:12] Bugs System
Pushed into 5.0.79 (revid:joro@sun.com-20090309135922-a0di9ebkxoj4d4wv) (version source revid:sergey.glukhov@sun.com-20090218115330-abvhochinjfc9s3j) (merge vers: 5.0.79) (pib:6)
[9 Mar 2009 14:50] Paul DuBois
Noted in 5.0.79 changelog.

Setting report to NDI pending push into 5.1.x.
[13 Mar 2009 19:04] Bugs System
Pushed into 5.1.33 (revid:joro@sun.com-20090313111355-7bsi1hgkvrg8pdds) (version source revid:joro@sun.com-20090218102611-g70evby3dgfd88rr) (merge vers: 5.1.33) (pib:6)
[13 Mar 2009 20:11] Paul DuBois
Correction: Not noted in 5.0.79 changelog; no changelog entry is needed.
[9 May 2009 16:45] Bugs System
Pushed into 5.1.34-ndb-6.2.18 (revid:jonas@mysql.com-20090508185236-p9b3as7qyauybefl) (version source revid:jonas@mysql.com-20090508100057-30ote4xggi4nq14v) (merge vers: 5.1.33-ndb-6.2.18) (pib:6)
[9 May 2009 17:42] Bugs System
Pushed into 5.1.34-ndb-6.3.25 (revid:jonas@mysql.com-20090509063138-1u3q3v09wnn2txyt) (version source revid:jonas@mysql.com-20090508175813-s6yele2z3oh6o99z) (merge vers: 5.1.33-ndb-6.3.25) (pib:6)
[9 May 2009 18:39] Bugs System
Pushed into 5.1.34-ndb-7.0.6 (revid:jonas@mysql.com-20090509154927-im9a7g846c6u1hzc) (version source revid:jonas@mysql.com-20090509073226-09bljakh9eppogec) (merge vers: 5.1.33-ndb-7.0.6) (pib:6)