From 50aa733fec6c3ccbf8e889339f43766f8c5a9c5d Mon Sep 17 00:00:00 2001 From: Roland Bock Date: Sun, 8 Oct 2023 11:34:59 +0200 Subject: [PATCH] [mysql] Remove (auto-)reconnect MySQL 8.0.34 deprecates `MYSQL_OPT_RECONNECT`. As discussed in #530, this commit is removing library support for (auto-)reconnect. It is of course still possible to reconnect directly using the native handle. --- include/sqlpp11/mysql/connection.h | 5 ----- include/sqlpp11/mysql/connection_config.h | 5 ++--- include/sqlpp11/mysql/detail/connection_handle.h | 13 ------------- 3 files changed, 2 insertions(+), 21 deletions(-) diff --git a/include/sqlpp11/mysql/connection.h b/include/sqlpp11/mysql/connection.h index d597041a..e23e0e76 100644 --- a/include/sqlpp11/mysql/connection.h +++ b/include/sqlpp11/mysql/connection.h @@ -286,11 +286,6 @@ namespace sqlpp return _handle->ping_server(); } - void reconnect() - { - return _handle->reconnect(); - } - const std::shared_ptr& get_config() { return _handle->config; diff --git a/include/sqlpp11/mysql/connection_config.h b/include/sqlpp11/mysql/connection_config.h index 6d382f9a..a518a326 100644 --- a/include/sqlpp11/mysql/connection_config.h +++ b/include/sqlpp11/mysql/connection_config.h @@ -42,15 +42,14 @@ namespace sqlpp std::string unix_socket; unsigned long client_flag{0}; std::string charset{"utf8"}; - bool auto_reconnect{true}; bool debug{false}; unsigned int connect_timeout_seconds{0}; // 0 = do not override MySQL library default bool operator==(const connection_config& other) const { return (other.host == host and other.user == user and other.password == password and - other.database == database and other.charset == charset and other.auto_reconnect == auto_reconnect and - other.debug == debug and other.connect_timeout_seconds == connect_timeout_seconds); + other.database == database and other.charset == charset and other.debug == debug and + other.connect_timeout_seconds == connect_timeout_seconds); } bool operator!=(const connection_config& other) const diff --git a/include/sqlpp11/mysql/detail/connection_handle.h b/include/sqlpp11/mysql/detail/connection_handle.h index 45b4b868..1629d53c 100644 --- a/include/sqlpp11/mysql/detail/connection_handle.h +++ b/include/sqlpp11/mysql/detail/connection_handle.h @@ -79,15 +79,6 @@ namespace sqlpp throw sqlpp::exception{"MySQL: could not init mysql data structure"}; } - if (config->auto_reconnect) - { - my_bool my_true{true}; - if (mysql_options(native_handle(), MYSQL_OPT_RECONNECT, &my_true)) - { - throw sqlpp::exception{"MySQL: could not set option MYSQL_OPT_RECONNECT"}; - } - } - connect(native_handle(), *config); } @@ -114,10 +105,6 @@ namespace sqlpp return mysql_ping(native_handle()) == 0; } - void reconnect() - { - connect(native_handle(), *config); - } }; } // namespace detail } // namespace mysql