Index: trunk/phase3/includes/db/DatabaseMysql.php |
— | — | @@ -403,6 +403,7 @@ |
404 | 404 | } |
405 | 405 | |
406 | 406 | function duplicateTableStructure( $oldName, $newName, $temporary = false, $fname = 'DatabaseMysql::duplicateTableStructure' ) { |
| 407 | + $tmp = $temporary ? 'TEMPORARY ' : ''; |
407 | 408 | if ( strcmp( $this->getServerVersion(), '4.1' ) < 0 ) { |
408 | 409 | # Hack for MySQL versions < 4.1, which don't support |
409 | 410 | # "CREATE TABLE ... LIKE". Note that |
— | — | @@ -414,17 +415,17 @@ |
415 | 416 | |
416 | 417 | $res = $this->query( "SHOW CREATE TABLE $oldName" ); |
417 | 418 | $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) { |
422 | 423 | # Couldn't do replacement |
423 | 424 | throw new MWException( "could not create temporary table $newName" ); |
424 | 425 | } |
425 | | - $this->query( $create_tmp, $fname ); |
426 | 426 | } else { |
427 | | - return parent::duplicateTableStructure( $oldName, $newName, $temporary ); |
| 427 | + $query = "CREATE $tmp TABLE $newName (LIKE $oldName)"; |
428 | 428 | } |
| 429 | + $this->query( $query, $fname ); |
429 | 430 | } |
430 | 431 | |
431 | 432 | } |
Index: trunk/phase3/includes/db/Database.php |
— | — | @@ -2002,7 +2002,7 @@ |
2003 | 2003 | * @return Boolean: true if operation was successful |
2004 | 2004 | */ |
2005 | 2005 | 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' ); |
2007 | 2007 | } |
2008 | 2008 | |
2009 | 2009 | /** |