summaryrefslogtreecommitdiff
blob: dea1a0178531af282d686cf428c47a2688b028c6 (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
--- a/apps/snmptrapd_sql.c
+++ b/apps/snmptrapd_sql.c
@@ -54,6 +54,7 @@
 #include <my_sys.h>
 #include <mysql.h>
 #include <errmsg.h>
+#include <mysql_version.h>
 
 netsnmp_feature_require(container_fifo)
 
@@ -437,6 +438,7 @@ netsnmp_mysql_init(void)
         return -1;
     }
 
+#if MYSQL_VERSION_ID < 100000
 #ifdef HAVE_BROKEN_LIBMYSQLCLIENT
     my_init();
 #else
@@ -445,6 +447,7 @@ netsnmp_mysql_init(void)
 
     /** load .my.cnf values */
     load_defaults ("my", _sql.groups, &not_argc, &not_argv);
+#endif
     for(i=0; i < not_argc; ++i) {
         if (NULL == not_argv[i])
             continue;
@@ -542,6 +545,10 @@ netsnmp_mysql_init(void)
         return -1;
     }
 
+#if MYSQL_VERSION_ID > 100000
+    mysql_options(_sql.conn, MYSQL_READ_DEFAULT_GROUP, "snmptrapd");
+#endif
+
     /** try to connect; we'll try again later if we fail */
     (void) netsnmp_mysql_connect();
 
--- a/apps/snmptrapd_sql.c
+++ b/apps/snmptrapd_sql.c
@@ -50,11 +50,16 @@
 #undef PACKAGE_STRING
 #undef PACKAGE_TARNAME
 #undef PACKAGE_VERSION
+#ifdef HAVE_BROKEN_LIBMYSQLCLIENT
+#include <mysql.h>
+#include <errmsg.h>
+#else
 #include <my_global.h>
 #include <my_sys.h>
 #include <mysql.h>
 #include <errmsg.h>
 #include <mysql_version.h>
+#endif
 
 netsnmp_feature_require(container_fifo)