Merge "Inject "srvCache" and local DB connections into LockManagerDB"
[lhc/web/wiklou.git] / includes / libs / rdbms / database / DatabaseMysqlBase.php
index 2d19081..675bc87 100644 (file)
@@ -518,6 +518,17 @@ abstract class DatabaseMysqlBase extends DatabaseBase {
                return (int)$rows;
        }
 
+       function tableExists( $table, $fname = __METHOD__ ) {
+               $table = $this->tableName( $table, 'raw' );
+               if ( isset( $this->mSessionTempTables[$table] ) ) {
+                       return true; // already known to exist and won't show in SHOW TABLES anyway
+               }
+
+               $encLike = $this->buildLike( $table );
+
+               return $this->query( "SHOW TABLES $encLike", $fname )->numRows() > 0;
+       }
+
        /**
         * @param string $table
         * @param string $field
@@ -962,8 +973,8 @@ abstract class DatabaseMysqlBase extends DatabaseBase {
         * @since 1.20
         */
        public function lockIsFree( $lockName, $method ) {
-               $lockName = $this->addQuotes( $this->makeLockName( $lockName ) );
-               $result = $this->query( "SELECT IS_FREE_LOCK($lockName) AS lockstatus", $method );
+               $encName = $this->addQuotes( $this->makeLockName( $lockName ) );
+               $result = $this->query( "SELECT IS_FREE_LOCK($encName) AS lockstatus", $method );
                $row = $this->fetchObject( $result );
 
                return ( $row->lockstatus == 1 );
@@ -976,8 +987,8 @@ abstract class DatabaseMysqlBase extends DatabaseBase {
         * @return bool
         */
        public function lock( $lockName, $method, $timeout = 5 ) {
-               $lockName = $this->addQuotes( $this->makeLockName( $lockName ) );
-               $result = $this->query( "SELECT GET_LOCK($lockName, $timeout) AS lockstatus", $method );
+               $encName = $this->addQuotes( $this->makeLockName( $lockName ) );
+               $result = $this->query( "SELECT GET_LOCK($encName, $timeout) AS lockstatus", $method );
                $row = $this->fetchObject( $result );
 
                if ( $row->lockstatus == 1 ) {
@@ -985,7 +996,7 @@ abstract class DatabaseMysqlBase extends DatabaseBase {
                        return true;
                }
 
-               $this->queryLogger->debug( __METHOD__ . " failed to acquire lock\n" );
+               $this->queryLogger->warning( __METHOD__ . " failed to acquire lock '$lockName'\n" );
 
                return false;
        }
@@ -998,8 +1009,8 @@ abstract class DatabaseMysqlBase extends DatabaseBase {
         * @return bool
         */
        public function unlock( $lockName, $method ) {
-               $lockName = $this->addQuotes( $this->makeLockName( $lockName ) );
-               $result = $this->query( "SELECT RELEASE_LOCK($lockName) as lockstatus", $method );
+               $encName = $this->addQuotes( $this->makeLockName( $lockName ) );
+               $result = $this->query( "SELECT RELEASE_LOCK($encName) as lockstatus", $method );
                $row = $this->fetchObject( $result );
 
                if ( $row->lockstatus == 1 ) {
@@ -1007,7 +1018,7 @@ abstract class DatabaseMysqlBase extends DatabaseBase {
                        return true;
                }
 
-               $this->queryLogger->debug( __METHOD__ . " failed to release lock\n" );
+               $this->queryLogger->warning( __METHOD__ . " failed to release lock '$lockName'\n" );
 
                return false;
        }
@@ -1258,21 +1269,6 @@ abstract class DatabaseMysqlBase extends DatabaseBase {
                return $this->query( "DROP TABLE IF EXISTS " . $this->tableName( $tableName ), $fName );
        }
 
-       /**
-        * @return array
-        */
-       protected function getDefaultSchemaVars() {
-               $vars = parent::getDefaultSchemaVars();
-               $vars['wgDBTableOptions'] = str_replace( 'TYPE', 'ENGINE', $GLOBALS['wgDBTableOptions'] );
-               $vars['wgDBTableOptions'] = str_replace(
-                       'CHARSET=mysql4',
-                       'CHARSET=binary',
-                       $vars['wgDBTableOptions']
-               );
-
-               return $vars;
-       }
-
        /**
         * Get status information from SHOW STATUS in an associative array
         *