Bug #37605 client displays wrong command prompt after # or -- comment in --comment mode
Submitted: 24 Jun 2008 14:48 Modified: 7 Aug 2008 9:00
Reporter: Gleb Shchepa
Status: Analyzing
Category:Client Severity:S3 (Non-critical)
Version:5.0+, 5.1.25 OS:Any
Assigned to: Bugs System Target Version:
Triage: D3 (Medium)

[24 Jun 2008 14:48] Gleb Shchepa
Description:
In the "preserve commentary" mode mysql client shows the "    ->" command prompt
(extension of previous line) after _single-line_ commentaries:

mysql command line client uses several command prompts dependi
mysql> -- test
    -> this line looks like extension of _single-line_ commentary!

mysql client without -c option treats single-line comments as expected:

mysql> -- test
mysql>

How to repeat:
$ mysql -c
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 24
Server version: 5.0.66-debug Source distribution

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> -- test
    -> SELECT 1;
+---+
| 1 |
+---+
| 1 | 
+---+
1 row in set (0.00 sec)

Suggested fix:
Looks like mysql client should clean glob_buffer before printing of a command prompt, if
this buffer contains nothing but a single-line commentary.
[24 Jun 2008 15:04] Valeriy Kravchuk
Thank you for a bug report. Verified just as described, also - with client from 5.1.25.
[25 Jun 2008 19:38] 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/48514

2644 Chad MILLER	2008-06-25
      Bug#37605, client displays wrong command prompt after # or -- comment \
      	in --comment mode
      
      In comment-preservation mode of the mysql command-line client, comments are
      not discarded by the client, and are sent to the server.  This fooled the 
      code that tracks what state the prompt should be in.
      
      Now, keep a new state variable that tells us whether we should update 
      the state of the prompt or not.  After single-line comments, the next
      prompt should always be the previous state.  Rather than keep up with
      that, let's only conditionally update the prompt.
[4 Jul 2008 19:17] Chad MILLER
Jimw says this is not a bug, as the prompt should follow protocol state in addition to
SQL-level quote state.  If we're in comment-preservation mode, and type a comment, then
we accumulate stuff that we have not yet sent to the server.

Omer will bring it up at some meeting.  Since its bug-itude is in question, I'm setting
back to Open.