mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 11:25:00 +00:00
Bug 739697 - Don't begin a transaction for formhistory.sqlite if there's an existing one since we don't support nesting them. r=zpao,rnewman a=tracking-firefox
--HG-- extra : rebase_source : c78eed21037ffbd063230f9f16b1008eebb01310
This commit is contained in:
parent
7280dac94a
commit
03a3c4d899
@ -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!");
|
||||
}
|
||||
}
|
||||
|
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user