You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@spamassassin.apache.org by Dave Hansen <da...@sr71.net> on 2025/03/07 15:41:16 UTC

[PATCH] Avoid accidental use of BayesStore::SQL with MySQL or Postgres

The longer story is in here:

	https://bz.apache.org/SpamAssassin/show_bug.cgi?id=8315

But the short version is: I have a spamassassin config that is a bit
old. I'd say I originally wrote it in ~2005. It's been happily using:

bayes_store_module           Mail::SpamAssassin::BayesStore::SQL

for many, many years with both Postgres and MySQL. But, after a recent
Debian upgrade, bayes filtering broke because BayesStore::SQL stopped
working for MySQL. The failure mode is really insidious because the
tokens go in the database just fine and spam/ham classification
_happens_, just very badly.

The Mail::SpamAssassin::BayesStore::SQL manpage has been updated to
say not to use BayesStore::SQL with MySQL, which is great. But I
suspect that won't reach many existing users.  sql/README.bayes also
talks about BayesStore::MySQL as being a tiny optimization over
BayesStore::SQL and doesn't talk about this landmine. So the docs are
inconsistent at best.

Considering that my config worked and worked for a *LONG* time, could
we add a little check to the BayesStore::SQL code to make it fail more
quickly and gracefully?

The attached patch looks at the DBI handle and checks for "mysql" and
"Pg" databases. If it sees one, it refuses to proceed and spits an
error into the debug log. This should be a lot easier on users because
the failure is much more obvious and explicit.

I also updated the bayes README just to make it clear that you *must*
use the right module for your database. It's not just a "small boost
in performance".

If this is something folks are interested merging, I'd appreciate any
guidance for how best to submit these changes. I'm happy to send along
individual patches or open up Bugzilla entries for these. Just let me
know what's easiest on you folks.