Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Bug 739697 - Don't begin a transaction for formhistory.sqlite if ther…

…e's an existing one since we don't support nesting them. r=zpao,rnewman a=tracking-firefox

--HG--
extra : rebase_source : c78eed21037ffbd063230f9f16b1008eebb01310
  • Loading branch information...
commit d30a56ad87ea0102e37a98830c8aa8fbdb1761a9 1 parent a4e54a7
@mnoorenberghe mnoorenberghe authored
View
38 services/sync/tests/unit/test_forms_store.js
@@ -85,4 +85,42 @@ function run_test() {
for (let id in store.getAllIDs()) {
do_throw("Shouldn't get any ids!");
}
+
+ _("Add another entry to delete using applyIncomingBatch");
+ let toDelete = {
+ id: Utils.makeGUID(),
+ name: "todelete",
+ value: "entry"
+ };
+ applyEnsureNoFailures([toDelete]);
+ id = "";
+ for (let _id in store.getAllIDs()) {
+ if (id == "")
+ id = _id;
+ else
+ do_throw("Should have only gotten one!");
+ }
+ do_check_true(store.itemExists(id));
+ // mark entry as deleted
+ toDelete.id = id;
+ toDelete.deleted = true;
+ applyEnsureNoFailures([toDelete]);
+ for (let id in store.getAllIDs()) {
+ do_throw("Shouldn't get any ids!");
+ }
+
+ _("Add an entry to wipe");
+ applyEnsureNoFailures([{
+ id: Utils.makeGUID(),
+ name: "towipe",
+ value: "entry"
+ }]);
+
+ Utils.runInTransaction(Svc.Form.DBConnection, function() {
+ store.wipe();
+ });
+
+ for (let id in store.getAllIDs()) {
+ do_throw("Shouldn't get any ids!");
+ }
}
View
49 toolkit/components/satchel/nsFormHistory.js
@@ -248,9 +248,13 @@ FormHistory.prototype = {
let stmt;
let query = "DELETE FROM moz_formhistory WHERE id = :id";
let params = { id : id };
+ let existingTransactionInProgress;
try {
- this.dbConnection.beginTransaction();
+ // Don't start a transaction if one is already in progress since we can't nest them.
+ existingTransactionInProgress = this.dbConnection.transactionInProgress;
+ if (!existingTransactionInProgress)
+ this.dbConnection.beginTransaction();
this.moveToDeletedTable("VALUES (:guid, :timeDeleted)", {
guid: guid,
timeDeleted: Date.now()
@@ -261,7 +265,8 @@ FormHistory.prototype = {
stmt.execute();
this.sendStringNotification("removeEntry", name, value, guid);
} catch (e) {
- this.dbConnection.rollbackTransaction();
+ if (!existingTransactionInProgress)
+ this.dbConnection.rollbackTransaction();
this.log("removeEntry failed: " + e);
throw e;
} finally {
@@ -269,7 +274,8 @@ FormHistory.prototype = {
stmt.reset();
}
}
- this.dbConnection.commitTransaction();
+ if (!existingTransactionInProgress)
+ this.dbConnection.commitTransaction();
},
@@ -281,9 +287,13 @@ FormHistory.prototype = {
let stmt;
let query = "DELETE FROM moz_formhistory WHERE fieldname = :fieldname";
let params = { fieldname : name };
+ let existingTransactionInProgress;
try {
- this.dbConnection.beginTransaction();
+ // Don't start a transaction if one is already in progress since we can't nest them.
+ existingTransactionInProgress = this.dbConnection.transactionInProgress;
+ if (!existingTransactionInProgress)
+ this.dbConnection.beginTransaction();
this.moveToDeletedTable(
"SELECT guid, :timeDeleted FROM moz_formhistory " +
"WHERE fieldname = :fieldname", {
@@ -295,7 +305,8 @@ FormHistory.prototype = {
stmt.execute();
this.sendStringNotification("removeEntriesForName", name);
} catch (e) {
- this.dbConnection.rollbackTransaction();
+ if (!existingTransactionInProgress)
+ this.dbConnection.rollbackTransaction();
this.log("removeEntriesForName failed: " + e);
throw e;
} finally {
@@ -303,7 +314,8 @@ FormHistory.prototype = {
stmt.reset();
}
}
- this.dbConnection.commitTransaction();
+ if (!existingTransactionInProgress)
+ this.dbConnection.commitTransaction();
},
@@ -314,9 +326,13 @@ FormHistory.prototype = {
let stmt;
let query = "DELETE FROM moz_formhistory";
+ let existingTransactionInProgress;
try {
- this.dbConnection.beginTransaction();
+ // Don't start a transaction if one is already in progress since we can't nest them.
+ existingTransactionInProgress = this.dbConnection.transactionInProgress;
+ if (!existingTransactionInProgress)
+ this.dbConnection.beginTransaction();
this.moveToDeletedTable(
"SELECT guid, :timeDeleted FROM moz_formhistory", {
timeDeleted: Date.now()
@@ -326,7 +342,8 @@ FormHistory.prototype = {
stmt.execute();
this.sendNotification("removeAllEntries", null);
} catch (e) {
- this.dbConnection.rollbackTransaction();
+ if (!existingTransactionInProgress)
+ this.dbConnection.rollbackTransaction();
this.log("removeAllEntries failed: " + e);
throw e;
} finally {
@@ -334,7 +351,8 @@ FormHistory.prototype = {
stmt.reset();
}
}
- this.dbConnection.commitTransaction();
+ if (!existingTransactionInProgress)
+ this.dbConnection.commitTransaction();
},
@@ -375,8 +393,13 @@ FormHistory.prototype = {
beginTime : beginTime,
endTime : endTime
};
+ let existingTransactionInProgress;
+
try {
- this.dbConnection.beginTransaction();
+ // Don't start a transaction if one is already in progress since we can't nest them.
+ existingTransactionInProgress = this.dbConnection.transactionInProgress;
+ if (!existingTransactionInProgress)
+ this.dbConnection.beginTransaction();
this.moveToDeletedTable(
"SELECT guid, :timeDeleted FROM moz_formhistory " +
"WHERE firstUsed >= :beginTime AND firstUsed <= :endTime", {
@@ -388,7 +411,8 @@ FormHistory.prototype = {
stmt.executeStep();
this.sendIntNotification("removeEntriesByTimeframe", beginTime, endTime);
} catch (e) {
- this.dbConnection.rollbackTransaction();
+ if (!existingTransactionInProgress)
+ this.dbConnection.rollbackTransaction();
this.log("removeEntriesByTimeframe failed: " + e);
throw e;
} finally {
@@ -396,7 +420,8 @@ FormHistory.prototype = {
stmt.reset();
}
}
- this.dbConnection.commitTransaction();
+ if (!existingTransactionInProgress)
+ this.dbConnection.commitTransaction();
},
moveToDeletedTable : function moveToDeletedTable(values, params) {
Please sign in to comment.
Something went wrong with that request. Please try again.