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).