You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spamassassin.apache.org by mm...@apache.org on 2007/09/26 16:48:02 UTC
svn commit: r579680 - in /spamassassin/trunk/sql: README.bayes bayes_pg.sql
Author: mmartinec
Date: Wed Sep 26 07:48:01 2007
New Revision: 579680
URL: http://svn.apache.org/viewvc?rev=579680&view=rev
Log:
applied patch in 4653, fixes PostgreSQL 7.* and does not hurt 8.*
Modified:
spamassassin/trunk/sql/README.bayes
spamassassin/trunk/sql/bayes_pg.sql
Modified: spamassassin/trunk/sql/README.bayes
URL: http://svn.apache.org/viewvc/spamassassin/trunk/sql/README.bayes?rev=579680&r1=579679&r2=579680&view=diff
==============================================================================
--- spamassassin/trunk/sql/README.bayes (original)
+++ spamassassin/trunk/sql/README.bayes Wed Sep 26 07:48:01 2007
@@ -3,7 +3,7 @@
-------------------------------------------------------
SpamAssassin can now store users' bayesian filter data in a SQL
-database. The most common use for a system like this would be for
+database. The most common use for a system like this would be for
users to be able to have per user bayesian filter data on systems
where users may not have a home directory to store the data.
@@ -50,7 +50,7 @@
you have installed to access your database (initially tested with
MySQL, PostgreSQL, and SQLite). <database> must be the name of the
database that you created to store the bayes data tables. <hostname>
-is the name of the host that contains the SQL database server.
+is the name of the host that contains the SQL database server.
<port> is the optional port number where your database server is
listening.
@@ -73,8 +73,9 @@
In order for SpamAssassin to work with your SQL database, you must
have the perl DBI module installed, AS WELL AS the DBD driver/module
for your specific database. For example, if using MySQL as your
-RDBMS, you must have the DBD::mysql module installed. Check CPAN for
-the latest versions of DBI and your database driver/module.
+RDBMS, you must have the DBD::mysql module installed, a PostgreSQL
+database requires DBD::Pg. Check CPAN for latest versions of DBI
+and your database driver/module.
The BayesStore::SQL module was tested with:
@@ -82,8 +83,8 @@
DBD-mysql-2.9002
perl v5.8.0
-But older versions should work fine as the SQL code in SpamAssassin is as
-simple as could be.
+But older (and newer) versions should work fine as the SQL code in
+SpamAssassin is as simple as could be.
NOTE: Some users have reported problems using DBD::Pg v1.22. There appears
to be a bug in how parameters are quoted in that version, we recommend you
@@ -131,10 +132,6 @@
psql -U <username> -f bayes_pg.sql <databasename>
-(If you are using older versions of PostgreSQL, such as version 7.4.x, you may
-need to patch this. See
-http://issues.apache.org/SpamAssassin/show_bug.cgi?id=4653 )
-
From a security viewpoint, it is wise to grant the minimum privileges
needed to the user on the bayes tables. These grants largely depend
on your system policies but here are some example grants to get you
@@ -159,7 +156,7 @@
then test spamd with a message by calling spamc. You can use the
sample-spam.txt file with the following command:
-cat sample-spam.txt | spamc
+spamc < sample-spam.txt
Watch the debug output from spamd and look for the following debug
line:
@@ -210,4 +207,3 @@
NOTE: sa-learn must be run as the user who's data you are loading, or
you must make use of the bayes_sql_override_username config
option.
-
Modified: spamassassin/trunk/sql/bayes_pg.sql
URL: http://svn.apache.org/viewvc/spamassassin/trunk/sql/bayes_pg.sql?rev=579680&r1=579679&r2=579680&view=diff
==============================================================================
--- spamassassin/trunk/sql/bayes_pg.sql (original)
+++ spamassassin/trunk/sql/bayes_pg.sql Wed Sep 26 07:48:01 2007
@@ -60,13 +60,18 @@
AS 'SELECT CASE WHEN $1 < $2 THEN $1 ELSE $2 END;'
LANGUAGE SQL;
-CREATE OR REPLACE FUNCTION put_tokens(inuserid INTEGER,
- intokenary BYTEA[],
- inspam_count INTEGER,
- inham_count INTEGER,
- inatime INTEGER)
+CREATE OR REPLACE FUNCTION put_tokens(INTEGER,
+ BYTEA[],
+ INTEGER,
+ INTEGER,
+ INTEGER)
RETURNS VOID AS '
DECLARE
+ inuserid ALIAS FOR $1;
+ intokenary ALIAS FOR $2;
+ inspam_count ALIAS FOR $3;
+ inham_count ALIAS FOR $4;
+ inatime ALIAS FOR $5;
_token BYTEA;
new_tokens INTEGER := 0;
BEGIN
@@ -97,11 +102,11 @@
newest_token_age = greatest_int(newest_token_age, inatime),
oldest_token_age = least_int(oldest_token_age, inatime)
WHERE id = inuserid;
- ELSEIF new_tokens > 0 AND NOT inatime > 0 THEN
+ ELSIF new_tokens > 0 AND NOT inatime > 0 THEN
UPDATE bayes_vars
SET token_count = token_count + new_tokens
WHERE id = inuserid;
- ELSEIF NOT new_tokens > 0 AND inatime > 0 THEN
+ ELSIF NOT new_tokens > 0 AND inatime > 0 THEN
UPDATE bayes_vars
SET newest_token_age = greatest_int(newest_token_age, inatime),
oldest_token_age = least_int(oldest_token_age, inatime)