Ilja Booij wrote:
On Fri, 24 Sep 2004 22:53:25 +0200, Paul J Stevens [EMAIL PROTECTED] wrote:
Leif, I see your point, but I feel that migration from 1.2 to 2.0 will be and
remain non-trivial for all
users. In fact, so much so, that I feel that dbmail-smtp/imapd/pop3d actually
should refuse to run at all
against a database in 1.2 state. The fact that they do run are cause for
serious concern from my point of view
as debian maintainer.
Agreed. Perhaps we can do something simple like this:
check if the physmessage table is present. If it's not - refuse to run.
Ilja, I thought it would be easiest to provide a patch in the dbmail packages
that does just this.
For people who migrate from dbmail-1.2 this patch might be of use.
Basically i run: select 1=1 from dbmail_physmessage limit 1 offset 0 to check
for the physmessage table, which should work in mysql and postgresql both.
--
Paul Stevens [EMAIL PROTECTED]
NET FACILITIES GROUP GPG/PGP: 1024D/11F8CD31
The Netherlands___www.nfg.nl
#! /bin/sh -e
## 04_version_check.dpatch by [EMAIL PROTECTED]
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: No description.
if [ $# -lt 1 ]; then
echo `basename $0`: script expects -patch|-unpatch as argument 2
exit 1
fi
[ -f debian/patches/00patch-opts ] . debian/patches/00patch-opts
patch_opts=${patch_opts:--f --no-backup-if-mismatch} ${2:+-d $2}
case $1 in
-patch) patch -p1 ${patch_opts} $0;;
-unpatch) patch -R -p1 ${patch_opts} $0;;
*)
echo `basename $0`: script expects -patch|-unpatch as argument 2
exit 1;;
esac
exit 0
@DPATCH@
diff -urNad /usr/src/dbmail2/dbmail-2.0.0/db.c dbmail-2.0.0/db.c
--- /usr/src/dbmail2/dbmail-2.0.0/db.c 2004-09-27 12:56:08.0 +0200
+++ dbmail-2.0.0/db.c 2004-09-27 12:56:51.0 +0200
@@ -131,6 +131,20 @@
*/
void convert_inbox_to_uppercase(char *name);
+/*
+ * check to make sure the database has been upgraded
+ */
+int db_check_version(void)
+{
+ snprintf(query, DEF_QUERYSIZE, SELECT 1=1 FROM dbmail_physmessage
LIMIT 1 OFFSET 0);
+ if (db_query(query) == -1) {
+ trace(TRACE_FATAL, %s,%s: database incompatible. You may need
to run the conversion script,
+ __FILE__,__func__);
+ return -1;
+ }
+ return 0;
+}
+
int db_begin_transaction()
{
snprintf(query, DEF_QUERYSIZE,
diff -urNad /usr/src/dbmail2/dbmail-2.0.0/db.h dbmail-2.0.0/db.h
--- /usr/src/dbmail2/dbmail-2.0.0/db.h 2004-09-27 12:56:08.0 +0200
+++ dbmail-2.0.0/db.h 2004-09-27 12:56:08.0 +0200
@@ -76,6 +76,12 @@
*/
int db_connect(void);
+/*
+ * make sure we're running against a 2.0 database layout
+ */
+
+int db_check_version(void);
+
/**
* \brief disconnect from database server
* \return 0
diff -urNad /usr/src/dbmail2/dbmail-2.0.0/main.c dbmail-2.0.0/main.c
--- /usr/src/dbmail2/dbmail-2.0.0/main.c2004-09-27 12:56:08.0
+0200
+++ dbmail-2.0.0/main.c 2004-09-27 12:56:08.0 +0200
@@ -355,6 +355,11 @@
exitcode = EX_TEMPFAIL;
goto freeall;
}
+
+ if (db_check_version() != 0) {
+ exitcode = EX_TEMPFAIL;
+ goto freeall;
+ }
/* read the whole message */
if (read_whole_message_pipe(stdin, whole_message,
diff -urNad /usr/src/dbmail2/dbmail-2.0.0/maintenance.c
dbmail-2.0.0/maintenance.c
--- /usr/src/dbmail2/dbmail-2.0.0/maintenance.c 2004-09-27 12:56:08.0
+0200
+++ dbmail-2.0.0/maintenance.c 2004-09-27 12:56:08.0 +0200
@@ -224,6 +224,11 @@
return -1;
}
+ if (db_check_version() != 0) {
+ printf(Database version incompatible. Please upgrade your
database.\n);
+ return -1;
+ }
+
printf(Ok. Connected\n);
if (purge_deleted) {
diff -urNad /usr/src/dbmail2/dbmail-2.0.0/serverchild.c
dbmail-2.0.0/serverchild.c
--- /usr/src/dbmail2/dbmail-2.0.0/serverchild.c 2004-09-27 12:56:08.0
+0200
+++ dbmail-2.0.0/serverchild.c 2004-09-27 12:56:08.0 +0200
@@ -277,6 +277,8 @@
PerformChildTask(): could not connect to
authentication);
return -1;
}
+ if (db_check_version() != 0)
+ return -1;
srand((int) ((int) time(NULL) + (int) getpid()));
connected = 1;
diff -urNad /usr/src/dbmail2/dbmail-2.0.0/sievecmd.c dbmail-2.0.0/sievecmd.c
--- /usr/src/dbmail2/dbmail-2.0.0/sievecmd.c2004-09-27 12:56:08.0
+0200
+++ dbmail-2.0.0/sievecmd.c 2004-09-27 12:56:08.0 +0200
@@ -120,6 +120,12 @@
(Failed. Could not connect to authentication
(check log)\n);
return -1;
}
+