Bug 784878 - Use version 2 by default when no version in found in permissions.sqlite. r=sicking
authorMounir Lamouri <mounir.lamouri@gmail.com>
Thu, 23 Aug 2012 11:42:52 -0700
changeset 105169 53f3963dedc01f50f36a94c39f9110622f1f2040
parent 105168 82eea30b2963d3e621dd11214b6958cdd0e1c044
child 105170 4bb90f8c690974bc60f9df01a36f275729248c24
child 105260 6bd825157e6cc3050804ceb2b901fd5f62dfc79f
push id55
push usershu@rfrn.org
push dateThu, 30 Aug 2012 01:33:09 +0000
reviewerssicking
bugs784878, 784884
milestone17.0a1
Bug 784878 - Use version 2 by default when no version in found in permissions.sqlite. r=sicking This is a patch to workaround the fact that talos has wrongly gerenated permissions.sqlite files which don't have a user_version and are version 2. This is going to be replaced by a MOZ_ASSERT by bug 784884.
extensions/cookie/nsPermissionManager.cpp
--- a/extensions/cookie/nsPermissionManager.cpp
+++ b/extensions/cookie/nsPermissionManager.cpp
@@ -403,16 +403,18 @@ nsPermissionManager::InitDB(bool aRemove
 
         rv = mDBConn->ExecuteSimpleSQL(NS_LITERAL_CSTRING(
               "ALTER TABLE moz_hosts ADD expireTime INTEGER"));
         NS_ENSURE_SUCCESS(rv, rv);
       }
 
       // fall through to the next upgrade
 
+    // TODO: we want to make default version as version 2 in order to fix bug 784875.
+    case 0:
     case 2:
       {
         // Add appId/isInBrowserElement fields.
         rv = mDBConn->ExecuteSimpleSQL(NS_LITERAL_CSTRING(
               "ALTER TABLE moz_hosts ADD appId INTEGER"));
         NS_ENSURE_SUCCESS(rv, rv);
 
         rv = mDBConn->ExecuteSimpleSQL(NS_LITERAL_CSTRING(
@@ -424,30 +426,16 @@ nsPermissionManager::InitDB(bool aRemove
       }
 
       // fall through to the next upgrade
 
     // current version.
     case HOSTS_SCHEMA_VERSION:
       break;
 
-    case 0:
-      {
-        NS_WARNING("couldn't get schema version!");
-          
-        // the table may be usable; someone might've just clobbered the schema
-        // version. we can treat this case like a downgrade using the codepath
-        // below, by verifying the columns we care about are all there. for now,
-        // re-set the schema version in the db, in case the checks succeed (if
-        // they don't, we're dropping the table anyway).
-        rv = mDBConn->SetSchemaVersion(HOSTS_SCHEMA_VERSION);
-        NS_ENSURE_SUCCESS(rv, rv);
-      }
-      // fall through to downgrade check
-
     // downgrading.
     // if columns have been added to the table, we can still use the ones we
     // understand safely. if columns have been deleted or altered, just
     // blow away the table and start from scratch! if you change the way
     // a column is interpreted, make sure you also change its name so this
     // check will catch it.
     default:
       {