Merge "Make addIdentifierQuotes part of IDatabase"
[lhc/web/wiklou.git] / includes / libs / rdbms / database / Database.php
index bafdb44..49b2792 100644 (file)
@@ -1347,12 +1347,19 @@ abstract class Database implements IDatabase, IMaintainableDatabase, LoggerAware
        }
 
        /**
+        * Error out if the DB is not in a valid state for a query via query()
+        *
         * @param string $sql
         * @param string $fname
         * @throws DBTransactionStateError
         */
        private function assertTransactionStatus( $sql, $fname ) {
-               if ( $this->getQueryVerb( $sql ) === 'ROLLBACK' ) { // transaction/savepoint
+               $verb = $this->getQueryVerb( $sql );
+               if ( $verb === 'USE' ) {
+                       throw new DBUnexpectedError( $this, "Got USE query; use selectDomain() instead." );
+               }
+
+               if ( $verb === 'ROLLBACK' ) { // transaction/savepoint
                        return;
                }
 
@@ -2675,15 +2682,6 @@ abstract class Database implements IDatabase, IMaintainableDatabase, LoggerAware
                }
        }
 
-       /**
-        * Quotes an identifier using `backticks` or "double quotes" depending on the database type.
-        * MySQL uses `backticks` while basically everything else uses double quotes.
-        * Since MySQL is the odd one out here the double quotes are our generic
-        * and we implement backticks in DatabaseMysqlBase.
-        *
-        * @param string $s
-        * @return string
-        */
        public function addIdentifierQuotes( $s ) {
                return '"' . str_replace( '"', '""', $s ) . '"';
        }