Google+ Followers

donderdag 4 september 2014

Why I like PostgreSQL more than MySQL: Errors on triggers.

You can use triggers to modify the contents of tables. However, if the query inside the trigger fails, MySQL gives you only the error itself, not the context. If the query fails because some field is NOT NULL, then you will just get "Field X cannot be NULL".

Now, if the column is not usable in the original query that triggered the trigger, then you may be tempted to start looking for it. But if the column is part of the original query, and the query tries to set it to a value other than NULL, then yoou can only scratch your head.

Other databases tell you the exact query that failed. In this case, the query that the trigger started. They will even tell you the name of the trigger in which the query failed.