www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | Submodules | README | LICENSE

commit 50a0b2d36c5a6b5debdf65b3647df71a94020b81
parent e7d7d2a94354b1135bd17c95cad5073669de65da
Author: Dan Stillman <dstillman@zotero.org>
Date:   Sat, 16 Feb 2013 23:06:31 -0500

Apparently the dummy transaction hasn't been necessary since 2007 or so

https://bugzilla.mozilla.org/show_bug.cgi?id=380345

Diffstat:
Mchrome/content/zotero/xpcom/db.js | 76++--------------------------------------------------------------------------
Mchrome/content/zotero/xpcom/zotero.js | 2--
2 files changed, 2 insertions(+), 76 deletions(-)

diff --git a/chrome/content/zotero/xpcom/db.js b/chrome/content/zotero/xpcom/db.js @@ -23,7 +23,8 @@ ***** END LICENSE BLOCK ***** */ -// Exclusive locking mode (default) prevents access to Zotero database while Firefox is open. +// Exclusive locking mode (default) prevents access to Zotero database while Zotero is open +// and speeds up DB access (http://www.sqlite.org/pragma.html#pragma_locking_mode). // Normal mode is more convenient for development, but risks database corruption, particularly if // the same database is accessed simultaneously by multiple Zotero instances. const DB_LOCK_EXCLUSIVE = true; @@ -793,7 +794,6 @@ Zotero.DBConnection.prototype.checkException = function (e) { Zotero.DBConnection.prototype.closeDatabase = function () { if(this._connection) { - this.stopDummyStatement(); this._connection.close(); return true; } @@ -875,14 +875,10 @@ Zotero.DBConnection.prototype.backupDatabase = function (suffix) { // Turn off DB locking before backup and reenable after, since otherwise // the lock is lost - var hadDummyStatement = !!this._dummyStatement; try { if (DB_LOCK_EXCLUSIVE) { this.query("PRAGMA locking_mode=NORMAL"); } - if (hadDummyStatement) { - this.stopDummyStatement(); - } var store = Components.classes["@mozilla.org/storage/service;1"]. getService(Components.interfaces.mozIStorageService); @@ -897,9 +893,6 @@ Zotero.DBConnection.prototype.backupDatabase = function (suffix) { if (DB_LOCK_EXCLUSIVE) { this.query("PRAGMA locking_mode=EXCLUSIVE"); } - if (hadDummyStatement) { - this.startDummyStatement(); - } } // Opened database files can't be moved on Windows, so we have to skip @@ -968,71 +961,6 @@ Zotero.DBConnection.prototype.backupDatabase = function (suffix) { } -/* - * Keep the SQLite shared cache live between transactions with a dummy statement, - * which speeds up DB access dramatically (at least on Windows and Linux--OS X - * seems to be much faster already, perhaps due to its own disk cache) - * - * This is the same technique used by Mozilla code. The one downside is that it - * prevents schema changes, so this is called after schema updating. If the - * schema really needs to be updated at another point, use stopDummyStatement(). - * - * See http://developer.mozilla.org/en/docs/Storage:Performance for more info. - */ -Zotero.DBConnection.prototype.startDummyStatement = function () { - try { - if (!this._dummyConnection) { - this._debug("Opening database '" + this._dbName + "' for dummy statement"); - // Get the storage service - var store = Components.classes["@mozilla.org/storage/service;1"]. - getService(Components.interfaces.mozIStorageService); - var file = Zotero.getZoteroDatabase(this._dbName); - this._dummyConnection = store.openDatabase(file); - } - - if (this._dummyStatement) { - Zotero.debug("Dummy statement is already open"); - return; - } - - Zotero.debug("Initializing dummy statement for '" + this._dbName + "'"); - - var sql = "CREATE TABLE IF NOT EXISTS zoteroDummyTable (id INTEGER PRIMARY KEY)"; - this._dummyConnection.executeSimpleSQL(sql); - - sql = "INSERT OR IGNORE INTO zoteroDummyTable VALUES (1)"; - this._dummyConnection.executeSimpleSQL(sql); - - sql = "SELECT id FROM zoteroDummyTable LIMIT 1" - this._dummyStatement = this._dummyConnection.createStatement(sql) - this._dummyStatement.executeStep() - - } - catch (e) { - Components.utils.reportError(e); - Zotero.debug(e); - } -} - - -/* - * Stop the dummy statement temporarily to allow for schema changess - * - * The statement needs to be started again or performance will suffer. - */ -Zotero.DBConnection.prototype.stopDummyStatement = function () { - if (!this._dummyStatement) { - return; - } - - Zotero.debug("Stopping dummy statement for '" + this._dbName + "'"); - this._dummyStatement.finalize(); - this._dummyConnection.close(); - delete this._dummyConnection; - delete this._dummyStatement; -} - - /** * Determine the necessary data type for SQLite parameter binding * diff --git a/chrome/content/zotero/xpcom/zotero.js b/chrome/content/zotero/xpcom/zotero.js @@ -640,8 +640,6 @@ Components.utils.import("resource://gre/modules/Services.jsm"); } } - Zotero.DB.startDummyStatement(); - // Populate combined tables for custom types and fields -- this is likely temporary if (!upgraded && !updated) { Zotero.Schema.updateCustomTables();