rdbms: inject the mysql index name aliases into Database
[lhc/web/wiklou.git] / includes / libs / rdbms / database / DatabaseMysqlBase.php
index 1e845e8..d1d0179 100644 (file)
@@ -527,13 +527,16 @@ abstract class DatabaseMysqlBase extends Database {
                // checking if the target table has an auto-increment column that
                // isn't set in $varMap, that seems unlikely to be worth the extra
                // complexity.
-               return ( (int)$row->innodb_autoinc_lock_mode === 0 );
+               return (
+                       in_array( 'NO_AUTO_COLUMNS', $insertOptions ) ||
+                       (int)$row->innodb_autoinc_lock_mode === 0
+               );
        }
 
        /**
         * @return stdClass Process cached row
         */
-       private function getReplicationSafetyInfo() {
+       protected function getReplicationSafetyInfo() {
                if ( $this->replicationInfoRow === null ) {
                        $this->replicationInfoRow = $this->selectRow(
                                false,
@@ -668,7 +671,7 @@ abstract class DatabaseMysqlBase extends Database {
                        }
                }
 
-               return empty( $result ) ? false : $result;
+               return $result ?: false;
        }
 
        /**
@@ -1415,44 +1418,19 @@ abstract class DatabaseMysqlBase extends Database {
                return in_array( $name, $this->listViews( $prefix ) );
        }
 
+       protected function isTransactableQuery( $sql ) {
+               return parent::isTransactableQuery( $sql ) &&
+                       !preg_match( '/^SELECT\s+(GET|RELEASE|IS_FREE)_LOCK\(/', $sql );
+       }
+
        /**
-        * Allows for index remapping in queries where this is not consistent across DBMS
-        *
-        * @param string $index
+        * @param string $field Field or column to cast
         * @return string
         */
-       protected function indexName( $index ) {
-               /**
-                * When SQLite indexes were introduced in r45764, it was noted that
-                * SQLite requires index names to be unique within the whole database,
-                * not just within a schema. As discussed in CR r45819, to avoid the
-                * need for a schema change on existing installations, the indexes
-                * were implicitly mapped from the new names to the old names.
-                *
-                * This mapping can be removed if DB patches are introduced to alter
-                * the relevant tables in existing installations. Note that because
-                * this index mapping applies to table creation, even new installations
-                * of MySQL have the old names (except for installations created during
-                * a period where this mapping was inappropriately removed, see
-                * T154872).
-                */
-               $renamed = [
-                       'ar_usertext_timestamp' => 'usertext_timestamp',
-                       'un_user_id' => 'user_id',
-                       'un_user_ip' => 'user_ip',
-               ];
-
-               if ( isset( $renamed[$index] ) ) {
-                       return $renamed[$index];
-               } else {
-                       return $index;
-               }
+       public function buildIntegerCast( $field ) {
+               return 'CAST( ' . $field . ' AS SIGNED )';
        }
 
-       protected function isTransactableQuery( $sql ) {
-               return parent::isTransactableQuery( $sql ) &&
-                       !preg_match( '/^SELECT\s+(GET|RELEASE|IS_FREE)_LOCK\(/', $sql );
-       }
 }
 
 class_alias( DatabaseMysqlBase::class, 'DatabaseMysqlBase' );