зеркало из https://github.com/mozilla/gecko-dev.git
Backed out changeset f8dfee6dc6e5 (bug 1549912) for xpcshell failure on test_permmanager_migrate_9-10.js CLOSE TREE.
This commit is contained in:
Родитель
f5a15fe9db
Коммит
39769bf17e
|
@ -1572,8 +1572,58 @@ nsresult nsPermissionManager::InitDB(bool aRemoveFile) {
|
|||
// fall through to the next upgrade
|
||||
MOZ_FALLTHROUGH;
|
||||
|
||||
// Version 10 removes appId from moz_hosts. SQLite doesn't support the
|
||||
// dropping of columns from existing tables. We need to create a temporary
|
||||
// table, copy the data, drop the old table, rename the new one.
|
||||
case 9: {
|
||||
rv = mDBConn->SetSchemaVersion(HOSTS_SCHEMA_VERSION);
|
||||
rv = mDBConn->BeginTransaction();
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
bool tableExists = false;
|
||||
mDBConn->TableExists(NS_LITERAL_CSTRING("moz_hosts_v9"), &tableExists);
|
||||
if (tableExists) {
|
||||
NS_WARNING(
|
||||
"The temporary database moz_hosts_v9 already exists, dropping "
|
||||
"it.");
|
||||
rv = mDBConn->ExecuteSimpleSQL(
|
||||
NS_LITERAL_CSTRING("DROP TABLE moz_hosts_v9"));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
rv = mDBConn->ExecuteSimpleSQL(
|
||||
NS_LITERAL_CSTRING("CREATE TABLE moz_hosts_v9 ("
|
||||
" id INTEGER PRIMARY KEY"
|
||||
",host TEXT"
|
||||
",type TEXT"
|
||||
",permission INTEGER"
|
||||
",expireType INTEGER"
|
||||
",expireTime INTEGER"
|
||||
",modificationTime INTEGER"
|
||||
",isInBrowserElement INTEGER"
|
||||
")"));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = mDBConn->ExecuteSimpleSQL(NS_LITERAL_CSTRING(
|
||||
"INSERT INTO moz_hosts_v9 "
|
||||
"(id, host, type, permission, expireType, "
|
||||
"expireTime, modificationTime, isInBrowserElement) "
|
||||
"SELECT id, host, type, permission, expireType, expireTime, "
|
||||
"modificationTime, isInBrowserElement FROM moz_hosts WHERE appId = "
|
||||
"0"));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = mDBConn->ExecuteSimpleSQL(
|
||||
NS_LITERAL_CSTRING("DROP TABLE moz_hosts"));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = mDBConn->ExecuteSimpleSQL(
|
||||
NS_LITERAL_CSTRING("ALTER TABLE moz_hosts_v9 RENAME TO moz_hosts"));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = mDBConn->SetSchemaVersion(10);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = mDBConn->CommitTransaction();
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче