upgrades

Clint Adams schizo at debian.org
Thu Nov 11 02:27:26 CET 2004


Since I'm going to want to switch to db4.3 soon, I propose the following
auto-upgrade code.  I haven't tested this at all.

Index: src/datastore_db.c
===================================================================
RCS file: /cvsroot/bogofilter/bogofilter/src/datastore_db.c,v
retrieving revision 1.118
diff -u -r1.118 datastore_db.c
--- src/datastore_db.c	10 Nov 2004 16:21:57 -0000	1.118
+++ src/datastore_db.c	11 Nov 2004 01:25:28 -0000
@@ -131,6 +131,31 @@
 		database ? database : "NIL", type, (unsigned long)flags,
 		resolveopenflags(flags), mode, ret, db_strerror(ret));
 
+    if (ret == DB_OLD_VERSION)
+    {
+	ret = db->upgrade(db, file, 0);
+
+    	if (DEBUG_DATABASE(1) || getenv("BF_DEBUG_DB_UPGRADE"))
+	    fprintf(dbgout, "[pid %lu] DB->upgrade(db=%p, file=%s, "
+		"flags=0) -> %d %s\n",
+		(unsigned long)getpid(), (void *)db, file,
+		ret, db_strerror(ret));
+
+	ret = db->open(db,
+#if DB_AT_LEAST(4,1)
+	    0,	/* TXN handle - we use autocommit instead */
+#endif
+	    file, database, type, flags, mode);
+
+    	if (DEBUG_DATABASE(1) || getenv("BF_DEBUG_DB_OPEN"))
+	    fprintf(dbgout, "[pid %lu] DB->open(db=%p, file=%s, database=%s, "
+		"type=%x, flags=%#lx=%s, mode=%#o) -> %d %s\n",
+		(unsigned long)getpid(), (void *)db, file,
+		database ? database : "NIL", type, (unsigned long)flags,
+		resolveopenflags(flags), mode, ret, db_strerror(ret));
+
+    }
+
     return ret;
 }
 



More information about the bogofilter-dev mailing list