Hi there,
I've got some trouble using DB2 Express-C 9.5 for sql bayes and sql
based awl:
_WARN: Can't bind unknown parameter marker '2' at
/usr/lib/perl5/site_perl/5.8.8/Mail/SpamAssassin/SQLBasedAddrList.pm
line 197
I did some modification in BayesStore/SQL.pm and SQLBasedAddrList.pm
The resulting patch is attached. Please can someone check the modification?
Thanks,
Uwe
Index: Mail-SpamAssassin-3.2.5/lib/Mail/SpamAssassin/BayesStore/SQL.pm
===================================================================
--- Mail-SpamAssassin-3.2.5/lib/Mail/SpamAssassin/BayesStore/SQL.pm
(revision 3)
+++ Mail-SpamAssassin-3.2.5/lib/Mail/SpamAssassin/BayesStore/SQL.pm
(working copy)
@@ -433,9 +433,7 @@
return undef unless (defined($self->{_dbh}));
- my $sql = "SELECT flag FROM bayes_seen
- WHERE id = ?
- AND msgid = ?";
+ my $sql = "SELECT flag FROM bayes_seen WHERE id = ? AND msgid = ?";
my $sth = $self->{_dbh}->prepare_cached($sql);
@@ -444,8 +442,18 @@
return undef;
}
- my $rc = $sth->execute($self->{_userid}, $msgid);
+ dbg("MSG-ID: ".$msgid."\n");
+ dbg("UID : ".$self->{_userid}."\n");
+
+ $sth->bind_param(1, $self->{_userid});
+ $sth->bind_param(2, $msgid);
+
+
+ #no automatic bindings in DBD::DB2 here
+ #my $rc = $sth->execute($self->{_userid}, $msgid);
+ my $rc = $sth->execute();
+
unless ($rc) {
dbg("bayes: seen_get: SQL error: ".$self->{_dbh}->errstr());
return undef;
@@ -479,9 +487,22 @@
my $sql = "INSERT INTO bayes_seen (id, msgid, flag)
VALUES (?,?,?)";
- my $rows = $self->{_dbh}->do($sql,
- undef,
- $self->{_userid}, $msgid, $flag);
+ my $sth = $self->{_dbh}->prepare($sql);
+
+ unless (defined($sth)) {
+ dbg("bayes: seen_put: SQL error: ".$self->{_dbh}->errstr());
+ return undef;
+ }
+
+ $sth->bind_param(1, $self->{_userid});
+ $sth->bind_param(2, $msgid);
+ $sth->bind_param(3, $flag);
+
+ my $rows = $sth->execute();
+
+ #my $rows = $self->{_dbh}->do($sql,
+ # undef,
+ # $self->{_userid}, $msgid, $flag);
unless (defined($rows)) {
dbg("bayes: seen_put: SQL error: ".$self->{_dbh}->errstr());
@@ -817,8 +838,14 @@
return (0,0,0);
}
- my $rc = $sth->execute($self->{_userid}, $token);
+ $sth->bind_param(1, $self->{_userid});
+ $sth->bind_param(2, $token);
+ #no automatic bindings in DBB::DB2 here
+ #my $rc = $sth->execute($self->{_userid}, $token);
+
+ my $rc = $sth->execute();
+
unless ($rc) {
dbg("bayes: tok_get: SQL error: ".$self->{_dbh}->errstr());
return (0,0,0);
@@ -1854,11 +1881,20 @@
return 0;
}
- my $rc = $sth->execute($self->{_userid},
- $token,
- $spam_count,
- $ham_count,
- $atime);
+ $sth->bind_param(1, $self->{_userid});
+ $sth->bind_param(2, $token);
+ $sth->bind_param(3, $spam_count);
+ $sth->bind_param(4, $ham_count);
+ $sth->bind_param(5, $atime);
+
+ my $rc = $sth->execute();
+
+ #no automatic bindings in DBD::DB2 here
+ #my $rc = $sth->execute($self->{_userid},
+ # $token,
+ # $spam_count,
+ # $ham_count,
+ # $atime);
unless ($rc) {
dbg("bayes: _put_token: SQL error: ".$self->{_dbh}->errstr());
Index: Mail-SpamAssassin-3.2.5/lib/Mail/SpamAssassin/SQLBasedAddrList.pm
===================================================================
--- Mail-SpamAssassin-3.2.5/lib/Mail/SpamAssassin/SQLBasedAddrList.pm
(revision 3)
+++ Mail-SpamAssassin-3.2.5/lib/Mail/SpamAssassin/SQLBasedAddrList.pm
(working copy)
@@ -194,8 +194,14 @@
my $sql = "SELECT count, totscore FROM $self->{tablename}
WHERE username = ? AND email = ? AND ip = ?";
my $sth = $self->{dbh}->prepare($sql);
- my $rc = $sth->execute($self->{_username}, $email, $ip);
+ $sth->bind_param(1, $self->{_username});
+ $sth->bind_param(2, $email);
+ $sth->bind_param(3, $ip);
+
+# my $rc = $sth->execute($self->{_username}, $email, $ip);
+ my $rc = $sth->execute();
+
if (!$rc) { # there was an error, but try to go on
my $err = $self->{dbh}->errstr;
dbg("auto-whitelist: sql-based get_addr_entry: SQL error: $err");
@@ -255,7 +261,12 @@
WHERE username = ? AND email = ? AND ip = ?";
my $sth = $self->{dbh}->prepare($sql);
- my $rc = $sth->execute($score, $self->{_username}, $email, $ip);
+ $sth->bind_param(1, $score);
+ $sth->bind_param(2, $self->{_username});
+ $sth->bind_param(3, $email);
+ $sth->bind_param(4, $ip);
+ #my $rc = $sth->execute($score, $self->{_username}, $email, $ip);
+ my $rc = $sth->execute();
if (!$rc) {
my $err = $self->{dbh}->errstr;
@@ -269,7 +280,14 @@
else { # no entry yet, so insert a new entry
my $sql = "INSERT INTO $self->{tablename}
(username,email,ip,count,totscore) VALUES (?,?,?,?,?)";
my $sth = $self->{dbh}->prepare($sql);
- my $rc = $sth->execute($self->{_username},$email,$ip,1,$score);
+ $sth->bind_param(1, $self->{_username});
+ $sth->bind_param(2, $email);
+ $sth->bind_param(3, $ip);
+ $sth->bind_param(4, 1);
+ $sth->bind_param(5, $score);
+
+ #my $rc = $sth->execute($self->{_username},$email,$ip,1,$score);
+ my $rc = $sth->execute();
if (!$rc) {
my $err = $self->{dbh}->errstr;
dbg("auto-whitelist: sql-based add_score: SQL error: $err");