donderdag 2 oktober 2014

Why I like PostgreSQL more than MySQL: stubbornly refusing to admit errors.

MySQL has a long history of pretending that there are no such things as errors. Everywhere you turn there are features that allow you to make mistakes and never be told about them, or even worse: pretend that there actually was no error at all. If you've ever restored a database with views you'll know how MySQL treats the view as a table which is later converted into a view, just in case the target database does not support views.

The command line options are much the same; if you are adding a command line option to MySQL in a shell script you can actually tell MySQL not to throw an error if it does not support that option.

From the manual:

If an option is prefixed by --loose, a program does not exit with an error if it does not recognize the option, but instead issues only a warning:
shell> mysql --loose-no-such-optionmysql: WARNING: unknown option '--no-such-option'

So if your script needs to do something that the target database might not be able to do, then just pretend that it can, and it'll be fine. Well, what's the worst that could happen... your database gets destroyed, big deal, you've got backups... right?