Thursday, October 17

A bad feature in mysql command line tool: auto-completion

One feature in the mysql command line tool is very annoying: The double tab is being interpreted as a request to auto-completion.

For example, in your editor (or workbench) you have a perfect sql:
SELECT * FROM  `abc`
WHERE id =  '6690-2'
AND result >300
order by result;
This is a legitimate sql, and it runs pretty well in workbench. But when you copy it into mysql command line tool, you get this:
mysql> select * from abc
    -> where id='6690-2'
    ->
Display all 1437 possibilities? (y or n)
    -> D result >300
    -> order by result;
What happened? The double tab before "AND" was interpreted as a request to auto-completion, so the application replied to ask whether you want to show all the auto-completion options (1437 of them). The application still accept key in "A" and "N", then decided the "N" means you don't want to see the 1437 options, so it stops the interruption, that is why you have "D" in the next line.

Yes that is annoying. I can't even maintain proper indents in my source file. It took me some time to look for tab-space auto-conversion in MySQL Workbench, as any decent editor would have this feature, but failed.

The solution is easy, and it is actually spelled out every time you change database in my mysql command line tool:

mysql> use import_temp;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
After starting the tool using -A option, the annoying feature is disabled.

So I added an alias to use -A all the time:
alias mysql 'mysql -A'
(and add this into .bashrc)

PS: To show warnings by default, change the line to:
alias mysql 'mysql -A --show-warnings'


Tuesday, October 8

拔智齿

在periodontist这里,他决定要给我拔智齿。4棵,全干掉。
一次干4棵太麻烦了,所以说好了,今天弄左边两颗,等左边好了,可以嚼东西了,再拔右边的。

下午到了那里,往左边上面、 下面都打了麻药。等5分钟,麻劲上来了,再打一次,这次针筒可以刺深一些。
拔牙齿 拔牙齿. 嗨吆嗨吆,拔牙齿,嗨吆嗨吆,拔不动,老太婆,快快来,快来帮我们拔牙齿.
麻药真好用,医生告诉我说上面的智齿已经拔出来了,我还不知道。

然后牙医盯着下面的智齿看了又看,决定照X光。照个头啊!上个月做 Deep Cleaning的时候照过,上星期来确定拔牙的时候也照过,现在干了一半了,你开始决定照X光?

正所谓人为刀俎我为鱼肉。照完X光,牙医决定还是收工了,把下面这颗牙齿留给oral surgeon来干。因为这颗牙齿斜着长,已经顶着旁边的牙了(这也是它为什么要被拔的原因)

缝了几针,咬着一块布止血。吃了止痛药,随后3小时用冰敷15分钟后放开15分钟,不断重复。