Bug 617779 - Downgrading from places branch to trunk wrongly assumes the database is corrupt.

r=sdwilsh a=blocking
This commit is contained in:
Marco Bonardo 2010-12-09 20:14:45 +01:00
Родитель 6201f28da0
Коммит 4055083c0f
1 изменённых файлов: 16 добавлений и 12 удалений

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

@ -677,18 +677,22 @@ nsNavHistory::InitDB()
nsresult rv = mDBConn->GetSchemaVersion(&currentSchemaVersion);
NS_ENSURE_SUCCESS(rv, rv);
// Get the page size. This may be different than the default if the
// database file already existed with a different page size.
nsCOMPtr<mozIStorageStatement> statement;
rv = mDBConn->CreateStatement(NS_LITERAL_CSTRING("PRAGMA page_size"),
getter_AddRefs(statement));
NS_ENSURE_SUCCESS(rv, rv);
PRInt32 pageSize = 0;
{
// Get the page size. This may be different than the default if the
// database file already existed with a different page size.
nsCOMPtr<mozIStorageStatement> statement;
rv = mDBConn->CreateStatement(NS_LITERAL_CSTRING("PRAGMA page_size"),
getter_AddRefs(statement));
NS_ENSURE_SUCCESS(rv, rv);
PRBool hasResult;
mozStorageStatementScoper scoper(statement);
rv = statement->ExecuteStep(&hasResult);
NS_ENSURE_TRUE(NS_SUCCEEDED(rv) && hasResult, NS_ERROR_FAILURE);
PRInt32 pageSize = statement->AsInt32(0);
PRBool hasResult;
mozStorageStatementScoper scoper(statement);
rv = statement->ExecuteStep(&hasResult);
NS_ENSURE_TRUE(NS_SUCCEEDED(rv) && hasResult, NS_ERROR_FAILURE);
pageSize = statement->AsInt32(0);
}
NS_ASSERTION(pageSize >= 512 && pageSize <= 65536, "Invalid page size.");
// Ensure that temp tables are held in memory, not on disk. We use temp
// tables mainly for fsync and I/O reduction.
@ -734,7 +738,7 @@ nsNavHistory::InitDB()
rv = mDBConn->ExecuteSimpleSQL(NS_LITERAL_CSTRING(
"PRAGMA journal_mode = " DATABASE_JOURNAL_MODE));
NS_ENSURE_SUCCESS(rv, rv);
NS_ASSERTION(NS_SUCCEEDED(rv), "Unable to set journal mode.");
// We are going to initialize tables, so everything from now on should be in
// a transaction for performances.