Bug 666580 - Use a transaction for indexedDB schema creation.

r=bent
This commit is contained in:
Marco Bonardo 2011-09-28 12:04:21 +02:00
parent 3b3f1cf4c7
commit 2e6a5d289e
2 changed files with 8 additions and 2 deletions

View File

@ -412,11 +412,17 @@ CreateDatabaseConnection(const nsAString& aName,
NS_ENSURE_SUCCESS(rv, rv);
}
mozStorageTransaction transaction(connection, PR_FALSE,
mozIStorageConnection::TRANSACTION_IMMEDIATE);
rv = CreateTables(connection);
NS_ENSURE_SUCCESS(rv, rv);
rv = CreateMetaData(connection, aName);
NS_ENSURE_SUCCESS(rv, rv);
rv = transaction.Commit();
NS_ENSURE_SUCCESS(rv, rv);
}
// Check to make sure that the database schema is correct again.

View File

@ -280,7 +280,7 @@ IDBTransaction::GetOrCreateConnection(mozIStorageConnection** aResult)
NS_ENSURE_TRUE(connection, NS_ERROR_FAILURE);
nsCString beginTransaction;
if (mMode == nsIIDBTransaction::READ_WRITE) {
if (mMode != nsIIDBTransaction::READ_ONLY) {
beginTransaction.AssignLiteral("BEGIN IMMEDIATE TRANSACTION;");
}
else {
@ -978,7 +978,7 @@ CommitHelper::Run()
IndexedDatabaseManager::SetCurrentDatabase(database);
if (!mAborted) {
NS_NAMED_LITERAL_CSTRING(release, "END TRANSACTION");
NS_NAMED_LITERAL_CSTRING(release, "COMMIT TRANSACTION");
if (NS_FAILED(mConnection->ExecuteSimpleSQL(release))) {
mAborted = true;
}