r59965 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r59964‎ | r59965 | r59966 >
Date:19:53, 11 December 2009
Author:maxsem
Status:ok
Tags:
Comment:
Per CR for r58631, moved default duplicateTableStructure() implementation to DatabaseMysql, replacing it with 'not implemented' exception throw
Modified paths:
  • /trunk/phase3/includes/db/Database.php (modified) (history)
  • /trunk/phase3/includes/db/DatabaseMysql.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/db/DatabaseMysql.php
@@ -403,6 +403,7 @@
404404 }
405405
406406 function duplicateTableStructure( $oldName, $newName, $temporary = false, $fname = 'DatabaseMysql::duplicateTableStructure' ) {
 407+ $tmp = $temporary ? 'TEMPORARY ' : '';
407408 if ( strcmp( $this->getServerVersion(), '4.1' ) < 0 ) {
408409 # Hack for MySQL versions < 4.1, which don't support
409410 # "CREATE TABLE ... LIKE". Note that
@@ -414,17 +415,17 @@
415416
416417 $res = $this->query( "SHOW CREATE TABLE $oldName" );
417418 $row = $this->fetchRow( $res );
418 - $create = $row[1];
419 - $create_tmp = preg_replace( '/CREATE TABLE `(.*?)`/',
420 - 'CREATE ' . ( $temporary ? 'TEMPORARY ' : '' ) . "TABLE `$newName`", $create );
421 - if ($create === $create_tmp) {
 419+ $oldQuery = $row[1];
 420+ $query = preg_replace( '/CREATE TABLE `(.*?)`/',
 421+ "CREATE $tmp TABLE `$newName`", $oldQuery );
 422+ if ($oldQuery === $query) {
422423 # Couldn't do replacement
423424 throw new MWException( "could not create temporary table $newName" );
424425 }
425 - $this->query( $create_tmp, $fname );
426426 } else {
427 - return parent::duplicateTableStructure( $oldName, $newName, $temporary );
 427+ $query = "CREATE $tmp TABLE $newName (LIKE $oldName)";
428428 }
 429+ $this->query( $query, $fname );
429430 }
430431
431432 }
Index: trunk/phase3/includes/db/Database.php
@@ -2002,7 +2002,7 @@
20032003 * @return Boolean: true if operation was successful
20042004 */
20052005 function duplicateTableStructure( $oldName, $newName, $temporary = false, $fname = 'Database::duplicateTableStructure' ) {
2006 - return $this->query( 'CREATE ' . ( $temporary ? 'TEMPORARY ' : '' ) . " TABLE $newName (LIKE $oldName)", $fname );
 2006+ throw new MWException( 'DatabaseBase::duplicateTableStructure is not implemented in descendant class' );
20072007 }
20082008
20092009 /**

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r58631Abstracted some parts of database interaction for parser tests, needs verific...maxsem10:17, 6 November 2009

Status & tagging log