简体   繁体   English

MySQL Shell中不区分大小写的完成

[英]Case-insensitive completion in MySQL shell

MySQL can tab-complete shell commands and SQL declarations. MySQL可以制表完整的shell命令和SQL声明。

But for SQL, it only completes for upper-case input. 但是对于SQL,它仅对大写输入完成。 For example, 'SEL' will work for 'SELECT' but 'sel' will not. 例如, 'SEL'将对'SELECT'起作用,但'sel'将不起作用。

Is there something like .inputrc for MySQL that I can configure it as case-insensitve completion? 是否有类似MySQL的.inputrc这样的东西,可以将其配置为不区分大小写的完成方式?

I came to StackOverflow looking for an answer to this question but since there wasn't, I figured I'd research the answer, myself. 我来到StackOverflow寻找这个问题的答案,但是由于没有答案,我以为自己会研究答案。

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 . MySQL命令行客户端与GNU Readline库链接以提供制表符完成,并且由于MySQL客户端解析.inputrc (从使用strace检查MySQL客户端进行的系统调用可以看出),我认为这会付钱注意选项,例如set completion-ignore-case On Unfortunately, that's not the case. 不幸的是,事实并非如此。

Use the source, Luke 使用消息来源卢克

Though I'm not a C++ developer, I examined the source code for the command line client . 尽管我不是C ++开发人员,但我检查了命令行客户端源代码

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. 您可以看到build_completion_hash()函数将诸如SQL关键字,表名和字段名之类的名称添加到用于提供完成的哈希(数据结构的快速有效形式)中。 However, the part which adds SQL commands to the hash simply adds the following list of SQL commands . 但是, 将SQL命令添加到哈希的部分仅添加了以下SQL命令列表

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. 这些SQL命令大多数以大写字母列出,但是有一些例外情况,例如create databasecreate tableshow databasesshow fields from show databasesshow fields from均以小写字母列出。 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. 由于此生成的列表中的SQL关键字全部使用大写字母,因此,如果使用小写字母键入SQL关键字,则补全不起作用。

This list used to include a short list of SQL commands (in lower case), eg, select , drop , insert . 该列表曾经包括一小段SQL命令(小写),例如selectdropinsert However, in January 2008 , this short list was replaced by a generated list of SQL commands supported by MySQL. 但是,在20081月 ,该简短列表被MySQL支持的生成的SQL命令列表取代。

Note: I linked to the source of the MariaDB fork of MySQL since it's more web accessible. 注意:我链接到MySQL的MariaDB分支的源代码,因为它可以通过Web访问。 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). MariaDB是Oracle现在拥有的MySQL代码库中的二进制兼容分支(该项目由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. TLDR:答案似乎是否定的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM