From 77984d4ce326dd9feebcdb6a3eb612886f9cba79 Mon Sep 17 00:00:00 2001 From: "dmose%mozilla.org" Date: Tue, 28 Feb 2006 21:24:46 +0000 Subject: [PATCH] Fix storage calendar version migration bustage caused by failure to call reset() on a statement. Thanks to Stefan Sitter for the patch; r=dmose. --- calendar/providers/storage/calStorageCalendar.js | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/calendar/providers/storage/calStorageCalendar.js b/calendar/providers/storage/calStorageCalendar.js index 793afea441da..ab5221013ca1 100644 --- a/calendar/providers/storage/calStorageCalendar.js +++ b/calendar/providers/storage/calStorageCalendar.js @@ -861,24 +861,34 @@ calStorageCalendar.prototype = { */ getVersion: function calStorageGetVersion() { var selectSchemaVersion; + var version = null; try { selectSchemaVersion = createStatement(this.mDB, "SELECT version FROM " + "cal_calendar_schema_version LIMIT 1"); if (selectSchemaVersion.step()) { - return selectSchemaVersion.row.version; + version = selectSchemaVersion.row.version; + } + selectSchemaVersion.reset(); + + if (version !== null) { + // This is the only place to leave this function gracefully. + return version; } } catch (e) { + if (selectSchemaVersion) { + selectSchemaVersion.reset(); + } dump ("++++++++++++ calStorageGetVersion() error: " + this.mDB.lastErrorString + "\n"); Components.utils.reportError("Error getting storage calendar " + "schema version! DB Error: " + this.mDB.lastErrorString); throw e; - } + } - throw "cal_calendar_schema_version SELECT returned no results"; + throw "cal_calendar_schema_version SELECT returned no results"; }, upgradeDB: function (oldVersion) {