Package: spamassassin
Version: 3.1.0a-2
Severity: normal
The file /usr/share/doc/spamassassin/sql/bayes_pg.sql included with
spamassassin causes syntax errors on sarge's postgres (7.4) in the
last function. I have fixed it up, and include the last function with
this email. I am a recent convert to postgres, so I may be missing
something, but the included one just blew up, so I sort of think not
:)
Thanks,
-- System Information:
Debian Release: 3.1
Architecture: powerpc (ppc)
Kernel: Linux 2.6.8-powerpc
Locale: LANG=en_US.ISO-8859-1, LC_CTYPE=en_US.ISO-8859-1 (charmap=ISO-8859-1)
(ignored: LC_ALL set to en_US.ISO-8859-1)
Versions of packages spamassassin depends on:
ii libdigest-sha1-perl 2.10-1 NIST SHA-1 message digest algorith
ii libhtml-parser-perl 3.45-2 A collection of modules that parse
ii libnet-dns-perl 0.48-1 Perform DNS queries from a Perl sc
ii libsocket6-perl 0.17-1 Perl extensions for IPv6
ii perl 5.8.4-8sarge3 Larry Wall's Practical Extraction
-- debconf information:
spamassassin/upgrade/2.40:
spamassassin/upgrade/2.40w:
spamassassin/upgrade/cancel: Continue
spamassassin/upgrade/2.42m: No
spamassassin/upgrade/2.42u: No
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
for i in array_lower(intokenary, 1) .. array_upper(intokenary, 1)
LOOP
_token := intokenary[i];
UPDATE bayes_token
SET spam_count = greatest_int(spam_count + inspam_count, 0),
ham_count = greatest_int(ham_count + inham_count, 0),
atime = greatest_int(atime, inatime)
WHERE id = inuserid
AND token = _token;
IF NOT FOUND THEN
IF NOT (inspam_count < 0 OR inham_count < 0) THEN
INSERT INTO bayes_token (id, token, spam_count, ham_count, atime)
VALUES (inuserid, _token, inspam_count, inham_count, inatime);
IF FOUND THEN
new_tokens := new_tokens + 1;
END IF;
END IF;
END IF;
END LOOP;
IF new_tokens > 0 AND inatime > 0 THEN
UPDATE bayes_vars
SET token_count = token_count + new_tokens,
newest_token_age = greatest_int(newest_token_age, inatime),
oldest_token_age = least_int(oldest_token_age, inatime)
WHERE id = inuserid;
ELSIF new_tokens > 0 AND NOT inatime > 0 THEN
UPDATE bayes_vars
SET token_count = token_count + new_tokens
WHERE id = inuserid;
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)
WHERE id = inuserid;
END IF;
RETURN;
END;
' LANGUAGE 'plpgsql';