Update of /cvsroot/bogofilter/bogofilter/src
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1734/src
Modified Files:
datastore_sqlite.c
Log Message:
(sqlite3 based builds only) Print reminder to register tokens before
scoring if preparing the SELECT statement fails.
Index: datastore_sqlite.c
===================================================================
RCS file: /cvsroot/bogofilter/bogofilter/src/datastore_sqlite.c,v
retrieving revision 1.41
retrieving revision 1.42
diff -u -d -r1.41 -r1.42
--- datastore_sqlite.c 4 Sep 2005 14:49:43 -0000 1.41
+++ datastore_sqlite.c 6 Sep 2005 08:56:44 -0000 1.42
@@ -152,12 +152,14 @@
return rc;
}
-static sqlite3_stmt *sqlprep(dbh_t *dbh, const char *cmd) {
+static sqlite3_stmt *sqlprep(dbh_t *dbh, const char *cmd, bool bailout /** exit on error? */) {
const char *tail; /* dummy */
sqlite3_stmt *ptr;
if (sqlite3_prepare(dbh->db, cmd, strlen(cmd), &ptr, &tail) != SQLITE_OK) {
print_error(__FILE__, __LINE__, "cannot compile %s: %s\n", cmd, sqlite3_errmsg(dbh->db));
- exit(EX_ERROR);
+ if (bailout)
+ exit(EX_ERROR);
+ return NULL;
}
return ptr;
}
@@ -357,8 +359,16 @@
* dbh->insert is not here as it's needed earlier,
* so it sets itself up lazily
*/
- dbh->select = sqlprep(dbh, "SELECT value FROM bogofilter WHERE key=? LIMIT 1;");
- dbh->delete = sqlprep(dbh, "DELETE FROM bogofilter WHERE(key = ?);");
+ dbh->select = sqlprep(dbh, "SELECT value FROM bogofilter WHERE key=? LIMIT 1;", false);
+ if (dbh->select == NULL)
+ {
+ fprintf(stderr,
+ "\nRemember to register some spam and ham messages before you\n"
+ "use bogofilter to evaluate mail for its probable spam status!\n\n");
+ exit(EX_ERROR);
+ }
+
+ dbh->delete = sqlprep(dbh, "DELETE FROM bogofilter WHERE(key = ?);", true);
/* check if byteswapped */
{
@@ -504,7 +514,7 @@
dbh_t *dbh = vhandle;
if (!dbh->insert)
- dbh->insert = sqlprep(dbh, "INSERT OR REPLACE INTO bogofilter VALUES(?,?);");
+ dbh->insert = sqlprep(dbh, "INSERT OR REPLACE INTO bogofilter VALUES(?,?);", true);
sqlite3_bind_blob(dbh->insert, 1, key->data, key->leng, SQLITE_STATIC);
sqlite3_bind_blob(dbh->insert, 2, val->data, val->leng, SQLITE_STATIC);
|