Reputation: 4535
MySQL can tab-complete shell commands and SQL declarations.
But for SQL, it only completes for upper-case input. For example, 'SEL'
will work for 'SELECT'
but 'sel'
will not.
Is there something like .inputrc
for MySQL that I can configure it as case-insensitve completion?
Upvotes: 4
Views: 489
Reputation: 11983
I came to StackOverflow looking for an answer to this question but since there wasn’t, I figured I’d research the answer, myself.
The MySQL command-line client is linked against the GNU Readline library to provide tab completion and since the MySQL client parses .inputrc
(as can be seen from using strace
to examine the system calls made by the MySQL client), I thought it would pay attention to options such as set completion-ignore-case On
. Unfortunately, that’s not the case.
Though I’m not a C++ developer, I examined the source code for the command line client.
You can see that the build_completion_hash()
function adds names such as
SQL keywords, table names and field names to a hash (fast and efficient form
of data structure) that is used to provide the completion. However, the part
which adds SQL commands to the hash simply adds the following list of SQL commands.
Most of these SQL commands are listed in upper-case but there are a few exceptions such as create database
, create table
, show databases
, show fields from
are listed using lower-case. Since the SQL key words in this generated list are all in upper case, completion doesn’t work when SQL key-words are typed in lower case.
This list used to include a short list of SQL commands (in lower case), e.g, select
, drop
, insert
. However, in January 2008, this short list was replaced by a generated list of SQL commands supported by MySQL.
Note: I linked to the source of the MariaDB fork of MySQL since it’s more web accessible. MariaDB is a binary compatible fork from the MySQL code-base now owned by Oracle (the project is run by the same people behind MySQL AB). From checking the version control history, the parts of the client code that I’ve referred to haven’t changed much over the past few years.
TLDR: The answer appears to be no.
Upvotes: 2