r68604 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r68603‎ | r68604 | r68605 >
Date:12:10, 26 June 2010
Author:maxsem
Status:ok
Tags:
Comment:
Support for $wgSharedDB in SQlite
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/db/DatabaseSqlite.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/db/DatabaseSqlite.php
@@ -24,10 +24,14 @@
2525 * Parameters $server, $user and $password are not used.
2626 */
2727 function __construct( $server = false, $user = false, $password = false, $dbName = false, $failFunction = false, $flags = 0 ) {
 28+ global $wgSharedDB;
2829 $this->mFailFunction = $failFunction;
2930 $this->mFlags = $flags;
3031 $this->mName = $dbName;
31 - $this->open( $server, $user, $password, $dbName );
 32+
 33+ if ( $this->open( $server, $user, $password, $dbName ) && $wgSharedDB ) {
 34+ $this->attachDatabase( $wgSharedDB );
 35+ }
3236 }
3337
3438 function getType() {
@@ -145,6 +149,21 @@
146150 }
147151
148152 /**
 153+ * Attaches external database to our connection, see http://sqlite.org/lang_attach.html
 154+ * for details.
 155+ * @param $name: Database name to be used in queries like SELECT foo FROM dbname.table
 156+ * @param $file: Database file name. If omitted, will be generated using $name and $wgSQLiteDataDir
 157+ */
 158+ function attachDatabase( $name, $file = false, $fname = 'DatabaseSqlite::attachDatabase' ) {
 159+ global $wgSQLiteDataDir;
 160+ if ( !$file ) {
 161+ $file = self::generateFileName( $wgSQLiteDataDir, $name );
 162+ }
 163+ $file = $this->addQuotes( $file );
 164+ return $this->query( "ATTACH DATABASE $file AS $name", $fname );
 165+ }
 166+
 167+ /**
149168 * SQLite doesn't allow buffered results or data seeking etc, so we'll use fetchAll as the result
150169 */
151170 function doQuery( $sql ) {
Index: trunk/phase3/RELEASE-NOTES
@@ -93,6 +93,7 @@
9494 * (bug 11641) \dotsc \dotsm \dotsi \dotso can now be used in <math>
9595 * (bug 21475) \mathtt and \textsf can now be used in <math>
9696 * texvc is now run via ulimit4.sh, to limit execution time.
 97+* SQLite now supports $wgSharedDB.
9798
9899 === Bug fixes in 1.17 ===
99100 * (bug 17560) Half-broken deletion moved image files to deletion archive

Follow-up revisions

RevisionCommit summaryAuthorDate
r68625Follow-up to r68604: recognise ATTACH DATABASE as a read-only statementmaxsem12:35, 27 June 2010

Status & tagging log