return mysql_select_db( $db, $this->mConn );
}
- /**
- * @return string
- */
- function getServerVersion() {
- return mysql_get_server_info( $this->mConn );
- }
-
protected function mysqlFreeResult( $res ) {
return mysql_free_result( $res );
}
protected $mFakeMaster = false;
+ /** @var string|null */
+ private $serverVersion = null;
+
/**
* @return string
*/
* @return string
*/
public function getSoftwareLink() {
- // MariaDB includes its name in its version string (sent when the connection is opened),
- // and this is how MariaDB's version of the mysql command-line client identifies MariaDB
- // servers (see the mariadb_connection() function in libmysql/libmysql.c).
+ // MariaDB includes its name in its version string; this is how MariaDB's version of
+ // the mysql command-line client identifies MariaDB servers (see mariadb_connection()
+ // in libmysql/libmysql.c).
$version = $this->getServerVersion();
if ( strpos( $version, 'MariaDB' ) !== false || strpos( $version, '-maria-' ) !== false ) {
return '[{{int:version-db-mariadb-url}} MariaDB]';
return '[{{int:version-db-mysql-url}} MySQL]';
}
+ /**
+ * @return string
+ */
+ public function getServerVersion() {
+ // Not using mysql_get_server_info() or similar for consistency: in the handshake,
+ // MariaDB 10 adds the prefix "5.5.5-", and only some newer client libraries strip
+ // it off (see RPL_VERSION_HACK in include/mysql_com.h).
+ if ( $this->serverVersion === null ) {
+ $this->serverVersion = $this->selectField( '', 'VERSION()', '', __METHOD__ );
+ }
+ return $this->serverVersion;
+ }
+
/**
* @param array $options
*/