<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>
<channel>
	<title>Comments on: Why SQL_MODE is important? Part I</title>
	<atom:link href="http://ronaldbradford.com/blog/why-sql_mode-is-important-part-i-2008-07-17/feed/" rel="self" type="application/rss+xml" />
	<link>http://ronaldbradford.com/blog/why-sql_mode-is-important-part-i-2008-07-17/</link>
	<description>Information in black and white, and sometimes some color.</description>
	<pubDate>Fri, 21 Nov 2008 03:13:58 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5.1</generator>
		<item>
		<title>By: Xaprb</title>
		<link>http://ronaldbradford.com/blog/why-sql_mode-is-important-part-i-2008-07-17/#comment-96679</link>
		<dc:creator>Xaprb</dc:creator>
		<pubDate>Thu, 17 Jul 2008 12:35:38 +0000</pubDate>
		<guid isPermaLink="false">http://ronaldbradford.com/blog/?p=1126#comment-96679</guid>
		<description>"In version 5.0, the introduction of SQL_MODE solved this problem"  I would say partially solved.  It was a good step towards sanity, but there are still ways to get garbage in :)</description>
		<content:encoded><![CDATA[<p>&#8220;In version 5.0, the introduction of SQL_MODE solved this problem&#8221;  I would say partially solved.  It was a good step towards sanity, but there are still ways to get garbage in <img src='http://ronaldbradford.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mark R</title>
		<link>http://ronaldbradford.com/blog/why-sql_mode-is-important-part-i-2008-07-17/#comment-96677</link>
		<dc:creator>Mark R</dc:creator>
		<pubDate>Thu, 17 Jul 2008 08:15:23 +0000</pubDate>
		<guid isPermaLink="false">http://ronaldbradford.com/blog/?p=1126#comment-96677</guid>
		<description>I think that setting the server to TRADITIONAL for a server used in a service where well-tested code is used, which has been tested under the same circumstances, is a very good thing to do.

Change is bad. Change will introduce bugs. Changing SQL_MODE is a major change to the way that MySQL works which will cause new bugs in existing code- therefore doing so in an existing application is significantly risky.

One case where changing SQL_MODE might be acceptable is if you're doing such a major change anyway that every single query must be tested- for example upgrading the MySQL version. 

Typical open source PHP applications are generally so buggy and have such poor error handling that even diagnosing or detecting bugs caused by SQL_MODE will be very time consuming. Convincing their maintainers that these are bugs proves difficult (in my experience). Don't use such applications in production.

For a new application- great - provided you are completely sure that the developers' test environments will also use that setting (which should be easy, as your developers must always use a system which is as close in configuration to production as possible).

Mark</description>
		<content:encoded><![CDATA[<p>I think that setting the server to TRADITIONAL for a server used in a service where well-tested code is used, which has been tested under the same circumstances, is a very good thing to do.</p>
<p>Change is bad. Change will introduce bugs. Changing SQL_MODE is a major change to the way that MySQL works which will cause new bugs in existing code- therefore doing so in an existing application is significantly risky.</p>
<p>One case where changing SQL_MODE might be acceptable is if you&#8217;re doing such a major change anyway that every single query must be tested- for example upgrading the MySQL version. </p>
<p>Typical open source PHP applications are generally so buggy and have such poor error handling that even diagnosing or detecting bugs caused by SQL_MODE will be very time consuming. Convincing their maintainers that these are bugs proves difficult (in my experience). Don&#8217;t use such applications in production.</p>
<p>For a new application- great - provided you are completely sure that the developers&#8217; test environments will also use that setting (which should be easy, as your developers must always use a system which is as close in configuration to production as possible).</p>
<p>Mark</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Roland Bouman</title>
		<link>http://ronaldbradford.com/blog/why-sql_mode-is-important-part-i-2008-07-17/#comment-96676</link>
		<dc:creator>Roland Bouman</dc:creator>
		<pubDate>Thu, 17 Jul 2008 08:02:05 +0000</pubDate>
		<guid isPermaLink="false">http://ronaldbradford.com/blog/?p=1126#comment-96676</guid>
		<description>Hi,

"One could also argue that MySQL should make the default SQL_MODE at least TRADITIONAL, and that only when you want backward compatibility should you then change the SQL_MODE."

I'd like that too, except that many applications (esp. the typical PHP webapps) will instantly crap out on you (Try it). In fact, many applications do not withstand any non-default options, like the default engine, default auto_commit etc. (so it's not just confined to SQL_MODE)

As for sql_mode, both ANSI and TRADITIONAL are most likely to sink the typical PHP app. Many PHP apps simply use double quotes to delimit strings in their SQL statements, and many schemas simply rely on '0000-00-00' dates.

I have been told by some appdevs that I am shooting myself in the foot by changing things like the sql_mode at the server level, and that's only fair that I should suffer from problems with their apps. 

I disagree.

Personally I would urge every application developer to always have their code explicitly set the sql_mode (and any other settings, such as autocommit mode) at the session level immediately after connecting to MySQL to what suits their application best. For most applications that would boil down to a single statement:

SET sql_mode := '', autocommit = true, storage_engine = MyISAM;

If you look at the installation documentation for most PHP apps, you will almost never see any reference to these kinds of MySQL config requirements. They simply assume a default installation, always.

I don't see this getting better anytime soon. If MySQL would change the default configuration, it would just lead to a lot of broken apps and scrolls and scrolls of slashdot rants.</description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>&#8220;One could also argue that MySQL should make the default SQL_MODE at least TRADITIONAL, and that only when you want backward compatibility should you then change the SQL_MODE.&#8221;</p>
<p>I&#8217;d like that too, except that many applications (esp. the typical PHP webapps) will instantly crap out on you (Try it). In fact, many applications do not withstand any non-default options, like the default engine, default auto_commit etc. (so it&#8217;s not just confined to SQL_MODE)</p>
<p>As for sql_mode, both ANSI and TRADITIONAL are most likely to sink the typical PHP app. Many PHP apps simply use double quotes to delimit strings in their SQL statements, and many schemas simply rely on &#8216;0000-00-00&#8242; dates.</p>
<p>I have been told by some appdevs that I am shooting myself in the foot by changing things like the sql_mode at the server level, and that&#8217;s only fair that I should suffer from problems with their apps. </p>
<p>I disagree.</p>
<p>Personally I would urge every application developer to always have their code explicitly set the sql_mode (and any other settings, such as autocommit mode) at the session level immediately after connecting to MySQL to what suits their application best. For most applications that would boil down to a single statement:</p>
<p>SET sql_mode := &#8221;, autocommit = true, storage_engine = MyISAM;</p>
<p>If you look at the installation documentation for most PHP apps, you will almost never see any reference to these kinds of MySQL config requirements. They simply assume a default installation, always.</p>
<p>I don&#8217;t see this getting better anytime soon. If MySQL would change the default configuration, it would just lead to a lot of broken apps and scrolls and scrolls of slashdot rants.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
