From a9927b34c5e4a14c6a1db6c56b3ce9ba90b42834 Mon Sep 17 00:00:00 2001 From: Max Semenik Date: Sun, 6 Dec 2009 11:09:39 +0000 Subject: [PATCH] Fixed duplicateTableStructure() for SQLite, it previously didn't copy row properties such as autoincrement. Resolves bug 20549 - parser tests now work with SQLite. --- RELEASE-NOTES | 1 + includes/db/DatabaseSqlite.php | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index e050a63c70..af9b47236f 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -668,6 +668,7 @@ Hopefully we will remove this configuration var soon) the page selector when they have only one page * (bug 21559) "logempty" message is now wrapped in a div with class "mw-warning-logempty" when used in log extract +* (bug 20549) Parser tests were broken on SQLite backend == API changes in 1.16 == diff --git a/includes/db/DatabaseSqlite.php b/includes/db/DatabaseSqlite.php index bab37cd8fa..745bc71e18 100644 --- a/includes/db/DatabaseSqlite.php +++ b/includes/db/DatabaseSqlite.php @@ -521,7 +521,10 @@ class DatabaseSqlite extends DatabaseBase { } function duplicateTableStructure( $oldName, $newName, $temporary = false, $fname = 'DatabaseSqlite::duplicateTableStructure' ) { - return $this->query( 'CREATE ' . ( $temporary ? 'TEMPORARY ' : '' ) . " TABLE $newName AS SELECT * FROM $oldName LIMIT 0", $fname ); + $res = $this->query( "SELECT sql FROM sqlite_master WHERE tbl_name='$oldName' AND type='table'", $fname ); + $sql = $this->fetchObject( $res )->sql; + $sql = preg_replace( '/\b' . preg_quote( $oldName ) . '\b/', $newName, $sql, 1 ); + return $this->query( $sql, $fname ); } } // end DatabaseSqlite class -- 2.20.1