commit b27e64f9c87c7766dd60351bf54691a5970fa323
parent 291b739b761ee6ea6b3142ef2d89973435441654
Author: Dan Stillman <dstillman@zotero.org>
Date: Thu, 25 Aug 2011 21:03:24 +0000
Block database access during Zotero.wait() only if a transaction is in progress
Diffstat:
1 file changed, 11 insertions(+), 11 deletions(-)
diff --git a/chrome/content/zotero/xpcom/db.js b/chrome/content/zotero/xpcom/db.js
@@ -220,13 +220,13 @@ Zotero.DBConnection.prototype.columnQuery = function (sql,params) {
* [1,"hello",3] or [{'int':2},{'string':'foobar'}]
*/
Zotero.DBConnection.prototype.getStatement = function (sql, params, checkParams) {
+ var db = this._getDBConnection();
+
// TODO: limit to Zotero.DB, not all Zotero.DBConnections?
- if (Zotero.waiting) {
- throw ("Cannot access database layer during active Zotero.wait()");
+ if (db.transactionInProgress && Zotero.waiting) {
+ throw ("Cannot access database layer during active Zotero.wait() if a transaction is open");
}
- var db = this._getDBConnection();
-
// First, determine the type of query using first word
var matches = sql.match(/^[^\s\(]*/);
var queryMethod = matches[0].toLowerCase();
@@ -422,16 +422,16 @@ Zotero.DBConnection.prototype.getLastErrorString = function () {
Zotero.DBConnection.prototype.beginTransaction = function () {
- // TODO: limit to Zotero.DB, not all Zotero.DBConnections?
- if (Zotero.waiting) {
- var msg = "Cannot access database layer during active Zotero.wait()";
- Zotero.debug(msg, 2);
- throw (msg);
- }
-
var db = this._getDBConnection();
if (db.transactionInProgress) {
+ // TODO: limit to Zotero.DB, not all Zotero.DBConnections?
+ if (Zotero.waiting) {
+ var msg = "Cannot access database layer during active Zotero.wait() if a transaction is in progress";
+ Zotero.debug(msg, 2);
+ throw (msg);
+ }
+
this._transactionNestingLevel++;
this._debug('Transaction in progress -- increasing level to '
+ this._transactionNestingLevel, 5);