$this->$var = $params[$var];
}
}
- $this->sqlMode = $params['sqlMode'] ?? '';
+ $this->sqlMode = $params['sqlMode'] ?? null;
$this->utf8Mode = !empty( $params['utf8Mode'] );
$this->insertSelectIsSafe = isset( $params['insertSelectIsSafe'] )
? (bool)$params['insertSelectIsSafe'] : null;
}
// Set any custom settings defined by site config
// (e.g. https://dev.mysql.com/doc/refman/4.1/en/innodb-parameters.html)
- foreach ( $this->sessionVars as $var => $val ) {
+ foreach ( $this->connectionVariables as $var => $val ) {
// Escape strings but not numbers to avoid MySQL complaining
if ( !is_int( $val ) && !is_float( $val ) ) {
$val = $this->addQuotes( $val );
if ( $database !== $this->getDBname() ) {
$sql = 'USE ' . $this->addIdentifierQuotes( $database );
- $ret = $this->doQuery( $sql );
- if ( $ret === false ) {
- $error = $this->lastError();
- $errno = $this->lastErrno();
- $this->reportQueryError( $error, $errno, $sql, __METHOD__ );
+ list( $res, $err, $errno ) =
+ $this->executeQuery( $sql, __METHOD__, self::QUERY_IGNORE_DBO_TRX );
+
+ if ( $res === false ) {
+ $this->reportQueryError( $err, $errno, $sql, __METHOD__ );
+ return false; // unreachable
}
}
abstract protected function mysqlSetCharset( $charset );
/**
- * @param ResultWrapper|resource $res
+ * @param IResultWrapper|resource $res
* @throws DBUnexpectedError
*/
public function freeResult( $res ) {
abstract protected function mysqlFreeResult( $res );
/**
- * @param ResultWrapper|resource $res
+ * @param IResultWrapper|resource $res
* @return stdClass|bool
* @throws DBUnexpectedError
*/
* Fetch a result row as an associative and numeric array
*
* @param resource $res Raw result
- * @return array
+ * @return array|false
*/
abstract protected function mysqlFetchArray( $res );
/**
* @throws DBUnexpectedError
- * @param ResultWrapper|resource $res
+ * @param IResultWrapper|resource $res
* @return int
*/
function numRows( $res ) {
abstract protected function mysqlNumRows( $res );
/**
- * @param ResultWrapper|resource $res
+ * @param IResultWrapper|resource $res
* @return int
*/
public function numFields( $res ) {
abstract protected function mysqlNumFields( $res );
/**
- * @param ResultWrapper|resource $res
+ * @param IResultWrapper|resource $res
* @param int $n
* @return string
*/
/**
* Get the name of the specified field in a result
*
- * @param ResultWrapper|resource $res
+ * @param IResultWrapper|resource $res
* @param int $n
* @return string
*/
/**
* mysql_field_type() wrapper
- * @param ResultWrapper|resource $res
+ * @param IResultWrapper|resource $res
* @param int $n
* @return string
*/
/**
* Get the type of the specified field in a result
*
- * @param ResultWrapper|resource $res
+ * @param IResultWrapper|resource $res
* @param int $n
* @return string
*/
abstract protected function mysqlFieldType( $res, $n );
/**
- * @param ResultWrapper|resource $res
+ * @param IResultWrapper|resource $res
* @param int $row
* @return bool
*/
/**
* Move internal result pointer
*
- * @param ResultWrapper|resource $res
+ * @param IResultWrapper|resource $res
* @param int $row
* @return bool
*/
$gtidArg = $this->addQuotes( implode( ',', $gtidsWait ) );
if ( strpos( $gtidArg, ':' ) !== false ) {
// MySQL GTIDs, e.g "source_id:transaction_id"
- $res = $this->doQuery( "SELECT WAIT_FOR_EXECUTED_GTID_SET($gtidArg, $timeout)" );
+ $sql = "SELECT WAIT_FOR_EXECUTED_GTID_SET($gtidArg, $timeout)";
} else {
// MariaDB GTIDs, e.g."domain:server:sequence"
- $res = $this->doQuery( "SELECT MASTER_GTID_WAIT($gtidArg, $timeout)" );
+ $sql = "SELECT MASTER_GTID_WAIT($gtidArg, $timeout)";
}
} else {
// Wait on the binlog coordinates
$encFile = $this->addQuotes( $pos->getLogFile() );
$encPos = intval( $pos->getLogPosition()[$pos::CORD_EVENT] );
- $res = $this->doQuery( "SELECT MASTER_POS_WAIT($encFile, $encPos, $timeout)" );
+ $sql = "SELECT MASTER_POS_WAIT($encFile, $encPos, $timeout)";
}
+ list( $res, $err ) = $this->executeQuery( $sql, __METHOD__, self::QUERY_IGNORE_DBO_TRX );
$row = $res ? $this->fetchRow( $res ) : false;
if ( !$row ) {
- throw new DBExpectedError( $this, "Replication wait failed: {$this->lastError()}" );
+ throw new DBExpectedError( $this, "Replication wait failed: {$err}" );
}
// Result can be NULL (error), -1 (timeout), or 0+ per the MySQL manual
/**
* @param string $tableName
* @param string $fName
- * @return bool|ResultWrapper
+ * @return bool|IResultWrapper
*/
public function dropTable( $tableName, $fName = __METHOD__ ) {
if ( !$this->tableExists( $tableName, $fName ) ) {