]> git.pld-linux.org Git - packages/dspam.git/blame - dspam-mysql-runtime.patch
- up
[packages/dspam.git] / dspam-mysql-runtime.patch
CommitLineData
c2a52a53
AM
1diff -urN dspam-3.6.3.org/src/mysql_drv.c dspam-3.6.3/src/mysql_drv.c
2--- dspam-3.6.3.org/src/mysql_drv.c 2006-01-18 17:48:53.000000000 +0100
149738e1
AM
3+++ dspam-3.6.3/src/mysql_drv.c 2006-02-01 21:23:06.000000000 +0100
4@@ -67,6 +67,8 @@
5 #include "config_shared.h"
6 #endif
7
8+static int use_mysql40 = 0;
9+
10 int test(MYSQL *, char *);
11
12 int test(MYSQL *dbh, char *query) {
13@@ -80,10 +82,20 @@
14 int
15 dspam_init_driver (DRIVER_CTX *DTX)
16 {
17+
18 #if defined(MYSQL4_INITIALIZATION) && MYSQL_VERSION_ID >= 40001
c2a52a53
AM
19 const char *server_default_groups[]=
20 { "server", "embedded", "mysql_SERVER", 0 };
149738e1
AM
21+#endif
22+
23+ if (DTX == NULL)
24+ return 0;
25+
26+#if defined(MYSQL4_INITIALIZATION) && MYSQL_VERSION_ID >= 40001
8425e0ea 27+ if (_ds_match_attribute(DTX->CTX->config->attributes, "MySQLVersion40", "on"))
149738e1 28+ use_mysql40 = 1;
c2a52a53 29
149738e1 30+ if (!use_mysql40)
c2a52a53
AM
31 if (mysql_server_init(0, NULL, (char**) server_default_groups)) {
32 LOGDEBUG("dspam_init_driver() failed");
33 return EFAILURE;
149738e1 34@@ -148,6 +160,7 @@
c2a52a53
AM
35 }
36
37 #if defined(MYSQL4_INITIALIZATION) && MYSQL_VERSION_ID >= 40001
149738e1 38+ if (!use_mysql40)
c2a52a53
AM
39 mysql_server_end();
40 #endif
41 return 0;
149738e1 42@@ -610,6 +623,7 @@
c2a52a53
AM
43 }
44
45 #if MYSQL_VERSION_ID >= 40100
149738e1 46+ if (!use_mysql40) {
c2a52a53
AM
47 insert = buffer_create(NULL);
48 if (insert == NULL)
49 {
149738e1 50@@ -617,6 +631,7 @@
c2a52a53
AM
51 LOG (LOG_CRIT, ERR_MEM_ALLOC);
52 return EUNKNOWN;
53 }
54+ }
55 #endif
56
57 ds_diction_getstat(diction, s->control_token, &control);
149738e1 58@@ -633,6 +648,7 @@
c2a52a53
AM
59 buffer_cat (query, scratch);
60
61 #if MYSQL_VERSION_ID >= 40100
149738e1 62+ if (!use_mysql40)
c2a52a53
AM
63 buffer_copy (insert, "insert into dspam_token_data(uid, token, spam_hits, "
64 "innocent_hits, last_hit) values");
65 #endif
149738e1 66@@ -679,6 +695,7 @@
c2a52a53
AM
67 {
68 char ins[1024];
69 #if MYSQL_VERSION_ID >= 40100
149738e1 70+ if (!use_mysql40) {
c2a52a53
AM
71 snprintf (ins, sizeof (ins),
72 "%s(%d, '%llu', %d, %d, current_date())",
73 (insert_any) ? ", " : "",
149738e1 74@@ -689,6 +706,7 @@
c2a52a53
AM
75
76 insert_any = 1;
77 buffer_cat(insert, ins);
78+ } else {
79 #else
80 snprintf(ins, sizeof (ins),
81 "insert into dspam_token_data(uid, token, spam_hits, "
149738e1 82@@ -702,6 +720,9 @@
c2a52a53
AM
83 if (MYSQL_RUN_QUERY (s->dbh, ins))
84 stat.status |= TST_DISK;
85 #endif
86+#if MYSQL_VERSION_ID >= 40100
87+ }
88+#endif
89 }
90
91 if (stat.status & TST_DISK) {
149738e1 92@@ -749,6 +770,7 @@
c2a52a53
AM
93 }
94
95 #if MYSQL_VERSION_ID >= 40100
149738e1 96+ if (!use_mysql40) {
c2a52a53
AM
97 if (insert_any)
98 {
99 snprintf (scratch, sizeof (scratch),
149738e1
AM
100@@ -770,6 +792,7 @@
101 }
102
103 buffer_destroy(insert);
104+ }
105 #endif
106
107 buffer_destroy (query);
This page took 0.089946 seconds and 4 git commands to generate.