Mailing List Archive

[Bug 8042] Bayes warnings when using MySQL
https://bz.apache.org/SpamAssassin/show_bug.cgi?id=8042

Kent Oyer <kent@mxguardian.net> changed:

What |Removed |Added
----------------------------------------------------------------------------
CC| |kent@mxguardian.net

--- Comment #9 from Kent Oyer <kent@mxguardian.net> ---
I ran into this issue as well. I must have created my database back when the
token column was CHAR(5) instead on BINARY(5). I agree that changing the schema
is the proper solution but changing the schema on a production table with 200
million rows requires some time and effort. I found that a quick workaround is
to change the query to cast the values to binary format.

--- a/lib/Mail/SpamAssassin/BayesStore/MySQL.pm
+++ b/lib/Mail/SpamAssassin/BayesStore/MySQL.pm
@@ -438,7 +438,7 @@ sub tok_get_all {

$bunch_end = $search_index + $bunch_size;
for ( ; $search_index < $bunch_end; $search_index++) {
- $in_str .= '?,';
+ $in_str .= 'BINARY ?,';
push(@tok, $tokens[$search_index]);
}
chop $in_str;


This will prevent the "Illegal mix of collations" error and get your Bayes
working right away. I don't know if it's worth including in the next release or
not but I'm posting here in case it helps someone.

On another note...it would have been very helpful if the SQL error message was
a `warn` instead of a `dbg`. I would have been able to catch this problem
sooner if it showed up in my logs.

--- a/lib/Mail/SpamAssassin/BayesStore/MySQL.pm
+++ b/lib/Mail/SpamAssassin/BayesStore/MySQL.pm
@@ -461,7 +461,7 @@ sub tok_get_all {
my $rc = $sth->execute();

unless ($rc) {
- dbg("bayes: tok_get_all: SQL error: ".$self->{_dbh}->errstr());
+ warn("bayes: tok_get_all: SQL error: ".$self->{_dbh}->errstr());
$self->{_dbh}->rollback();
return [];
}

There are 41 other instances like this in MySQL.pm. I can submit new bug report
with a patch file if there is interest.

Thanks
Kent

--
You are receiving this mail because:
You are the assignee for the bug.