mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-07 13:24:12 +00:00
Bug 491954 - Views should select exact columns, r=sdwilsh
This commit is contained in:
parent
da3dbb9b77
commit
6c48d2f50e
@ -52,6 +52,7 @@
|
||||
#include "nsVariant.h"
|
||||
#include "nsNavBookmarks.h"
|
||||
#include "nsPlacesTables.h"
|
||||
#include "nsPlacesIndexes.h"
|
||||
|
||||
const PRInt32 nsAnnotationService::kAnnoIndex_ID = 0;
|
||||
const PRInt32 nsAnnotationService::kAnnoIndex_PageOrItem = 1;
|
||||
@ -269,9 +270,7 @@ nsAnnotationService::InitTables(mozIStorageConnection* aDBConn)
|
||||
rv = aDBConn->ExecuteSimpleSQL(CREATE_MOZ_ANNOS);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = aDBConn->ExecuteSimpleSQL(NS_LITERAL_CSTRING(
|
||||
"CREATE UNIQUE INDEX moz_annos_placeattributeindex "
|
||||
"ON moz_annos (place_id, anno_attribute_id)"));
|
||||
rv = aDBConn->ExecuteSimpleSQL(CREATE_IDX_MOZ_ANNOS_PLACEATTRIBUTE);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
@ -287,9 +286,7 @@ nsAnnotationService::InitTables(mozIStorageConnection* aDBConn)
|
||||
if (! exists) {
|
||||
rv = aDBConn->ExecuteSimpleSQL(CREATE_MOZ_ITEMS_ANNOS);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
rv = aDBConn->ExecuteSimpleSQL(NS_LITERAL_CSTRING(
|
||||
"CREATE UNIQUE INDEX moz_items_annos_itemattributeindex "
|
||||
"ON moz_items_annos (item_id, anno_attribute_id)"));
|
||||
rv = aDBConn->ExecuteSimpleSQL(CREATE_IDX_MOZ_ITEMSANNOS_PLACEATTRIBUTE);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
|
@ -68,6 +68,7 @@
|
||||
#include "mozIStoragePendingStatement.h"
|
||||
#include "mozIStorageStatementCallback.h"
|
||||
#include "mozIStorageError.h"
|
||||
#include "nsPlacesTables.h"
|
||||
|
||||
// For favicon optimization
|
||||
#include "imgITools.h"
|
||||
@ -184,10 +185,10 @@ nsFaviconService::Init()
|
||||
rv = mDBConn->CreateStatement(NS_LITERAL_CSTRING(
|
||||
"SELECT f.id, f.url, length(f.data), f.expiration "
|
||||
"FROM ( "
|
||||
"SELECT * FROM moz_places_temp "
|
||||
"SELECT " MOZ_PLACES_COLUMNS " FROM moz_places_temp "
|
||||
"WHERE url = ?1 "
|
||||
"UNION ALL "
|
||||
"SELECT * FROM moz_places "
|
||||
"SELECT " MOZ_PLACES_COLUMNS " FROM moz_places "
|
||||
"WHERE url = ?1 "
|
||||
") AS h JOIN moz_favicons f ON h.favicon_id = f.id "
|
||||
"LIMIT 1"),
|
||||
|
@ -53,6 +53,7 @@
|
||||
#include "nsILivemarkService.h"
|
||||
#include "nsPlacesTriggers.h"
|
||||
#include "nsPlacesTables.h"
|
||||
#include "nsPlacesIndexes.h"
|
||||
|
||||
const PRInt32 nsNavBookmarks::kFindBookmarksIndex_ID = 0;
|
||||
const PRInt32 nsNavBookmarks::kFindBookmarksIndex_Type = 1;
|
||||
@ -159,21 +160,16 @@ nsNavBookmarks::InitTables(mozIStorageConnection* aDBConn)
|
||||
// bookmarked (used by history queries and vacuuming, for example).
|
||||
// Making it compound with "type" speeds up type-differentiation
|
||||
// queries, such as expiration and search.
|
||||
rv = aDBConn->ExecuteSimpleSQL(NS_LITERAL_CSTRING(
|
||||
"CREATE INDEX moz_bookmarks_itemindex ON moz_bookmarks (fk, type)"));
|
||||
rv = aDBConn->ExecuteSimpleSQL(CREATE_IDX_MOZ_BOOKMARKS_PLACETYPE);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// The most common operation is to find the children given a parent and position.
|
||||
rv = aDBConn->ExecuteSimpleSQL(NS_LITERAL_CSTRING(
|
||||
"CREATE INDEX moz_bookmarks_parentindex "
|
||||
"ON moz_bookmarks (parent, position)"));
|
||||
rv = aDBConn->ExecuteSimpleSQL(CREATE_IDX_MOZ_BOOKMARKS_PARENTPOSITION);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// fast access to lastModified is useful during sync and to get
|
||||
// last modified bookmark title for tags container's children.
|
||||
rv = aDBConn->ExecuteSimpleSQL(NS_LITERAL_CSTRING(
|
||||
"CREATE INDEX moz_bookmarks_itemlastmodifiedindex "
|
||||
"ON moz_bookmarks (fk, lastModified)"));
|
||||
rv = aDBConn->ExecuteSimpleSQL(CREATE_IDX_MOZ_BOOKMARKS_PLACELASTMODIFIED);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
|
@ -47,7 +47,12 @@
|
||||
#include "nsNavHistory.h"
|
||||
#include "nsNavBookmarks.h"
|
||||
#include "nsAnnotationService.h"
|
||||
#include "nsIIdleService.h"
|
||||
#include "nsILivemarkService.h"
|
||||
|
||||
#include "nsPlacesTables.h"
|
||||
#include "nsPlacesIndexes.h"
|
||||
#include "nsPlacesTriggers.h"
|
||||
|
||||
#include "nsIArray.h"
|
||||
#include "nsTArray.h"
|
||||
@ -93,10 +98,7 @@
|
||||
#include "mozStorageCID.h"
|
||||
#include "mozStorageHelper.h"
|
||||
#include "mozIStorageError.h"
|
||||
#include "nsPlacesTriggers.h"
|
||||
#include "nsAppDirectoryServiceDefs.h"
|
||||
#include "nsIIdleService.h"
|
||||
#include "nsILivemarkService.h"
|
||||
|
||||
#include "nsMathUtils.h" // for NS_ceilf()
|
||||
|
||||
@ -828,25 +830,20 @@ nsNavHistory::InitDB()
|
||||
rv = mDBConn->ExecuteSimpleSQL(CREATE_MOZ_PLACES);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = mDBConn->ExecuteSimpleSQL(NS_LITERAL_CSTRING(
|
||||
"CREATE UNIQUE INDEX moz_places_url_uniqueindex ON moz_places (url)"));
|
||||
rv = mDBConn->ExecuteSimpleSQL(CREATE_IDX_MOZ_PLACES_URL);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// This index is used for favicon expiration, see nsNavHistoryExpire::ExpireItems.
|
||||
rv = mDBConn->ExecuteSimpleSQL(NS_LITERAL_CSTRING(
|
||||
"CREATE INDEX moz_places_faviconindex ON moz_places (favicon_id)"));
|
||||
rv = mDBConn->ExecuteSimpleSQL(CREATE_IDX_MOZ_PLACES_FAVICON);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = mDBConn->ExecuteSimpleSQL(NS_LITERAL_CSTRING(
|
||||
"CREATE INDEX moz_places_hostindex ON moz_places (rev_host)"));
|
||||
rv = mDBConn->ExecuteSimpleSQL(CREATE_IDX_MOZ_PLACES_REVHOST);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = mDBConn->ExecuteSimpleSQL(NS_LITERAL_CSTRING(
|
||||
"CREATE INDEX moz_places_visitcount ON moz_places (visit_count)"));
|
||||
rv = mDBConn->ExecuteSimpleSQL(CREATE_IDX_MOZ_PLACES_VISITCOUNT);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = mDBConn->ExecuteSimpleSQL(NS_LITERAL_CSTRING(
|
||||
"CREATE INDEX moz_places_frecencyindex ON moz_places (frecency)"));
|
||||
rv = mDBConn->ExecuteSimpleSQL(CREATE_IDX_MOZ_PLACES_FRECENCY);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
@ -857,19 +854,15 @@ nsNavHistory::InitDB()
|
||||
rv = mDBConn->ExecuteSimpleSQL(CREATE_MOZ_HISTORYVISITS);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = mDBConn->ExecuteSimpleSQL(NS_LITERAL_CSTRING(
|
||||
"CREATE INDEX moz_historyvisits_placedateindex "
|
||||
"ON moz_historyvisits (place_id, visit_date)"));
|
||||
rv = mDBConn->ExecuteSimpleSQL(CREATE_IDX_MOZ_HISTORYVISITS_PLACEDATE);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// This makes a big difference in startup time for large profiles because of
|
||||
// finding bookmark redirects using the referring page.
|
||||
rv = mDBConn->ExecuteSimpleSQL(NS_LITERAL_CSTRING(
|
||||
"CREATE INDEX moz_historyvisits_fromindex ON moz_historyvisits (from_visit)"));
|
||||
rv = mDBConn->ExecuteSimpleSQL(CREATE_IDX_MOZ_HISTORYVISITS_FROMVISIT);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = mDBConn->ExecuteSimpleSQL(NS_LITERAL_CSTRING(
|
||||
"CREATE INDEX moz_historyvisits_dateindex ON moz_historyvisits (visit_date)"));
|
||||
rv = mDBConn->ExecuteSimpleSQL(CREATE_IDX_MOZ_HISTORYVISITS_VISITDATE);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
@ -983,24 +976,19 @@ nsNavHistory::InitTempTables()
|
||||
rv = mDBConn->ExecuteSimpleSQL(CREATE_MOZ_PLACES_TEMP);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = mDBConn->ExecuteSimpleSQL(NS_LITERAL_CSTRING(
|
||||
"CREATE UNIQUE INDEX moz_places_temp_url_uniqueindex ON moz_places_temp (url)"));
|
||||
rv = mDBConn->ExecuteSimpleSQL(CREATE_IDX_MOZ_PLACES_TEMP_URL);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = mDBConn->ExecuteSimpleSQL(NS_LITERAL_CSTRING(
|
||||
"CREATE INDEX moz_places_temp_faviconindex ON moz_places_temp (favicon_id)"));
|
||||
rv = mDBConn->ExecuteSimpleSQL(CREATE_IDX_MOZ_PLACES_TEMP_FAVICON);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = mDBConn->ExecuteSimpleSQL(NS_LITERAL_CSTRING(
|
||||
"CREATE INDEX moz_places_temp_hostindex ON moz_places_temp (rev_host)"));
|
||||
rv = mDBConn->ExecuteSimpleSQL(CREATE_IDX_MOZ_PLACES_TEMP_REVHOST);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = mDBConn->ExecuteSimpleSQL(NS_LITERAL_CSTRING(
|
||||
"CREATE INDEX moz_places_temp_visitcount ON moz_places_temp (visit_count)"));
|
||||
rv = mDBConn->ExecuteSimpleSQL(CREATE_IDX_MOZ_PLACES_TEMP_VISITCOUNT);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = mDBConn->ExecuteSimpleSQL(NS_LITERAL_CSTRING(
|
||||
"CREATE INDEX moz_places_temp_frecencyindex ON moz_places_temp (frecency)"));
|
||||
rv = mDBConn->ExecuteSimpleSQL(CREATE_IDX_MOZ_PLACES_TEMP_FRECENCY);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = mDBConn->ExecuteSimpleSQL(CREATE_MOZ_PLACES_SYNC_TRIGGER);
|
||||
@ -1011,19 +999,13 @@ nsNavHistory::InitTempTables()
|
||||
rv = mDBConn->ExecuteSimpleSQL(CREATE_MOZ_HISTORYVISITS_TEMP);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = mDBConn->ExecuteSimpleSQL(NS_LITERAL_CSTRING(
|
||||
"CREATE INDEX moz_historyvisits_temp_placedateindex "
|
||||
"ON moz_historyvisits_temp (place_id, visit_date)"));
|
||||
rv = mDBConn->ExecuteSimpleSQL(CREATE_IDX_MOZ_HISTORYVISITS_TEMP_PLACEDATE);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = mDBConn->ExecuteSimpleSQL(NS_LITERAL_CSTRING(
|
||||
"CREATE INDEX moz_historyvisits_temp_fromindex "
|
||||
"ON moz_historyvisits_temp (from_visit)"));
|
||||
rv = mDBConn->ExecuteSimpleSQL(CREATE_IDX_MOZ_HISTORYVISITS_TEMP_FROMVISIT);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = mDBConn->ExecuteSimpleSQL(NS_LITERAL_CSTRING(
|
||||
"CREATE INDEX moz_historyvisits_temp_dateindex "
|
||||
"ON moz_historyvisits_temp (visit_date)"));
|
||||
rv = mDBConn->ExecuteSimpleSQL(CREATE_IDX_MOZ_HISTORYVISITS_TEMP_VISITDATE);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = mDBConn->ExecuteSimpleSQL(CREATE_MOZ_HISTORYVISITS_SYNC_TRIGGER);
|
||||
@ -1506,28 +1488,21 @@ nsNavHistory::MigrateV6Up(mozIStorageConnection* aDBConn)
|
||||
// 5. recreate the indexes
|
||||
// NOTE: tests showed that it's faster to create the indexes prior to filling
|
||||
// the table than it is to add them afterwards.
|
||||
rv = mDBConn->ExecuteSimpleSQL(NS_LITERAL_CSTRING(
|
||||
"CREATE UNIQUE INDEX moz_places_url_uniqueindex ON moz_places (url)"));
|
||||
rv = mDBConn->ExecuteSimpleSQL(CREATE_IDX_MOZ_PLACES_URL);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
rv = mDBConn->ExecuteSimpleSQL(NS_LITERAL_CSTRING(
|
||||
"CREATE INDEX moz_places_faviconindex ON moz_places (favicon_id)"));
|
||||
rv = mDBConn->ExecuteSimpleSQL(CREATE_IDX_MOZ_PLACES_FAVICON);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
rv = mDBConn->ExecuteSimpleSQL(NS_LITERAL_CSTRING(
|
||||
"CREATE INDEX moz_places_hostindex ON moz_places (rev_host)"));
|
||||
rv = mDBConn->ExecuteSimpleSQL(CREATE_IDX_MOZ_PLACES_REVHOST);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
rv = mDBConn->ExecuteSimpleSQL(NS_LITERAL_CSTRING(
|
||||
"CREATE INDEX moz_places_visitcount ON moz_places (visit_count)"));
|
||||
rv = mDBConn->ExecuteSimpleSQL(CREATE_IDX_MOZ_PLACES_VISITCOUNT);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
rv = mDBConn->ExecuteSimpleSQL(NS_LITERAL_CSTRING(
|
||||
"CREATE INDEX moz_places_frecencyindex ON moz_places (frecency)"));
|
||||
rv = mDBConn->ExecuteSimpleSQL(CREATE_IDX_MOZ_PLACES_FRECENCY);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// 6. copy all data into moz_places
|
||||
rv = mDBConn->ExecuteSimpleSQL(NS_LITERAL_CSTRING(
|
||||
"INSERT INTO moz_places "
|
||||
"SELECT id, url, title, rev_host, visit_count, hidden, typed, "
|
||||
"favicon_id, frecency "
|
||||
"FROM moz_places_backup"));
|
||||
"INSERT INTO moz_places (" MOZ_PLACES_COLUMNS ")"
|
||||
"SELECT " MOZ_PLACES_COLUMNS " FROM moz_places_backup"));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// 7. drop moz_places_backup
|
||||
@ -1554,9 +1529,7 @@ nsNavHistory::MigrateV7Up(mozIStorageConnection* aDBConn)
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (!lastModIndexExists) {
|
||||
rv = aDBConn->ExecuteSimpleSQL(NS_LITERAL_CSTRING(
|
||||
"CREATE INDEX moz_bookmarks_itemlastmodifiedindex "
|
||||
"ON moz_bookmarks (fk, lastModified)"));
|
||||
rv = aDBConn->ExecuteSimpleSQL(CREATE_IDX_MOZ_BOOKMARKS_PLACELASTMODIFIED);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
@ -1575,9 +1548,7 @@ nsNavHistory::MigrateV7Up(mozIStorageConnection* aDBConn)
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// create the new multi-column index
|
||||
rv = aDBConn->ExecuteSimpleSQL(NS_LITERAL_CSTRING(
|
||||
"CREATE INDEX IF NOT EXISTS moz_historyvisits_placedateindex "
|
||||
"ON moz_historyvisits (place_id, visit_date)"));
|
||||
rv = aDBConn->ExecuteSimpleSQL(CREATE_IDX_MOZ_HISTORYVISITS_PLACEDATE);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
@ -1596,9 +1567,7 @@ nsNavHistory::MigrateV7Up(mozIStorageConnection* aDBConn)
|
||||
|
||||
// create index for the frecency column
|
||||
// XXX multi column index with typed, and visit_count?
|
||||
rv = aDBConn->ExecuteSimpleSQL(NS_LITERAL_CSTRING(
|
||||
"CREATE INDEX IF NOT EXISTS moz_places_frecencyindex "
|
||||
"ON moz_places (frecency)"));
|
||||
rv = aDBConn->ExecuteSimpleSQL(CREATE_IDX_MOZ_PLACES_FRECENCY);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// for place: items and unvisited livemark items, we need to set
|
||||
@ -1742,8 +1711,7 @@ nsNavHistory::MigrateV8Up(mozIStorageConnection *aDBConn)
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// create new uri annos index
|
||||
rv = mDBConn->ExecuteSimpleSQL(
|
||||
NS_LITERAL_CSTRING("CREATE UNIQUE INDEX moz_annos_placeattributeindex ON moz_annos (place_id, anno_attribute_id)"));
|
||||
rv = mDBConn->ExecuteSimpleSQL(CREATE_IDX_MOZ_ANNOS_PLACEATTRIBUTE);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// drop old item annos index
|
||||
@ -1752,8 +1720,7 @@ nsNavHistory::MigrateV8Up(mozIStorageConnection *aDBConn)
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// create new item annos index
|
||||
rv = mDBConn->ExecuteSimpleSQL(
|
||||
NS_LITERAL_CSTRING("CREATE UNIQUE INDEX moz_items_annos_itemattributeindex ON moz_items_annos (item_id, anno_attribute_id)"));
|
||||
rv = mDBConn->ExecuteSimpleSQL(CREATE_IDX_MOZ_ITEMSANNOS_PLACEATTRIBUTE);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
|
@ -81,6 +81,7 @@
|
||||
#include "mozIStoragePendingStatement.h"
|
||||
#include "mozIStorageStatementCallback.h"
|
||||
#include "mozIStorageError.h"
|
||||
#include "nsPlacesTables.h"
|
||||
|
||||
#define NS_AUTOCOMPLETESIMPLERESULT_CONTRACTID \
|
||||
"@mozilla.org/autocomplete/simple-result;1"
|
||||
@ -205,9 +206,9 @@ void GetAutoCompleteBaseQuery(nsACString& aQuery) {
|
||||
"SELECT h.url, h.title, f.url") + BOOK_TAG_SQL + NS_LITERAL_CSTRING(", "
|
||||
"h.visit_count, h.typed "
|
||||
"FROM ("
|
||||
"SELECT * FROM moz_places_temp "
|
||||
"SELECT " MOZ_PLACES_COLUMNS " FROM moz_places_temp "
|
||||
"UNION ALL "
|
||||
"SELECT * FROM moz_places "
|
||||
"SELECT " MOZ_PLACES_COLUMNS " FROM moz_places "
|
||||
"ORDER BY frecency DESC LIMIT ?2 OFFSET ?3) h "
|
||||
"LEFT OUTER JOIN moz_favicons f ON f.id = h.favicon_id "
|
||||
"WHERE h.frecency <> 0 "
|
||||
@ -737,10 +738,10 @@ nsNavHistory::StartSearch(const nsAString & aSearchString,
|
||||
"SELECT h.url, h.title, f.url") + BOOK_TAG_SQL + NS_LITERAL_CSTRING(", "
|
||||
"h.visit_count, h.typed "
|
||||
"FROM ( "
|
||||
"SELECT * FROM moz_places_temp "
|
||||
"SELECT " MOZ_PLACES_COLUMNS " FROM moz_places_temp "
|
||||
"WHERE url IN (") + bindings + NS_LITERAL_CSTRING(") "
|
||||
"UNION ALL "
|
||||
"SELECT * FROM moz_places "
|
||||
"SELECT " MOZ_PLACES_COLUMNS " FROM moz_places "
|
||||
"WHERE id NOT IN (SELECT id FROM moz_places_temp) "
|
||||
"AND url IN (") + bindings + NS_LITERAL_CSTRING(") "
|
||||
") AS h "
|
||||
@ -938,7 +939,7 @@ nsNavHistory::AutoCompleteAdaptiveSearch()
|
||||
{
|
||||
mozStorageStatementScoper scope(mDBAdaptiveQuery);
|
||||
|
||||
nsresult rv = mDBAdaptiveQuery->BindInt32Parameter(0, GetTagsFolder());
|
||||
nsresult rv = mDBAdaptiveQuery->BindInt64Parameter(0, GetTagsFolder());
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = mDBAdaptiveQuery->BindStringParameter(1, mCurrentSearchString);
|
||||
@ -953,7 +954,7 @@ nsNavHistory::AutoCompleteAdaptiveSearch()
|
||||
nsresult
|
||||
nsNavHistory::AutoCompletePreviousSearch()
|
||||
{
|
||||
nsresult rv = mDBPreviousQuery->BindInt32Parameter(0, GetTagsFolder());
|
||||
nsresult rv = mDBPreviousQuery->BindInt64Parameter(0, GetTagsFolder());
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = AutoCompleteProcessSearch(mDBPreviousQuery, QUERY_FILTERED);
|
||||
@ -979,7 +980,7 @@ nsNavHistory::AutoCompleteFullHistorySearch(PRBool* aHasMoreResults)
|
||||
{
|
||||
mozStorageStatementScoper scope(mDBCurrentQuery);
|
||||
|
||||
nsresult rv = mDBCurrentQuery->BindInt32Parameter(0, GetTagsFolder());
|
||||
nsresult rv = mDBCurrentQuery->BindInt64Parameter(0, GetTagsFolder());
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = mDBCurrentQuery->BindInt32Parameter(1, mAutoCompleteSearchChunkSize);
|
||||
|
166
toolkit/components/places/src/nsPlacesIndexes.h
Normal file
166
toolkit/components/places/src/nsPlacesIndexes.h
Normal file
@ -0,0 +1,166 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
* vim: sw=2 ts=2 et lcs=trail\:.,tab\:>~ :
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Places code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Mozilla Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2009
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Marco Bonardo <mak77@bonardo.net> (Original Author)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef __nsPlacesIndexes_h__
|
||||
#define __nsPlacesIndexes_h__
|
||||
|
||||
#define CREATE_PLACES_IDX(__name, __table, __columns, __type) \
|
||||
NS_LITERAL_CSTRING( \
|
||||
"CREATE " __type " INDEX IF NOT EXISTS " __table "_" __name \
|
||||
" ON " __table " (" __columns ")" \
|
||||
)
|
||||
|
||||
/**
|
||||
* 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", "" \
|
||||
)
|
||||
|
||||
/**
|
||||
* 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", "" \
|
||||
)
|
||||
|
||||
/**
|
||||
* moz_bookmarks
|
||||
*/
|
||||
|
||||
#define CREATE_IDX_MOZ_BOOKMARKS_PLACETYPE \
|
||||
CREATE_PLACES_IDX( \
|
||||
"itemindex", "moz_bookmarks", "fk, type", "" \
|
||||
)
|
||||
|
||||
#define CREATE_IDX_MOZ_BOOKMARKS_PARENTPOSITION \
|
||||
CREATE_PLACES_IDX( \
|
||||
"parentindex", "moz_bookmarks", "parent, position", "" \
|
||||
)
|
||||
|
||||
#define CREATE_IDX_MOZ_BOOKMARKS_PLACELASTMODIFIED \
|
||||
CREATE_PLACES_IDX( \
|
||||
"itemlastmodifiedindex", "moz_bookmarks", "fk, lastModified", "" \
|
||||
)
|
||||
|
||||
/**
|
||||
* moz_annos
|
||||
*/
|
||||
|
||||
#define CREATE_IDX_MOZ_ANNOS_PLACEATTRIBUTE \
|
||||
CREATE_PLACES_IDX( \
|
||||
"placeattributeindex", "moz_annos", "place_id, anno_attribute_id", "UNIQUE" \
|
||||
)
|
||||
|
||||
/**
|
||||
* moz_items_annos
|
||||
*/
|
||||
|
||||
#define CREATE_IDX_MOZ_ITEMSANNOS_PLACEATTRIBUTE \
|
||||
CREATE_PLACES_IDX( \
|
||||
"itemattributeindex", "moz_items_annos", "item_id, anno_attribute_id", "UNIQUE" \
|
||||
)
|
||||
|
||||
|
||||
#endif // __nsPlacesIndexes_h__
|
@ -1,4 +1,5 @@
|
||||
/* vim: sw=2 ts=2 sts=2 expandtab
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
* vim: sw=2 ts=2 et lcs=trail\:.,tab\:>~ :
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
@ -61,6 +62,9 @@
|
||||
"SELECT * FROM moz_places " \
|
||||
"WHERE id NOT IN (SELECT id FROM moz_places_temp) " \
|
||||
)
|
||||
#define MOZ_PLACES_COLUMNS \
|
||||
"id, url, title, rev_host, visit_count, hidden, typed, favicon_id, " \
|
||||
"frecency"
|
||||
|
||||
#define CREATE_MOZ_HISTORYVISITS_BASE(__name, __temporary) NS_LITERAL_CSTRING( \
|
||||
"CREATE " __temporary " TABLE " __name " (" \
|
||||
@ -83,6 +87,8 @@
|
||||
"SELECT * FROM moz_historyvisits " \
|
||||
"WHERE id NOT IN (SELECT id FROM moz_historyvisits_temp) " \
|
||||
)
|
||||
#define MOZ_HISTORYVISITS_COLUMNS \
|
||||
"id, from_visit, place_id, visit_date, visit_type, session"
|
||||
|
||||
#define CREATE_MOZ_INPUTHISTORY NS_LITERAL_CSTRING( \
|
||||
"CREATE TABLE moz_inputhistory (" \
|
||||
|
@ -1,4 +1,5 @@
|
||||
/* vim: sw=2 ts=2 sts=2 expandtab
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
* vim: sw=2 ts=2 et lcs=trail\:.,tab\:>~ :
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
@ -36,9 +37,19 @@
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsPlacesTables.h"
|
||||
|
||||
#ifndef __nsPlacesTriggers_h__
|
||||
#define __nsPlacesTriggers_h__
|
||||
|
||||
/**
|
||||
* Exclude these visit types:
|
||||
* 0 - invalid
|
||||
* 4 - EMBED
|
||||
* 7 - DOWNLOAD
|
||||
**/
|
||||
#define EXCLUDED_VISIT_TYPES "0, 4, 7"
|
||||
|
||||
/**
|
||||
* Trigger checks to ensure that at least one bookmark is still using a keyword
|
||||
* when any bookmark is deleted. If there are no more bookmarks using it, the
|
||||
@ -71,10 +82,7 @@
|
||||
"INSTEAD OF INSERT " \
|
||||
"ON moz_places_view " \
|
||||
"BEGIN " \
|
||||
"INSERT INTO moz_places_temp ( " \
|
||||
"id, url, title, rev_host, visit_count, hidden, typed, favicon_id, " \
|
||||
"frecency " \
|
||||
") " \
|
||||
"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, " \
|
||||
@ -113,9 +121,8 @@
|
||||
"INSTEAD OF UPDATE " \
|
||||
"ON moz_places_view " \
|
||||
"BEGIN " \
|
||||
"INSERT OR IGNORE INTO moz_places_temp " \
|
||||
"SELECT * " \
|
||||
"FROM moz_places " \
|
||||
"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), " \
|
||||
@ -143,22 +150,19 @@
|
||||
"INSTEAD OF INSERT " \
|
||||
"ON moz_historyvisits_view " \
|
||||
"BEGIN " \
|
||||
"INSERT INTO moz_historyvisits_temp ( " \
|
||||
"id, from_visit, place_id, visit_date, visit_type, session " \
|
||||
") " \
|
||||
"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 " \
|
||||
"SELECT * " \
|
||||
"FROM moz_places " \
|
||||
"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 (0, 4, 7); " \
|
||||
"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 (0, 4, 7); " /* invalid, EMBED, DOWNLOAD */ \
|
||||
"AND NEW.visit_type NOT IN (" EXCLUDED_VISIT_TYPES "); " \
|
||||
"END" \
|
||||
)
|
||||
|
||||
@ -179,15 +183,14 @@
|
||||
"WHERE id = OLD.id; " \
|
||||
"DELETE FROM moz_historyvisits " \
|
||||
"WHERE id = OLD.id; " \
|
||||
"INSERT OR IGNORE INTO moz_places_temp " \
|
||||
"SELECT * " \
|
||||
"FROM moz_places " \
|
||||
"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 (0, 4, 7); " \
|
||||
"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 (0, 4, 7); " /* invalid, EMBED, DOWNLOAD */ \
|
||||
"AND OLD.visit_type NOT IN (" EXCLUDED_VISIT_TYPES "); " \
|
||||
"END" \
|
||||
)
|
||||
|
||||
@ -204,9 +207,8 @@
|
||||
"INSTEAD OF UPDATE " \
|
||||
"ON moz_historyvisits_view " \
|
||||
"BEGIN " \
|
||||
"INSERT OR IGNORE INTO moz_historyvisits_temp " \
|
||||
"SELECT * " \
|
||||
"FROM moz_historyvisits " \
|
||||
"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), " \
|
||||
@ -226,18 +228,18 @@
|
||||
* 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) NS_LITERAL_CSTRING( \
|
||||
#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 " " \
|
||||
"SELECT * FROM " __table "_temp " \
|
||||
"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")
|
||||
CREATE_TEMP_SYNC_TRIGGER_BASE("moz_places", MOZ_PLACES_COLUMNS)
|
||||
#define CREATE_MOZ_HISTORYVISITS_SYNC_TRIGGER \
|
||||
CREATE_TEMP_SYNC_TRIGGER_BASE("moz_historyvisits")
|
||||
CREATE_TEMP_SYNC_TRIGGER_BASE("moz_historyvisits", MOZ_HISTORYVISITS_COLUMNS)
|
||||
|
||||
#endif // __nsPlacesTriggers_h__
|
||||
|
Loading…
Reference in New Issue
Block a user