зеркало из https://github.com/mozilla/gecko-dev.git
Bug 707945 - Remove the keywords trigger since it's a useless perf hog.
r=dietrich
This commit is contained in:
Родитель
911d07510c
Коммит
e0132a9c8f
|
@ -649,6 +649,11 @@ Database::InitSchema(bool* aDatabaseMigrated)
|
|||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
if (currentSchemaVersion < 15) {
|
||||
rv = MigrateV15Up();
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
// Firefox 11 uses schema version 14.
|
||||
|
||||
// Schema Upgrades must add migration code here.
|
||||
|
@ -708,8 +713,6 @@ Database::InitSchema(bool* aDatabaseMigrated)
|
|||
// moz_keywords.
|
||||
rv = mMainConn->ExecuteSimpleSQL(CREATE_MOZ_KEYWORDS);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
rv = mMainConn->ExecuteSimpleSQL(CREATE_KEYWORD_VALIDITY_TRIGGER);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// moz_favicons.
|
||||
rv = mMainConn->ExecuteSimpleSQL(CREATE_MOZ_FAVICONS);
|
||||
|
@ -1122,10 +1125,6 @@ Database::MigrateV7Up()
|
|||
"WHERE b.id IS NULL"
|
||||
")"));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Now we create our trigger
|
||||
rv = mMainConn->ExecuteSimpleSQL(CREATE_KEYWORD_VALIDITY_TRIGGER);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
// Add the moz_inputhistory table, if missing.
|
||||
|
@ -1362,6 +1361,32 @@ Database::MigrateV14Up()
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
Database::MigrateV15Up()
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
// Drop moz_bookmarks_beforedelete_v1_trigger, since it's more expensive than
|
||||
// useful.
|
||||
nsresult rv = mMainConn->ExecuteSimpleSQL(NS_LITERAL_CSTRING(
|
||||
"DROP TRIGGER IF EXISTS moz_bookmarks_beforedelete_v1_trigger"
|
||||
));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Remove any orphan keywords.
|
||||
rv = mMainConn->ExecuteSimpleSQL(NS_LITERAL_CSTRING(
|
||||
"DELETE FROM moz_keywords "
|
||||
"WHERE NOT EXISTS ( "
|
||||
"SELECT id "
|
||||
"FROM moz_bookmarks "
|
||||
"WHERE keyword_id = moz_keywords.id "
|
||||
")"
|
||||
));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
Database::Shutdown()
|
||||
{
|
||||
|
|
|
@ -47,7 +47,7 @@
|
|||
|
||||
// This is the schema version. Update it at any schema change and add a
|
||||
// corresponding migrateVxx method below.
|
||||
#define DATABASE_SCHEMA_VERSION 14
|
||||
#define DATABASE_SCHEMA_VERSION 15
|
||||
|
||||
// Fired after Places inited.
|
||||
#define TOPIC_PLACES_INIT_COMPLETE "places-init-complete"
|
||||
|
@ -290,6 +290,7 @@ protected:
|
|||
nsresult MigrateV11Up();
|
||||
nsresult MigrateV13Up();
|
||||
nsresult MigrateV14Up();
|
||||
nsresult MigrateV15Up();
|
||||
|
||||
nsresult CheckAndUpdateGUIDs();
|
||||
|
||||
|
|
|
@ -2586,11 +2586,36 @@ nsNavBookmarks::SetItemIndex(PRInt64 aItemId, PRInt32 aNewIndex)
|
|||
nsresult
|
||||
nsNavBookmarks::UpdateKeywordsHashForRemovedBookmark(PRInt64 aItemId)
|
||||
{
|
||||
nsAutoString kw;
|
||||
if (NS_SUCCEEDED(GetKeywordForBookmark(aItemId, kw)) && !kw.IsEmpty()) {
|
||||
nsAutoString keyword;
|
||||
if (NS_SUCCEEDED(GetKeywordForBookmark(aItemId, keyword)) &&
|
||||
!keyword.IsEmpty()) {
|
||||
nsresult rv = EnsureKeywordsHash();
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
mBookmarkToKeywordHash.Remove(aItemId);
|
||||
|
||||
// If the keyword is unused, remove it from the database.
|
||||
keywordSearchData searchData;
|
||||
searchData.keyword.Assign(keyword);
|
||||
searchData.itemId = -1;
|
||||
mBookmarkToKeywordHash.EnumerateRead(SearchBookmarkForKeyword, &searchData);
|
||||
if (searchData.itemId == -1) {
|
||||
nsCOMPtr<mozIStorageAsyncStatement> stmt = mDB->GetAsyncStatement(
|
||||
"DELETE FROM moz_keywords "
|
||||
"WHERE keyword = :keyword "
|
||||
"AND NOT EXISTS ( "
|
||||
"SELECT id "
|
||||
"FROM moz_bookmarks "
|
||||
"WHERE keyword_id = moz_keywords.id "
|
||||
")"
|
||||
);
|
||||
NS_ENSURE_STATE(stmt);
|
||||
|
||||
rv = stmt->BindStringByName(NS_LITERAL_CSTRING("keyword"), keyword);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
nsCOMPtr<mozIStoragePendingStatement> pendingStmt;
|
||||
rv = stmt->ExecuteAsync(nsnull, getter_AddRefs(pendingStmt));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -50,27 +50,6 @@
|
|||
* 7 - FRAMED_LINK
|
||||
**/
|
||||
#define EXCLUDED_VISIT_TYPES "0, 4, 7, 8"
|
||||
/**
|
||||
* Trigger checks to ensure that at least one bookmark is still using a keyword
|
||||
* when any bookmark is deleted. If there are no more bookmarks using it, the
|
||||
* keyword is deleted.
|
||||
*/
|
||||
#define CREATE_KEYWORD_VALIDITY_TRIGGER NS_LITERAL_CSTRING( \
|
||||
"CREATE TRIGGER moz_bookmarks_beforedelete_v1_trigger " \
|
||||
"BEFORE DELETE ON moz_bookmarks FOR EACH ROW " \
|
||||
"WHEN OLD.keyword_id NOT NULL " \
|
||||
"BEGIN " \
|
||||
"DELETE FROM moz_keywords " \
|
||||
"WHERE id = OLD.keyword_id " \
|
||||
"AND NOT EXISTS ( " \
|
||||
"SELECT id " \
|
||||
"FROM moz_bookmarks " \
|
||||
"WHERE keyword_id = OLD.keyword_id " \
|
||||
"AND id <> OLD.id " \
|
||||
"LIMIT 1 " \
|
||||
");" \
|
||||
"END" \
|
||||
)
|
||||
|
||||
/**
|
||||
* This triggers update visit_count and last_visit_date based on historyvisits
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
const CURRENT_SCHEMA_VERSION = 14;
|
||||
const CURRENT_SCHEMA_VERSION = 15;
|
||||
|
||||
const NS_APP_USER_PROFILE_50_DIR = "ProfD";
|
||||
const NS_APP_PROFILE_DIR_STARTUP = "ProfDS";
|
||||
|
|
Загрузка…
Ссылка в новой задаче