Avoiding implicit transactions when applying
authorAaron Schulz <aschulz@wikimedia.org>
Thu, 21 Nov 2013 23:54:02 +0000 (15:54 -0800)
committerAaron Schulz <aschulz@wikimedia.org>
Thu, 21 Nov 2013 23:54:06 +0000 (15:54 -0800)
* Some callers get the DB and flip DBO_TRX off, which does not
  help much if simply connecting to the DB starts a transaction.

Change-Id: I2bc90a1cdeade13ccb546db1183ab08f25156da1

includes/db/DatabaseMysqlBase.php

index e0ad003..1f80aa7 100644 (file)
@@ -123,7 +123,12 @@ abstract class DatabaseMysqlBase extends DatabaseBase {
                // Set SQL mode, default is turning them all off, can be overridden or skipped with null
                if ( is_string( $wgSQLMode ) ) {
                        $mode = $this->addQuotes( $wgSQLMode );
-                       $this->query( "SET sql_mode = $mode", __METHOD__ );
+                       // Use doQuery() to avoid opening implicit transactions (DBO_TRX)
+                       $success = $this->doQuery( "SET sql_mode = $mode", __METHOD__ );
+                       if ( !$success ) {
+                               wfLogDBError( "Error setting sql_mode to $mode on server {$this->mServer}" );
+                               return $this->reportConnectionError( "Error setting sql_mode to $mode" );
+                       }
                }
 
                $this->mOpened = true;