]> git.pld-linux.org Git - packages/dspam.git/blame - dspam-mysql-runtime.patch
- bcond works (mysql40)
[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
0584fe0f 3+++ dspam-3.6.3/src/mysql_drv.c 2006-02-01 21:46:52.000000000 +0100
149738e1
AM
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) ? ", " : "",
8a37e5da 74@@ -689,7 +706,8 @@
c2a52a53
AM
75
76 insert_any = 1;
77 buffer_cat(insert, ins);
8a37e5da 78-#else
c2a52a53 79+ } else {
8a37e5da 80+#endif
c2a52a53
AM
81 snprintf(ins, sizeof (ins),
82 "insert into dspam_token_data(uid, token, spam_hits, "
8a37e5da
AM
83 "innocent_hits, last_hit) values(%d, '%llu', %d, %d, "
84@@ -701,6 +719,8 @@
85
c2a52a53
AM
86 if (MYSQL_RUN_QUERY (s->dbh, ins))
87 stat.status |= TST_DISK;
c2a52a53
AM
88+#if MYSQL_VERSION_ID >= 40100
89+ }
8a37e5da 90 #endif
c2a52a53
AM
91 }
92
8a37e5da 93@@ -749,6 +769,7 @@
c2a52a53
AM
94 }
95
96 #if MYSQL_VERSION_ID >= 40100
149738e1 97+ if (!use_mysql40) {
c2a52a53
AM
98 if (insert_any)
99 {
100 snprintf (scratch, sizeof (scratch),
8a37e5da 101@@ -770,6 +791,7 @@
149738e1
AM
102 }
103
104 buffer_destroy(insert);
105+ }
106 #endif
107
108 buffer_destroy (query);
0584fe0f
AM
109@@ -2701,6 +2723,9 @@
110 char db[64] = { 0 };
111 int port = 3306, i = 0, real_connect_flag = 0;
112
113+ if (_ds_match_attribute(CTX->config->attributes, "MySQLVersion40", "on"))
114+ use_mysql40 = 1;
115+
116 /* Read storage attributes */
117 if (_ds_read_attribute(CTX->config->attributes, "MySQLServer")) {
118 char *p;
This page took 0.076666 seconds and 4 git commands to generate.