Bug #72108 Hard to read history file
Submitted: 24 Mar 2014 9:45 Modified: 24 Mar 2014 10:06
Reporter: Valeriy Kravchuk Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Command-line Clients Severity:S3 (Non-critical)
Version:5.6.16, 5.6.18, 5.7.5 OS:Any
Assigned to: CPU Architecture:Any
Tags: client, editline, regression

[24 Mar 2014 9:45] Valeriy Kravchuk
Description:
The history file produced by MySQL 5.6's mysql client is no longer easy to read:

[openxs@chief mysql-5.6.16-linux-glibc2.5-x86_64]$ tail -10 ~/.mysql_history    show\040variables\040like\040'char%';
show\040create\040table\040test3\134G
alter\040table\040test3\040modify\040test_column\040varchar(10)\040charset\040utf8mb4;
show\040create\040table\040test3\134G
insert\040into\040test2\040values(unhex('f09f9884'));
insert\040into\040test3\040values(unhex('f09f9884'));
select\040*\040from\040test3;
select\040now();
select\040now(),\040now();
select\040now(),\040version();

It seems that Oracle's mysql client somehow "knows" how to deal with these \040 and other similar sequences, but still it would be nice to be able to read .mysql_history using any plain text viewer, command or editor. 

It does not happen with 5.5 so may have something to do with processing related to hiding plain text passwords in 5.6.

How to repeat:
[openxs@chief mysql-5.6.16-linux-glibc2.5-x86_64]$ bin/mysql --no-defaults -uroot test
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.16 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 now(), version();
+---------------------+-----------+
| now()               | version() |
+---------------------+-----------+
| 2014-03-24 11:35:47 | 5.6.16    |
+---------------------+-----------+
1 row in set (0.00 sec)

mysql> exit
Bye
[openxs@chief mysql-5.6.16-linux-glibc2.5-x86_64]$ tail -1 ~/.mysql_history
select\040now(),\040version();

Suggested fix:
Do something to have all that \040 etc NOT written into the history file.
[24 Mar 2014 10:06] MySQL Verification Team
Hello Valeriy,

Thank you for the bug report.
Verified as described.

Thanks,
Umesh
[24 Mar 2014 10:08] MySQL Verification Team
// 5.5 vs 5.6

// 5.5.38

# more ~/.mysql_history
select version();
\q

// 5.6.18

# more ~/.mysql_history
_HiStOrY_V2_
select\040version();
\134q
[24 Mar 2014 10:11] MySQL Verification Team
// 5.7.5 - affected

# more ~/.mysql_history
_HiStOrY_V2_
select\040version();
\134q
[31 Mar 2014 9:21] Hartmut Holzgraefe
AFAIR this is a readline vs. libedit problem ...?

Definitely not something new to 5.6, I remember having seen this every once in a while long before 5.6 was released ...
[9 Apr 2014 17:44] Jonathan Nicol
related to http://bugs.mysql.com/bug.php?id=69991
[17 Aug 2014 12:29] Daniƫl van Eeden
Also related: Bug #68925