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