Use getters and setters for database schema version

RESOLVED FIXED in mozilla1.9alpha8

Status

()

Toolkit
Preferences
RESOLVED FIXED
11 years ago
11 years ago

People

(Reporter: sdwilsh, Assigned: sdwilsh)

Tracking

Trunk
mozilla1.9alpha8
Points:
---
Bug Flags:
in-testsuite -

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

(Assignee)

Updated

11 years ago
Depends on: 386366
No longer depends on: 386184
(Assignee)

Comment 1

11 years ago
Created attachment 270556 [details] [diff] [review]
v1.0

not sure who is good to review this...
Assignee: nobody → sdwilsh
Status: NEW → ASSIGNED
(Assignee)

Updated

11 years ago
Attachment #270556 - Flags: review?(myk)
Comment on attachment 270556 [details] [diff] [review]
v1.0

>Index: toolkit/components/contentprefs/src/nsContentPrefService.js
>===================================================================
>RCS file: /cvsroot/mozilla/toolkit/components/contentprefs/src/nsContentPrefService.js,v
>retrieving revision 1.7
>diff -u -8 -p -r1.7 nsContentPrefService.js
>--- toolkit/components/contentprefs/src/nsContentPrefService.js	26 Jun 2007 04:57:30 -0000	1.7
>+++ toolkit/components/contentprefs/src/nsContentPrefService.js	2 Jul 2007 08:48:36 -0000
>@@ -683,25 +683,17 @@ ContentPrefService.prototype = {
>       this._log("no database file; creating database");
>       dbConnection = this._dbCreate(dbService, dbFile);
>     }
>     else {
>       try {
>         dbConnection = dbService.openDatabase(dbFile);
> 
>         // Get the version of the database in the file.
>-        var statement, version;
>-        try {
>-          statement = dbConnection.createStatement("PRAGMA user_version");
>-          statement.executeStep();
>-          version = statement.getInt32(0);
>-        }
>-        finally {
>-          statement.reset();
>-        }
>+        var version = dbConnection.schemaVersion;
> 
>         if (version != this._dbVersion) {
>           this._log("database: v" + version + ", application: v" +
>                     this._dbVersion + "; migrating database");
>           this._dbMigrate(dbConnection, version, this._dbVersion);
>         }

Seems like we could drop the temporary variable entirely here and just use dbConnection.schemaVersion wherever needed.  But it's ok this way too, and the rest of the patch looks great.  Thanks for adding this feature!
Attachment #270556 - Flags: review?(myk) → review+
(Assignee)

Comment 3

11 years ago
It still executes the query each time, so the member variable is probably a good thing to use.
(Assignee)

Comment 4

11 years ago
Checking in toolkit/components/contentprefs/src/nsContentPrefService.js;
new revision: 1.8; previous revision: 1.7
Status: ASSIGNED → RESOLVED
Last Resolved: 11 years ago
Resolution: --- → FIXED

Updated

11 years ago
Flags: in-testsuite-
You need to log in before you can comment on or make changes to this bug.