mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-11 20:35:50 +00:00
Backed out changeset a673a956d339 on CLOSED TREE
This commit is contained in:
parent
12586f8f4f
commit
6da1912946
@ -191,10 +191,9 @@ function ensure_opentabs_match_db() {
|
||||
|
||||
try {
|
||||
var stmt = db.createStatement(
|
||||
"SELECT IFNULL(p_t.url, p.url) AS url, open_count, place_id " +
|
||||
"SELECT p.url AS url, open_count, place_id " +
|
||||
"FROM moz_openpages_temp " +
|
||||
"LEFT JOIN moz_places p ON p.id=place_id " +
|
||||
"LEFT JOIN moz_places_temp p_t ON p_t.id=place_id");
|
||||
"LEFT JOIN moz_places p ON p.id = place_id");
|
||||
} catch (e) {
|
||||
ok(false, "error creating db statement: " + e);
|
||||
return;
|
||||
|
@ -356,10 +356,7 @@ BrowserGlue.prototype = {
|
||||
}
|
||||
|
||||
// Load the "more info" page for a locked places.sqlite
|
||||
// This property is set earlier in the startup process:
|
||||
// nsPlacesDBFlush loads after profile-after-change and initializes
|
||||
// the history service, which sends out places-database-locked
|
||||
// which sets this property.
|
||||
// This property is set earlier by places-database-locked topic.
|
||||
if (this._isPlacesDatabaseLocked) {
|
||||
this._showPlacesLockedNotificationBox();
|
||||
}
|
||||
|
@ -58,9 +58,7 @@ let expirationObserver = {
|
||||
.DBConnection;
|
||||
|
||||
let stmt = db.createStatement(
|
||||
"SELECT id FROM moz_places_temp WHERE url = :page_url "
|
||||
+ "UNION ALL "
|
||||
+ "SELECT id FROM moz_places WHERE url = :page_url "
|
||||
"SELECT id FROM moz_places WHERE url = :page_url "
|
||||
);
|
||||
|
||||
try {
|
||||
|
@ -342,7 +342,6 @@
|
||||
@BINPATH@/components/toolkitplaces.manifest
|
||||
@BINPATH@/components/nsLivemarkService.js
|
||||
@BINPATH@/components/nsTaggingService.js
|
||||
@BINPATH@/components/nsPlacesDBFlush.js
|
||||
@BINPATH@/components/nsPlacesAutoComplete.manifest
|
||||
@BINPATH@/components/nsPlacesAutoComplete.js
|
||||
@BINPATH@/components/nsPlacesExpiration.js
|
||||
|
@ -864,3 +864,4 @@ extensions/inspector@mozilla.org/components/@DLL_PREFIX@inspector@DLL_SUFFIX@
|
||||
extensions/inspector@mozilla.org/chrome/icons/default/winInspectorMain.ico
|
||||
components/nsPlacesTransactionsService.js
|
||||
components/browserplaces.xpt
|
||||
components/nsPlacesDBFlush.js
|
||||
|
@ -22,7 +22,7 @@ if (!window.location.href.match("posted=1")) {
|
||||
form.action = window.location.href + "?posted=1";
|
||||
form.submit();
|
||||
} else {
|
||||
window.opener.finishTest();
|
||||
window.location.href = "http://mochi.test:8888/tests/docshell/test/bug94514-postpage.html";
|
||||
}
|
||||
|
||||
</script>
|
||||
|
@ -44,6 +44,24 @@ SimpleTest.ok(!gh.isVisited(startPage),
|
||||
SimpleTest.ok(!gh.isVisited(postedPage),
|
||||
"Posted page does not start in global history.");
|
||||
|
||||
// Because adding visits is async, we will not be notified imemdiately.
|
||||
var os = Cc["@mozilla.org/observer-service;1"].
|
||||
getService(Ci.nsIObserverService);
|
||||
var visitObserver = {
|
||||
_visitCount: 0,
|
||||
observe: function(aSubject, aTopic, aData)
|
||||
{
|
||||
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
||||
if (!startPage.equals(aSubject.QueryInterface(Ci.nsIURI)) ||
|
||||
++this._visitCount < 2) {
|
||||
return;
|
||||
}
|
||||
os.removeObserver(this, aTopic, false);
|
||||
finishTest();
|
||||
},
|
||||
};
|
||||
os.addObserver(visitObserver, "uri-visit-saved", false);
|
||||
|
||||
var w = window.open(startURI, "", "width=10,height=10");
|
||||
|
||||
function finishTest()
|
||||
|
@ -86,7 +86,6 @@ EXTRA_COMPONENTS = \
|
||||
toolkitplaces.manifest \
|
||||
nsLivemarkService.js \
|
||||
nsTaggingService.js \
|
||||
nsPlacesDBFlush.js \
|
||||
nsPlacesExpiration.js \
|
||||
nsMicrosummaryService.js \
|
||||
$(NULL)
|
||||
|
@ -212,8 +212,6 @@ nsPlacesDBUtils.prototype = {
|
||||
"DELETE FROM moz_annos WHERE id IN ( " +
|
||||
"SELECT id FROM moz_annos a " +
|
||||
"WHERE NOT EXISTS " +
|
||||
"(SELECT id FROM moz_places_temp WHERE id = a.place_id LIMIT 1) " +
|
||||
"AND NOT EXISTS " +
|
||||
"(SELECT id FROM moz_places WHERE id = a.place_id LIMIT 1) " +
|
||||
")");
|
||||
cleanupStatements.push(deleteOrphanAnnos);
|
||||
@ -288,7 +286,6 @@ nsPlacesDBUtils.prototype = {
|
||||
") AND id IN (" +
|
||||
"SELECT b.id FROM moz_bookmarks b " +
|
||||
"WHERE fk NOT NULL AND b.type = :bookmark_type " +
|
||||
"AND NOT EXISTS (SELECT url FROM moz_places_temp WHERE id = b.fk LIMIT 1) " +
|
||||
"AND NOT EXISTS (SELECT url FROM moz_places WHERE id = b.fk LIMIT 1) " +
|
||||
")");
|
||||
deleteNoPlaceItems.params["bookmark_type"] = this._bms.TYPE_BOOKMARK;
|
||||
@ -447,7 +444,6 @@ nsPlacesDBUtils.prototype = {
|
||||
// D.11 remove old livemarks status items
|
||||
// Livemark status items are now static but some livemark has still old
|
||||
// status items bookmarks inside it. We should remove them.
|
||||
// Note: This does not need to query the temp table.
|
||||
let removeLivemarkStaticItems = this._dbConn.createStatement(
|
||||
"DELETE FROM moz_bookmarks WHERE type = :bookmark_type AND fk IN ( " +
|
||||
"SELECT id FROM moz_places WHERE url = :lmloading OR url = :lmfailed " +
|
||||
@ -463,8 +459,6 @@ nsPlacesDBUtils.prototype = {
|
||||
"DELETE FROM moz_favicons WHERE id IN (" +
|
||||
"SELECT id FROM moz_favicons f " +
|
||||
"WHERE NOT EXISTS " +
|
||||
"(SELECT id FROM moz_places_temp WHERE favicon_id = f.id LIMIT 1) " +
|
||||
"AND NOT EXISTS" +
|
||||
"(SELECT id FROM moz_places WHERE favicon_id = f.id LIMIT 1) " +
|
||||
")");
|
||||
cleanupStatements.push(deleteOrphanIcons);
|
||||
@ -475,8 +469,6 @@ nsPlacesDBUtils.prototype = {
|
||||
"DELETE FROM moz_historyvisits WHERE id IN (" +
|
||||
"SELECT id FROM moz_historyvisits v " +
|
||||
"WHERE NOT EXISTS " +
|
||||
"(SELECT id FROM moz_places_temp WHERE id = v.place_id LIMIT 1) " +
|
||||
"AND NOT EXISTS " +
|
||||
"(SELECT id FROM moz_places WHERE id = v.place_id LIMIT 1) " +
|
||||
")");
|
||||
cleanupStatements.push(deleteOrphanVisits);
|
||||
@ -487,8 +479,6 @@ nsPlacesDBUtils.prototype = {
|
||||
"DELETE FROM moz_inputhistory WHERE place_id IN (" +
|
||||
"SELECT place_id FROM moz_inputhistory i " +
|
||||
"WHERE NOT EXISTS " +
|
||||
"(SELECT id FROM moz_places_temp WHERE id = i.place_id LIMIT 1) " +
|
||||
"AND NOT EXISTS " +
|
||||
"(SELECT id FROM moz_places WHERE id = i.place_id LIMIT 1) " +
|
||||
")");
|
||||
cleanupStatements.push(deleteOrphanInputHistory);
|
||||
@ -536,22 +526,17 @@ nsPlacesDBUtils.prototype = {
|
||||
|
||||
/* XXX needs test
|
||||
// L.2 recalculate visit_count
|
||||
// We're detecting errors only in disk table since temp tables could have
|
||||
// different values based on the number of visits not yet synced to disk.
|
||||
let detectWrongCountPlaces = this._dbConn.createStatement(
|
||||
"SELECT id FROM moz_places h " +
|
||||
"WHERE id NOT IN (SELECT id FROM moz_places_temp) " +
|
||||
"AND h.visit_count <> " +
|
||||
"WHERE h.visit_count <> " +
|
||||
"(SELECT count(*) FROM moz_historyvisits " +
|
||||
"WHERE place_id = h.id AND visit_type NOT IN (0,4,7,8))");
|
||||
while (detectWrongCountPlaces.executeStep()) {
|
||||
let placeId = detectWrongCountPlaces.getInt64(0);
|
||||
let fixCountForPlace = this._dbConn.createStatement(
|
||||
"UPDATE moz_places_view SET visit_count = ( " +
|
||||
"UPDATE moz_places SET visit_count = ( " +
|
||||
"(SELECT count(*) FROM moz_historyvisits " +
|
||||
"WHERE place_id = :place_id AND visit_type NOT IN (0,4,7,8)) + " +
|
||||
"(SELECT count(*) FROM moz_historyvisits_temp " +
|
||||
"WHERE place_id = :place_id AND visit_type NOT IN (0,4,7,8)) + " +
|
||||
"WHERE place_id = :place_id AND visit_type NOT IN (0,4,7,8)) + "
|
||||
") WHERE id = :place_id");
|
||||
fixCountForPlace.params["place_id"] = placeId;
|
||||
cleanupStatements.push(fixCountForPlace);
|
||||
|
@ -150,7 +150,6 @@ var PlacesUtils = {
|
||||
TOPIC_DATABASE_LOCKED: "places-database-locked",
|
||||
TOPIC_EXPIRATION_FINISHED: "places-expiration-finished",
|
||||
TOPIC_FEEDBACK_UPDATED: "places-autocomplete-feedback-updated",
|
||||
TOPIC_SYNC_FINISHED: "places-sync-finished",
|
||||
TOPIC_FAVICONS_EXPIRED: "places-favicons-expired",
|
||||
TOPIC_VACUUM_STARTING: "places-vacuum-starting",
|
||||
|
||||
|
@ -136,23 +136,17 @@ nsAnnotationService::GetStatement(const nsCOMPtr<mozIStorageStatement>& aStmt)
|
||||
"SELECT n.name "
|
||||
"FROM moz_anno_attributes n "
|
||||
"JOIN moz_annos a ON a.anno_attribute_id = n.id "
|
||||
"JOIN ( "
|
||||
"SELECT id FROM moz_places_temp WHERE url = :page_url "
|
||||
"UNION "
|
||||
"SELECT id FROM moz_places WHERE url = :page_url "
|
||||
") AS h ON h.id = a.place_id"));
|
||||
"JOIN moz_places h ON h.id = a.place_id "
|
||||
"WHERE h.url = :page_url"));
|
||||
|
||||
RETURN_IF_STMT(mDBGetPageAnnotationValue, NS_LITERAL_CSTRING(
|
||||
"SELECT a.id, a.place_id, :anno_name, a.mime_type, a.content, a.flags, "
|
||||
"a.expiration, a.type "
|
||||
"FROM moz_anno_attributes n "
|
||||
"JOIN moz_annos a ON n.id = a.anno_attribute_id "
|
||||
"JOIN ( "
|
||||
"SELECT id FROM moz_places_temp WHERE url = :page_url "
|
||||
"UNION "
|
||||
"SELECT id FROM moz_places WHERE url = :page_url "
|
||||
") AS h ON h.id = a.place_id "
|
||||
"WHERE n.name = :anno_name"));
|
||||
"JOIN moz_places h ON h.id = a.place_id "
|
||||
"WHERE h.url = :page_url "
|
||||
"AND n.name = :anno_name"));
|
||||
|
||||
RETURN_IF_STMT(mDBGetItemAnnotationValue, NS_LITERAL_CSTRING(
|
||||
"SELECT a.id, a.item_id, :anno_name, a.mime_type, a.content, a.flags, "
|
||||
@ -181,26 +175,22 @@ nsAnnotationService::GetStatement(const nsCOMPtr<mozIStorageStatement>& aStmt)
|
||||
|
||||
RETURN_IF_STMT(mDBRemovePageAnnotation, NS_LITERAL_CSTRING(
|
||||
"DELETE FROM moz_annos "
|
||||
"WHERE place_id = ( "
|
||||
"SELECT id FROM moz_places_temp WHERE url = :page_url "
|
||||
"UNION "
|
||||
"SELECT id FROM moz_places WHERE url = :page_url) "
|
||||
"AND anno_attribute_id = "
|
||||
"(SELECT id FROM moz_anno_attributes WHERE name = :anno_name)"));
|
||||
"WHERE place_id = (SELECT id FROM moz_places WHERE url = :page_url) "
|
||||
"AND anno_attribute_id = "
|
||||
"(SELECT id FROM moz_anno_attributes WHERE name = :anno_name)"));
|
||||
|
||||
RETURN_IF_STMT(mDBRemoveItemAnnotation, NS_LITERAL_CSTRING(
|
||||
"DELETE FROM moz_items_annos "
|
||||
"WHERE item_id = :item_id "
|
||||
"AND anno_attribute_id = "
|
||||
"(SELECT id FROM moz_anno_attributes WHERE name = :anno_name)"));
|
||||
"AND anno_attribute_id = "
|
||||
"(SELECT id FROM moz_anno_attributes WHERE name = :anno_name)"));
|
||||
|
||||
RETURN_IF_STMT(mDBGetPagesWithAnnotation, NS_LITERAL_CSTRING(
|
||||
"SELECT IFNULL(h_t.url, h.url) AS coalesced_url "
|
||||
"SELECT h.url "
|
||||
"FROM moz_anno_attributes n "
|
||||
"JOIN moz_annos a ON n.id = a.anno_attribute_id "
|
||||
"LEFT JOIN moz_places h ON h.id = a.place_id "
|
||||
"LEFT JOIN moz_places_temp h_t ON h_t.id = a.place_id "
|
||||
"WHERE n.name = :anno_name AND coalesced_url NOT NULL"));
|
||||
"JOIN moz_places h ON h.id = a.place_id "
|
||||
"WHERE n.name = :anno_name"));
|
||||
|
||||
RETURN_IF_STMT(mDBGetItemsWithAnnotation, NS_LITERAL_CSTRING(
|
||||
"SELECT a.item_id "
|
||||
@ -212,12 +202,10 @@ nsAnnotationService::GetStatement(const nsCOMPtr<mozIStorageStatement>& aStmt)
|
||||
"SELECT h.id, "
|
||||
"(SELECT id FROM moz_anno_attributes WHERE name = :anno_name) AS nameid, "
|
||||
"a.id, a.dateAdded "
|
||||
"FROM (SELECT id FROM moz_places_temp WHERE url = :page_url "
|
||||
"UNION "
|
||||
"SELECT id FROM moz_places WHERE url = :page_url "
|
||||
") AS h "
|
||||
"FROM moz_places h "
|
||||
"LEFT JOIN moz_annos a ON a.place_id = h.id "
|
||||
"AND a.anno_attribute_id = nameid"));
|
||||
"AND a.anno_attribute_id = nameid "
|
||||
"WHERE h.url = :page_url"));
|
||||
|
||||
RETURN_IF_STMT(mDBCheckItemAnnotation, NS_LITERAL_CSTRING(
|
||||
"SELECT b.id, "
|
||||
@ -1582,9 +1570,7 @@ nsAnnotationService::RemovePageAnnotations(nsIURI* aURI)
|
||||
nsCOMPtr<mozIStorageStatement> statement;
|
||||
nsresult rv = mDBConn->CreateStatement(NS_LITERAL_CSTRING(
|
||||
"DELETE FROM moz_annos WHERE place_id = "
|
||||
"(SELECT id FROM moz_places_temp WHERE url = :page_url "
|
||||
"UNION "
|
||||
"SELECT id FROM moz_places WHERE url = :page_url)"),
|
||||
"(SELECT id FROM moz_places WHERE url = :page_url)"),
|
||||
getter_AddRefs(statement));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
rv = URIBinder::Bind(statement, NS_LITERAL_CSTRING("page_url"), aURI);
|
||||
@ -1644,18 +1630,13 @@ nsAnnotationService::CopyPageAnnotations(nsIURI* aSourceURI,
|
||||
nsCOMPtr<mozIStorageStatement> sourceStmt;
|
||||
nsresult rv = mDBConn->CreateStatement(NS_LITERAL_CSTRING(
|
||||
"SELECT h.id, n.id, n.name, a2.id "
|
||||
"FROM ( "
|
||||
"SELECT id from moz_places_temp WHERE url = :source_url "
|
||||
"UNION "
|
||||
"SELECT id FROM moz_places WHERE url = :source_url "
|
||||
") AS h "
|
||||
"FROM moz_places h "
|
||||
"JOIN moz_annos a ON a.place_id = h.id "
|
||||
"JOIN moz_anno_attributes n ON n.id = a.anno_attribute_id "
|
||||
"LEFT JOIN moz_annos a2 ON a2.place_id = ( "
|
||||
"SELECT id FROM moz_places_temp WHERE url = :dest_url "
|
||||
"UNION "
|
||||
"SELECT id FROM moz_places WHERE url = :dest_url "
|
||||
") AND a2.anno_attribute_id = n.id"),
|
||||
"LEFT JOIN moz_annos a2 ON a2.place_id = "
|
||||
"(SELECT id FROM moz_places WHERE url = :dest_url) "
|
||||
"AND a2.anno_attribute_id = n.id "
|
||||
"WHERE url = :source_url"),
|
||||
getter_AddRefs(sourceStmt));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
@ -1669,12 +1650,9 @@ nsAnnotationService::CopyPageAnnotations(nsIURI* aSourceURI,
|
||||
"INSERT INTO moz_annos "
|
||||
"(place_id, anno_attribute_id, mime_type, content, flags, expiration, "
|
||||
"type, dateAdded, lastModified) "
|
||||
"SELECT ( "
|
||||
"SELECT id FROM moz_places_temp WHERE url = :page_url "
|
||||
"UNION "
|
||||
"SELECT id FROM moz_places WHERE url = :page_url "
|
||||
"), anno_attribute_id, mime_type, content, flags, expiration, type, "
|
||||
":date, :date "
|
||||
"SELECT (SELECT id FROM moz_places WHERE url = :page_url), "
|
||||
"anno_attribute_id, mime_type, content, flags, expiration, type, "
|
||||
":date, :date "
|
||||
"FROM moz_annos "
|
||||
"WHERE place_id = :page_id "
|
||||
"AND anno_attribute_id = :name_id"),
|
||||
|
@ -171,30 +171,20 @@ nsFaviconService::GetStatement(const nsCOMPtr<mozIStorageStatement>& aStmt)
|
||||
RETURN_IF_STMT(mDBGetIconInfoWithPage, NS_LITERAL_CSTRING(
|
||||
"SELECT id, length(data), expiration, data, mime_type, "
|
||||
"IFNULL(url = (SELECT f.url "
|
||||
"FROM ( "
|
||||
"SELECT favicon_id FROM moz_places_temp "
|
||||
"WHERE url = :page_url "
|
||||
"UNION ALL "
|
||||
"SELECT favicon_id FROM moz_places "
|
||||
"WHERE url = :page_url "
|
||||
") AS h "
|
||||
"FROM moz_places h "
|
||||
"JOIN moz_favicons f ON h.favicon_id = f.id "
|
||||
"WHERE h.url = :page_url "
|
||||
"LIMIT 1), "
|
||||
"0)"
|
||||
"0) "
|
||||
"FROM moz_favicons WHERE url = :icon_url"));
|
||||
|
||||
RETURN_IF_STMT(mDBGetURL, NS_LITERAL_CSTRING(
|
||||
"SELECT f.id, f.url, length(f.data), f.expiration "
|
||||
"FROM ( "
|
||||
"SELECT " MOZ_PLACES_COLUMNS " FROM moz_places_temp "
|
||||
"WHERE url = :page_url "
|
||||
"UNION ALL "
|
||||
"SELECT " MOZ_PLACES_COLUMNS " FROM moz_places "
|
||||
"WHERE url = :page_url "
|
||||
") AS h JOIN moz_favicons f ON h.favicon_id = f.id "
|
||||
"FROM moz_places h "
|
||||
"JOIN moz_favicons f ON h.favicon_id = f.id "
|
||||
"WHERE h.url = :page_url "
|
||||
"LIMIT 1"));
|
||||
|
||||
|
||||
RETURN_IF_STMT(mDBGetData, NS_LITERAL_CSTRING(
|
||||
"SELECT f.data, f.mime_type FROM moz_favicons f WHERE url = :icon_url"));
|
||||
|
||||
@ -208,10 +198,10 @@ nsFaviconService::GetStatement(const nsCOMPtr<mozIStorageStatement>& aStmt)
|
||||
"WHERE id = :icon_id"));
|
||||
|
||||
RETURN_IF_STMT(mDBSetPageFavicon, NS_LITERAL_CSTRING(
|
||||
"UPDATE moz_places_view SET favicon_id = :icon_id WHERE id = :page_id"));
|
||||
"UPDATE moz_places SET favicon_id = :icon_id WHERE id = :page_id"));
|
||||
|
||||
RETURN_IF_STMT(mDBAssociateFaviconURIToPageURI, NS_LITERAL_CSTRING(
|
||||
"UPDATE moz_places_view "
|
||||
"UPDATE moz_places "
|
||||
"SET favicon_id = (SELECT id FROM moz_favicons WHERE url = :icon_url) "
|
||||
"WHERE url = :page_url"));
|
||||
|
||||
@ -220,15 +210,8 @@ nsFaviconService::GetStatement(const nsCOMPtr<mozIStorageStatement>& aStmt)
|
||||
"SET favicon_id = NULL "
|
||||
"WHERE favicon_id NOT NULL"));
|
||||
|
||||
RETURN_IF_STMT(mDBRemoveTempReferences, NS_LITERAL_CSTRING(
|
||||
"UPDATE moz_places_temp "
|
||||
"SET favicon_id = NULL "
|
||||
"WHERE favicon_id NOT NULL"));
|
||||
|
||||
RETURN_IF_STMT(mDBRemoveAllFavicons, NS_LITERAL_CSTRING(
|
||||
"DELETE FROM moz_favicons WHERE id NOT IN ("
|
||||
"SELECT favicon_id FROM moz_places_temp WHERE favicon_id NOT NULL "
|
||||
"UNION ALL "
|
||||
"SELECT favicon_id FROM moz_places WHERE favicon_id NOT NULL "
|
||||
")"));
|
||||
|
||||
@ -262,16 +245,11 @@ nsFaviconService::ExpireAllFavicons()
|
||||
{
|
||||
mFaviconsExpirationRunning = true;
|
||||
|
||||
// We do this in 2 steps, first we null-out all favicons in the disk table,
|
||||
// then we do the same in the temp table. This is because the view UPDATE
|
||||
// trigger does not allow setting a NULL value to prevent dataloss.
|
||||
|
||||
mozIStorageBaseStatement *stmts[] = {
|
||||
GetStatement(mDBRemoveOnDiskReferences),
|
||||
GetStatement(mDBRemoveTempReferences),
|
||||
GetStatement(mDBRemoveAllFavicons),
|
||||
};
|
||||
NS_ENSURE_STATE(stmts[0] && stmts[1] && stmts[2]);
|
||||
NS_ENSURE_STATE(stmts[0] && stmts[1]);
|
||||
nsCOMPtr<mozIStoragePendingStatement> ps;
|
||||
nsCOMPtr<ExpireFaviconsStatementCallbackNotifier> callback =
|
||||
new ExpireFaviconsStatementCallbackNotifier(&mFaviconsExpirationRunning);
|
||||
@ -1051,7 +1029,6 @@ nsFaviconService::FinalizeStatements() {
|
||||
mDBUpdateIcon,
|
||||
mDBSetPageFavicon,
|
||||
mDBRemoveOnDiskReferences,
|
||||
mDBRemoveTempReferences,
|
||||
mDBRemoveAllFavicons,
|
||||
mDBAssociateFaviconURIToPageURI,
|
||||
};
|
||||
|
@ -190,7 +190,6 @@ private:
|
||||
nsCOMPtr<mozIStorageStatement> mDBSetPageFavicon;
|
||||
nsCOMPtr<mozIStorageStatement> mDBAssociateFaviconURIToPageURI;
|
||||
nsCOMPtr<mozIStorageStatement> mDBRemoveOnDiskReferences;
|
||||
nsCOMPtr<mozIStorageStatement> mDBRemoveTempReferences;
|
||||
nsCOMPtr<mozIStorageStatement> mDBRemoveAllFavicons;
|
||||
|
||||
static nsFaviconService* gFaviconService;
|
||||
|
@ -251,17 +251,12 @@ nsNavBookmarks::GetStatement(const nsCOMPtr<mozIStorageStatement>& aStmt)
|
||||
|
||||
// Double ordering covers possible lastModified ties, that could happen when
|
||||
// importing, syncing or due to extensions.
|
||||
// Note: not using a JOIN is cheaper in this case.
|
||||
RETURN_IF_STMT(mDBFindURIBookmarks, NS_LITERAL_CSTRING(
|
||||
"SELECT b.id "
|
||||
"FROM moz_bookmarks b "
|
||||
"WHERE b.type = :item_type AND b.fk = ( "
|
||||
"SELECT id FROM moz_places_temp "
|
||||
"WHERE url = :page_url "
|
||||
"UNION "
|
||||
"SELECT id FROM moz_places "
|
||||
"WHERE url = :page_url "
|
||||
"LIMIT 1 "
|
||||
") "
|
||||
"WHERE b.fk = (SELECT id FROM moz_places WHERE url = :page_url) "
|
||||
"AND b.fk NOTNULL "
|
||||
"ORDER BY b.lastModified DESC, b.id DESC "));
|
||||
|
||||
// Select all children of a given folder, sorted by position.
|
||||
@ -271,15 +266,10 @@ nsNavBookmarks::GetStatement(const nsCOMPtr<mozIStorageStatement>& aStmt)
|
||||
// by mDBGetURLPageInfo, and additionally contains columns for position,
|
||||
// item_child, and folder_child from moz_bookmarks.
|
||||
RETURN_IF_STMT(mDBGetChildren, NS_LITERAL_CSTRING(
|
||||
"SELECT IFNULL(h_t.id, h.id), IFNULL(h_t.url, h.url), "
|
||||
"COALESCE(b.title, h_t.title, h.title), "
|
||||
"IFNULL(h_t.rev_host, h.rev_host), "
|
||||
"IFNULL(h_t.visit_count, h.visit_count), "
|
||||
"IFNULL(h_t.last_visit_date, h.last_visit_date), "
|
||||
"f.url, null, b.id, b.dateAdded, b.lastModified, b.parent, null, "
|
||||
"b.position, b.type, b.fk, b.folder_type "
|
||||
"SELECT h.id, h.url, IFNULL(b.title, h.title), h.rev_host, h.visit_count, "
|
||||
"h.last_visit_date, f.url, null, b.id, b.dateAdded, b.lastModified, "
|
||||
"b.parent, null, b.position, b.type, b.fk, b.folder_type "
|
||||
"FROM moz_bookmarks b "
|
||||
"LEFT JOIN moz_places_temp h_t ON b.fk = h_t.id "
|
||||
"LEFT JOIN moz_places h ON b.fk = h.id "
|
||||
"LEFT JOIN moz_favicons f ON h.favicon_id = f.id "
|
||||
"WHERE b.parent = :parent "
|
||||
@ -298,8 +288,7 @@ nsNavBookmarks::GetStatement(const nsCOMPtr<mozIStorageStatement>& aStmt)
|
||||
// Get bookmark/folder/separator properties.
|
||||
RETURN_IF_STMT(mDBGetItemProperties, NS_LITERAL_CSTRING(
|
||||
"SELECT b.id, "
|
||||
"IFNULL((SELECT url FROM moz_places_temp WHERE id = b.fk), "
|
||||
"(SELECT url FROM moz_places WHERE id = b.fk)), "
|
||||
"(SELECT url FROM moz_places WHERE id = b.fk), "
|
||||
"b.title, b.position, b.fk, b.parent, b.type, b.folder_type, "
|
||||
"b.dateAdded, b.lastModified "
|
||||
"FROM moz_bookmarks b "
|
||||
@ -323,12 +312,9 @@ nsNavBookmarks::GetStatement(const nsCOMPtr<mozIStorageStatement>& aStmt)
|
||||
"SELECT 1 FROM moz_bookmarks WHERE fk = :page_id"));
|
||||
|
||||
RETURN_IF_STMT(mDBIsURIBookmarkedInDatabase, NS_LITERAL_CSTRING(
|
||||
"SELECT 1 FROM moz_bookmarks WHERE fk = ("
|
||||
"SELECT id FROM moz_places_temp WHERE url = :page_url "
|
||||
"UNION ALL "
|
||||
"SELECT id FROM moz_places WHERE url = :page_url "
|
||||
"LIMIT 1"
|
||||
")"));
|
||||
"SELECT 1 FROM moz_bookmarks b "
|
||||
"JOIN moz_places h ON b.fk = h.id "
|
||||
"WHERE h.url = :page_url"));
|
||||
|
||||
// Checks to make sure a place id is a bookmark, and isn't a livemark.
|
||||
RETURN_IF_STMT(mDBIsRealBookmark, NS_LITERAL_CSTRING(
|
||||
@ -365,16 +351,10 @@ nsNavBookmarks::GetStatement(const nsCOMPtr<mozIStorageStatement>& aStmt)
|
||||
|
||||
RETURN_IF_STMT(mDBGetKeywordForURI, NS_LITERAL_CSTRING(
|
||||
"SELECT k.keyword "
|
||||
"FROM ( "
|
||||
"SELECT id FROM moz_places_temp "
|
||||
"WHERE url = :page_url "
|
||||
"UNION ALL "
|
||||
"SELECT id FROM moz_places "
|
||||
"WHERE url = :page_url "
|
||||
"LIMIT 1 "
|
||||
") AS h "
|
||||
"FROM moz_places h "
|
||||
"JOIN moz_bookmarks b ON b.fk = h.id "
|
||||
"JOIN moz_keywords k ON k.id = b.keyword_id"));
|
||||
"JOIN moz_keywords k ON k.id = b.keyword_id "
|
||||
"WHERE h.url = :page_url "));
|
||||
|
||||
RETURN_IF_STMT(mDBAdjustPosition, NS_LITERAL_CSTRING(
|
||||
"UPDATE moz_bookmarks SET position = position + :delta "
|
||||
@ -421,14 +401,6 @@ nsNavBookmarks::GetStatement(const nsCOMPtr<mozIStorageStatement>& aStmt)
|
||||
// For most cases these levels of redirects should be fine though, it's hard
|
||||
// to hit a page that is 4 or 5 levels of redirects below a bookmarked page.
|
||||
//
|
||||
// Moreover this query does not mix-up all possible cases of disk and temp
|
||||
// tables. This is because we expect a redirects chain to be completely on
|
||||
// disk or completely in memory. We never bring back visits from disk to
|
||||
// memory, we sync visits on a timer (the chained visits have narrow times),
|
||||
// or on bookmarks changes. The likely possiblity that we break a chain in
|
||||
// the middle is so much smaller than the perf and readability hit we would
|
||||
// get making complete crossing joins.
|
||||
//
|
||||
// As a bonus the query also checks first if place_id is already a bookmark,
|
||||
// so you don't have to check that apart.
|
||||
|
||||
@ -441,31 +413,13 @@ nsNavBookmarks::GetStatement(const nsCOMPtr<mozIStorageStatement>& aStmt)
|
||||
nsINavHistoryService::TRANSITION_REDIRECT_TEMPORARY);
|
||||
|
||||
RETURN_IF_STMT(mDBFindRedirectedBookmark, NS_LITERAL_CSTRING(
|
||||
"SELECT IFNULL( "
|
||||
"(SELECT url FROM moz_places_temp WHERE id = :page_id), "
|
||||
"SELECT "
|
||||
"(SELECT url FROM moz_places WHERE id = :page_id) "
|
||||
") "
|
||||
"FROM moz_bookmarks b "
|
||||
"WHERE b.fk = :page_id "
|
||||
"UNION ALL " // Not directly bookmarked.
|
||||
"SELECT IFNULL( "
|
||||
"(SELECT url FROM moz_places_temp WHERE id = " COALESCE_PLACEID "), "
|
||||
"SELECT "
|
||||
"(SELECT url FROM moz_places WHERE id = " COALESCE_PLACEID ") "
|
||||
") "
|
||||
"FROM moz_historyvisits_temp self "
|
||||
"JOIN moz_bookmarks b ON b.fk = " COALESCE_PLACEID
|
||||
"LEFT JOIN moz_historyvisits_temp parent ON parent.id = self.from_visit "
|
||||
"LEFT JOIN moz_historyvisits_temp grandparent ON parent.from_visit = grandparent.id "
|
||||
"AND parent.visit_type IN (") + redirectsFragment + NS_LITERAL_CSTRING(") "
|
||||
"LEFT JOIN moz_historyvisits_temp greatgrandparent ON grandparent.from_visit = greatgrandparent.id "
|
||||
"AND grandparent.visit_type IN (") + redirectsFragment + NS_LITERAL_CSTRING(") "
|
||||
"WHERE self.visit_type IN (") + redirectsFragment + NS_LITERAL_CSTRING(") "
|
||||
"AND self.place_id = :page_id "
|
||||
"UNION ALL " // Not in the temp table.
|
||||
"SELECT IFNULL( "
|
||||
"(SELECT url FROM moz_places_temp WHERE id = " COALESCE_PLACEID "), "
|
||||
"(SELECT url FROM moz_places WHERE id = " COALESCE_PLACEID ") "
|
||||
") "
|
||||
"FROM moz_historyvisits self "
|
||||
"JOIN moz_bookmarks b ON b.fk = " COALESCE_PLACEID
|
||||
"LEFT JOIN moz_historyvisits parent ON parent.id = self.from_visit "
|
||||
@ -2630,8 +2584,6 @@ nsNavBookmarks::GetBookmarkIdsForURITArray(nsIURI* aURI,
|
||||
DECLARE_AND_ASSIGN_SCOPED_LAZY_STMT(stmt, mDBFindURIBookmarks);
|
||||
nsresult rv = URIBinder::Bind(stmt, NS_LITERAL_CSTRING("page_url"), aURI);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
rv = stmt->BindInt32ByName(NS_LITERAL_CSTRING("item_type"), TYPE_BOOKMARK);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
PRBool more;
|
||||
while (NS_SUCCEEDED((rv = stmt->ExecuteStep(&more))) && more) {
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -99,6 +99,8 @@
|
||||
// If you need to listen for Places shutdown, you should really use
|
||||
// places-shutdown, because places-teardown is guaranteed to break your code.
|
||||
#define TOPIC_PLACES_TEARDOWN "places-teardown"
|
||||
// Fired when the database connection has been closed.
|
||||
#define TOPIC_PLACES_DATABASE_CLOSED "places-database-closed"
|
||||
// Fired when Places found a locked database while initing.
|
||||
#define TOPIC_DATABASE_LOCKED "places-database-locked"
|
||||
// Fired after Places inited.
|
||||
@ -550,7 +552,6 @@ protected:
|
||||
*/
|
||||
nsresult InitAdditionalDBItems();
|
||||
nsresult InitTempTables();
|
||||
nsresult InitViews();
|
||||
nsresult InitFunctions();
|
||||
nsresult InitStatements();
|
||||
nsresult ForceMigrateBookmarksDB(mozIStorageConnection *aDBConn);
|
||||
@ -560,6 +561,7 @@ protected:
|
||||
nsresult MigrateV8Up(mozIStorageConnection *aDBConn);
|
||||
nsresult MigrateV9Up(mozIStorageConnection *aDBConn);
|
||||
nsresult MigrateV10Up(mozIStorageConnection *aDBConn);
|
||||
nsresult MigrateV11Up(mozIStorageConnection *aDBConn);
|
||||
|
||||
nsresult RemovePagesInternal(const nsCString& aPlaceIdsQueryString);
|
||||
nsresult PreparePlacesForVisitsDelete(const nsCString& aPlaceIdsQueryString);
|
||||
|
@ -108,33 +108,6 @@ const kTitleTagsSeparator = " \u2013 ";
|
||||
|
||||
const kBrowserUrlbarBranch = "browser.urlbar.";
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//// Global Functions
|
||||
|
||||
/**
|
||||
* Generates the SQL subquery to get the best favicon for a given revhost. This
|
||||
* is the favicon for the most recent visit.
|
||||
*
|
||||
* @param aTableName
|
||||
* The table to join to the moz_favicons table with. This must have a
|
||||
* column called favicon_id.
|
||||
* @return the SQL subquery (in string form) to get the best favicon.
|
||||
*/
|
||||
function best_favicon_for_revhost(aTableName)
|
||||
{
|
||||
return "(" +
|
||||
"SELECT f.url " +
|
||||
"FROM " + aTableName + " " +
|
||||
"JOIN moz_favicons f ON f.id = favicon_id " +
|
||||
"WHERE rev_host = IFNULL( " +
|
||||
"(SELECT rev_host FROM moz_places_temp WHERE id = b.fk), " +
|
||||
"(SELECT rev_host FROM moz_places WHERE id = b.fk) " +
|
||||
") " +
|
||||
"ORDER BY frecency DESC " +
|
||||
"LIMIT 1 " +
|
||||
")";
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//// AutoCompleteStatementCallbackWrapper class
|
||||
|
||||
@ -211,32 +184,24 @@ function nsPlacesAutoComplete()
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//// Shared Constants for Smart Getters
|
||||
|
||||
// Define common pieces of various queries.
|
||||
// TODO bug 412736 in case of a frecency tie, break it with h.typed and
|
||||
// h.visit_count which is better than nothing. This is slow, so not doing it
|
||||
// yet...
|
||||
// Note: h.frecency is only selected because we need it for ordering.
|
||||
function sql_base_fragment(aTableName) {
|
||||
return "SELECT h.url, h.title, f.url, " + kBookTagSQLFragment + ", " +
|
||||
"h.visit_count, h.typed, h.id, :query_type, t.open_count, " +
|
||||
"h.frecency " +
|
||||
"FROM " + aTableName + " h " +
|
||||
"LEFT OUTER JOIN moz_favicons f ON f.id = h.favicon_id " +
|
||||
"LEFT OUTER JOIN moz_openpages_temp t ON t.place_id = h.id " +
|
||||
"WHERE h.frecency <> 0 " +
|
||||
"AND AUTOCOMPLETE_MATCH(:searchString, h.url, " +
|
||||
"IFNULL(bookmark, h.title), tags, " +
|
||||
"h.visit_count, h.typed, parent, " +
|
||||
"t.open_count, " +
|
||||
":matchBehavior, :searchBehavior) " +
|
||||
"{ADDITIONAL_CONDITIONS} ";
|
||||
}
|
||||
const SQL_BASE = sql_base_fragment("moz_places_temp") +
|
||||
"UNION ALL " +
|
||||
sql_base_fragment("moz_places") +
|
||||
"AND +h.id NOT IN (SELECT id FROM moz_places_temp) " +
|
||||
"ORDER BY h.frecency DESC, h.id DESC " +
|
||||
"LIMIT :maxResults";
|
||||
const SQL_BASE = "SELECT h.url, h.title, f.url, " + kBookTagSQLFragment + ", "
|
||||
+ "h.visit_count, h.typed, h.id, :query_type, "
|
||||
+ "t.open_count "
|
||||
+ "FROM moz_places h "
|
||||
+ "LEFT JOIN moz_favicons f ON f.id = h.favicon_id "
|
||||
+ "LEFT JOIN moz_openpages_temp t ON t.place_id = h.id "
|
||||
+ "WHERE h.frecency <> 0 "
|
||||
+ "AND AUTOCOMPLETE_MATCH(:searchString, h.url, "
|
||||
+ "IFNULL(bookmark, h.title), tags, "
|
||||
+ "h.visit_count, h.typed, parent, "
|
||||
+ "t.open_count, "
|
||||
+ ":matchBehavior, :searchBehavior) "
|
||||
+ "{ADDITIONAL_CONDITIONS} "
|
||||
+ "ORDER BY h.frecency DESC, h.id DESC "
|
||||
+ "LIMIT :maxResults";
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//// Smart Getters
|
||||
@ -269,42 +234,42 @@ function nsPlacesAutoComplete()
|
||||
|
||||
XPCOMUtils.defineLazyGetter(this, "_defaultQuery", function() {
|
||||
let replacementText = "";
|
||||
return this._db.createStatement(
|
||||
return this._db.createAsyncStatement(
|
||||
SQL_BASE.replace("{ADDITIONAL_CONDITIONS}", replacementText, "g")
|
||||
);
|
||||
});
|
||||
|
||||
XPCOMUtils.defineLazyGetter(this, "_historyQuery", function() {
|
||||
let replacementText = "AND h.visit_count > 0";
|
||||
return this._db.createStatement(
|
||||
return this._db.createAsyncStatement(
|
||||
SQL_BASE.replace("{ADDITIONAL_CONDITIONS}", replacementText, "g")
|
||||
);
|
||||
});
|
||||
|
||||
XPCOMUtils.defineLazyGetter(this, "_bookmarkQuery", function() {
|
||||
let replacementText = "AND bookmark IS NOT NULL";
|
||||
return this._db.createStatement(
|
||||
return this._db.createAsyncStatement(
|
||||
SQL_BASE.replace("{ADDITIONAL_CONDITIONS}", replacementText, "g")
|
||||
);
|
||||
});
|
||||
|
||||
XPCOMUtils.defineLazyGetter(this, "_tagsQuery", function() {
|
||||
let replacementText = "AND tags IS NOT NULL";
|
||||
return this._db.createStatement(
|
||||
return this._db.createAsyncStatement(
|
||||
SQL_BASE.replace("{ADDITIONAL_CONDITIONS}", replacementText, "g")
|
||||
);
|
||||
});
|
||||
|
||||
XPCOMUtils.defineLazyGetter(this, "_openPagesQuery", function() {
|
||||
let replacementText = "AND t.open_count > 0";
|
||||
return this._db.createStatement(
|
||||
return this._db.createAsyncStatement(
|
||||
SQL_BASE.replace("{ADDITIONAL_CONDITIONS}", replacementText, "g")
|
||||
);
|
||||
});
|
||||
|
||||
XPCOMUtils.defineLazyGetter(this, "_typedQuery", function() {
|
||||
let replacementText = "AND h.typed = 1";
|
||||
return this._db.createStatement(
|
||||
return this._db.createAsyncStatement(
|
||||
SQL_BASE.replace("{ADDITIONAL_CONDITIONS}", replacementText, "g")
|
||||
);
|
||||
});
|
||||
@ -313,58 +278,55 @@ function nsPlacesAutoComplete()
|
||||
// In this query, we are taking kBookTagSQLFragment only for h.id because it
|
||||
// uses data from the moz_bookmarks table and we sync tables on bookmark
|
||||
// insert. So, most likely, h.id will always be populated when we have any
|
||||
// bookmark. We still need to join on moz_places_temp for other data (eg.
|
||||
// title).
|
||||
return this._db.createStatement(
|
||||
"/* do not warn (bug 487789) */ " +
|
||||
"SELECT IFNULL(h_t.url, h.url) AS c_url, " +
|
||||
"IFNULL(h_t.title, h.title) AS c_title, f.url, " +
|
||||
kBookTagSQLFragment + ", " +
|
||||
"IFNULL(h_t.visit_count, h.visit_count) AS c_visit_count, " +
|
||||
"IFNULL(h_t.typed, h.typed) AS c_typed, " +
|
||||
"IFNULL(h_t.id, h.id), :query_type, t.open_count, rank " +
|
||||
"FROM ( " +
|
||||
"SELECT ROUND(MAX(((i.input = :search_string) + " +
|
||||
"(SUBSTR(i.input, 1, LENGTH(:search_string)) = :search_string)) * " +
|
||||
"i.use_count), 1) AS rank, place_id " +
|
||||
"FROM moz_inputhistory i " +
|
||||
"GROUP BY i.place_id " +
|
||||
"HAVING rank > 0 " +
|
||||
") AS i " +
|
||||
"LEFT JOIN moz_places h ON h.id = i.place_id " +
|
||||
"LEFT JOIN moz_places_temp h_t ON h_t.id = i.place_id " +
|
||||
"LEFT JOIN moz_favicons f ON f.id = IFNULL(h_t.favicon_id, h.favicon_id) " +
|
||||
"LEFT JOIN moz_openpages_temp t ON t.place_id = i.place_id " +
|
||||
"WHERE c_url NOTNULL " +
|
||||
"AND AUTOCOMPLETE_MATCH(:searchString, c_url, " +
|
||||
"IFNULL(bookmark, c_title), tags, " +
|
||||
"c_visit_count, c_typed, parent, " +
|
||||
"t.open_count, " +
|
||||
":matchBehavior, :searchBehavior) " +
|
||||
"ORDER BY rank DESC, IFNULL(h_t.frecency, h.frecency) DESC"
|
||||
// bookmark.
|
||||
return this._db.createAsyncStatement(
|
||||
"/* do not warn (bug 487789) */ "
|
||||
+ "SELECT h.url, h.title, f.url, " + kBookTagSQLFragment + ", "
|
||||
+ "h.visit_count, h.typed, h.id, :query_type, t.open_count, rank "
|
||||
+ "FROM ( "
|
||||
+ "SELECT ROUND( "
|
||||
+ "MAX(((i.input = :search_string) + "
|
||||
+ "(SUBSTR(i.input, 1, LENGTH(:search_string)) = :search_string) "
|
||||
+ ") * i.use_count "
|
||||
+ ") , 1 " // Round at first decimal.
|
||||
+ ") AS rank, place_id "
|
||||
+ "FROM moz_inputhistory i "
|
||||
+ "GROUP BY i.place_id "
|
||||
+ "HAVING rank > 0 "
|
||||
+ ") AS i "
|
||||
+ "JOIN moz_places h ON h.id = i.place_id "
|
||||
+ "LEFT JOIN moz_favicons f ON f.id = h.favicon_id "
|
||||
+ "LEFT JOIN moz_openpages_temp t ON t.place_id = i.place_id "
|
||||
+ "WHERE AUTOCOMPLETE_MATCH(:searchString, h.url, "
|
||||
+ "IFNULL(bookmark, h.title), tags, "
|
||||
+ "h.visit_count, h.typed, parent, "
|
||||
+ "t.open_count, "
|
||||
+ ":matchBehavior, :searchBehavior) "
|
||||
+ "ORDER BY rank DESC, h.frecency DESC "
|
||||
);
|
||||
});
|
||||
|
||||
XPCOMUtils.defineLazyGetter(this, "_keywordQuery", function() {
|
||||
return this._db.createStatement(
|
||||
"/* do not warn (bug 487787) */ " +
|
||||
"SELECT IFNULL( " +
|
||||
"(SELECT REPLACE(url, '%s', :query_string) FROM moz_places_temp WHERE id = b.fk), " +
|
||||
"(SELECT REPLACE(url, '%s', :query_string) FROM moz_places WHERE id = b.fk) " +
|
||||
") AS search_url, IFNULL(h_t.title, h.title), " +
|
||||
"COALESCE(f.url, " + best_favicon_for_revhost("moz_places_temp") + "," +
|
||||
best_favicon_for_revhost("moz_places") + "), b.parent, " +
|
||||
"b.title, NULL, IFNULL(h_t.visit_count, h.visit_count), " +
|
||||
"IFNULL(h_t.typed, h.typed), COALESCE(h_t.id, h.id, b.fk), " +
|
||||
":query_type, t.open_count " +
|
||||
"FROM moz_keywords k " +
|
||||
"JOIN moz_bookmarks b ON b.keyword_id = k.id " +
|
||||
"LEFT JOIN moz_places AS h ON h.url = search_url " +
|
||||
"LEFT JOIN moz_places_temp AS h_t ON h_t.url = search_url " +
|
||||
"LEFT JOIN moz_favicons f ON f.id = IFNULL(h_t.favicon_id, h.favicon_id) " +
|
||||
"LEFT JOIN moz_openpages_temp t ON t.place_id = IFNULL(h_t.id, h.id) " +
|
||||
"WHERE LOWER(k.keyword) = LOWER(:keyword) " +
|
||||
"ORDER BY IFNULL(h_t.frecency, h.frecency) DESC"
|
||||
return this._db.createAsyncStatement(
|
||||
"/* do not warn (bug 487787) */ "
|
||||
+ "SELECT "
|
||||
+ "(SELECT REPLACE(url, '%s', :query_string) FROM moz_places WHERE id = b.fk) "
|
||||
+ "AS search_url, h.title, "
|
||||
+ "IFNULL(f.url, (SELECT f.url "
|
||||
+ "FROM moz_places "
|
||||
+ "JOIN moz_favicons f ON f.id = favicon_id "
|
||||
+ "WHERE rev_host = (SELECT rev_host FROM moz_places WHERE id = b.fk) "
|
||||
+ "ORDER BY frecency DESC "
|
||||
+ "LIMIT 1) "
|
||||
+ "), b.parent, b.title, NULL, h.visit_count, h.typed, IFNULL(h.id, b.fk), "
|
||||
+ ":query_type, t.open_count "
|
||||
+ "FROM moz_keywords k "
|
||||
+ "JOIN moz_bookmarks b ON b.keyword_id = k.id "
|
||||
+ "LEFT JOIN moz_places h ON h.url = search_url "
|
||||
+ "LEFT JOIN moz_favicons f ON f.id = h.favicon_id "
|
||||
+ "LEFT JOIN moz_openpages_temp t ON t.place_id = h.id "
|
||||
+ "WHERE LOWER(k.keyword) = LOWER(:keyword) "
|
||||
+ "ORDER BY h.frecency DESC "
|
||||
);
|
||||
});
|
||||
|
||||
|
@ -210,23 +210,10 @@ const EXPIRATION_QUERIES = {
|
||||
QUERY_FIND_VISITS_TO_EXPIRE: {
|
||||
sql: "INSERT INTO expiration_notify "
|
||||
+ "(v_id, url, visit_date, expected_results) "
|
||||
+ "SELECT v.id, IFNULL(h_t.url, h.url) AS url, "
|
||||
+ "v.visit_date AS visit_date, "
|
||||
+ ":limit_visits AS expected_results "
|
||||
+ "FROM moz_historyvisits_temp v "
|
||||
+ "LEFT JOIN moz_places_temp AS h_t ON h_t.id = v.place_id "
|
||||
+ "LEFT JOIN moz_places AS h ON h.id = v.place_id "
|
||||
+ "WHERE ((SELECT COUNT(*) FROM moz_places_temp) + "
|
||||
+ "(SELECT COUNT(*) FROM moz_places)) > :max_uris "
|
||||
+ "UNION ALL "
|
||||
+ "SELECT v.id, IFNULL(h_t.url, h.url) AS url, "
|
||||
+ "v.visit_date AS visit_date, "
|
||||
+ ":limit_visits AS expected_results "
|
||||
+ "SELECT v.id, h.url, v.visit_date, :limit_visits "
|
||||
+ "FROM moz_historyvisits v "
|
||||
+ "LEFT JOIN moz_places_temp AS h_t ON h_t.id = v.place_id "
|
||||
+ "LEFT JOIN moz_places AS h ON h.id = v.place_id "
|
||||
+ "WHERE ((SELECT COUNT(*) FROM moz_places_temp) + "
|
||||
+ "(SELECT COUNT(*) FROM moz_places)) > :max_uris "
|
||||
+ "JOIN moz_places h ON h.id = v.place_id "
|
||||
+ "WHERE (SELECT COUNT(*) FROM moz_places) > :max_uris "
|
||||
+ "ORDER BY v.visit_date ASC "
|
||||
+ "LIMIT :limit_visits",
|
||||
actions: ACTION.TIMED_OVERLIMIT | ACTION.SHUTDOWN | ACTION.IDLE |
|
||||
@ -235,7 +222,7 @@ const EXPIRATION_QUERIES = {
|
||||
|
||||
// Removes the previously found visits.
|
||||
QUERY_EXPIRE_VISITS: {
|
||||
sql: "DELETE FROM moz_historyvisits_view WHERE id IN ( "
|
||||
sql: "DELETE FROM moz_historyvisits WHERE id IN ( "
|
||||
+ "SELECT v_id FROM expiration_notify WHERE v_id NOTNULL "
|
||||
+ ")",
|
||||
actions: ACTION.TIMED_OVERLIMIT | ACTION.SHUTDOWN | ACTION.IDLE |
|
||||
@ -248,26 +235,13 @@ const EXPIRATION_QUERIES = {
|
||||
QUERY_FIND_URIS_TO_EXPIRE: {
|
||||
sql: "INSERT INTO expiration_notify "
|
||||
+ "(p_id, url, visit_date, expected_results) "
|
||||
+ "SELECT h.id, h.url, h.last_visit_date AS visit_date, "
|
||||
+ ":limit_uris AS expected_results "
|
||||
+ "FROM moz_places_temp h "
|
||||
+ "LEFT JOIN moz_historyvisits v ON h.id = v.place_id "
|
||||
+ "LEFT JOIN moz_historyvisits_temp v_t ON h.id = v_t.place_id "
|
||||
+ "LEFT JOIN moz_bookmarks b ON h.id = b.fk "
|
||||
+ "WHERE v.id IS NULL "
|
||||
+ "AND v_t.id IS NULL "
|
||||
+ "AND b.id IS NULL "
|
||||
+ "AND h.ROWID <> IFNULL(:null_skips_last, (SELECT MAX(ROWID) FROM moz_places_temp)) "
|
||||
+ "UNION ALL "
|
||||
+ "SELECT h.id, h.url, h.last_visit_date AS visit_date, "
|
||||
+ ":limit_uris AS expected_results "
|
||||
+ "SELECT h.id, h.url, h.last_visit_date, :limit_uris "
|
||||
+ "FROM moz_places h "
|
||||
+ "LEFT JOIN moz_historyvisits v ON h.id = v.place_id "
|
||||
+ "LEFT JOIN moz_historyvisits_temp v_t ON h.id = v_t.place_id "
|
||||
+ "LEFT JOIN moz_bookmarks b ON h.id = b.fk "
|
||||
+ "WHERE v.id IS NULL "
|
||||
+ "AND v_t.id IS NULL "
|
||||
+ "AND b.id IS NULL "
|
||||
+ "AND h.ROWID <> IFNULL(:null_skips_last, (SELECT MAX(ROWID) FROM moz_places)) "
|
||||
+ "LIMIT :limit_uris",
|
||||
actions: ACTION.TIMED | ACTION.TIMED_OVERLIMIT | ACTION.SHUTDOWN |
|
||||
ACTION.IDLE | ACTION.DEBUG
|
||||
@ -275,7 +249,7 @@ const EXPIRATION_QUERIES = {
|
||||
|
||||
// Expire found URIs from the database.
|
||||
QUERY_EXPIRE_URIS: {
|
||||
sql: "DELETE FROM moz_places_view WHERE id IN ( "
|
||||
sql: "DELETE FROM moz_places WHERE id IN ( "
|
||||
+ "SELECT p_id FROM expiration_notify WHERE p_id NOTNULL "
|
||||
+ ")",
|
||||
actions: ACTION.TIMED | ACTION.TIMED_OVERLIMIT | ACTION.SHUTDOWN |
|
||||
@ -284,26 +258,13 @@ const EXPIRATION_QUERIES = {
|
||||
|
||||
// Expire orphan URIs from the database.
|
||||
QUERY_SILENT_EXPIRE_ORPHAN_URIS: {
|
||||
sql: "DELETE FROM moz_places_view WHERE id IN ( "
|
||||
+ "SELECT h.id "
|
||||
+ "FROM moz_places_temp h "
|
||||
+ "LEFT JOIN moz_historyvisits v ON h.id = v.place_id "
|
||||
+ "LEFT JOIN moz_historyvisits_temp v_t ON h.id = v_t.place_id "
|
||||
+ "LEFT JOIN moz_bookmarks b ON h.id = b.fk "
|
||||
+ "WHERE v.id IS NULL "
|
||||
+ "AND v_t.id IS NULL "
|
||||
+ "AND b.id IS NULL "
|
||||
+ "AND SUBSTR(h.url, 1, 6) <> 'place:' "
|
||||
+ "UNION ALL "
|
||||
sql: "DELETE FROM moz_places WHERE id IN ( "
|
||||
+ "SELECT h.id "
|
||||
+ "FROM moz_places h "
|
||||
+ "LEFT JOIN moz_historyvisits v ON h.id = v.place_id "
|
||||
+ "LEFT JOIN moz_historyvisits_temp v_t ON h.id = v_t.place_id "
|
||||
+ "LEFT JOIN moz_bookmarks b ON h.id = b.fk "
|
||||
+ "WHERE v.id IS NULL "
|
||||
+ "AND v_t.id IS NULL "
|
||||
+ "AND b.id IS NULL "
|
||||
+ "AND SUBSTR(h.url, 1, 6) <> 'place:' "
|
||||
+ "LIMIT :limit_uris "
|
||||
+ ")",
|
||||
actions: ACTION.CLEAR_HISTORY
|
||||
@ -314,9 +275,7 @@ const EXPIRATION_QUERIES = {
|
||||
sql: "DELETE FROM moz_favicons WHERE id IN ( "
|
||||
+ "SELECT f.id FROM moz_favicons f "
|
||||
+ "LEFT JOIN moz_places h ON f.id = h.favicon_id "
|
||||
+ "LEFT JOIN moz_places_temp h_t ON f.id = h_t.favicon_id "
|
||||
+ "WHERE h.favicon_id IS NULL "
|
||||
+ "AND h_t.favicon_id IS NULL "
|
||||
+ "LIMIT :limit_favicons "
|
||||
+ ")",
|
||||
actions: ACTION.TIMED | ACTION.TIMED_OVERLIMIT | ACTION.CLEAR_HISTORY |
|
||||
@ -328,12 +287,9 @@ const EXPIRATION_QUERIES = {
|
||||
sql: "DELETE FROM moz_annos WHERE id in ( "
|
||||
+ "SELECT a.id FROM moz_annos a "
|
||||
+ "LEFT JOIN moz_places h ON a.place_id = h.id "
|
||||
+ "LEFT JOIN moz_places_temp h_t ON a.place_id = h_t.id "
|
||||
+ "LEFT JOIN moz_historyvisits v ON a.place_id = v.place_id "
|
||||
+ "LEFT JOIN moz_historyvisits_temp v_t ON a.place_id = v_t.place_id "
|
||||
+ "WHERE (h.id IS NULL AND h_t.id IS NULL) "
|
||||
+ "OR (v.id IS NULL AND v_t.id IS NULL AND "
|
||||
+ "a.expiration <> :expire_never) "
|
||||
+ "WHERE h.id IS NULL "
|
||||
+ "OR (v.id IS NULL AND a.expiration <> :expire_never) "
|
||||
+ "LIMIT :limit_annos "
|
||||
+ ")",
|
||||
actions: ACTION.TIMED | ACTION.TIMED_OVERLIMIT | ACTION.CLEAR_HISTORY |
|
||||
@ -370,8 +326,6 @@ const EXPIRATION_QUERIES = {
|
||||
QUERY_EXPIRE_ANNOS_WITH_HISTORY: {
|
||||
sql: "DELETE FROM moz_annos "
|
||||
+ "WHERE expiration = :expire_with_history "
|
||||
+ "AND NOT EXISTS (SELECT id FROM moz_historyvisits_temp "
|
||||
+ "WHERE place_id = moz_annos.place_id LIMIT 1) "
|
||||
+ "AND NOT EXISTS (SELECT id FROM moz_historyvisits "
|
||||
+ "WHERE place_id = moz_annos.place_id LIMIT 1)",
|
||||
actions: ACTION.TIMED | ACTION.TIMED_OVERLIMIT | ACTION.CLEAR_HISTORY |
|
||||
@ -407,9 +361,7 @@ const EXPIRATION_QUERIES = {
|
||||
sql: "DELETE FROM moz_inputhistory WHERE place_id IN ( "
|
||||
+ "SELECT i.place_id FROM moz_inputhistory i "
|
||||
+ "LEFT JOIN moz_places h ON h.id = i.place_id "
|
||||
+ "LEFT JOIN moz_places_temp h_t ON h_t.id = i.place_id "
|
||||
+ "WHERE h.id IS NULL "
|
||||
+ "AND h_t.id IS NULL "
|
||||
+ "LIMIT :limit_inputhistory "
|
||||
+ ")",
|
||||
actions: ACTION.CLEAR_HISTORY | ACTION.SHUTDOWN | ACTION.IDLE | ACTION.DEBUG
|
||||
@ -522,8 +474,8 @@ nsPlacesExpiration.prototype = {
|
||||
this._timer = null;
|
||||
}
|
||||
|
||||
// We must be sure to run after all other shutdown observers (but DBFlush)
|
||||
// thus we enqueue the calls.
|
||||
// We must be sure to run after all other shutdown observers thus we
|
||||
// enqueue the calls.
|
||||
let self = this;
|
||||
Services.tm.mainThread.dispatch({
|
||||
run: function() {
|
||||
@ -617,8 +569,7 @@ nsPlacesExpiration.prototype = {
|
||||
// Check if we are over history capacity, if so visits must be expired.
|
||||
if (!this._cachedStatements["LIMIT_COUNT"]) {
|
||||
this._cachedStatements["LIMIT_COUNT"] = this._db.createAsyncStatement(
|
||||
"SELECT (SELECT COUNT(*) FROM moz_places_temp) + "
|
||||
+ "(SELECT COUNT(*) FROM moz_places)"
|
||||
"SELECT COUNT(*) FROM moz_places"
|
||||
);
|
||||
}
|
||||
let self = this;
|
||||
|
@ -49,55 +49,31 @@
|
||||
/**
|
||||
* moz_places
|
||||
*/
|
||||
#define CREATE_IDX_MOZ_PLACES_TEMP_URL \
|
||||
CREATE_PLACES_IDX( \
|
||||
"url_uniqueindex", "moz_places_temp", "url", "UNIQUE" \
|
||||
)
|
||||
#define CREATE_IDX_MOZ_PLACES_URL \
|
||||
CREATE_PLACES_IDX( \
|
||||
"url_uniqueindex", "moz_places", "url", "UNIQUE" \
|
||||
)
|
||||
|
||||
#define CREATE_IDX_MOZ_PLACES_TEMP_FAVICON \
|
||||
CREATE_PLACES_IDX( \
|
||||
"faviconindex", "moz_places_temp", "favicon_id", "" \
|
||||
)
|
||||
#define CREATE_IDX_MOZ_PLACES_FAVICON \
|
||||
CREATE_PLACES_IDX( \
|
||||
"faviconindex", "moz_places", "favicon_id", "" \
|
||||
)
|
||||
|
||||
#define CREATE_IDX_MOZ_PLACES_TEMP_REVHOST \
|
||||
CREATE_PLACES_IDX( \
|
||||
"hostindex", "moz_places_temp", "rev_host", "" \
|
||||
)
|
||||
#define CREATE_IDX_MOZ_PLACES_REVHOST \
|
||||
CREATE_PLACES_IDX( \
|
||||
"hostindex", "moz_places", "rev_host", "" \
|
||||
)
|
||||
|
||||
#define CREATE_IDX_MOZ_PLACES_TEMP_VISITCOUNT \
|
||||
CREATE_PLACES_IDX( \
|
||||
"visitcount", "moz_places_temp", "visit_count", "" \
|
||||
)
|
||||
#define CREATE_IDX_MOZ_PLACES_VISITCOUNT \
|
||||
CREATE_PLACES_IDX( \
|
||||
"visitcount", "moz_places", "visit_count", "" \
|
||||
)
|
||||
|
||||
#define CREATE_IDX_MOZ_PLACES_TEMP_FRECENCY \
|
||||
CREATE_PLACES_IDX( \
|
||||
"frecencyindex", "moz_places_temp", "frecency", "" \
|
||||
)
|
||||
#define CREATE_IDX_MOZ_PLACES_FRECENCY \
|
||||
CREATE_PLACES_IDX( \
|
||||
"frecencyindex", "moz_places", "frecency", "" \
|
||||
)
|
||||
|
||||
#define CREATE_IDX_MOZ_PLACES_TEMP_LASTVISITDATE \
|
||||
CREATE_PLACES_IDX( \
|
||||
"lastvisitdateindex", "moz_places_temp", "last_visit_date", "" \
|
||||
)
|
||||
#define CREATE_IDX_MOZ_PLACES_LASTVISITDATE \
|
||||
CREATE_PLACES_IDX( \
|
||||
"lastvisitdateindex", "moz_places", "last_visit_date", "" \
|
||||
@ -107,28 +83,16 @@
|
||||
* moz_historyvisits
|
||||
*/
|
||||
|
||||
#define CREATE_IDX_MOZ_HISTORYVISITS_TEMP_PLACEDATE \
|
||||
CREATE_PLACES_IDX( \
|
||||
"placedateindex", "moz_historyvisits_temp", "place_id, visit_date", "" \
|
||||
)
|
||||
#define CREATE_IDX_MOZ_HISTORYVISITS_PLACEDATE \
|
||||
CREATE_PLACES_IDX( \
|
||||
"placedateindex", "moz_historyvisits", "place_id, visit_date", "" \
|
||||
)
|
||||
|
||||
#define CREATE_IDX_MOZ_HISTORYVISITS_TEMP_FROMVISIT \
|
||||
CREATE_PLACES_IDX( \
|
||||
"fromindex", "moz_historyvisits_temp", "from_visit", "" \
|
||||
)
|
||||
#define CREATE_IDX_MOZ_HISTORYVISITS_FROMVISIT \
|
||||
CREATE_PLACES_IDX( \
|
||||
"fromindex", "moz_historyvisits", "from_visit", "" \
|
||||
)
|
||||
|
||||
#define CREATE_IDX_MOZ_HISTORYVISITS_TEMP_VISITDATE \
|
||||
CREATE_PLACES_IDX( \
|
||||
"dateindex", "moz_historyvisits_temp", "visit_date", "" \
|
||||
)
|
||||
#define CREATE_IDX_MOZ_HISTORYVISITS_VISITDATE \
|
||||
CREATE_PLACES_IDX( \
|
||||
"dateindex", "moz_historyvisits", "visit_date", "" \
|
||||
|
@ -40,8 +40,9 @@
|
||||
#ifndef __nsPlacesTables_h__
|
||||
#define __nsPlacesTables_h__
|
||||
|
||||
#define CREATE_MOZ_PLACES_BASE(__name, __temporary) NS_LITERAL_CSTRING( \
|
||||
"CREATE " __temporary " TABLE " __name " ( " \
|
||||
|
||||
#define CREATE_MOZ_PLACES NS_LITERAL_CSTRING( \
|
||||
"CREATE TABLE moz_places ( " \
|
||||
" id INTEGER PRIMARY KEY" \
|
||||
", url LONGVARCHAR" \
|
||||
", title LONGVARCHAR" \
|
||||
@ -54,22 +55,12 @@
|
||||
", last_visit_date INTEGER " \
|
||||
")" \
|
||||
)
|
||||
#define CREATE_MOZ_PLACES CREATE_MOZ_PLACES_BASE("moz_places", "")
|
||||
#define CREATE_MOZ_PLACES_TEMP CREATE_MOZ_PLACES_BASE("moz_places_temp", "TEMP")
|
||||
#define MOZ_PLACES_COLUMNS \
|
||||
"id, url, title, rev_host, visit_count, hidden, typed, favicon_id, " \
|
||||
"frecency, last_visit_date"
|
||||
#define CREATE_MOZ_PLACES_VIEW NS_LITERAL_CSTRING( \
|
||||
"CREATE TEMPORARY VIEW moz_places_view AS " \
|
||||
"SELECT " MOZ_PLACES_COLUMNS " FROM moz_places_temp " \
|
||||
"UNION ALL " \
|
||||
"SELECT " MOZ_PLACES_COLUMNS " FROM moz_places " \
|
||||
"WHERE id NOT IN (SELECT id FROM moz_places_temp) " \
|
||||
)
|
||||
|
||||
|
||||
#define CREATE_MOZ_HISTORYVISITS_BASE(__name, __temporary) NS_LITERAL_CSTRING( \
|
||||
"CREATE " __temporary " TABLE " __name " (" \
|
||||
#define CREATE_MOZ_HISTORYVISITS NS_LITERAL_CSTRING( \
|
||||
"CREATE TABLE moz_historyvisits (" \
|
||||
" id INTEGER PRIMARY KEY" \
|
||||
", from_visit INTEGER" \
|
||||
", place_id INTEGER" \
|
||||
@ -78,19 +69,9 @@
|
||||
", session INTEGER" \
|
||||
")" \
|
||||
)
|
||||
#define CREATE_MOZ_HISTORYVISITS \
|
||||
CREATE_MOZ_HISTORYVISITS_BASE("moz_historyvisits", "")
|
||||
#define CREATE_MOZ_HISTORYVISITS_TEMP \
|
||||
CREATE_MOZ_HISTORYVISITS_BASE("moz_historyvisits_temp", "TEMP")
|
||||
#define MOZ_HISTORYVISITS_COLUMNS \
|
||||
"id, from_visit, place_id, visit_date, visit_type, session"
|
||||
#define CREATE_MOZ_HISTORYVISITS_VIEW NS_LITERAL_CSTRING( \
|
||||
"CREATE TEMPORARY VIEW moz_historyvisits_view AS " \
|
||||
"SELECT " MOZ_HISTORYVISITS_COLUMNS " FROM moz_historyvisits_temp " \
|
||||
"UNION ALL " \
|
||||
"SELECT " MOZ_HISTORYVISITS_COLUMNS " FROM moz_historyvisits " \
|
||||
"WHERE id NOT IN (SELECT id FROM moz_historyvisits_temp) " \
|
||||
)
|
||||
|
||||
|
||||
#define CREATE_MOZ_INPUTHISTORY NS_LITERAL_CSTRING( \
|
||||
"CREATE TABLE moz_inputhistory (" \
|
||||
|
@ -72,194 +72,35 @@
|
||||
"END" \
|
||||
)
|
||||
|
||||
/**
|
||||
* This trigger allows for an insertion into moz_places_view. It enters the new
|
||||
* data into the temporary table, ensuring that the new id is one greater than
|
||||
* the largest id value found.
|
||||
*/
|
||||
#define CREATE_PLACES_VIEW_INSERT_TRIGGER NS_LITERAL_CSTRING( \
|
||||
"CREATE TEMPORARY TRIGGER moz_places_view_insert_trigger " \
|
||||
"INSTEAD OF INSERT " \
|
||||
"ON moz_places_view " \
|
||||
"BEGIN " \
|
||||
"INSERT INTO moz_places_temp (" MOZ_PLACES_COLUMNS ") " \
|
||||
"VALUES (MAX(IFNULL((SELECT MAX(id) FROM moz_places_temp), 0), " \
|
||||
"IFNULL((SELECT MAX(id) FROM moz_places), 0)) + 1," \
|
||||
"NEW.url, NEW.title, NEW.rev_host, " \
|
||||
"IFNULL(NEW.visit_count, 0), " /* enforce having a value */ \
|
||||
"NEW.hidden, NEW.typed, NEW.favicon_id, NEW.frecency, " \
|
||||
"NEW.last_visit_date);" \
|
||||
"END" \
|
||||
)
|
||||
|
||||
/**
|
||||
* This trigger allows for the deletion of a record in moz_places_view. It
|
||||
* removes any entry in the temporary table, the permanent table, and any
|
||||
* associated entry in moz_openpages_temp.
|
||||
* This triggers update visit_count and last_visit_date based on historyvisits
|
||||
* table changes.
|
||||
*/
|
||||
#define CREATE_PLACES_VIEW_DELETE_TRIGGER NS_LITERAL_CSTRING( \
|
||||
"CREATE TEMPORARY TRIGGER moz_places_view_delete_trigger " \
|
||||
"INSTEAD OF DELETE " \
|
||||
"ON moz_places_view " \
|
||||
#define CREATE_HISTORYVISITS_AFTERINSERT_TRIGGER NS_LITERAL_CSTRING( \
|
||||
"CREATE TRIGGER moz_historyvisits_afterinsert_v2_trigger " \
|
||||
"AFTER INSERT ON moz_historyvisits FOR EACH ROW " \
|
||||
"BEGIN " \
|
||||
"DELETE FROM moz_places_temp " \
|
||||
"WHERE id = OLD.id; " \
|
||||
"DELETE FROM moz_places " \
|
||||
"WHERE id = OLD.id; " \
|
||||
"DELETE FROM moz_openpages_temp " \
|
||||
"WHERE place_id = OLD.id; " \
|
||||
"END" \
|
||||
)
|
||||
|
||||
/**
|
||||
* This trigger allows for updates to a record in moz_places_view. It first
|
||||
* copies the row from the permanent table over to the temp table if it does not
|
||||
* exist in the temporary table. Then, it will update the temporary table with
|
||||
* the new data.
|
||||
* We use INSERT OR IGNORE to avoid looking if the place already exists in the
|
||||
* temp table.
|
||||
*/
|
||||
#define CREATE_PLACES_VIEW_UPDATE_TRIGGER NS_LITERAL_CSTRING( \
|
||||
"CREATE TEMPORARY TRIGGER moz_places_view_update_trigger " \
|
||||
"INSTEAD OF UPDATE " \
|
||||
"ON moz_places_view " \
|
||||
"BEGIN " \
|
||||
"INSERT OR IGNORE INTO moz_places_temp (" MOZ_PLACES_COLUMNS ") " \
|
||||
"SELECT " MOZ_PLACES_COLUMNS " FROM moz_places " \
|
||||
"WHERE id = OLD.id; " \
|
||||
"UPDATE moz_places_temp " \
|
||||
"SET url = IFNULL(NEW.url, OLD.url), " \
|
||||
"title = IFNULL(NEW.title, OLD.title), " \
|
||||
"rev_host = IFNULL(NEW.rev_host, OLD.rev_host), " \
|
||||
"visit_count = IFNULL(NEW.visit_count, OLD.visit_count), " \
|
||||
"hidden = IFNULL(NEW.hidden, OLD.hidden), " \
|
||||
"typed = IFNULL(NEW.typed, OLD.typed), " \
|
||||
"favicon_id = IFNULL(NEW.favicon_id, OLD.favicon_id), " \
|
||||
"frecency = IFNULL(NEW.frecency, OLD.frecency), " \
|
||||
"last_visit_date = IFNULL(NEW.last_visit_date, OLD.last_visit_date) " \
|
||||
"WHERE id = OLD.id; " \
|
||||
"END" \
|
||||
)
|
||||
|
||||
/**
|
||||
* This trigger allows for an insertion into moz_historyvisits_view. It enters
|
||||
* the new data into the temporary table, ensuring that the new id is one
|
||||
* greater than the largest id value found. It then updates moz_places_view
|
||||
* with the new visit count.
|
||||
* We use INSERT OR IGNORE to avoid looking if the place already exists in the
|
||||
* temp table.
|
||||
* In this case when updating last_visit_date we can simply check the maximum
|
||||
* between new visit date and the actual cached value (or 0 if it is NULL).
|
||||
*/
|
||||
#define CREATE_HISTORYVISITS_VIEW_INSERT_TRIGGER NS_LITERAL_CSTRING( \
|
||||
"CREATE TEMPORARY TRIGGER moz_historyvisits_view_insert_trigger " \
|
||||
"INSTEAD OF INSERT " \
|
||||
"ON moz_historyvisits_view " \
|
||||
"BEGIN " \
|
||||
"INSERT INTO moz_historyvisits_temp (" MOZ_HISTORYVISITS_COLUMNS ") " \
|
||||
"VALUES (MAX(IFNULL((SELECT MAX(id) FROM moz_historyvisits_temp), 0), " \
|
||||
"IFNULL((SELECT MAX(id) FROM moz_historyvisits), 0)) + 1, " \
|
||||
"NEW.from_visit, NEW.place_id, NEW.visit_date, NEW.visit_type, " \
|
||||
"NEW.session); " \
|
||||
"INSERT OR IGNORE INTO moz_places_temp (" MOZ_PLACES_COLUMNS ") " \
|
||||
"SELECT " MOZ_PLACES_COLUMNS " FROM moz_places " \
|
||||
"WHERE id = NEW.place_id " \
|
||||
"AND NEW.visit_type NOT IN (" EXCLUDED_VISIT_TYPES "); " \
|
||||
"UPDATE moz_places_temp " \
|
||||
"SET visit_count = visit_count + 1 " \
|
||||
"WHERE id = NEW.place_id " \
|
||||
"AND NEW.visit_type NOT IN (" EXCLUDED_VISIT_TYPES "); " \
|
||||
"UPDATE moz_places_temp " \
|
||||
"SET last_visit_date = MAX(IFNULL(last_visit_date, 0), NEW.visit_date)" \
|
||||
"UPDATE moz_places SET " \
|
||||
"visit_count = visit_count + (SELECT NEW.visit_type NOT IN (" EXCLUDED_VISIT_TYPES ")), "\
|
||||
"last_visit_date = MAX(IFNULL(last_visit_date, 0), NEW.visit_date) " \
|
||||
"WHERE id = NEW.place_id;" \
|
||||
"END" \
|
||||
)
|
||||
|
||||
/**
|
||||
* This trigger allows for the deletion of a record in moz_historyvisits_view.
|
||||
* It removes any entry in the temporary table, and removes any entry in the
|
||||
* permanent table as well. It then updates moz_places_view with the new visit
|
||||
* count.
|
||||
* We use INSERT OR IGNORE to avoid looking if the place already exists in the
|
||||
* temp table.
|
||||
*/
|
||||
#define CREATE_HISTORYVISITS_VIEW_DELETE_TRIGGER NS_LITERAL_CSTRING( \
|
||||
"CREATE TEMPORARY TRIGGER moz_historyvisits_view_delete_trigger " \
|
||||
"INSTEAD OF DELETE " \
|
||||
"ON moz_historyvisits_view " \
|
||||
#define CREATE_HISTORYVISITS_AFTERDELETE_TRIGGER NS_LITERAL_CSTRING( \
|
||||
"CREATE TRIGGER moz_historyvisits_afterdelete_v2_trigger " \
|
||||
"AFTER DELETE ON moz_historyvisits FOR EACH ROW " \
|
||||
"BEGIN " \
|
||||
"DELETE FROM moz_historyvisits_temp " \
|
||||
"WHERE id = OLD.id; " \
|
||||
"DELETE FROM moz_historyvisits " \
|
||||
"WHERE id = OLD.id; " \
|
||||
"INSERT OR IGNORE INTO moz_places_temp (" MOZ_PLACES_COLUMNS ") " \
|
||||
"SELECT " MOZ_PLACES_COLUMNS " FROM moz_places " \
|
||||
"WHERE id = OLD.place_id " \
|
||||
"AND OLD.visit_type NOT IN (" EXCLUDED_VISIT_TYPES "); " \
|
||||
"UPDATE moz_places_temp " \
|
||||
"SET visit_count = visit_count - 1 " \
|
||||
"WHERE id = OLD.place_id " \
|
||||
"AND OLD.visit_type NOT IN (" EXCLUDED_VISIT_TYPES "); " \
|
||||
"UPDATE moz_places_temp " \
|
||||
"SET last_visit_date = " \
|
||||
"(SELECT visit_date FROM moz_historyvisits_temp " \
|
||||
"WHERE place_id = OLD.place_id " \
|
||||
"UNION ALL " \
|
||||
"SELECT visit_date FROM moz_historyvisits " \
|
||||
"WHERE place_id = OLD.place_id " \
|
||||
"ORDER BY visit_date DESC LIMIT 1) " \
|
||||
"WHERE id = OLD.place_id; " \
|
||||
"UPDATE moz_places SET " \
|
||||
"visit_count = visit_count - (SELECT OLD.visit_type NOT IN (" EXCLUDED_VISIT_TYPES ")), "\
|
||||
"last_visit_date = (SELECT visit_date FROM moz_historyvisits " \
|
||||
"WHERE place_id = OLD.place_id " \
|
||||
"ORDER BY visit_date DESC LIMIT 1) " \
|
||||
"WHERE id = OLD.place_id;" \
|
||||
"END" \
|
||||
)
|
||||
|
||||
/**
|
||||
* This trigger allows for updates to a record in moz_historyvisits_view. It
|
||||
* first copies the row from the permanent table over to the temp table if it
|
||||
* does not exist in the temporary table. Then it will update the temporary
|
||||
* table with the new data.
|
||||
* We use INSERT OR IGNORE to avoid looking if the visit already exists in the
|
||||
* temp table.
|
||||
*/
|
||||
#define CREATE_HISTORYVISITS_VIEW_UPDATE_TRIGGER NS_LITERAL_CSTRING( \
|
||||
"CREATE TEMPORARY TRIGGER moz_historyvisits_view_update_trigger " \
|
||||
"INSTEAD OF UPDATE " \
|
||||
"ON moz_historyvisits_view " \
|
||||
"BEGIN " \
|
||||
"INSERT OR IGNORE INTO moz_historyvisits_temp (" MOZ_HISTORYVISITS_COLUMNS ") " \
|
||||
"SELECT " MOZ_HISTORYVISITS_COLUMNS " FROM moz_historyvisits " \
|
||||
"WHERE id = OLD.id; " \
|
||||
"UPDATE moz_historyvisits_temp " \
|
||||
"SET from_visit = IFNULL(NEW.from_visit, OLD.from_visit), " \
|
||||
"place_id = IFNULL(NEW.place_id, OLD.place_id), " \
|
||||
"visit_date = IFNULL(NEW.visit_date, OLD.visit_date), " \
|
||||
"visit_type = IFNULL(NEW.visit_type, OLD.visit_type), " \
|
||||
"session = IFNULL(NEW.session, OLD.session) " \
|
||||
"WHERE id = OLD.id; " \
|
||||
"END" \
|
||||
)
|
||||
|
||||
/**
|
||||
* This trigger moves the data out of a temporary table into the permanent one
|
||||
* before deleting from the temporary table.
|
||||
*
|
||||
* Note - it's OK to use an INSERT OR REPLACE here because the only conflict
|
||||
* that will happen is the primary key. As a result, the row will be deleted,
|
||||
* and the replacement will be inserted with the same id.
|
||||
*/
|
||||
#define CREATE_TEMP_SYNC_TRIGGER_BASE(__table, __columns) NS_LITERAL_CSTRING( \
|
||||
"CREATE TEMPORARY TRIGGER " __table "_beforedelete_trigger " \
|
||||
"BEFORE DELETE ON " __table "_temp FOR EACH ROW " \
|
||||
"BEGIN " \
|
||||
"INSERT OR REPLACE INTO " __table " (" __columns ") " \
|
||||
"SELECT " __columns " FROM " __table "_temp " \
|
||||
"WHERE id = OLD.id;" \
|
||||
"END" \
|
||||
)
|
||||
#define CREATE_MOZ_PLACES_SYNC_TRIGGER \
|
||||
CREATE_TEMP_SYNC_TRIGGER_BASE("moz_places", MOZ_PLACES_COLUMNS)
|
||||
#define CREATE_MOZ_HISTORYVISITS_SYNC_TRIGGER \
|
||||
CREATE_TEMP_SYNC_TRIGGER_BASE("moz_historyvisits", MOZ_HISTORYVISITS_COLUMNS)
|
||||
|
||||
|
||||
/**
|
||||
* This trigger removes a row from moz_openpages_temp when open_count reaches 0.
|
||||
|
@ -8,12 +8,6 @@ contract @mozilla.org/browser/tagging-service;1 {bbc23860-2553-479d-8b78-94d9038
|
||||
component {1dcc23b0-d4cb-11dc-9ad6-479d56d89593} nsTaggingService.js
|
||||
contract @mozilla.org/autocomplete/search;1?name=places-tag-autocomplete {1dcc23b0-d4cb-11dc-9ad6-479d56d89593}
|
||||
|
||||
# nsPlacesDBFlush.js
|
||||
component {c1751cfc-e8f1-4ade-b0bb-f74edfb8ef6a} nsPlacesDBFlush.js
|
||||
contract @mozilla.org/places/sync;1 {c1751cfc-e8f1-4ade-b0bb-f74edfb8ef6a}
|
||||
category bookmark-observers nsPlacesDBFlush @mozilla.org/places/sync;1
|
||||
category history-observers nsPlacesDBFlush @mozilla.org/places/sync;1
|
||||
|
||||
# nsPlacesExpiration.js
|
||||
component {705a423f-2f69-42f3-b9fe-1517e0dee56f} nsPlacesExpiration.js
|
||||
contract @mozilla.org/places/expiration;1 {705a423f-2f69-42f3-b9fe-1517e0dee56f}
|
||||
|
@ -49,7 +49,6 @@ MODULE = test_places
|
||||
XPCSHELL_TESTS = \
|
||||
autocomplete \
|
||||
expiration \
|
||||
sync \
|
||||
bookmarks \
|
||||
queries \
|
||||
unit \
|
||||
|
@ -72,7 +72,7 @@ function run_test()
|
||||
// open the result container
|
||||
queryRes.root.containerOpen = true;
|
||||
// debug queries
|
||||
// dump_table("moz_places_view");
|
||||
// dump_table("moz_places");
|
||||
do_check_eq(queryRes.root.childCount, 1);
|
||||
// call the untested code path
|
||||
listener.onValueRemoved(null, uri.spec, true);
|
||||
|
@ -36,8 +36,6 @@ var conn = PlacesUtils.history.QueryInterface(Ci.nsPIPlacesDatabase).DBConnectio
|
||||
function getColumn(table, column, fromColumnName, fromColumnValue)
|
||||
{
|
||||
var stmt = conn.createStatement(
|
||||
"SELECT " + column + " FROM " + table + "_temp WHERE " + fromColumnName + "=:val " +
|
||||
"UNION ALL " +
|
||||
"SELECT " + column + " FROM " + table + " WHERE " + fromColumnName + "=:val " +
|
||||
"LIMIT 1");
|
||||
try {
|
||||
|
@ -51,8 +51,6 @@ var conn = PlacesUtils.history.QueryInterface(Ci.nsPIPlacesDatabase).DBConnectio
|
||||
function getColumn(table, column, fromColumnName, fromColumnValue)
|
||||
{
|
||||
var stmt = conn.createStatement(
|
||||
"SELECT " + column + " FROM " + table + "_temp WHERE " + fromColumnName + "=:val " +
|
||||
"UNION ALL " +
|
||||
"SELECT " + column + " FROM " + table + " WHERE " + fromColumnName + "=:val " +
|
||||
"LIMIT 1");
|
||||
try {
|
||||
|
@ -182,16 +182,12 @@ do_get_place(nsIURI* aURI, PlaceRecord& result)
|
||||
do_check_success(rv);
|
||||
|
||||
rv = dbConn->CreateStatement(NS_LITERAL_CSTRING(
|
||||
"SELECT id, hidden, typed, visit_count FROM moz_places_temp "
|
||||
"WHERE url=?1 "
|
||||
"UNION ALL "
|
||||
"SELECT id, hidden, typed, visit_count FROM moz_places "
|
||||
"WHERE url=?1 "
|
||||
"LIMIT 1"
|
||||
), getter_AddRefs(stmt));
|
||||
do_check_success(rv);
|
||||
|
||||
rv = stmt->BindUTF8StringParameter(0, spec);
|
||||
rv = stmt->BindUTF8StringByIndex(0, spec);
|
||||
do_check_success(rv);
|
||||
|
||||
PRBool hasResults;
|
||||
@ -222,16 +218,13 @@ do_get_lastVisit(PRInt64 placeId, VisitRecord& result)
|
||||
nsCOMPtr<mozIStorageStatement> stmt;
|
||||
|
||||
nsresult rv = dbConn->CreateStatement(NS_LITERAL_CSTRING(
|
||||
"SELECT id, from_visit, visit_type FROM moz_historyvisits_temp "
|
||||
"WHERE place_id=?1 "
|
||||
"UNION ALL "
|
||||
"SELECT id, from_visit, visit_type FROM moz_historyvisits "
|
||||
"WHERE place_id=?1 "
|
||||
"LIMIT 1"
|
||||
), getter_AddRefs(stmt));
|
||||
do_check_success(rv);
|
||||
|
||||
rv = stmt->BindInt64Parameter(0, placeId);
|
||||
rv = stmt->BindInt64ByIndex(0, placeId);
|
||||
do_check_success(rv);
|
||||
|
||||
PRBool hasResults;
|
||||
|
@ -90,7 +90,7 @@ function add_old_anno(aIdentifier, aName, aValue, aExpirePolicy,
|
||||
// Update dateAdded for the last added annotation.
|
||||
sql = "UPDATE moz_annos SET dateAdded = :expire_date, lastModified = :last_modified " +
|
||||
"WHERE id = (SELECT a.id FROM moz_annos a " +
|
||||
"LEFT JOIN moz_places_view h on h.id = a.place_id " +
|
||||
"LEFT JOIN moz_places h on h.id = a.place_id " +
|
||||
"WHERE h.url = :id " +
|
||||
"ORDER BY a.dateAdded DESC LIMIT 1)";
|
||||
}
|
||||
|
@ -88,7 +88,7 @@ function add_old_anno(aIdentifier, aName, aValue, aExpirePolicy,
|
||||
"WHERE id = ( " +
|
||||
"SELECT a.id FROM moz_annos a " +
|
||||
"JOIN moz_anno_attributes n ON n.id = a.anno_attribute_id " +
|
||||
"JOIN moz_places_view h on h.id = a.place_id " +
|
||||
"JOIN moz_places h on h.id = a.place_id " +
|
||||
"WHERE h.url = :id " +
|
||||
"AND n.name = :anno_name " +
|
||||
"ORDER BY a.dateAdded DESC LIMIT 1 " +
|
||||
|
@ -457,34 +457,3 @@ function is_time_ordered(before, after) {
|
||||
let skew = isWindows ? 20000000 : 0;
|
||||
return after - before > -skew;
|
||||
}
|
||||
|
||||
|
||||
// These tests are known to randomly fail due to bug 507790 when database
|
||||
// flushes are active, so we turn off syncing for them.
|
||||
let (randomFailingSyncTests = [
|
||||
"test_multi_word_tags.js",
|
||||
"test_removeVisitsByTimeframe.js",
|
||||
"test_utils_getURLsForContainerNode.js",
|
||||
"test_exclude_livemarks.js",
|
||||
"test_402799.js",
|
||||
"test_results-as-visit.js",
|
||||
"test_sorting.js",
|
||||
"test_redirectsMode.js",
|
||||
"test_384228.js",
|
||||
"test_395593.js",
|
||||
"test_containersQueries_sorting.js",
|
||||
"test_browserGlue_smartBookmarks.js",
|
||||
"test_browserGlue_distribution.js",
|
||||
"test_331487.js",
|
||||
"test_tags.js",
|
||||
"test_385829.js",
|
||||
"test_405938_restore_queries.js",
|
||||
]) {
|
||||
let currentTestFilename = do_get_file(_TEST_FILE[0], true).leafName;
|
||||
if (randomFailingSyncTests.indexOf(currentTestFilename) != -1) {
|
||||
print("Test " + currentTestFilename +
|
||||
" is known random due to bug 507790, disabling PlacesDBFlush.");
|
||||
let sync = Cc["@mozilla.org/places/sync;1"].getService(Ci.nsIObserver);
|
||||
sync.observe(null, "places-debug-stop-sync", null);
|
||||
}
|
||||
}
|
||||
|
@ -158,11 +158,11 @@ function checkDB(data){
|
||||
ghist.addURI(this.mChannel.URI, true, true, referrer);
|
||||
|
||||
// Get all pages visited from the original typed one
|
||||
var sql = "SELECT url FROM moz_historyvisits_view " +
|
||||
"JOIN moz_places_view h ON h.id = place_id " +
|
||||
var sql = "SELECT url FROM moz_historyvisits " +
|
||||
"JOIN moz_places h ON h.id = place_id " +
|
||||
"WHERE from_visit IN " +
|
||||
"(SELECT v.id FROM moz_historyvisits_view v " +
|
||||
"JOIN moz_places_view p ON p.id = v.place_id " +
|
||||
"(SELECT v.id FROM moz_historyvisits v " +
|
||||
"JOIN moz_places p ON p.id = v.place_id " +
|
||||
"WHERE p.url = ?1)";
|
||||
var stmt = mDBConn.createStatement(sql);
|
||||
stmt.bindUTF8StringParameter(0, typedURI.spec);
|
||||
|
@ -109,8 +109,8 @@ function run_test() {
|
||||
function continue_test() {
|
||||
let stmt = DBConn().createStatement(
|
||||
"SELECT v.id, h.url, v.from_visit, v.visit_date, v.visit_type, v.session " +
|
||||
"FROM moz_historyvisits_view v " +
|
||||
"JOIN moz_places_view h on h.id = v.place_id " +
|
||||
"FROM moz_historyvisits v " +
|
||||
"JOIN moz_places h on h.id = v.place_id " +
|
||||
"ORDER BY v.id ASC");
|
||||
const EXPECTED = [
|
||||
{ id: 1,
|
||||
|
@ -85,7 +85,7 @@ function populateDB(aArray) {
|
||||
if (qdata.title && !qdata.isDetails) {
|
||||
// Set the page title synchronously, otherwise setPageTitle is LAZY.
|
||||
let stmt = DBConn().createStatement(
|
||||
"UPDATE moz_places_view SET title = :title WHERE url = :url"
|
||||
"UPDATE moz_places SET title = :title WHERE url = :url"
|
||||
);
|
||||
stmt.params.title = qdata.title;
|
||||
stmt.params.url = qdata.uri;
|
||||
@ -102,7 +102,7 @@ function populateDB(aArray) {
|
||||
// Set a fake visit_count, this is not a real count but can be used
|
||||
// to test sorting by visit_count.
|
||||
let stmt = DBConn().createStatement(
|
||||
"UPDATE moz_places_view SET visit_count = :vc WHERE url = :url");
|
||||
"UPDATE moz_places SET visit_count = :vc WHERE url = :url");
|
||||
stmt.params.vc = qdata.visitCount;
|
||||
stmt.params.url = qdata.uri;
|
||||
try {
|
||||
|
@ -100,10 +100,8 @@ function run_test() {
|
||||
testData[i].title = null;
|
||||
}
|
||||
|
||||
dump_table("moz_places");
|
||||
dump_table("moz_places_temp");
|
||||
dump_table("moz_historyvisits");
|
||||
dump_table("moz_historyvisits_temp");
|
||||
//dump_table("moz_places");
|
||||
//dump_table("moz_historyvisits");
|
||||
|
||||
var numSortFunc = function (a,b) { return (a - b); };
|
||||
var arrs = testDataTyped.concat(testDataDownload).concat(testDataBookmark)
|
||||
|
@ -45,8 +45,6 @@ var histsvc = Cc["@mozilla.org/browser/nav-history-service;1"].
|
||||
var bhist = histsvc.QueryInterface(Ci.nsIBrowserHistory);
|
||||
var bmsvc = Cc["@mozilla.org/browser/nav-bookmarks-service;1"].
|
||||
getService(Ci.nsINavBookmarksService);
|
||||
var ios = Cc["@mozilla.org/network/io-service;1"].
|
||||
getService(Components.interfaces.nsIIOService);
|
||||
|
||||
/**
|
||||
* Function prohibits an attempt to pop up a confirmation
|
||||
@ -249,22 +247,13 @@ function run_test() {
|
||||
var pb = get_PBSvc();
|
||||
|
||||
if (pb) { // Private Browsing might not be available
|
||||
// need to catch places sync notifications
|
||||
var os = Cc["@mozilla.org/observer-service;1"].
|
||||
getService(Ci.nsIObserverService);
|
||||
const kSyncFinished = "places-sync-finished";
|
||||
do_test_pending();
|
||||
|
||||
var prefBranch = Cc["@mozilla.org/preferences-service;1"].
|
||||
getService(Ci.nsIPrefBranch);
|
||||
prefBranch.setBoolPref("browser.privatebrowsing.keep_current_session", true);
|
||||
|
||||
var bookmark_A_URI = ios.newURI("http://google.com/", null, null);
|
||||
var bookmark_B_URI = ios.newURI("http://bugzilla.mozilla.org/", null, null);
|
||||
var onBookmarkAAdded = {
|
||||
observe: function (aSubject, aTopic, aData) {
|
||||
os.removeObserver(this, kSyncFinished);
|
||||
Services.prefs.setBoolPref("browser.privatebrowsing.keep_current_session", true);
|
||||
|
||||
var bookmark_A_URI = NetUtil.newURI("http://google.com/");
|
||||
var bookmark_B_URI = NetUtil.newURI("http://bugzilla.mozilla.org/");
|
||||
var onBookmarkAAdded = function() {
|
||||
check_placesItem_Count();
|
||||
|
||||
// Bookmark-A should be bookmarked, data should be retrievable
|
||||
@ -298,16 +287,11 @@ function run_test() {
|
||||
do_check_true(bmsvc.isBookmarked(bookmark_A_URI));
|
||||
do_check_eq("google",bmsvc.getKeywordForURI(bookmark_A_URI));
|
||||
|
||||
os.addObserver(onBookmarkBAdded, kSyncFinished, false);
|
||||
|
||||
// Create Bookmark-B
|
||||
myBookmarks[1] = create_bookmark(bookmark_B_URI,"title 2", "bugzilla");
|
||||
}
|
||||
onBookmarkBAdded();
|
||||
};
|
||||
var onBookmarkBAdded = {
|
||||
observe: function (aSubject, aTopic, aData) {
|
||||
os.removeObserver(this, kSyncFinished);
|
||||
|
||||
var onBookmarkBAdded = function() {
|
||||
// A check on the history count should be same as before, 7 history entries with
|
||||
// now 2 bookmark items (A) and bookmark (B), so we set num_places_entries to 9
|
||||
num_places_entries = 10; // Bookmark-B successfully added but not the history entries.
|
||||
@ -330,9 +314,8 @@ function run_test() {
|
||||
do_check_true(bhist.isVisited(uri(visited_uri)));
|
||||
}
|
||||
|
||||
prefBranch.clearUserPref("browser.privatebrowsing.keep_current_session");
|
||||
Services.prefs.clearUserPref("browser.privatebrowsing.keep_current_session");
|
||||
do_test_finished();
|
||||
}
|
||||
};
|
||||
|
||||
// History database should be empty
|
||||
@ -344,8 +327,6 @@ function run_test() {
|
||||
// History database should have entries
|
||||
do_check_true(histsvc.hasHistoryEntries);
|
||||
|
||||
os.addObserver(onBookmarkAAdded, kSyncFinished, false);
|
||||
|
||||
// Create Bookmark-A
|
||||
myBookmarks[0] = create_bookmark(bookmark_A_URI,"title 1", "google");
|
||||
|
||||
@ -354,5 +335,7 @@ function run_test() {
|
||||
do_check_true(bhist.isVisited(uri(visited_uri)));
|
||||
do_check_true(uri_in_db(uri(visited_uri)));
|
||||
}
|
||||
|
||||
onBookmarkAAdded();
|
||||
}
|
||||
}
|
||||
|
@ -292,7 +292,7 @@ function getFrecency(url)
|
||||
var stmt;
|
||||
var frecency;
|
||||
|
||||
sql = "SELECT frecency FROM moz_places_view WHERE url = ?1";
|
||||
sql = "SELECT frecency FROM moz_places WHERE url = ?1";
|
||||
stmt = dbConn.createStatement(sql);
|
||||
stmt.bindUTF8StringParameter(0, url);
|
||||
do_check_true(stmt.executeStep());
|
||||
@ -307,7 +307,7 @@ function prepTest(testName, callback)
|
||||
{
|
||||
print("Test: " + testName);
|
||||
waitForClearHistory(function() {
|
||||
dbConn.executeSimpleSQL("DELETE FROM moz_places_view");
|
||||
dbConn.executeSimpleSQL("DELETE FROM moz_places");
|
||||
dbConn.executeSimpleSQL("DELETE FROM moz_bookmarks WHERE id > " +
|
||||
defaultBookmarksMaxId);
|
||||
callback();
|
||||
|
@ -57,7 +57,7 @@ function add_visit(aURI, aVisitDate, aVisitType) {
|
||||
aVisitType != hs.TRANSITION_DOWNLOAD)
|
||||
visit_count ++;
|
||||
// Get the place id
|
||||
var sql = "SELECT place_id FROM moz_historyvisits_view WHERE id = ?1";
|
||||
var sql = "SELECT place_id FROM moz_historyvisits WHERE id = ?1";
|
||||
var stmt = mDBConn.createStatement(sql);
|
||||
stmt.bindInt64Parameter(0, visitId);
|
||||
do_check_true(stmt.executeStep());
|
||||
|
@ -138,8 +138,8 @@ let historyObserver = {
|
||||
return;
|
||||
|
||||
// dump tables, useful if the test fails.
|
||||
dump_table("moz_places_temp");
|
||||
dump_table("moz_favicons");
|
||||
//dump_table("moz_places");
|
||||
//dump_table("moz_favicons");
|
||||
|
||||
// Ensure we have been called by the last test.
|
||||
do_check_true(pageURI.equals(uri("http://test4.bar/")));
|
||||
|
@ -51,12 +51,8 @@ let os = Cc["@mozilla.org/observer-service;1"].
|
||||
let lms = Cc["@mozilla.org/browser/livemark-service;2"].
|
||||
getService(Ci.nsILivemarkService);
|
||||
|
||||
const kSyncFinished = "places-sync-finished";
|
||||
const kExpirationFinished = "places-expiration-finished";
|
||||
|
||||
// Number of expected sync notifications, we expect one per bookmark.
|
||||
const EXPECTED_SYNCS = 4;
|
||||
|
||||
function add_fake_livemark() {
|
||||
let lmId = lms.createLivemarkFolderOnly(bs.toolbarFolder,
|
||||
"Livemark",
|
||||
@ -91,42 +87,84 @@ let observer = {
|
||||
// check browserHistory returns no entries
|
||||
do_check_eq(0, bh.count);
|
||||
|
||||
// Check that frecency for not cleared items (bookmarks) has been converted
|
||||
// to -MAX(visit_count, 1), so we will be able to recalculate frecency
|
||||
// starting from most frecent bookmarks.
|
||||
stmt = mDBConn.createStatement(
|
||||
"SELECT h.id FROM moz_places h WHERE h.frecency > 0 " +
|
||||
"AND EXISTS (SELECT id FROM moz_bookmarks WHERE fk = h.id) LIMIT 1");
|
||||
do_check_false(stmt.executeStep());
|
||||
stmt.finalize();
|
||||
|
||||
stmt = mDBConn.createStatement(
|
||||
"SELECT h.id FROM moz_places h WHERE h.frecency = -2 " +
|
||||
"AND EXISTS (SELECT id FROM moz_bookmarks WHERE fk = h.id) LIMIT 1");
|
||||
do_check_true(stmt.executeStep());
|
||||
stmt.finalize();
|
||||
|
||||
let expirationObserver = {
|
||||
observe: function (aSubject, aTopic, aData) {
|
||||
os.removeObserver(this, kExpirationFinished, false);
|
||||
|
||||
// Check that frecency for not cleared items (bookmarks) has been converted
|
||||
// to -MAX(visit_count, 1), so we will be able to recalculate frecency
|
||||
// starting from most frecent bookmarks.
|
||||
// Memory table has been updated, disk table has not
|
||||
stmt = mDBConn.createStatement(
|
||||
"SELECT id FROM moz_places_temp WHERE frecency > 0 LIMIT 1");
|
||||
do_check_false(stmt.executeStep());
|
||||
stmt.finalize();
|
||||
|
||||
stmt = mDBConn.createStatement(
|
||||
"SELECT h.id FROM moz_places_temp h WHERE h.frecency = -2 " +
|
||||
"AND EXISTS (SELECT id FROM moz_bookmarks WHERE fk = h.id) LIMIT 1");
|
||||
do_check_true(stmt.executeStep());
|
||||
stmt.finalize();
|
||||
|
||||
// Check that all visit_counts have been brought to 0
|
||||
stmt = mDBConn.createStatement(
|
||||
"SELECT id FROM moz_places_temp WHERE visit_count <> 0 LIMIT 1");
|
||||
"SELECT id FROM moz_places WHERE visit_count <> 0 LIMIT 1");
|
||||
do_check_false(stmt.executeStep());
|
||||
stmt.finalize();
|
||||
|
||||
// Check that history tables are empty
|
||||
stmt = mDBConn.createStatement(
|
||||
"SELECT * FROM (SELECT id FROM moz_historyvisits_temp LIMIT 1) " +
|
||||
"UNION ALL " +
|
||||
"SELECT * FROM (SELECT id FROM moz_historyvisits LIMIT 1)");
|
||||
do_check_false(stmt.executeStep());
|
||||
stmt.finalize();
|
||||
|
||||
// force a sync and check again disk tables, insertBookmark will do that
|
||||
bs.insertBookmark(bs.unfiledBookmarksFolder, uri("place:folder=4"),
|
||||
bs.DEFAULT_INDEX, "shortcut");
|
||||
// Check that all moz_places entries except bookmarks and place: have been removed
|
||||
stmt = mDBConn.createStatement(
|
||||
"SELECT h.id FROM moz_places h WHERE SUBSTR(h.url, 1, 6) <> 'place:' "+
|
||||
"AND NOT EXISTS (SELECT id FROM moz_bookmarks WHERE fk = h.id) LIMIT 1");
|
||||
do_check_false(stmt.executeStep());
|
||||
stmt.finalize();
|
||||
|
||||
// Check that we only have favicons for retained places
|
||||
stmt = mDBConn.createStatement(
|
||||
"SELECT f.id FROM moz_favicons f WHERE NOT EXISTS " +
|
||||
"(SELECT id FROM moz_places WHERE favicon_id = f.id) LIMIT 1");
|
||||
do_check_false(stmt.executeStep());
|
||||
stmt.finalize();
|
||||
|
||||
// Check that we only have annotations for retained places
|
||||
stmt = mDBConn.createStatement(
|
||||
"SELECT a.id FROM moz_annos a WHERE NOT EXISTS " +
|
||||
"(SELECT id FROM moz_places WHERE id = a.place_id) LIMIT 1");
|
||||
do_check_false(stmt.executeStep());
|
||||
stmt.finalize();
|
||||
|
||||
// Check that we only have inputhistory for retained places
|
||||
stmt = mDBConn.createStatement(
|
||||
"SELECT i.place_id FROM moz_inputhistory i WHERE NOT EXISTS " +
|
||||
"(SELECT id FROM moz_places WHERE id = i.place_id) LIMIT 1");
|
||||
do_check_false(stmt.executeStep());
|
||||
stmt.finalize();
|
||||
|
||||
// Check that place:uris have frecency 0
|
||||
stmt = mDBConn.createStatement(
|
||||
"SELECT h.id FROM moz_places h " +
|
||||
"WHERE SUBSTR(h.url, 1, 6) = 'place:' AND h.frecency <> 0 LIMIT 1");
|
||||
do_check_false(stmt.executeStep());
|
||||
stmt.finalize();
|
||||
|
||||
// Check that livemarks children don't have frecency <> 0
|
||||
stmt = mDBConn.createStatement(
|
||||
"SELECT h.id FROM moz_places h " +
|
||||
"JOIN moz_bookmarks b ON h.id = b.fk " +
|
||||
"JOIN moz_bookmarks bp ON bp.id = b.parent " +
|
||||
"JOIN moz_items_annos t ON t.item_id = bp.id " +
|
||||
"JOIN moz_anno_attributes n ON t.anno_attribute_id = n.id " +
|
||||
"WHERE n.name = 'livemark/feedURI' AND h.frecency <> 0 LIMIT 1");
|
||||
do_check_false(stmt.executeStep());
|
||||
stmt.finalize();
|
||||
|
||||
do_test_finished();
|
||||
}
|
||||
}
|
||||
os.addObserver(expirationObserver, kExpirationFinished, false);
|
||||
@ -137,105 +175,12 @@ let observer = {
|
||||
onDeleteVisits: function() {
|
||||
},
|
||||
|
||||
QueryInterface: function(iid) {
|
||||
if (iid.equals(Ci.nsINavHistoryObserver) ||
|
||||
iid.equals(Ci.nsISupports)) {
|
||||
return this;
|
||||
}
|
||||
throw Cr.NS_ERROR_NO_INTERFACE;
|
||||
}
|
||||
QueryInterface: XPCOMUtils.generateQI([
|
||||
Ci.nsINavHistoryObserver
|
||||
]);
|
||||
}
|
||||
hs.addObserver(observer, false);
|
||||
|
||||
let syncObserver = {
|
||||
_runCount: 0,
|
||||
observe: function (aSubject, aTopic, aData) {
|
||||
if (++this._runCount < EXPECTED_SYNCS)
|
||||
return;
|
||||
if (this._runCount == EXPECTED_SYNCS) {
|
||||
bh.removeAllPages();
|
||||
return;
|
||||
}
|
||||
os.removeObserver(this, kSyncFinished, false);
|
||||
|
||||
// Sanity: check that places temp table is empty
|
||||
stmt = mDBConn.createStatement(
|
||||
"SELECT id FROM moz_places_temp LIMIT 1");
|
||||
do_check_false(stmt.executeStep());
|
||||
stmt.finalize();
|
||||
|
||||
// Check that frecency for not cleared items (bookmarks) has been converted
|
||||
// to -MAX(visit_count, 1), so we will be able to recalculate frecency
|
||||
// starting from most frecent bookmarks.
|
||||
stmt = mDBConn.createStatement(
|
||||
"SELECT id FROM moz_places WHERE frecency > 0 LIMIT 1");
|
||||
do_check_false(stmt.executeStep());
|
||||
stmt.finalize();
|
||||
|
||||
stmt = mDBConn.createStatement(
|
||||
"SELECT h.id FROM moz_places h WHERE h.frecency = -2 " +
|
||||
"AND EXISTS (SELECT id FROM moz_bookmarks WHERE fk = h.id) LIMIT 1");
|
||||
do_check_true(stmt.executeStep());
|
||||
stmt.finalize();
|
||||
|
||||
// Check that all visit_counts have been brought to 0
|
||||
stmt = mDBConn.createStatement(
|
||||
"SELECT id FROM moz_places WHERE visit_count <> 0 LIMIT 1");
|
||||
do_check_false(stmt.executeStep());
|
||||
stmt.finalize();
|
||||
|
||||
// Check that all moz_places entries except bookmarks and place: have been removed
|
||||
stmt = mDBConn.createStatement(
|
||||
"SELECT h.id FROM moz_places h WHERE SUBSTR(h.url, 1, 6) <> 'place:' "+
|
||||
"AND NOT EXISTS (SELECT id FROM moz_bookmarks WHERE fk = h.id) LIMIT 1");
|
||||
do_check_false(stmt.executeStep());
|
||||
stmt.finalize();
|
||||
|
||||
// Check that we only have favicons for retained places
|
||||
stmt = mDBConn.createStatement(
|
||||
"SELECT f.id FROM moz_favicons f WHERE NOT EXISTS " +
|
||||
"(SELECT id FROM moz_places WHERE favicon_id = f.id) LIMIT 1");
|
||||
do_check_false(stmt.executeStep());
|
||||
stmt.finalize();
|
||||
|
||||
// Check that we only have annotations for retained places
|
||||
stmt = mDBConn.createStatement(
|
||||
"SELECT a.id FROM moz_annos a WHERE NOT EXISTS " +
|
||||
"(SELECT id FROM moz_places WHERE id = a.place_id) LIMIT 1");
|
||||
do_check_false(stmt.executeStep());
|
||||
stmt.finalize();
|
||||
|
||||
// Check that we only have inputhistory for retained places
|
||||
stmt = mDBConn.createStatement(
|
||||
"SELECT i.place_id FROM moz_inputhistory i WHERE NOT EXISTS " +
|
||||
"(SELECT id FROM moz_places WHERE id = i.place_id) LIMIT 1");
|
||||
do_check_false(stmt.executeStep());
|
||||
stmt.finalize();
|
||||
|
||||
// Check that place:uris have frecency 0
|
||||
stmt = mDBConn.createStatement(
|
||||
"SELECT h.id FROM moz_places h " +
|
||||
"WHERE SUBSTR(h.url, 1, 6) = 'place:' AND h.frecency <> 0 LIMIT 1");
|
||||
do_check_false(stmt.executeStep());
|
||||
stmt.finalize();
|
||||
|
||||
// Check that livemarks children don't have frecency <> 0
|
||||
stmt = mDBConn.createStatement(
|
||||
"SELECT h.id FROM moz_places h " +
|
||||
"JOIN moz_bookmarks b ON h.id = b.fk " +
|
||||
"JOIN moz_bookmarks bp ON bp.id = b.parent " +
|
||||
"JOIN moz_items_annos t ON t.item_id = bp.id " +
|
||||
"JOIN moz_anno_attributes n ON t.anno_attribute_id = n.id " +
|
||||
"WHERE n.name = 'livemark/feedURI' AND h.frecency <> 0 LIMIT 1");
|
||||
do_check_false(stmt.executeStep());
|
||||
stmt.finalize();
|
||||
|
||||
do_test_finished();
|
||||
}
|
||||
}
|
||||
os.addObserver(syncObserver, kSyncFinished, false);
|
||||
|
||||
// main
|
||||
function run_test() {
|
||||
// Add a livemark with a visited and an unvisited child
|
||||
add_fake_livemark();
|
||||
@ -269,13 +214,23 @@ function run_test() {
|
||||
|
||||
// Add a bookmark
|
||||
// Bookmarked page should have history cleared and frecency = -old_visit_count
|
||||
// This will also finally sync temp tables to disk
|
||||
bs.insertBookmark(bs.unfiledBookmarksFolder, uri("http://typed.mozilla.org"),
|
||||
bs.DEFAULT_INDEX, "bookmark");
|
||||
|
||||
// this visit is not synced to disk
|
||||
hs.addVisit(uri("http://typed.mozilla.org"), Date.now(), null,
|
||||
hs.TRANSITION_BOOKMARK, false, 0);
|
||||
|
||||
// Since we are checking frecency, we have to disable some stuff that could
|
||||
// change values during test run. On idle-daily frecencies are updated.
|
||||
Services.obs.removeObserver(hs, "idle-daily");
|
||||
|
||||
// executeSoon allows us to fire the places-init-complete notification before
|
||||
// the removeAllPages call. Since we are creating a new database, on that
|
||||
// notification we will act on initial frecency, and that could disturb
|
||||
// this test's frecency checks.
|
||||
do_execute_soon(function () {
|
||||
bh.removeAllPages();
|
||||
});
|
||||
|
||||
do_test_pending();
|
||||
}
|
||||
|
@ -72,7 +72,7 @@ function run_test() {
|
||||
|
||||
_("Now that places has migrated, check that it calculated frecencies");
|
||||
var stmt = places.DBConnection.createStatement(
|
||||
"SELECT COUNT(*) FROM moz_places_view WHERE frecency < 0");
|
||||
"SELECT COUNT(*) FROM moz_places WHERE frecency < 0");
|
||||
stmt.executeAsync({
|
||||
handleResult: function(results) {
|
||||
_("Should always get a result from COUNT(*)");
|
||||
|
@ -390,7 +390,7 @@ function deleteAllHistoryAndBookmarks() {
|
||||
* @return the frecency of aURI
|
||||
*/
|
||||
function getFrecencyForURI(aURI) {
|
||||
let sql = "SELECT frecency FROM moz_places_view WHERE url = :url";
|
||||
let sql = "SELECT frecency FROM moz_places WHERE url = :url";
|
||||
let stmt = dbConn.createStatement(sql);
|
||||
stmt.params.url = aURI.spec;
|
||||
do_check_true(stmt.executeStep());
|
||||
@ -407,7 +407,7 @@ function getFrecencyForURI(aURI) {
|
||||
* the URI of a place
|
||||
*/
|
||||
function uriExistsInMozPlaces(aURI) {
|
||||
let sql = "SELECT id FROM moz_places_view WHERE url = :url";
|
||||
let sql = "SELECT id FROM moz_places WHERE url = :url";
|
||||
let stmt = dbConn.createStatement(sql);
|
||||
stmt.params.url = aURI.spec;
|
||||
var exists = stmt.executeStep();
|
||||
|
@ -345,7 +345,7 @@ function createLivemark(aLmChildItemURI) {
|
||||
* @return the frecency of aURL
|
||||
*/
|
||||
function getFrecency(aURL) {
|
||||
let sql = "SELECT frecency FROM moz_places_view WHERE url = :url";
|
||||
let sql = "SELECT frecency FROM moz_places WHERE url = :url";
|
||||
let stmt = dbConn.createStatement(sql);
|
||||
stmt.params.url = aURL;
|
||||
do_check_true(stmt.executeStep());
|
||||
|
Loading…
Reference in New Issue
Block a user