Add TEMPORARY TABLE support to Sqlite
authorBryan Tong Minh <btongminh@users.mediawiki.org>
Sat, 26 Feb 2011 14:30:52 +0000 (14:30 +0000)
committerBryan Tong Minh <btongminh@users.mediawiki.org>
Sat, 26 Feb 2011 14:30:52 +0000 (14:30 +0000)
includes/db/DatabaseSqlite.php

index 60cede3..b5baf21 100644 (file)
@@ -601,6 +601,12 @@ class DatabaseSqlite extends DatabaseBase {
                }
                $sql = $obj->sql;
                $sql = preg_replace( '/\b' . preg_quote( $oldName ) . '\b/', $newName, $sql, 1 );
+               if ( $temporary && strpos( $oldName, 'searchindex' ) === false ) {
+                       # For some reason TEMPORARY TABLE doesn't work with searchindex
+                       # We need to explicitly look for searchindex rather than VIRTUAL
+                       # because we don't want to clone the FTS subtables either
+                       $sql = str_replace( 'CREATE TABLE', 'CREATE TEMPORARY TABLE', $sql );
+               }
                return $this->query( $sql, $fname );
        }