From a77374a40d40fced69a5bbf121afeeb352bc3347 Mon Sep 17 00:00:00 2001 From: "sdwilsh%shawnwilsher.com" Date: Tue, 21 Apr 2009 15:44:09 +0000 Subject: [PATCH] Bug 487660 - Places depends on buggy behavior of SQLite's SUBSTR. r=dietrich, a=dveditz git-svn-id: svn://10.0.0.236/trunk@256999 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/toolkit/components/places/src/nsNavHistory.cpp | 6 +++--- .../toolkit/components/places/src/nsNavHistoryExpire.cpp | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/mozilla/toolkit/components/places/src/nsNavHistory.cpp b/mozilla/toolkit/components/places/src/nsNavHistory.cpp index 7493086a2be..4897c818094 100644 --- a/mozilla/toolkit/components/places/src/nsNavHistory.cpp +++ b/mozilla/toolkit/components/places/src/nsNavHistory.cpp @@ -2371,7 +2371,7 @@ nsNavHistory::FixInvalidFrecenciesForExcludedPlaces() "JOIN moz_items_annos annos ON attrs.id = annos.anno_attribute_id " "WHERE attrs.name = ?1) " "AND visit_count = 0) " - "OR SUBSTR(h.url,0,6) = 'place:')"), + "OR SUBSTR(h.url, 1, 6) = 'place:')"), getter_AddRefs(dbUpdateStatement)); NS_ENSURE_SUCCESS(rv, rv); @@ -3777,7 +3777,7 @@ nsNavHistory::RemovePagesInternal(const nsCString& aPlaceIdsQueryString) aPlaceIdsQueryString + NS_LITERAL_CSTRING(") AND " "NOT EXISTS (SELECT b.id FROM moz_bookmarks b WHERE b.fk = h.id LIMIT 1) " - "AND SUBSTR(h.url,0,6) <> 'place:')")); + "AND SUBSTR(h.url, 1, 6) <> 'place:')")); NS_ENSURE_SUCCESS(rv, rv); // placeId could have a livemark item, so setting the frecency to -1 @@ -5007,7 +5007,7 @@ nsNavHistory::QueryToSelectClause(nsNavHistoryQuery* aQuery, // const // make it use the index. if (NS_SUCCEEDED(aQuery->GetHasUri(&hasIt)) && hasIt) { if (aQuery->UriIsPrefix()) - clause.Condition("SUBSTR(h.url, 0, LENGTH(").Param(":uri").Str(")) =") + clause.Condition("SUBSTR(h.url, 1, LENGTH(").Param(":uri").Str(")) =") .Param(":uri"); else clause.Condition("h.url =").Param(":uri"); diff --git a/mozilla/toolkit/components/places/src/nsNavHistoryExpire.cpp b/mozilla/toolkit/components/places/src/nsNavHistoryExpire.cpp index 1cf0f3bd23d..049d6b52ecf 100644 --- a/mozilla/toolkit/components/places/src/nsNavHistoryExpire.cpp +++ b/mozilla/toolkit/components/places/src/nsNavHistoryExpire.cpp @@ -646,7 +646,7 @@ nsNavHistoryExpire::EraseHistory(mozIStorageConnection* aConnection, "(SELECT id FROM moz_historyvisits WHERE place_id = h.id LIMIT 1) " "AND NOT EXISTS " "(SELECT id FROM moz_bookmarks WHERE fk = h.id LIMIT 1) " - "AND SUBSTR(h.url,0,6) <> 'place:')")); + "AND SUBSTR(h.url, 1, 6) <> 'place:')")); } @@ -851,7 +851,7 @@ nsNavHistoryExpire::ExpireHistoryParanoid(mozIStorageConnection* aConnection, "SELECT h.id FROM moz_places h " "LEFT OUTER JOIN moz_historyvisits v ON h.id = v.place_id " "LEFT OUTER JOIN moz_bookmarks b ON h.id = b.fk " - "WHERE v.id IS NULL AND b.id IS NULL AND SUBSTR(h.url,0,6) <> 'place:'"); + "WHERE v.id IS NULL AND b.id IS NULL AND SUBSTR(h.url, 1, 6) <> 'place:'"); if (aMaxRecords != -1) { query.AppendLiteral(" LIMIT "); query.AppendInt(aMaxRecords);