Added support for specifying an sql mode

These are the changes I mentioned in Bugzilla.  It would be helpful if they could be incorporated upstream so they can be easily applied to all systems.