From 851155785cc06a52e3c471ab0f82ec005d8c1c5c Mon Sep 17 00:00:00 2001 From: JDierkse Date: Wed, 19 Oct 2022 15:43:08 +0200 Subject: [PATCH] Fix crash after unsuccessful reconnection attempt --- MySQL/MySQLClientImpl.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/MySQL/MySQLClientImpl.cpp b/MySQL/MySQLClientImpl.cpp index 3ae5a73..d045e1d 100644 --- a/MySQL/MySQLClientImpl.cpp +++ b/MySQL/MySQLClientImpl.cpp @@ -111,9 +111,20 @@ std::shared_ptr MySQLClientImpl::ExecuteQuery(const std::str if (!m_connected) { if (m_automaticReconnect) + { InternalConnect(); + if (!m_connected) + { + std::stringstream ss; + ss << "MySQLClientImpl::ExecuteQuery() - Error: Reconnect failed" << std::endl; + ss << "Query: " << query << std::endl; + Logging::Log(Logging::Severity::Error, ss.str()); + } + } else + { throw std::runtime_error("MySQLClientImpl::ExecuteQuery() - Not connected to a Database Server"); + } } try