Bug #69971 tab completion in 5.6.12 is still broken
Submitted: 9 Aug 2013 7:11 Modified: 3 Aug 2014 16:20
Reporter: Steven NOT_FOUND Email Updates:
Status: No Feedback Impact on me:
None 
Category:MySQL Server: Command-line Clients Severity:S2 (Serious)
Version:5.6.13 OS:Linux (redhat, centos, gentoo)
Assigned to: CPU Architecture:Any

[9 Aug 2013 7:11] Steven NOT_FOUND
Description:
I get no tab completion with 5.6.12.

Checking the documentation for 5.6.12 (and any number of previous versions) the use of 'mysql --auto-reash' , adding 'auto-rehash' to the [mysql] section of my.cnf, using 'rehash' at the mysql command prompt or \# at the command prompt were supposed to turn on tab completion.

Having tried all of the alternatives listed above singly and in combinations I cannot get tab completion to work.

How to repeat:
1. Validate the build environment has librealine:

# ls -l /lib64/libreadline.so.*
lrwxrwxrwx 1 root root     18 Jul  6  2012 /lib64/libreadline.so.5 -> libreadline.so.5.2
-rwxr-xr-x 1 root root 261144 Nov 10  2010 /lib64/libreadline.so.5.2
lrwxrwxrwx 1 root root     18 Jul 30 10:58 /lib64/libreadline.so.6 -> libreadline.so.6.0
-rwxr-xr-x 1 root root 272008 Jun 22  2012 /lib64/libreadline.so.6.0

2. Unpack a copy of mysql and build it:

#!/bin/bash

rm -f CMakeCache.txt;
[ -e Makefile ] && make clean;

# where libreadline lives.

export CFLAGS='-L/lib64';

cmake .                                         \
-DCMAKE_INSTALL_PREFIX:PATH=/opt/mysql/5.6.12   \
-DMYSQL_DATADIR:PATH=/scratch/mysql-data        \
2>&1 | tee 00-cmake.out;

make -wk 2>&1 | tee 02-make.out;

make -w test install 2>&1 | tee 03-make-test-all.out;

export PATH=/opt/mysql/bin:$PATH;

(
    cd mysql-test;
    perl mysql-test-run.pl;
) 2>&1 | tee 04-test-run.out;

3. Check that the readline portions of the build executed:

# grep 'readline' 0*out
02-make.out:[  5%] Building C object cmd-line-utils/libedit/CMakeFiles/edit.dir/readline.c.o
02-make.out:[ 84%] Building CXX object client/CMakeFiles/mysql.dir/readline.cc.o
02-make.out:[100%] Building CXX object libmysqld/examples/CMakeFiles/mysql_embedded.dir/__/__/client/readline.cc.o

Ignoring the hoops required to actually make the build succeed...

4. Start the mysql server so that the client has something to connect into:

 # /etc/init.d/mysql.server start
Starting MySQL.. SUCCESS!

5. Connect to the server using the mysql command line client:

 $ /opt/mysql/5.6.12/bin/mysql  -usomeuser -psomepass -hlocalhost --verbose --auto-rehash our_db;

6. Check that the tables do exist:

--------------
show full tables
--------------

+-------------------------+------------+
| Tables_in_my_db       | Table_type |
+-------------------------+------------+
| batch                   | BASE TABLE |
<snip>

7. Attempt to select the contents of a table using tab completion:

mysql> select * from bat          ;   <-- whitespace from "bat" to ";" == tabs
--------------
select * from bat;
--------------

ERROR 1146 (42S02): Table 'my.bat_rds' doesn't exist

8. Use the 'rehash' option to turn on auto rehash:

mysql> rehash;
mysql> select * from ba                         ;
--------------
select * from ba
--------------

ERROR 1146 (42S02): Table 'dev_etl.ba' doesn't exist

9. use \# to turn on auto-rehash:

mysql> \#
mysql> select * from ba                 ;
--------------
select * from ba
--------------

ERROR 1146 (42S02): Table 'dev_etl.ba' doesn't exist

10. Check the my.cnf file:

# less /opt/mysql/5.6.12/etc/my.cnf
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html

[mysql]

auto-rehash

[mysqld]

11. Check that there is no conflicting my.cnf file in /etc:

# find /etc/ -name 'my*';
/etc/rc.d/init.d/mysql.server

Net result: No matter which of the options used to turn on tab completion is used, the tab completion is not turned on even in the presence of a working readline.

Note that a variety of other applications on this system which use libreadline.so are working perfectly, so the readline library seems to be installed, working, and properly configured.

Another check of libreadline is that I can use escape-K to initiate command line editing without any issue. The only thing I cannot get is tab completion.

12. Double-check ~/.inputrc

$ cat ~/.inputrc
set editing-mode vi
set show-all-if-ambiguous on

To the extent that oracle chooses to use it, the inputrc shows vi editing mode (which is being used by libreadline) and is also configured for its own tab completion.

Suggested fix:
1. Figure out what is broken and either update the cmake system to properly include the necessary libraries or take a few moments to actually test the MySQL source code and ensure that if libreadline is available then the auto-rehash mechanism in MySQL uses it to complete the names.

2. Document any known solutions in the troubleshooting guide with reasonable workarounds (cut+paste is not a reasonable workaround).
[9 Aug 2013 7:16] Steven NOT_FOUND
Sorry, the build file shown left out:

cd /opt/mysql;
rm *;
ln -fs 5.6.12/* .;

which is why the path of "/opt/mysql/bin/:..." proved functional for testing.
[9 Aug 2013 8:07] Steven NOT_FOUND
Forgot to add that using "-DBUILD_CONFIG" leaves me with the same result.

So does adding "-DWITH_READLINE=ON" just in case the notes were wrong and the option were still used.
[9 Aug 2013 18:59] Steven NOT_FOUND
Double-checking: I do have /usr/include/readline/readline.h:

$  ls -l /usr/include/readline/
total 76
-rw-r--r-- 1 root root  4578 Jun 22  2012 chardefs.h
-rw-r--r-- 1 root root 10078 Jun 22  2012 history.h
-rw-r--r-- 1 root root  3397 Jun 22  2012 keymaps.h
-rw-r--r-- 1 root root 35193 Jun 22  2012 readline.h  <--- should be sufficient
-rw-r--r-- 1 root root  2189 Jun 22  2012 rlconf.h
-rw-r--r-- 1 root root  1546 Jun 22  2012 rlstdc.h
-rw-r--r-- 1 root root  2845 Jun 22  2012 rltypedefs.h
-rw-r--r-- 1 root root  3046 Jun 22  2012 tilde.h
[11 Aug 2013 1:37] Steven NOT_FOUND
Ditto the same experiment with 5.6.13.
[3 Jul 2014 16:20] Umesh Shastry
Hello Steven,

I could not repeat this issue on latest build of MySQL 5.6.19(with all default options on OL6) and also not able to repeat with binary tarballs)
Could you please check if it is still repeatable with 5.6.19? Could you please provide complete build command for the same if you still have this issue.

Thanks,
Umesh
[4 Aug 2014 1:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".