summaryrefslogtreecommitdiff
path: root/mail/dspam/patches/patch-ab
blob: 4cbcb82b05ed6908d851bddef490cbd746f6c44e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
$NetBSD: patch-ab,v 1.1 2004/10/27 23:27:00 xtraeme Exp $

Fix for MySQL 4.1.x users:

http://dspam.nuclearelephant.com/dspam-users/5709.html

--- mysql_drv.c.orig	2004-10-28 01:01:32.000000000 +0200
+++ mysql_drv.c	2004-10-28 01:07:44.000000000 +0200
@@ -512,10 +512,10 @@
   struct _ds_spam_stat stat, stat2;
   struct lht_node *node_lht;
   struct lht_c c_lht;
-  buffer *query, *insert;
+  buffer *query;
   char scratch[1024];
   struct passwd *p;
-  int update_one = 0, insert_one = 0;
+  int update_one = 0;
 
   if (s->dbh == NULL)
   {
@@ -546,14 +546,6 @@
     return EUNKNOWN;
   }
 
-  insert = buffer_create(NULL);
-  if (insert == NULL)
-  {
-    buffer_destroy(query);
-    LOG (LOG_CRIT, ERROR_MEM_ALLOC);
-    return EUNKNOWN;
-  }
-
   if (s->control_token == 0)
   {
     node_lht = c_lht_first (freq, &c_lht);
@@ -585,9 +577,6 @@
 
   buffer_cat (query, scratch);
 
-  buffer_copy (insert, "insert into dspam_token_data(uid, token, spam_hits, "
-                       "innocent_hits, last_hit) values");
-
   node_lht = c_lht_first (freq, &c_lht);
   while (node_lht != NULL)
   {
@@ -605,7 +594,7 @@
 
     if (stat2.disk != 'Y')
     {
-      char ins[1024];
+      char insert[1024];
 
       /* If we're processing a message with a MERGED group, assign it based on
          an empty count and not the current count (since the current count
@@ -615,25 +604,27 @@
          on the actual count (so that tools like dspam_merge don't break) */
 
       if (CTX->flags & DSF_MERGED) {
-        snprintf (ins, sizeof (ins),
-                  "%s(%d, '%llu', %d, %d, current_date())",
-                   (insert_one) ? ", " : "",
+	snprintf (insert, sizeof (insert),
+		"insert into dspam_token_data(uid, token, spam_hits, "
+		"innocent_hits, last_hit) values(%d, '%llu', %d, %d, "
+		"current_date())",
                    p->pw_uid, 
                    node_lht->key, 
                    stat.spam_hits > s->control_sh ? 1 : 0,
                    stat.innocent_hits > s->control_ih ? 1 : 0);
       } else {
-        snprintf (ins, sizeof (ins),
-                  "%s(%d, '%llu', %ld, %ld, current_date())",
-                   (insert_one) ? ", " : "",
+	snprintf(insert, sizeof (insert),
+		"insert into dspam_token_data(uid, token, spam_hits, "
+		"innocent_hits, last_hit) values(%d, '%llu', %ld, %ld, "
+		"current_date())",
                    p->pw_uid,
                    node_lht->key,
                    stat2.spam_hits, 
                    stat2.innocent_hits);
       }
 
-      insert_one = 1;
-      buffer_cat(insert, ins);
+      if (MYSQL_RUN_QUERY (s->dbh, insert))
+      stat2.disk = 'Y'; 
     }
 
     if (stat2.disk == 'Y')
@@ -675,17 +666,6 @@
     }
   }
 
-  if (insert_one)
-  {
-    if (MYSQL_RUN_QUERY (s->dbh, insert->data))
-    {
-      _mysql_drv_query_error (mysql_error (s->dbh), insert->data);
-      buffer_destroy(insert);
-      return EFAILURE;
-    }
-  }
-
-  buffer_destroy (insert);
   buffer_destroy (query);
   return 0;
 }