r104047 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r104046‎ | r104047 | r104048 >
Date:16:27, 23 November 2011
Author:reedy
Status:ok (Comments)
Tags:
Comment:
Kill mysql4 specific code from DatabaseMysql

Set minimum version of mysql in MysqlInstaller
Modified paths:
  • /trunk/phase3/includes/db/DatabaseMysql.php (modified) (history)
  • /trunk/phase3/includes/installer/MysqlInstaller.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/db/DatabaseMysql.php
@@ -114,23 +114,20 @@
115115 }
116116
117117 if ( $success ) {
118 - $version = $this->getServerVersion();
119 - if ( version_compare( $version, '4.1' ) >= 0 ) {
120 - // Tell the server we're communicating with it in UTF-8.
121 - // This may engage various charset conversions.
122 - global $wgDBmysql5;
123 - if( $wgDBmysql5 ) {
124 - $this->query( 'SET NAMES utf8', __METHOD__ );
125 - } else {
126 - $this->query( 'SET NAMES binary', __METHOD__ );
127 - }
128 - // Set SQL mode, default is turning them all off, can be overridden or skipped with null
129 - global $wgSQLMode;
130 - if ( is_string( $wgSQLMode ) ) {
131 - $mode = $this->addQuotes( $wgSQLMode );
132 - $this->query( "SET sql_mode = $mode", __METHOD__ );
133 - }
 118+ // Tell the server we're communicating with it in UTF-8.
 119+ // This may engage various charset conversions.
 120+ global $wgDBmysql5;
 121+ if( $wgDBmysql5 ) {
 122+ $this->query( 'SET NAMES utf8', __METHOD__ );
 123+ } else {
 124+ $this->query( 'SET NAMES binary', __METHOD__ );
134125 }
 126+ // Set SQL mode, default is turning them all off, can be overridden or skipped with null
 127+ global $wgSQLMode;
 128+ if ( is_string( $wgSQLMode ) ) {
 129+ $mode = $this->addQuotes( $wgSQLMode );
 130+ $this->query( "SET sql_mode = $mode", __METHOD__ );
 131+ }
135132
136133 // Turn off strict mode if it is on
137134 } else {
@@ -424,9 +421,7 @@
425422 /**
426423 * Returns slave lag.
427424 *
428 - * On MySQL 4.1.9 and later, this will do a SHOW SLAVE STATUS. On earlier
429 - * versions of MySQL, it uses SHOW PROCESSLIST, which requires the PROCESS
430 - * privilege.
 425+ * On MySQL 4.1.9 and later, this will do a SHOW SLAVE STATUS
431426 *
432427 * @return int
433428 */
@@ -436,11 +431,7 @@
437432 return $this->mFakeSlaveLag;
438433 }
439434
440 - if ( version_compare( $this->getServerVersion(), '4.1.9', '>=' ) ) {
441 - return $this->getLagFromSlaveStatus();
442 - } else {
443 - return $this->getLagFromProcesslist();
444 - }
 435+ return $this->getLagFromSlaveStatus();
445436 }
446437
447438 /**
@@ -463,6 +454,8 @@
464455 }
465456
466457 /**
 458+ * @deprecated in 1.19, use getLagFromSlaveStatus
 459+ *
467460 * @return bool|int
468461 */
469462 function getLagFromProcesslist() {
@@ -732,29 +725,9 @@
733726
734727 function duplicateTableStructure( $oldName, $newName, $temporary = false, $fname = 'DatabaseMysql::duplicateTableStructure' ) {
735728 $tmp = $temporary ? 'TEMPORARY ' : '';
736 - if ( strcmp( $this->getServerVersion(), '4.1' ) < 0 ) {
737 - # Hack for MySQL versions < 4.1, which don't support
738 - # "CREATE TABLE ... LIKE". Note that
739 - # "CREATE TEMPORARY TABLE ... SELECT * FROM ... LIMIT 0"
740 - # would not create the indexes we need....
741 - #
742 - # Note that we don't bother changing around the prefixes here be-
743 - # cause we know we're using MySQL anyway.
744 -
745 - $res = $this->query( 'SHOW CREATE TABLE ' . $this->addIdentifierQuotes( $oldName ) );
746 - $row = $this->fetchRow( $res );
747 - $oldQuery = $row[1];
748 - $query = preg_replace( '/CREATE TABLE `(.*?)`/',
749 - "CREATE $tmp TABLE " . $this->addIdentifierQuotes( $newName ), $oldQuery );
750 - if ($oldQuery === $query) {
751 - # Couldn't do replacement
752 - throw new MWException( "could not create temporary table $newName" );
753 - }
754 - } else {
755 - $newName = $this->addIdentifierQuotes( $newName );
756 - $oldName = $this->addIdentifierQuotes( $oldName );
757 - $query = "CREATE $tmp TABLE $newName (LIKE $oldName)";
758 - }
 729+ $newName = $this->addIdentifierQuotes( $newName );
 730+ $oldName = $this->addIdentifierQuotes( $oldName );
 731+ $query = "CREATE $tmp TABLE $newName (LIKE $oldName)";
759732 $this->query( $query, $fname );
760733 }
761734
Index: trunk/phase3/includes/installer/MysqlInstaller.php
@@ -32,7 +32,7 @@
3333
3434 public $supportedEngines = array( 'InnoDB', 'MyISAM' );
3535
36 - public $minimumVersion = '4.0.14';
 36+ public $minimumVersion = '5.0.0';
3737
3838 public $webUserPrivs = array(
3939 'DELETE',

Follow-up revisions

RevisionCommit summaryAuthorDate
r104209Improve comment from r104047...reedy00:16, 25 November 2011
r104437Bump MySQL version to 5.0.2 after r104047...reedy15:19, 28 November 2011

Comments

#Comment by Petrb (talk | contribs)   16:37, 23 November 2011

Probably you could write just

This will do a SHOW ... 

instead of

On MySQL 4.1.9 and later, this will do a ...

in comment since mysql 4x is not even supported it's probably clear

#Comment by Duplicatebug (talk | contribs)   19:53, 26 November 2011

Please update the RELEASE-NOTES, section 'Compatibility' (MySQL 4.0 or later)

Status & tagging log