Bug 1748509 - Add builder fields to snapshot groups and more indices. r=mak

Differential Revision: https://phabricator.services.mozilla.com/D135122
This commit is contained in:
Mark Banner 2022-01-07 07:20:35 +00:00
Родитель 6e286e149e
Коммит 9f226277e4
9 изменённых файлов: 89 добавлений и 7 удалений

Просмотреть файл

@ -474,7 +474,7 @@ const startupPhases = {
stat: 4,
fsync: 3,
read: 48,
write: 172,
write: 181,
},
{
// bug 1391590
@ -490,7 +490,7 @@ const startupPhases = {
fsync: 2,
read: 4,
stat: 3,
write: 1321,
write: 1324,
},
{
// bug 1391590

Просмотреть файл

@ -1225,7 +1225,12 @@ nsresult Database::InitSchema(bool* aDatabaseMigrated) {
NS_ENSURE_SUCCESS(rv, rv);
}
// Firefox 97 uses schema version 61
if (currentSchemaVersion < 62) {
rv = MigrateV62Up();
NS_ENSURE_SUCCESS(rv, rv);
}
// Firefox 97 uses schema version 62
// Schema Upgrades must add migration code here.
// >>> IMPORTANT! <<<
@ -1322,6 +1327,8 @@ nsresult Database::InitSchema(bool* aDatabaseMigrated) {
rv = mMainConn->ExecuteSimpleSQL(
CREATE_IDX_MOZ_PLACES_METADATA_PLACECREATED);
NS_ENSURE_SUCCESS(rv, rv);
rv = mMainConn->ExecuteSimpleSQL(CREATE_IDX_MOZ_PLACES_METADATA_REFERRER);
NS_ENSURE_SUCCESS(rv, rv);
// moz_places_metadata_search_queries
rv = mMainConn->ExecuteSimpleSQL(CREATE_MOZ_PLACES_METADATA_SEARCH_QUERIES);
@ -1330,11 +1337,17 @@ nsresult Database::InitSchema(bool* aDatabaseMigrated) {
// moz_places_metadata_snapshots
rv = mMainConn->ExecuteSimpleSQL(CREATE_MOZ_PLACES_METADATA_SNAPSHOTS);
NS_ENSURE_SUCCESS(rv, rv);
rv = mMainConn->ExecuteSimpleSQL(
CREATE_IDX_MOZ_PLACES_METADATA_SNAPSHOTS_PINNNED);
NS_ENSURE_SUCCESS(rv, rv);
// moz_places_metadata_snapshots_extra
rv =
mMainConn->ExecuteSimpleSQL(CREATE_MOZ_PLACES_METADATA_SNAPSHOTS_EXTRA);
NS_ENSURE_SUCCESS(rv, rv);
rv = mMainConn->ExecuteSimpleSQL(
CREATE_IDX_MOZ_PLACES_METADATA_SNAPSHOTS_EXTRA_TYPE);
NS_ENSURE_SUCCESS(rv, rv);
// moz_places_metadata_snapshots_groups
rv = mMainConn->ExecuteSimpleSQL(
@ -2366,6 +2379,32 @@ nsresult Database::MigrateV61Up() {
return NS_OK;
}
nsresult Database::MigrateV62Up() {
// Add previews tombstones table if necessary.
nsCOMPtr<mozIStorageStatement> stmt;
nsresult rv = mMainConn->CreateStatement(
"SELECT builder FROM moz_places_metadata_snapshots_groups"_ns,
getter_AddRefs(stmt));
if (NS_FAILED(rv)) {
rv = mMainConn->ExecuteSimpleSQL(
"ALTER TABLE moz_places "
"ADD COLUMN builder TEXT NOT NULL "
"ADD COLUMN builder_data TEXT "_ns);
NS_ENSURE_SUCCESS(rv, rv);
}
rv = mMainConn->ExecuteSimpleSQL(CREATE_IDX_MOZ_PLACES_METADATA_REFERRER);
NS_ENSURE_SUCCESS(rv, rv);
rv = mMainConn->ExecuteSimpleSQL(
CREATE_IDX_MOZ_PLACES_METADATA_SNAPSHOTS_PINNNED);
NS_ENSURE_SUCCESS(rv, rv);
rv = mMainConn->ExecuteSimpleSQL(
CREATE_IDX_MOZ_PLACES_METADATA_SNAPSHOTS_EXTRA_TYPE);
NS_ENSURE_SUCCESS(rv, rv);
return NS_OK;
}
nsresult Database::ConvertOldStyleQuery(nsCString& aURL) {
AutoTArray<QueryKeyValuePair, 8> tokens;
nsresult rv = TokenizeQueryString(aURL, &tokens);

Просмотреть файл

@ -18,7 +18,7 @@
// This is the schema version. Update it at any schema change and add a
// corresponding migrateVxx method below.
#define DATABASE_SCHEMA_VERSION 61
#define DATABASE_SCHEMA_VERSION 62
// Fired after Places inited.
#define TOPIC_PLACES_INIT_COMPLETE "places-init-complete"
@ -334,6 +334,7 @@ class Database final : public nsIObserver, public nsSupportsWeakReference {
nsresult MigrateV59Up();
nsresult MigrateV60Up();
nsresult MigrateV61Up();
nsresult MigrateV62Up();
void MigrateV52OriginFrecencies();

Просмотреть файл

@ -108,4 +108,18 @@
CREATE_PLACES_IDX("placecreated_uniqueindex", "moz_places_metadata", \
"place_id, created_at", "UNIQUE")
#define CREATE_IDX_MOZ_PLACES_METADATA_REFERRER \
CREATE_PLACES_IDX("referrerindex", "moz_places_metadata", \
"referrer_place_id", "")
// moz_places_metadata_snapshots
#define CREATE_IDX_MOZ_PLACES_METADATA_SNAPSHOTS_PINNNED \
CREATE_PLACES_IDX("pinnedindex", "moz_places_metadata_snapshots", \
"user_persisted, last_interaction_at", "")
// moz_places_metadata_snapshots_extra
#define CREATE_IDX_MOZ_PLACES_METADATA_SNAPSHOTS_EXTRA_TYPE \
CREATE_PLACES_IDX("typeindex", "moz_places_metadata_snapshots_extra", \
"type", "")
#endif // nsPlacesIndexes_h__

Просмотреть файл

@ -334,7 +334,9 @@
nsLiteralCString( \
"CREATE TABLE IF NOT EXISTS moz_places_metadata_snapshots_groups ( " \
" id INTEGER PRIMARY KEY, " \
" title TEXT NOT NULL " \
" title TEXT NOT NULL, " \
" builder TEXT NOT NULL, " \
" builder_data TEXT " \
")")
#define CREATE_MOZ_PLACES_METADATA_GROUPS_TO_SNAPSHOTS \

Просмотреть файл

@ -15,7 +15,7 @@ var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
// Put any other stuff relative to this test folder below.
const CURRENT_SCHEMA_VERSION = 61;
const CURRENT_SCHEMA_VERSION = 62;
const FIRST_UPGRADABLE_SCHEMA_VERSION = 43;
async function assertAnnotationsRemoved(db, expectedAnnos) {

Просмотреть файл

@ -47,3 +47,29 @@ add_task(async function previews_tombstones_in_database() {
let db = await PlacesUtils.promiseDBConnection();
await db.execute(`SELECT hash FROM moz_previews_tombstones`);
});
add_task(async function builder_fields_in_database() {
let db = await PlacesUtils.promiseDBConnection();
await db.execute(
`SELECT builder, builder_data FROM moz_places_metadata_snapshots_groups`
);
let rows = await db.execute(
`SELECT * FROM sqlite_master WHERE type = "index"`
);
let indexes = rows.map(r => r.getResultByName("name"));
Assert.ok(
indexes.includes("moz_places_metadata_referrerindex"),
"Should contain the referrer index"
);
Assert.ok(
indexes.includes("moz_places_metadata_snapshots_pinnedindex"),
"Should contain the pinned index"
);
Assert.ok(
indexes.includes("moz_places_metadata_snapshots_extra_typeindex"),
"Should contain the type index"
);
});

Просмотреть файл

@ -6,7 +6,7 @@ support-files =
places_outdated.sqlite
places_v43.sqlite
places_v54.sqlite
places_v61.sqlite
places_v62.sqlite
[test_current_from_downgraded.js]
[test_current_from_outdated.js]