From b324d5bea00604a6bcb3057f17ab7ed06bb4b90d Mon Sep 17 00:00:00 2001 From: Thomas Markwalder Date: Fri, 10 May 2024 14:58:09 +0000 Subject: [PATCH] Resolve "kea-dhcp4 and 6: WARNING: MYSQL_OPT_RECONNECT is deprecated and will be removed in a future version." --- ChangeLog | 7 +++++++ configure.ac | 10 ++++++++++ src/lib/mysql/mysql_connection.cc | 10 +++++++--- 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 68f977acc7..a15d20a501 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2229. [bug] tmark + Modified configure.ac to detect versions of MySQL + client libary for which MYSQL_OPT_RECONNECT is + deprecated and exclude from Kea core, code attempts + to set it false. + (Gitlab #3311) + Kea 2.5.8 (development) released on April 30, 2024 2228. [build] piotrek diff --git a/configure.ac b/configure.ac index 2ae66b69ae..1f0c2d7040 100644 --- a/configure.ac +++ b/configure.ac @@ -790,6 +790,16 @@ $(cat conftest.cpp) $(cat conftest.err)])] ) + # Beginning with MySQL 8.0.34 MYSQL_OPT_RECONNNECT is deprecated. + # Check if MYSQL_OPT_RECONNNECT is defined. + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([#include + auto temp = MYSQL_OPT_RECONNECT;] + [])], + [AC_MSG_RESULT([checking for MySQL MYSQL_OPT_RECONNNECT... yes]) + AC_DEFINE([HAVE_MYSQL_OPT_RECONNECT], [1], [MySQL has MYSQL_OPT_RECONNNECT])], + [AC_MSG_RESULT([checking for MySQL MYSQL_OPT_RECONNECT... no])]) + CPPFLAGS=$CPPFLAGS_SAVED LIBS=$LIBS_SAVED fi diff --git a/src/lib/mysql/mysql_connection.cc b/src/lib/mysql/mysql_connection.cc index 4ce3d15aa2..1bb2bcc78d 100644 --- a/src/lib/mysql/mysql_connection.cc +++ b/src/lib/mysql/mysql_connection.cc @@ -172,16 +172,20 @@ MySqlConnection::openDatabase() { // Set options for the connection: // - // Set options for the connection: - // Make sure auto_reconnect is OFF! Enabling it leaves us with an unusable + int result; +#ifdef HAS_MYSQL_OPT_RECONNECT + // Though still supported by Mariadb (as of 11.5.0), MYSQL_OPT_RECONNECT is + // deprecated as of MySQL 8.0.34. Where it is still supported we should + // continue to ensure it is off. Enabling it leaves us with an unusable // connection after a reconnect as among other things, it drops all our // pre-compiled statements. my_bool auto_reconnect = MLM_FALSE; - int result = mysql_options(mysql_, MYSQL_OPT_RECONNECT, &auto_reconnect); + result = mysql_options(mysql_, MYSQL_OPT_RECONNECT, &auto_reconnect); if (result != 0) { isc_throw(DbOpenError, "unable to set auto-reconnect option: " << mysql_error(mysql_)); } +#endif // Make sure we have a large idle time window ... say 30 days... const char *wait_time = "SET SESSION wait_timeout = 30 * 86400"; -- 2.47.2