MySQL TRADITIONAL mode

245 views
Skip to first unread message

A.E. van Bochoven

unread,
Feb 9, 2014, 4:33:12 AM2/9/14
to munki...@googlegroups.com
Triggered by some recent problems with MySQL 5.6, I revisited some MR models to see if they can support a more strict mode.
Most models are in compliance with sql mode 'TRADITIONAL' as far as I could see. I pushed new versions to the wip branch for the two that didn't (disk_report and directory_service).

It is very easy to switch modes, you just have to add sql_mode to pdo_opts:

$conf['pdo_opts'] = array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8, sql_mode = TRADITIONAL');

I want to propose to use sql mode TRADITIONAL, at least for development.
The MySQL site states: TRADITIONAL: 'Make MySQL behave like a “traditional” SQL database system. A simple description of this mode is “give an error instead of a warning” when inserting an incorrect value into a column.'

There is a little performance hit if you set the mode (although that may be minimal).

To switch off sql mode you can explicitly set it to an empty string:
$conf['pdo_opts'] = array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8, sql_mode = ""');


More about sql server modes:
http://dev.mysql.com/doc/refman/5.0/en/server-sql-mode.html
https://dev.mysql.com/doc/refman/5.5/en/faqs-sql-modes.html

-Arjen

Matthew Johnson

unread,
Feb 10, 2014, 12:30:51 PM2/10/14
to munki...@googlegroups.com
Thanks Arjen.  This is really helpful

Matt
Reply all
Reply to author
Forward
0 new messages