Bug 386368 - Use getters and setters for database schema version. r=sspitzer

This commit is contained in:
sdwilsh@shawnwilsher.com 2007-07-02 10:25:41 -07:00
parent dd606dc17d
commit 9091040e12

View File

@ -521,18 +521,8 @@ nsNavHistory::InitDB(PRBool *aDoImport)
// Get the places schema version, which we store in the user_version PRAGMA // Get the places schema version, which we store in the user_version PRAGMA
PRInt32 DBSchemaVersion; PRInt32 DBSchemaVersion;
{ rv = mDBConn->GetSchemaVersion(&DBSchemaVersion);
nsCOMPtr<mozIStorageStatement> statement; NS_ENSURE_SUCCESS(rv, rv);
rv = mDBConn->CreateStatement(NS_LITERAL_CSTRING("PRAGMA user_version"),
getter_AddRefs(statement));
NS_ENSURE_SUCCESS(rv, rv);
PRBool hasResult;
rv = statement->ExecuteStep(&hasResult);
NS_ENSURE_SUCCESS(rv, rv);
NS_ENSURE_TRUE(hasResult, NS_ERROR_FAILURE);
DBSchemaVersion = statement->AsInt32(0);
}
if (PLACES_SCHEMA_VERSION != DBSchemaVersion) { if (PLACES_SCHEMA_VERSION != DBSchemaVersion) {
// Migration How-to: // Migration How-to:
@ -711,9 +701,7 @@ nsNavHistory::InitDB(PRBool *aDoImport)
nsresult nsresult
nsNavHistory::UpdateSchemaVersion() nsNavHistory::UpdateSchemaVersion()
{ {
nsCAutoString schemaVersionPragma("PRAGMA user_version="); return mDBConn->SetSchemaVersion(PLACES_SCHEMA_VERSION);
schemaVersionPragma.AppendInt(PLACES_SCHEMA_VERSION);
return mDBConn->ExecuteSimpleSQL(schemaVersionPragma);
} }
// nsNavHistory::InitStatements // nsNavHistory::InitStatements