Bug #82866 Hard to use copied multi-line statements from the documentation
Submitted: 6 Sep 2016 5:41 Modified: 22 Sep 2016 17:08
Reporter: monty solomon Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Documentation Severity:S3 (Non-critical)
Version:5.7, all OS:Any
Assigned to: CPU Architecture:Any

[6 Sep 2016 5:41] monty solomon
Description:
It is not easy to copy a multi-line SQL statement from the documentation to paste and use elsewhere since the copied text will require editing to remove any arrows before pasting.

How to repeat:
Try to paste any of the multi-line statements, after copying, from 

How MySQL Uses Memory
http://dev.mysql.com/doc/refman/5.7/en/memory-use.html

For example, try to copy

SELECT * FROM performance_schema.setup_instruments WHERE NAME LIKE '%memory%';

from

mysql> SELECT * FROM performance_schema.setup_instruments
    -> WHERE NAME LIKE '%memory%';

and observe that the clipboard contains

SELECT * FROM performance_schema.setup_instruments
    -> WHERE NAME LIKE '%memory%';

Pasting the copied statement will generate an error

mysql> SELECT * FROM performance_schema.setup_instruments
    ->     -> WHERE NAME LIKE '%memory%';
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-> WHERE NAME LIKE '%memory%'' at line 2

Suggested fix:
Don't use arrows in multi-line examples in the documentation.

The multi-line statements in the SELECT documentation don't use arrows.

SELECT Syntax
https://dev.mysql.com/doc/refman/5.7/en/select.html
[6 Sep 2016 6:30] MySQL Verification Team
Hello Monty,

Thank you for the feedback!

Thanks,
Umesh
[12 Sep 2016 4:29] monty solomon
The copied text also includes the leading "mysql> " prompt when using the copy to clipboard feature in the upper right corner of the examples (as opposed to selecting the text to copy and using copy).

For example,

mysql> SELECT * FROM performance_schema.setup_instruments
    -> WHERE NAME LIKE '%memory%';

I suggest removing the "mysql> " prompts from the examples to make them useful when copying.
[22 Sep 2016 17:08] Stefan Hinz
Posted by developer:
 
Thanks for the suggestion, Monty!
After quite some discussion in the Docs team, we decided we'll implement an easier way to copy from examples. Unfortunately, that's a manual process, and such will take time. There are lots of examples where having a prompt makes sense, or is even a prerequisite for understanding. So, nothing we could fix with a lazy regex or XPath. We also discussed splitting examples into programlisting and screen elements, but found that would be an improvement for the worse, at least from a readability standpoint.