mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-11 20:35:50 +00:00
Bug 719002 - Use a transaction when upgrading addon.sqlite's schema; r=Mossop
This commit is contained in:
parent
8fe41d5a99
commit
829f3827f4
@ -1577,10 +1577,10 @@ var AddonDatabase = {
|
||||
}
|
||||
|
||||
this.connection.executeSimpleSQL("PRAGMA locking_mode = EXCLUSIVE");
|
||||
if (dbMissing)
|
||||
this._createSchema();
|
||||
|
||||
// Any errors in here should rollback
|
||||
try {
|
||||
this.connection.beginTransaction();
|
||||
switch (this.connection.schemaVersion) {
|
||||
case 0:
|
||||
LOG("Recreating database schema");
|
||||
@ -1603,14 +1603,15 @@ var AddonDatabase = {
|
||||
"appMinVersion TEXT, " +
|
||||
"appMaxVersion TEXT, " +
|
||||
"PRIMARY KEY (addon_internal_id, num)");
|
||||
this._createIndices();
|
||||
this._createTriggers();
|
||||
this.connection.schemaVersion = DB_SCHEMA;
|
||||
this._createIndices();
|
||||
this._createTriggers();
|
||||
this.connection.schemaVersion = DB_SCHEMA;
|
||||
case 3:
|
||||
break;
|
||||
default:
|
||||
return tryAgain();
|
||||
}
|
||||
this.connection.commitTransaction();
|
||||
} catch (e) {
|
||||
ERROR("Failed to create database schema", e);
|
||||
this.logSQLError(this.connection.lastError, this.connection.lastErrorString);
|
||||
@ -2196,10 +2197,7 @@ var AddonDatabase = {
|
||||
*/
|
||||
_createSchema: function AD__createSchema() {
|
||||
LOG("Creating database schema");
|
||||
this.connection.beginTransaction();
|
||||
|
||||
// Any errors in here should rollback
|
||||
try {
|
||||
this.connection.createTable("addon",
|
||||
"internal_id INTEGER PRIMARY KEY AUTOINCREMENT, " +
|
||||
"id TEXT UNIQUE, " +
|
||||
@ -2262,13 +2260,6 @@ var AddonDatabase = {
|
||||
this._createTriggers();
|
||||
|
||||
this.connection.schemaVersion = DB_SCHEMA;
|
||||
this.connection.commitTransaction();
|
||||
} catch (e) {
|
||||
ERROR("Failed to create database schema", e);
|
||||
this.logSQLError(this.connection.lastError, this.connection.lastErrorString);
|
||||
this.connection.rollbackTransaction();
|
||||
throw e;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user