Bug #27439 mysql command line client does not handle readline magic spaces
Submitted: 26 Mar 2007 12:28 Modified: 6 Aug 2009 20:31
Reporter: Marc Liyanage Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Command-line Clients Severity:S3 (Non-critical)
Version:5.1.6, 5.0 OS:MacOS (Mac OS X)
Assigned to: Jim Winstead CPU Architecture:Any

[26 Mar 2007 12:28] Marc Liyanage
Description:

The mysql command line client uses libreadline. If the .inputrc file maps Space to the "magic-space" function, it is impossible to type spaces in the mysql client.

http://www.entropy.ch/blog/Mac+OS+X/2007/03/26/MySQL-client-and-readline-magic-spaces.html

How to repeat:
Add this to ~/.inputrc:

Space: magic-space

Enter mysql client, try to type "show databases" or any other command with spaces. The client beeps when typing a space. It is possible to work around the issue by conditionalizing the magic-space assignment in .inputrc:

$if bash
Space: magic-space
$endif

Suggested fix:

The quick fix would be to treat magic-space exactly like space.

The nice fix would be to implement functionality similar to what the bash shell does when magic-space is input, which is to expand the completion of the word immediately preceding the space character and then insert a space.
[26 Mar 2007 15:26] Sveta Smirnova
Thank you for the report.

Verified as described.
[19 May 2009 1:49] Jim Winstead
Despite what the CHANGES file for readline says, magic-space isn't actually a feature of readline. It is implemented solely by bash, which defines that function itself. (You can find the implementation in bashline.c in the bash distribution. The only reference to magic-space in readline is in the CHANGES file and documentation.)
[19 May 2009 7:24] Marc Liyanage
Well the point was that the mysql command line tool becomes *unusable* if the user has configured magic space in the readline config, even if it was intended only for bash.

mysql should at least handle this situation, and treat magic-space as a space.
[19 May 2009 17:18] 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/74501

2901 Jim Winstead	2009-05-19
      The mysql command-line client didn't implement the readline magic-space
      command, which bash does, which could result in a user accidentally disabling
      the use of the space key in the mysql command-line client. (Bug #27439)
      modified:
        client/mysql.cc
[19 May 2009 17:22] Jim Winstead
The patch doesn't do anything about the other 27 bash readline commands we don't support, or readline's crazy behavior of just silently accepting bindings to non-existent functions, thus disabling the bound key. And I hope this won't blow up if/when readline itself implements magic-space. (The way things are now, it wouldn't cause problems, because readline does a linear search of the function array and built-ins come before anything added by us.)
[14 Jul 2009 17:22] Jim Winstead
Pushed to 5.1-bugteam and mysql-pe.
[4 Aug 2009 19:50] Bugs System
Pushed into 5.4.4-alpha (revid:alik@sun.com-20090804194615-h40sa098mx4z49qg) (version source revid:jimw@mysql.com-20090714171651-ziq080rkon3u244l) (merge vers: 5.4.4-alpha) (pib:11)
[4 Aug 2009 20:45] Bugs System
Pushed into 5.1.38 (revid:davi.arnaut@sun.com-20090804204317-ggodqkik7de6nfpz) (version source revid:davi.arnaut@sun.com-20090804204317-ggodqkik7de6nfpz) (merge vers: 5.1.38) (pib:11)
[6 Aug 2009 20:31] Paul DuBois
Noted in 5.1.38, 5.4.4 changelog.

If the mysql client was built with the readline library and the
.inputrc file mapped Space to the magic-space function, it became
impossible to enter spaces.
[12 Aug 2009 23:01] Paul DuBois
Noted in 5.4.2 changelog because next 5.4 version will be 5.4.2 and not 5.4.4.
[15 Aug 2009 2:19] Paul DuBois
Ignore previous comment about 5.4.2.
[1 Oct 2009 5:58] Bugs System
Pushed into 5.1.39-ndb-6.3.28 (revid:jonas@mysql.com-20091001055605-ap2kiaarr7p40mmv) (version source revid:jonas@mysql.com-20091001055605-ap2kiaarr7p40mmv) (merge vers: 5.1.39-ndb-6.3.28) (pib:11)
[1 Oct 2009 7:25] Bugs System
Pushed into 5.1.39-ndb-7.0.9 (revid:jonas@mysql.com-20091001072547-kv17uu06hfjhgjay) (version source revid:jonas@mysql.com-20091001071652-irejtnumzbpsbgk2) (merge vers: 5.1.39-ndb-7.0.9) (pib:11)
[1 Oct 2009 13:25] Bugs System
Pushed into 5.1.39-ndb-7.1.0 (revid:jonas@mysql.com-20091001123013-g9ob2tsyctpw6zs0) (version source revid:jonas@mysql.com-20091001123013-g9ob2tsyctpw6zs0) (merge vers: 5.1.39-ndb-7.1.0) (pib:11)
[5 Oct 2009 10:50] Bugs System
Pushed into 5.1.39-ndb-6.2.19 (revid:jonas@mysql.com-20091005103850-dwij2dojwpvf5hi6) (version source revid:jonas@mysql.com-20090930185117-bhud4ek1y0hsj1nv) (merge vers: 5.1.39-ndb-6.2.19) (pib:11)
[9 Oct 2009 1:30] Paul DuBois
The 5.4 fix has been pushed to 5.4.2.