diff --git a/toolkit/components/places/Database.cpp b/toolkit/components/places/Database.cpp index 7a263e7d65e5..154196a428e1 100644 --- a/toolkit/components/places/Database.cpp +++ b/toolkit/components/places/Database.cpp @@ -49,9 +49,6 @@ #define BYTES_PER_KIBIBYTE 1024 -// How much time Sqlite can wait before returning a SQLITE_BUSY error. -#define DATABASE_BUSY_TIMEOUT_MS 100 - // Old Sync GUID annotation. #define SYNCGUID_ANNO NS_LITERAL_CSTRING("sync/guid") @@ -600,10 +597,6 @@ Database::InitSchema(bool* aDatabaseMigrated) (void)mMainConn->SetGrowthIncrement(growthIncrementKiB * BYTES_PER_KIBIBYTE, EmptyCString()); } - nsAutoCString busyTimeoutPragma("PRAGMA busy_timeout = "); - busyTimeoutPragma.AppendInt(DATABASE_BUSY_TIMEOUT_MS); - (void)mMainConn->ExecuteSimpleSQL(busyTimeoutPragma); - // We use our functions during migration, so initialize them now. rv = InitFunctions(); NS_ENSURE_SUCCESS(rv, rv); @@ -1217,6 +1210,8 @@ Database::MigrateV7Up() return NS_ERROR_FILE_CORRUPTED; } + mozStorageTransaction transaction(mMainConn, false); + // We need an index on lastModified to catch quickly last modified bookmark // title for tag container's children. This will be useful for Sync, too. bool lastModIndexExists = false; @@ -1396,7 +1391,7 @@ Database::MigrateV7Up() NS_ENSURE_SUCCESS(rv, rv); } - return NS_OK; + return transaction.Commit(); } @@ -1404,6 +1399,7 @@ nsresult Database::MigrateV8Up() { MOZ_ASSERT(NS_IsMainThread()); + mozStorageTransaction transaction(mMainConn, false); nsresult rv = mMainConn->ExecuteSimpleSQL(NS_LITERAL_CSTRING( "DROP TRIGGER IF EXISTS moz_historyvisits_afterinsert_v1_trigger")); @@ -1449,7 +1445,7 @@ Database::MigrateV8Up() NS_ENSURE_SUCCESS(rv, rv); } - return NS_OK; + return transaction.Commit(); } @@ -1457,6 +1453,7 @@ nsresult Database::MigrateV9Up() { MOZ_ASSERT(NS_IsMainThread()); + mozStorageTransaction transaction(mMainConn, false); // Added in Bug 488966. The last_visit_date column caches the last // visit date, this enhances SELECT performances when we // need to sort visits by visit date. @@ -1488,7 +1485,7 @@ Database::MigrateV9Up() NS_ENSURE_SUCCESS(rv, rv); } - return NS_OK; + return transaction.Commit(); } diff --git a/toolkit/components/places/nsNavHistory.cpp b/toolkit/components/places/nsNavHistory.cpp index 6aa14e4d91d5..9886ac651d35 100644 --- a/toolkit/components/places/nsNavHistory.cpp +++ b/toolkit/components/places/nsNavHistory.cpp @@ -2267,9 +2267,7 @@ nsresult nsNavHistory::BeginUpdateBatch() { if (mBatchLevel++ == 0) { - mBatchDBTransaction = new mozStorageTransaction(mDB->MainConn(), false, - mozIStorageConnection::TRANSACTION_DEFERRED, - true); + mBatchDBTransaction = new mozStorageTransaction(mDB->MainConn(), false); NOTIFY_OBSERVERS(mCanNotify, mCacheObservers, mObservers, nsINavHistoryObserver, OnBeginUpdateBatch()); @@ -2334,9 +2332,7 @@ nsNavHistory::RemovePagesInternal(const nsCString& aPlaceIdsQueryString) if (aPlaceIdsQueryString.IsEmpty()) return NS_OK; - mozStorageTransaction transaction(mDB->MainConn(), false, - mozIStorageConnection::TRANSACTION_DEFERRED, - true); + mozStorageTransaction transaction(mDB->MainConn(), false); // Delete all visits for the specified place ids. nsresult rv = mDB->MainConn()->ExecuteSimpleSQL( @@ -2728,9 +2724,7 @@ nsNavHistory::RemoveVisitsByTimeframe(PRTime aBeginTime, PRTime aEndTime) // force a full refresh calling onEndUpdateBatch (will call Refresh()) UpdateBatchScoper batch(*this); // sends Begin/EndUpdateBatch to observers - mozStorageTransaction transaction(mDB->MainConn(), false, - mozIStorageConnection::TRANSACTION_DEFERRED, - true); + mozStorageTransaction transaction(mDB->MainConn(), false); // Delete all visits within the timeframe. nsCOMPtr deleteVisitsStmt = mDB->GetStatement( diff --git a/toolkit/components/places/tests/bookmarks/test_1017502-bookmarks_foreign_count.js b/toolkit/components/places/tests/bookmarks/test_1017502-bookmarks_foreign_count.js index 70bb9db9ad3c..d2046620d2b1 100644 --- a/toolkit/components/places/tests/bookmarks/test_1017502-bookmarks_foreign_count.js +++ b/toolkit/components/places/tests/bookmarks/test_1017502-bookmarks_foreign_count.js @@ -11,8 +11,7 @@ added or removed and also the maintenance task to fix wrong counts. const T_URI = NetUtil.newURI("https://www.mozilla.org/firefox/nightly/firstrun/"); -function* getForeignCountForURL(conn, url) { - yield promiseAsyncUpdates(); +function* getForeignCountForURL(conn, url){ let url = url instanceof Ci.nsIURI ? url.spec : url; let rows = yield conn.executeCached( "SELECT foreign_count FROM moz_places WHERE url = :t_url ", { t_url: url }); @@ -107,4 +106,4 @@ add_task(function* add_remove_tags_test(){ // Check foreign count is set to 0 when all tags are removed PlacesUtils.tagging.untagURI(T_URI, ["test tag", "one", "two"]); Assert.equal((yield getForeignCountForURL(conn, T_URI)), 0); -}); +}); \ No newline at end of file