Bug #72798 can't exit command on Windows
Submitted: 29 May 2014 13:50 Modified: 30 May 2014 7:47
Reporter: Peter Laursen (Basic Quality Contributor) Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server: Command-line Clients Severity:S3 (Non-critical)
Version:any OS:Windows
Assigned to: CPU Architecture:Any

[29 May 2014 13:50] Peter Laursen
Description:
This could very well be specific for the Windows implementation of the 'mysql' client. But I am not sure about this.

After starting a 'quoted string' and pressing ENTER (by mistake for instance) it is not possible to return to the "mysql>" command prompt. "\c" should do this, but it does not.

How to repeat:
...
...
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> select 1
    -> \c
mysql>     <-- so this worked fine
mysql> select '1
    '> \c
    '>     <-- goes on forever - also Ctrl+C does not return the prompt.

Suggested fix:
Not sure .. but notice the apostrophe in the "'>" line prompt. Looks like some buffer has invalid content but should be empty. And the client is not able to recover from that.

(and if "\c" is not supposed to work on Windows, the client should not tell user this "Type '\c' to clear the current input statement.").
[29 May 2014 14:06] MySQL Verification Team
Thank you for the bug report. See below (use the second ' which the client is waiting).

C:\dbs\5.6\bin>mysql -uroot -p
Enter password: ******
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.6.17 MySQL Community Server (GPL)

Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> select '1
    '> \c
    '> ' -- here
    -> \c
mysql> select "hello";
+-------+
| hello |
+-------+
| hello |
+-------+
1 row in set (0.00 sec)
[29 May 2014 14:18] Peter Laursen
This is non-obvious and also contradits what the client tells user at startup. There is no information that \c does not work inside a 'quote'. 

This is one more example of horrendous primitivity of the parsing abilites of mysql command line clients.
[29 May 2014 17:39] MySQL Verification Team
Then change the bug synopsis to \c should returns to mysql prompt disregarding
the prompt state. Thanks.
[30 May 2014 7:47] Peter Laursen
After all there is kind of a non-resolvable conflict here as " '\c' " is a valid string (and substring) in a query. So as long as a character sequence is used for exiting a command it is ambigious what should happen if this character sequence appears inside a 'quoted string'.

I also think the prompt tries to communicate to user that a 'quoted string' has been started, but not concluded yet - and that it must be before command character sequences can be used. So - even though I didn't find that obvious - let it be. 

And thanks for explaining.