mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 555218 - 3: (nsAnnotationService.cpp) Fix Places usage of deprecated Storage APIs. r=dietrich
This commit is contained in:
parent
6bbfb75c08
commit
3fe32acf6a
@ -77,6 +77,8 @@ const PRInt32 nsAnnotationService::kAnnoIndex_Type = 7;
|
||||
const PRInt32 nsAnnotationService::kAnnoIndex_DateAdded = 8;
|
||||
const PRInt32 nsAnnotationService::kAnnoIndex_LastModified = 9;
|
||||
|
||||
using namespace mozilla::places;
|
||||
|
||||
PLACES_FACTORY_SINGLETON_IMPLEMENTATION(nsAnnotationService, gAnnotationService)
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsAnnotationService,
|
||||
@ -128,101 +130,103 @@ nsAnnotationService::GetStatement(const nsCOMPtr<mozIStorageStatement>& aStmt)
|
||||
"SELECT n.name "
|
||||
"FROM moz_anno_attributes n "
|
||||
"JOIN moz_items_annos a ON a.anno_attribute_id = n.id "
|
||||
"WHERE a.item_id = ?1"));
|
||||
"WHERE a.item_id = :item_id"));
|
||||
|
||||
RETURN_IF_STMT(mDBGetAnnotationsForPage, NS_LITERAL_CSTRING(
|
||||
"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 = ?1 "
|
||||
"SELECT id FROM moz_places_temp WHERE url = :page_url "
|
||||
"UNION "
|
||||
"SELECT id FROM moz_places WHERE url = ?1 "
|
||||
"SELECT id FROM moz_places WHERE url = :page_url "
|
||||
") AS h ON h.id = a.place_id"));
|
||||
|
||||
RETURN_IF_STMT(mDBGetPageAnnotationValue, NS_LITERAL_CSTRING(
|
||||
"SELECT a.id, a.place_id, ?2, a.mime_type, a.content, a.flags, "
|
||||
"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 = ?1 "
|
||||
"SELECT id FROM moz_places_temp WHERE url = :page_url "
|
||||
"UNION "
|
||||
"SELECT id FROM moz_places WHERE url = ?1 "
|
||||
"SELECT id FROM moz_places WHERE url = :page_url "
|
||||
") AS h ON h.id = a.place_id "
|
||||
"WHERE n.name = ?2"));
|
||||
"WHERE n.name = :anno_name"));
|
||||
|
||||
RETURN_IF_STMT(mDBGetItemAnnotationValue, NS_LITERAL_CSTRING(
|
||||
"SELECT a.id, a.item_id, ?2, a.mime_type, a.content, a.flags, "
|
||||
"SELECT a.id, a.item_id, :anno_name, a.mime_type, a.content, a.flags, "
|
||||
"a.expiration, a.type "
|
||||
"FROM moz_anno_attributes n "
|
||||
"JOIN moz_items_annos a ON a.anno_attribute_id = n.id "
|
||||
"WHERE a.item_id = ?1 "
|
||||
"AND n.name = ?2"));
|
||||
"WHERE a.item_id = :item_id "
|
||||
"AND n.name = :anno_name"));
|
||||
|
||||
RETURN_IF_STMT(mDBAddAnnotationName, NS_LITERAL_CSTRING(
|
||||
"INSERT OR IGNORE INTO moz_anno_attributes (name) VALUES (?1)"));
|
||||
"INSERT OR IGNORE INTO moz_anno_attributes (name) VALUES (:anno_name)"));
|
||||
|
||||
RETURN_IF_STMT(mDBAddPageAnnotation, NS_LITERAL_CSTRING(
|
||||
"INSERT OR REPLACE INTO moz_annos "
|
||||
"(id, place_id, anno_attribute_id, mime_type, content, flags, "
|
||||
"expiration, type, dateAdded, lastModified) "
|
||||
"VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8, ?9, ?10)"));
|
||||
"VALUES (:id, :fk, :name_id, :mime_type, :content, :flags, "
|
||||
":expiration, :type, :date_added, :last_modified)"));
|
||||
|
||||
RETURN_IF_STMT(mDBAddItemAnnotation, NS_LITERAL_CSTRING(
|
||||
"INSERT OR REPLACE INTO moz_items_annos "
|
||||
"(id, item_id, anno_attribute_id, mime_type, content, flags, "
|
||||
"expiration, type, dateAdded, lastModified) "
|
||||
"VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8, ?9, ?10)"));
|
||||
"VALUES (:id, :fk, :name_id, :mime_type, :content, :flags, "
|
||||
":expiration, :type, :date_added, :last_modified)"));
|
||||
|
||||
RETURN_IF_STMT(mDBRemovePageAnnotation, NS_LITERAL_CSTRING(
|
||||
"DELETE FROM moz_annos "
|
||||
"WHERE place_id = ( "
|
||||
"SELECT id FROM moz_places_temp WHERE url = ?1 "
|
||||
"SELECT id FROM moz_places_temp WHERE url = :page_url "
|
||||
"UNION "
|
||||
"SELECT id FROM moz_places WHERE url = ?1) "
|
||||
"SELECT id FROM moz_places WHERE url = :page_url) "
|
||||
"AND anno_attribute_id = "
|
||||
"(SELECT id FROM moz_anno_attributes WHERE name = ?2)"));
|
||||
"(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 = ?1 "
|
||||
"WHERE item_id = :item_id "
|
||||
"AND anno_attribute_id = "
|
||||
"(SELECT id FROM moz_anno_attributes WHERE name = ?2)"));
|
||||
"(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 page_url "
|
||||
"SELECT IFNULL(h_t.url, h.url) AS coalesced_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 = ?1 AND page_url NOT NULL"));
|
||||
"WHERE n.name = :anno_name AND coalesced_url NOT NULL"));
|
||||
|
||||
RETURN_IF_STMT(mDBGetItemsWithAnnotation, NS_LITERAL_CSTRING(
|
||||
"SELECT a.item_id "
|
||||
"FROM moz_anno_attributes n "
|
||||
"JOIN moz_items_annos a ON n.id = a.anno_attribute_id "
|
||||
"WHERE n.name = ?1"));
|
||||
"WHERE n.name = :anno_name"));
|
||||
|
||||
RETURN_IF_STMT(mDBCheckPageAnnotation, NS_LITERAL_CSTRING(
|
||||
"SELECT h.id, "
|
||||
"(SELECT id FROM moz_anno_attributes WHERE name = ?1) AS nameid, "
|
||||
"(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 = ?2 "
|
||||
"FROM (SELECT id FROM moz_places_temp WHERE url = :page_url "
|
||||
"UNION "
|
||||
"SELECT id FROM moz_places WHERE url = ?2 "
|
||||
"SELECT id FROM moz_places WHERE url = :page_url "
|
||||
") AS h "
|
||||
"LEFT JOIN moz_annos a ON a.place_id = h.id "
|
||||
"AND a.anno_attribute_id = nameid"));
|
||||
|
||||
RETURN_IF_STMT(mDBCheckItemAnnotation, NS_LITERAL_CSTRING(
|
||||
"SELECT b.id, "
|
||||
"(SELECT id FROM moz_anno_attributes WHERE name = ?1) AS nameid, "
|
||||
"(SELECT id FROM moz_anno_attributes WHERE name = :anno_name) AS nameid, "
|
||||
"a.id, a.dateAdded "
|
||||
"FROM moz_bookmarks b "
|
||||
"LEFT JOIN moz_items_annos a ON a.item_id = b.id "
|
||||
"AND a.anno_attribute_id = nameid "
|
||||
"WHERE b.id = ?2"));
|
||||
"WHERE b.id = :item_id"));
|
||||
|
||||
return nsnull;
|
||||
}
|
||||
@ -287,9 +291,9 @@ nsAnnotationService::SetAnnotationStringInternal(nsIURI* aURI,
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
mozStorageStatementScoper scoper(statement);
|
||||
|
||||
rv = statement->BindStringParameter(kAnnoIndex_Content, aValue);
|
||||
rv = statement->BindStringByName(NS_LITERAL_CSTRING("content"), aValue);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
rv = statement->BindNullParameter(kAnnoIndex_MimeType);
|
||||
rv = statement->BindNullByName(NS_LITERAL_CSTRING("mime_type"));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = statement->Execute();
|
||||
@ -517,9 +521,9 @@ nsAnnotationService::SetAnnotationInt32Internal(nsIURI* aURI,
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
mozStorageStatementScoper scoper(statement);
|
||||
|
||||
rv = statement->BindInt32Parameter(kAnnoIndex_Content, aValue);
|
||||
rv = statement->BindInt32ByName(NS_LITERAL_CSTRING("content"), aValue);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
rv = statement->BindNullParameter(kAnnoIndex_MimeType);
|
||||
rv = statement->BindNullByName(NS_LITERAL_CSTRING("mime_type"));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = statement->Execute();
|
||||
@ -592,9 +596,9 @@ nsAnnotationService::SetAnnotationInt64Internal(nsIURI* aURI,
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
mozStorageStatementScoper scoper(statement);
|
||||
|
||||
rv = statement->BindInt64Parameter(kAnnoIndex_Content, aValue);
|
||||
rv = statement->BindInt64ByName(NS_LITERAL_CSTRING("content"), aValue);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
rv = statement->BindNullParameter(kAnnoIndex_MimeType);
|
||||
rv = statement->BindNullByName(NS_LITERAL_CSTRING("mime_type"));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = statement->Execute();
|
||||
@ -667,9 +671,9 @@ nsAnnotationService::SetAnnotationDoubleInternal(nsIURI* aURI,
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
mozStorageStatementScoper scoper(statement);
|
||||
|
||||
rv = statement->BindDoubleParameter(kAnnoIndex_Content, aValue);
|
||||
rv = statement->BindDoubleByName(NS_LITERAL_CSTRING("content"), aValue);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
rv = statement->BindNullParameter(kAnnoIndex_MimeType);
|
||||
rv = statement->BindNullByName(NS_LITERAL_CSTRING("mime_type"));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = statement->Execute();
|
||||
@ -747,9 +751,9 @@ nsAnnotationService::SetAnnotationBinaryInternal(nsIURI* aURI,
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
mozStorageStatementScoper scoper(statement);
|
||||
|
||||
rv = statement->BindBlobParameter(kAnnoIndex_Content, aData, aDataLen);
|
||||
rv = statement->BindBlobByName(NS_LITERAL_CSTRING("content"), aData, aDataLen);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
rv = statement->BindUTF8StringParameter(kAnnoIndex_MimeType, aMimeType);
|
||||
rv = statement->BindUTF8StringByName(NS_LITERAL_CSTRING("mime_type"), aMimeType);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = statement->Execute();
|
||||
@ -1281,7 +1285,7 @@ nsAnnotationService::GetPagesWithAnnotationCOMArray(const nsACString& aName,
|
||||
nsCOMArray<nsIURI>* _results)
|
||||
{
|
||||
DECLARE_AND_ASSIGN_SCOPED_LAZY_STMT(stmt, mDBGetPagesWithAnnotation);
|
||||
nsresult rv = stmt->BindUTF8StringParameter(0, aName);
|
||||
nsresult rv = stmt->BindUTF8StringByName(NS_LITERAL_CSTRING("anno_name"), aName);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
PRBool hasMore = PR_FALSE;
|
||||
@ -1344,7 +1348,7 @@ nsAnnotationService::GetItemsWithAnnotationTArray(const nsACString& aName,
|
||||
nsTArray<PRInt64>* _results)
|
||||
{
|
||||
DECLARE_AND_ASSIGN_SCOPED_LAZY_STMT(stmt, mDBGetItemsWithAnnotation);
|
||||
nsresult rv = stmt->BindUTF8StringParameter(0, aName);
|
||||
nsresult rv = stmt->BindUTF8StringByName(NS_LITERAL_CSTRING("anno_name"), aName);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
PRBool hasMore = PR_FALSE;
|
||||
@ -1415,9 +1419,9 @@ nsAnnotationService::GetAnnotationNamesTArray(nsIURI* aURI,
|
||||
mozStorageStatementScoper scoper(statement);
|
||||
nsresult rv;
|
||||
if (isItemAnnotation)
|
||||
rv = statement->BindInt64Parameter(0, aItemId);
|
||||
rv = statement->BindInt64ByName(NS_LITERAL_CSTRING("item_id"), aItemId);
|
||||
else
|
||||
rv = BindStatementURI(statement, 0, aURI);
|
||||
rv = URIBinder::Bind(statement, NS_LITERAL_CSTRING("page_url"), aURI);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
PRBool hasResult = PR_FALSE;
|
||||
@ -1524,12 +1528,12 @@ nsAnnotationService::RemoveAnnotationInternal(nsIURI* aURI,
|
||||
|
||||
nsresult rv;
|
||||
if (isItemAnnotation)
|
||||
rv = statement->BindInt64Parameter(0, aItemId);
|
||||
rv = statement->BindInt64ByName(NS_LITERAL_CSTRING("item_id"), aItemId);
|
||||
else
|
||||
rv = BindStatementURI(statement, 0, aURI);
|
||||
rv = URIBinder::Bind(statement, NS_LITERAL_CSTRING("page_url"), aURI);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = statement->BindUTF8StringParameter(1, aName);
|
||||
rv = statement->BindUTF8StringByName(NS_LITERAL_CSTRING("anno_name"), aName);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = statement->Execute();
|
||||
@ -1578,12 +1582,12 @@ 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 = ?1 "
|
||||
"(SELECT id FROM moz_places_temp WHERE url = :page_url "
|
||||
"UNION "
|
||||
"SELECT id FROM moz_places WHERE url = ?1)"),
|
||||
"SELECT id FROM moz_places WHERE url = :page_url)"),
|
||||
getter_AddRefs(statement));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
rv = BindStatementURI(statement, 0, aURI);
|
||||
rv = URIBinder::Bind(statement, NS_LITERAL_CSTRING("page_url"), aURI);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = statement->Execute();
|
||||
@ -1604,10 +1608,10 @@ nsAnnotationService::RemoveItemAnnotations(PRInt64 aItemId)
|
||||
// Should this be precompiled or a getter?
|
||||
nsCOMPtr<mozIStorageStatement> statement;
|
||||
nsresult rv = mDBConn->CreateStatement(NS_LITERAL_CSTRING(
|
||||
"DELETE FROM moz_items_annos WHERE item_id = ?1"),
|
||||
"DELETE FROM moz_items_annos WHERE item_id = :item_id"),
|
||||
getter_AddRefs(statement));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
rv = statement->BindInt64Parameter(0, aItemId);
|
||||
rv = statement->BindInt64ByName(NS_LITERAL_CSTRING("item_id"), aItemId);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = statement->Execute();
|
||||
@ -1641,23 +1645,23 @@ nsAnnotationService::CopyPageAnnotations(nsIURI* aSourceURI,
|
||||
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 = ?1 "
|
||||
"SELECT id from moz_places_temp WHERE url = :source_url "
|
||||
"UNION "
|
||||
"SELECT id FROM moz_places WHERE url = ?1 "
|
||||
"SELECT id FROM moz_places WHERE url = :source_url "
|
||||
") AS 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 = ?2 "
|
||||
"SELECT id FROM moz_places_temp WHERE url = :dest_url "
|
||||
"UNION "
|
||||
"SELECT id FROM moz_places WHERE url = ?2 "
|
||||
"SELECT id FROM moz_places WHERE url = :dest_url "
|
||||
") AND a2.anno_attribute_id = n.id"),
|
||||
getter_AddRefs(sourceStmt));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = BindStatementURI(sourceStmt, 0, aSourceURI);
|
||||
rv = URIBinder::Bind(sourceStmt, NS_LITERAL_CSTRING("source_url"), aSourceURI);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
rv = BindStatementURI(sourceStmt, 1, aDestURI);
|
||||
rv = URIBinder::Bind(sourceStmt, NS_LITERAL_CSTRING("dest_url"), aDestURI);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<mozIStorageStatement> copyStmt;
|
||||
@ -1666,13 +1670,14 @@ nsAnnotationService::CopyPageAnnotations(nsIURI* aSourceURI,
|
||||
"(place_id, anno_attribute_id, mime_type, content, flags, expiration, "
|
||||
"type, dateAdded, lastModified) "
|
||||
"SELECT ( "
|
||||
"SELECT id FROM moz_places_temp WHERE url = ?1 "
|
||||
"SELECT id FROM moz_places_temp WHERE url = :page_url "
|
||||
"UNION "
|
||||
"SELECT id FROM moz_places WHERE url = ?1 "
|
||||
"), anno_attribute_id, mime_type, content, flags, expiration, type, ?4, ?4"
|
||||
"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 = ?2 "
|
||||
"AND anno_attribute_id = ?3"),
|
||||
"WHERE place_id = :page_id "
|
||||
"AND anno_attribute_id = :name_id"),
|
||||
getter_AddRefs(copyStmt));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
@ -1694,13 +1699,13 @@ nsAnnotationService::CopyPageAnnotations(nsIURI* aSourceURI,
|
||||
|
||||
// Copy the annotation.
|
||||
mozStorageStatementScoper scoper(copyStmt);
|
||||
rv = BindStatementURI(copyStmt, 0, aDestURI);
|
||||
rv = URIBinder::Bind(copyStmt, NS_LITERAL_CSTRING("page_url"), aDestURI);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
rv = copyStmt->BindInt64Parameter(1, sourcePlaceId);
|
||||
rv = copyStmt->BindInt64ByName(NS_LITERAL_CSTRING("page_id"), sourcePlaceId);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
rv = copyStmt->BindInt64Parameter(2, annoNameID);
|
||||
rv = copyStmt->BindInt64ByName(NS_LITERAL_CSTRING("name_id"), annoNameID);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
rv = copyStmt->BindInt64Parameter(3, PR_Now());
|
||||
rv = copyStmt->BindInt64ByName(NS_LITERAL_CSTRING("date"), PR_Now());
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = copyStmt->Execute();
|
||||
@ -1732,15 +1737,15 @@ nsAnnotationService::CopyItemAnnotations(PRInt64 aSourceItemId,
|
||||
"FROM moz_bookmarks b "
|
||||
"JOIN moz_items_annos a ON a.item_id = b.id "
|
||||
"JOIN moz_anno_attributes n ON n.id = a.anno_attribute_id "
|
||||
"LEFT JOIN moz_items_annos a2 ON a2.item_id = ?2 "
|
||||
"LEFT JOIN moz_items_annos a2 ON a2.item_id = :dest_item_id "
|
||||
"AND a2.anno_attribute_id = n.id "
|
||||
"WHERE b.id = ?1"),
|
||||
"WHERE b.id = :source_item_id"),
|
||||
getter_AddRefs(sourceStmt));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = sourceStmt->BindInt64Parameter(0, aSourceItemId);
|
||||
rv = sourceStmt->BindInt64ByName(NS_LITERAL_CSTRING("source_item_id"), aSourceItemId);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
rv = sourceStmt->BindInt64Parameter(1, aDestItemId);
|
||||
rv = sourceStmt->BindInt64ByName(NS_LITERAL_CSTRING("dest_item_id"), aDestItemId);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<mozIStorageStatement> copyStmt;
|
||||
@ -1748,11 +1753,11 @@ nsAnnotationService::CopyItemAnnotations(PRInt64 aSourceItemId,
|
||||
"INSERT OR REPLACE INTO moz_items_annos "
|
||||
"(item_id, anno_attribute_id, mime_type, content, flags, expiration, "
|
||||
"type, dateAdded, lastModified) "
|
||||
"SELECT ?1, anno_attribute_id, mime_type, content, flags, expiration, "
|
||||
"type, ?4, ?4"
|
||||
"SELECT :dest_item_id, anno_attribute_id, mime_type, content, flags, expiration, "
|
||||
"type, :date, :date "
|
||||
"FROM moz_items_annos "
|
||||
"WHERE item_id = ?2 "
|
||||
"AND anno_attribute_id = ?3"),
|
||||
"WHERE item_id = :source_item_id "
|
||||
"AND anno_attribute_id = :name_id"),
|
||||
getter_AddRefs(copyStmt));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
@ -1773,13 +1778,13 @@ nsAnnotationService::CopyItemAnnotations(PRInt64 aSourceItemId,
|
||||
|
||||
// Copy the annotation.
|
||||
mozStorageStatementScoper scoper(copyStmt);
|
||||
rv = copyStmt->BindInt64Parameter(0, aDestItemId);
|
||||
rv = copyStmt->BindInt64ByName(NS_LITERAL_CSTRING("dest_item_id"), aDestItemId);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
rv = copyStmt->BindInt64Parameter(1, aSourceItemId);
|
||||
rv = copyStmt->BindInt64ByName(NS_LITERAL_CSTRING("source_item_id"), aSourceItemId);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
rv = copyStmt->BindInt64Parameter(2, annoNameID);
|
||||
rv = copyStmt->BindInt64ByName(NS_LITERAL_CSTRING("name_id"), annoNameID);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
rv = copyStmt->BindInt64Parameter(3, PR_Now());
|
||||
rv = copyStmt->BindInt64ByName(NS_LITERAL_CSTRING("date"), PR_Now());
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = copyStmt->Execute();
|
||||
@ -1857,12 +1862,12 @@ nsAnnotationService::HasAnnotationInternal(nsIURI* aURI,
|
||||
NS_ENSURE_STATE(stmt);
|
||||
mozStorageStatementScoper checkAnnoScoper(stmt);
|
||||
|
||||
nsresult rv = stmt->BindUTF8StringParameter(0, aName);
|
||||
nsresult rv = stmt->BindUTF8StringByName(NS_LITERAL_CSTRING("anno_name"), aName);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (isItemAnnotation)
|
||||
rv = stmt->BindInt64Parameter(1, aItemId);
|
||||
rv = stmt->BindInt64ByName(NS_LITERAL_CSTRING("item_id"), aItemId);
|
||||
else
|
||||
rv = BindStatementURI(stmt, 1, aURI);
|
||||
rv = URIBinder::Bind(stmt, NS_LITERAL_CSTRING("page_url"), aURI);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
PRBool hasResult;
|
||||
@ -1908,12 +1913,12 @@ nsAnnotationService::StartGetAnnotation(nsIURI* aURI,
|
||||
|
||||
nsresult rv;
|
||||
if (isItemAnnotation)
|
||||
rv = (*_statement)->BindInt64Parameter(0, aItemId);
|
||||
rv = (*_statement)->BindInt64ByName(NS_LITERAL_CSTRING("item_id"), aItemId);
|
||||
else
|
||||
rv = BindStatementURI(*_statement, 0, aURI);
|
||||
rv = URIBinder::Bind(*_statement, NS_LITERAL_CSTRING("page_url"), aURI);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = (*_statement)->BindUTF8StringParameter(1, aName);
|
||||
rv = (*_statement)->BindUTF8StringByName(NS_LITERAL_CSTRING("anno_name"), aName);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
PRBool hasResult = PR_FALSE;
|
||||
@ -1959,7 +1964,7 @@ nsAnnotationService::StartSetAnnotation(nsIURI* aURI,
|
||||
|
||||
// Ensure the annotation name exists.
|
||||
DECLARE_AND_ASSIGN_SCOPED_LAZY_STMT(addNameStmt, mDBAddAnnotationName);
|
||||
nsresult rv = addNameStmt->BindUTF8StringParameter(0, aName);
|
||||
nsresult rv = addNameStmt->BindUTF8StringByName(NS_LITERAL_CSTRING("anno_name"), aName);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
rv = addNameStmt->Execute();
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
@ -1976,12 +1981,12 @@ nsAnnotationService::StartSetAnnotation(nsIURI* aURI,
|
||||
GetStatement(mDBCheckItemAnnotation) : GetStatement(mDBCheckPageAnnotation);
|
||||
NS_ENSURE_STATE(stmt);
|
||||
mozStorageStatementScoper checkAnnoScoper(stmt);
|
||||
rv = stmt->BindUTF8StringParameter(0, aName);
|
||||
rv = stmt->BindUTF8StringByName(NS_LITERAL_CSTRING("anno_name"), aName);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (isItemAnnotation)
|
||||
rv = stmt->BindInt64Parameter(1, aItemId);
|
||||
rv = stmt->BindInt64ByName(NS_LITERAL_CSTRING("item_id"), aItemId);
|
||||
else
|
||||
rv = BindStatementURI(stmt, 1, aURI);
|
||||
rv = URIBinder::Bind(stmt, NS_LITERAL_CSTRING("page_url"), aURI);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
PRBool hasResult;
|
||||
@ -2005,30 +2010,30 @@ nsAnnotationService::StartSetAnnotation(nsIURI* aURI,
|
||||
|
||||
// Don't replace existing annotations.
|
||||
if (oldAnnoId > 0) {
|
||||
rv = (*_statement)->BindInt64Parameter(kAnnoIndex_ID, oldAnnoId);
|
||||
rv = (*_statement)->BindInt64ByName(NS_LITERAL_CSTRING("id"), oldAnnoId);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
rv = (*_statement)->BindInt64Parameter(kAnnoIndex_DateAdded, oldAnnoDate);
|
||||
rv = (*_statement)->BindInt64ByName(NS_LITERAL_CSTRING("date_added"), oldAnnoDate);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
else {
|
||||
rv = (*_statement)->BindNullParameter(kAnnoIndex_ID);
|
||||
rv = (*_statement)->BindNullByName(NS_LITERAL_CSTRING("id"));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
rv = (*_statement)->BindInt64Parameter(kAnnoIndex_DateAdded, PR_Now());
|
||||
rv = (*_statement)->BindInt64ByName(NS_LITERAL_CSTRING("date_added"), PR_Now());
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
rv = (*_statement)->BindInt64Parameter(kAnnoIndex_PageOrItem, fkId);
|
||||
rv = (*_statement)->BindInt64ByName(NS_LITERAL_CSTRING("fk"), fkId);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
rv = (*_statement)->BindInt64Parameter(kAnnoIndex_NameID, nameID);
|
||||
rv = (*_statement)->BindInt64ByName(NS_LITERAL_CSTRING("name_id"), nameID);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
// MimeType and Content will be bound by the caller.
|
||||
rv = (*_statement)->BindInt32Parameter(kAnnoIndex_Flags, aFlags);
|
||||
rv = (*_statement)->BindInt32ByName(NS_LITERAL_CSTRING("flags"), aFlags);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
rv = (*_statement)->BindInt32Parameter(kAnnoIndex_Expiration, aExpiration);
|
||||
rv = (*_statement)->BindInt32ByName(NS_LITERAL_CSTRING("expiration"), aExpiration);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
rv = (*_statement)->BindInt32Parameter(kAnnoIndex_Type, aType);
|
||||
rv = (*_statement)->BindInt32ByName(NS_LITERAL_CSTRING("type"), aType);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
rv = (*_statement)->BindInt64Parameter(kAnnoIndex_LastModified, PR_Now());
|
||||
rv = (*_statement)->BindInt64ByName(NS_LITERAL_CSTRING("last_modified"), PR_Now());
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// on success, leave the statement open, the caller will set the value
|
||||
|
Loading…
Reference in New Issue
Block a user