Bug #68925 Compatibility issue with mysql history ("\040" instead of space)
Submitted: 11 Apr 2013 5:57 Modified: 17 Aug 2014 12:30
Reporter: Daniël van Eeden (OCA) Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Command-line Clients Severity:S3 (Non-critical)
Version:5.6.10, 5.5.29, 8.0.35 OS:Any
Assigned to: CPU Architecture:Any
Tags: history, regression

[11 Apr 2013 5:57] Daniël van Eeden
Description:
A mysql history file (~/.mysql_history) with 5.5 readline stores history entries as "SELECT 'test';"

The output of "mysql --version"
mysql  Ver 14.14 Distrib 5.5.29, for debian-linux-gnu (x86_64) using readline 6.2

If now another client is started (e.g. with MySQL Sandbox) and closed then it's converted to "SELECT\040'test';"

The output of "mysql --version" for the second mysql client:
mysql  Ver 14.14 Distrib 5.6.10, for linux-glibc2.5 (x86_64) using  EditLine wrapper

See also:
http://forums.mysql.com/read.php?10,291388,291388
http://haxx.sinequanon.net/2012/01/mysql-history-munging/

How to repeat:
Generate history with 5.5-readline and then open and close a mysql 5.6-editline client. During all steps watch the contents of ~/.mysql_history

Suggested fix:
Don't touch history entries if it's not needed and/or convert the entries on open or close. Or use a different filename for editline and readline clients.
[11 Apr 2013 6:15] MySQL Verification Team
Setting as a duplicate of internally filed bug:
Bug 14634386 - HISTORY WRITTEN BY LIBEDIT IS NOT READABLE BY READLINE
[17 Aug 2014 12:30] Daniël van Eeden
added tags
[16 May 2015 16:55] Nirbhay Choubey
Suggested patch:

diff --git a/cmd-line-utils/libedit/history.c b/cmd-line-utils/libedit/history.c
index 6d2176c..6f9be53 100644
--- a/cmd-line-utils/libedit/history.c
+++ b/cmd-line-utils/libedit/history.c
@@ -827,7 +827,7 @@ history_save(TYPE(History) *h, const char *fname)
 			}
 			ptr = nptr;
 		}
-		(void) strvis(ptr, str, VIS_WHITE);
+		(void) strvis(ptr, str, VIS_SAFE);
 		(void) fprintf(fp, "%s\n", ptr);
 	}
 oomem:
[2 Jan 5:51] MySQL Verification Team
Bug #113532 marked as duplicate of this one
[2 Jan 6:19] walkerxk walkerxk
this bug haven't fix after 9 years?