]> git.pld-linux.org Git - packages/dspam.git/blob - dspam-mysql-runtime.patch
- up
[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: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
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,6 +706,7 @@
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, "
82 @@ -702,6 +720,9 @@
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) {
92 @@ -749,6 +770,7 @@
93    }
94  
95  #if MYSQL_VERSION_ID >= 40100
96 +  if (!use_mysql40) {
97    if (insert_any)
98    {
99       snprintf (scratch, sizeof (scratch),
100 @@ -770,6 +792,7 @@
101    }
102  
103    buffer_destroy(insert);
104 +  }
105  #endif
106  
107    buffer_destroy (query);
This page took 0.040909 seconds and 3 git commands to generate.