Some weird sqlite error stopping all upgrades/installs

Rainer Müller raimue at macports.org
Wed Oct 7 12:50:58 PDT 2015


On 2015-10-06 11:30, Clemens Lang wrote:
> You upgraded to a trunk version of MacPorts, which automatically updated your
> database to database version 1.202. In 1.202, I dropped a couple of fields (see
> [1]) we initially added to be future-compatible but never ended up using and can
> now be easily re-added if we need them due to the database upgrade code (that was
> not present when we initially wrote the database layout).
> 
> Then later on, you downgraded to 2.3.4, which is not compatible with these changes.

I added a check on trunk adds to detect this situation. That should
hopefully help to assess this problem in the future.

https://lists.macosforge.org/pipermail/macports-changes/2015-October/127461.html

Rainer
-------------- next part --------------
Index: src/cregistry/sql.c
===================================================================
--- src/cregistry/sql.c	(revision 140980)
+++ src/cregistry/sql.c	(working copy)
@@ -584,8 +584,17 @@
          *    already been started for you
          *  - end your query list with "COMMIT", NULL
          *  - set did_update = 1 and continue;
+         *  - update the current version number below
          */
 
+        if (sql_version(NULL, -1, version, -1, "1.202") > 0) {
+            /* the registry was already upgraded to a newer version and cannot be used anymore */
+            reg_throw(errPtr, REG_INVALID, "Version number in metadata table is newer than expected.");
+            sqlite3_finalize(stmt);
+            rollback_db(db);
+            return 0;
+        }
+
         /* if we arrive here, no update was done and we should end the
          * transaction. Using ROLLBACK here causes problems when rolling back
          * other transactions later in the program. */


More information about the macports-dev mailing list