2
0
mirror of https://gitlab.isc.org/isc-projects/kea synced 2025-08-30 05:27:55 +00:00

Resolve "kea-dhcp4 and 6: WARNING: MYSQL_OPT_RECONNECT is deprecated and will be removed in a future version."

This commit is contained in:
Thomas Markwalder 2024-05-10 14:58:09 +00:00
parent a3aa696655
commit b324d5bea0
3 changed files with 24 additions and 3 deletions

View File

@ -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

View File

@ -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 <mysql.h>
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

View File

@ -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";