MySQL and predictive option handling – bewarePeter Zaitsev
MySQL command line utilities have an interesting property – if you only use the prefix of the option or command it will go over the list of available command and if there is only one command with matching prefix it will execute it with no warnings or any kind, otherwise it will report the error. For example mysqladmin e works as there is only one command “extended-status” which starts with “e” mysqladmin f however does not work because there are multiple commands which start with “f”.
This behavior can cause all kings of issues especially if you make a typo. I made one today (thankfully on the test box). MySQL init Scripts use “stop” and “start” commands to start and stop the server while mysqladmin uses “shutdown”. I mixed this while trying to stop Percona Server:
root@smt2:/var/lib/mysql# mysqladmin stop
It would be quite confusing if mysqladmin would have “stop” command which does not do the same thing as “shutdown” . And it does not. The commands it has are
“start-slave” and “stop-slave” though as these are the only commands with such prefixes they are matched to “start” and “stop” appropriately.
I think such automated option prediction is very dangerous and it gets more dangerous the more options are added for the tools as it is more likely your mistake can be actually matching something… I think much better solution would be to have explicitly created synonyms and shortcuts if they are needed. For example “extended-status” is rather option and we can allow “extended” shortcut for it or might be even “ext” but allowing “e” is an overkill.