]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
Resolve "kea-dhcp4 and 6: WARNING: MYSQL_OPT_RECONNECT is deprecated and will be...
authorThomas Markwalder <tmark@isc.org>
Fri, 10 May 2024 14:58:09 +0000 (14:58 +0000)
committerThomas Markwalder <tmark@isc.org>
Fri, 10 May 2024 14:58:09 +0000 (14:58 +0000)
ChangeLog
configure.ac
src/lib/mysql/mysql_connection.cc

index 68f977acc725a2ddba354b994d1361a47063d87b..a15d20a501dd564913ffea8dfbc8afc2aff2b54a 100644 (file)
--- 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
index 2ae66b69ae015df2faef73cee90ef15e33d499d7..1f0c2d7040c442f0e915863b115baa26fbe54f4e 100644 (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
index 4ce3d15aa24ba91a728f53dda2f27f791ada153a..1bb2bcc78d4277acf04f75d89404c555d5049a60 100644 (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";