Bug #43996 subsequent prompt cannot be changed, only first, and should be a comment
Submitted: 31 Mar 2009 19:01 Modified: 1 Apr 2009 6:33
Reporter: Sheeri Cabral (Candidate Quality Contributor) Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Command-line Clients Severity:S4 (Feature request)
Version:all OS:Any
Assigned to:
Tags: comment, prompt, qc
Triage: Needs Triage: D5 (Feature request)

[31 Mar 2009 19:01] Sheeri Cabral
Description:
Taken from http://www.pythian.com/news/1798/the-little-things:

The default prompt that appears on the first line of the prompt is:
mysql>
The default (and unchangeable) second line of the prompt is four spaces followed by an ASCII arrow:

    ->

The second line of the prompt is hard-coded to match up very nicely with the first line in a fixed-width font:

mysql> SELECT
    -> 1+2;

However, you can change the prompt, which is pretty handy:

mysql> prompt \d:
PROMPT set to '\d: '
(none): use test;
Database changed
test:

But remember, the second line of the prompt is unchangeable, which leads to a very ugly:

test: SELECT
    -> 1+2;

This may not seem like a big deal. But for people that copy and paste examples (such as people double-checking their own work, a technical editor, or a reader), they might think to change the prompt, so they can copy and paste examples:

test: prompt /* mysql */
PROMPT set to '/* mysql */ '
/* mysql */ SELECT
    -> "If I could change the second line, then I could copy and paste multi-line examples!";

This should be an easy enough fix for the MySQL client. At the very least the prompt should default to something commented, in my opinion.

How to repeat:
change the prompt
write a multi-line command

Suggested fix:
option 1) make the 2nd line of the prompt changeable.

option 2) default the 1st and subsequent prompt lines to be comments, in addition to #1.
[1 Apr 2009 6:33] Valerii Kravchuk
Thank you for the feature request.
[26 May 2009 15:55] Mattias Jonsson
A quick hack to add the feature, tests are left as an exercise to the reader :) (it also handles multi-line comments)

Attachment: b43996_proposal.diff (application/octet-stream, text), 2.73 KiB.

[26 May 2009 16:03] Mattias Jonsson
The hack works when adding \C as the first characters in the prompt command, like this:

mysql> prompt \C commented prompt> 
PROMPT set to '\C commented prompt> '
/* commented prompt> */ select 5
/* -> */ +
/* -> */ 7
/* -> */ ;

and multi-line columns:
/* commented prompt> */ select now() /* here is a multi-
   /*> line comment */ , 1;