diff options
author | Martin Schanzenbach <mschanzenbach@posteo.de> | 2020-08-11 11:35:06 +0200 |
---|---|---|
committer | Martin Schanzenbach <mschanzenbach@posteo.de> | 2020-08-11 11:35:25 +0200 |
commit | 286759692f1d5c84da625d5c0ced374a2585e978 (patch) | |
tree | 997953d000fbda96123811b8faa63ee428539edf | |
parent | c0349b05c9736151899fa7aae3231cc64fca2bc4 (diff) | |
download | gnunet-286759692f1d5c84da625d5c0ced374a2585e978.tar.gz gnunet-286759692f1d5c84da625d5c0ced374a2585e978.zip |
fix: mysql version detection
Fix detection macro and support mysql8+ my_bool deprecation. Fixes #6465.
-rw-r--r-- | configure.ac | 18 | ||||
-rw-r--r-- | src/mysql/mysql.c | 8 |
2 files changed, 23 insertions, 3 deletions
diff --git a/configure.ac b/configure.ac index 39e7ffa7e..88a2134ef 100644 --- a/configure.ac +++ b/configure.ac | |||
@@ -1404,12 +1404,11 @@ AS_IF([test "$mysql" = "true" -a "x$enable_mysql_version_check" = "xyes"], | |||
1404 | AC_MSG_CHECKING(mysql version) | 1404 | AC_MSG_CHECKING(mysql version) |
1405 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM( | 1405 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM( |
1406 | [[ | 1406 | [[ |
1407 | #include <mysql/mysql.h>]], | 1407 | #include <mysql/mysql_version.h>]], |
1408 | [[ | 1408 | [[ |
1409 | #if (MYSQL_VERSION_ID < 40100) | 1409 | #if (MYSQL_VERSION_ID < 40100) |
1410 | #error needs at least version >= 4.1 | 1410 | #error needs at least version >= 4.1 |
1411 | #endif | 1411 | #endif |
1412 | int main () { return 0; } | ||
1413 | ]]) | 1412 | ]]) |
1414 | ], | 1413 | ], |
1415 | [mysql=true], | 1414 | [mysql=true], |
@@ -1423,6 +1422,21 @@ AS_IF([test "$mysql" = "true" -a "x$enable_mysql_version_check" = "xyes"], | |||
1423 | mysqlfail=false | 1422 | mysqlfail=false |
1424 | AC_MSG_RESULT(ok) | 1423 | AC_MSG_RESULT(ok) |
1425 | ]) | 1424 | ]) |
1425 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM( | ||
1426 | [[ | ||
1427 | #include <mysql/mysql_version.h>]], | ||
1428 | [[ | ||
1429 | #if (MYSQL_VERSION_ID < 80000) | ||
1430 | #error needs at least version >= 4.1 | ||
1431 | #endif | ||
1432 | ]]) | ||
1433 | ], | ||
1434 | [mysql8=true], | ||
1435 | [mysql8=false]) | ||
1436 | AS_IF([test x$mysql8 = xtrue], | ||
1437 | [ | ||
1438 | AC_DEFINE([HAVE_MYSQL8],[1],[Have mysql8]) | ||
1439 | ],[]) | ||
1426 | ]) | 1440 | ]) |
1427 | 1441 | ||
1428 | AM_CONDITIONAL(HAVE_MYSQL, test x$mysql = xtrue) | 1442 | AM_CONDITIONAL(HAVE_MYSQL, test x$mysql = xtrue) |
diff --git a/src/mysql/mysql.c b/src/mysql/mysql.c index 713227068..4df1893c6 100644 --- a/src/mysql/mysql.c +++ b/src/mysql/mysql.c | |||
@@ -26,6 +26,12 @@ | |||
26 | #include <mysql/mysql.h> | 26 | #include <mysql/mysql.h> |
27 | #include "gnunet_mysql_lib.h" | 27 | #include "gnunet_mysql_lib.h" |
28 | 28 | ||
29 | #ifdef HAVE_MYSQL8 | ||
30 | typedef bool MYSQL_BOOL; | ||
31 | #else | ||
32 | typedef my_bool MYSQL_BOOL; //MySQL < 8 wants this | ||
33 | #endif | ||
34 | |||
29 | /** | 35 | /** |
30 | * Maximum number of supported parameters for a prepared | 36 | * Maximum number of supported parameters for a prepared |
31 | * statement. Increase if needed. | 37 | * statement. Increase if needed. |
@@ -220,7 +226,7 @@ iopen (struct GNUNET_MYSQL_Context *mc) | |||
220 | char *mysql_user; | 226 | char *mysql_user; |
221 | char *mysql_password; | 227 | char *mysql_password; |
222 | unsigned long long mysql_port; | 228 | unsigned long long mysql_port; |
223 | my_bool reconnect; | 229 | MYSQL_BOOL reconnect; |
224 | unsigned int timeout; | 230 | unsigned int timeout; |
225 | 231 | ||
226 | mc->dbf = mysql_init (NULL); | 232 | mc->dbf = mysql_init (NULL); |