Mercurial > hg > orthanc-databases
diff Framework/MySQL/MySQLDatabase.cpp @ 46:6a574d810b98
Compatibility with MySQL 8.0
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 18 Jul 2018 12:27:40 +0200 |
parents | 17f849b2af34 |
children | 412e30336847 |
line wrap: on
line diff
--- a/Framework/MySQL/MySQLDatabase.cpp Tue Jul 17 08:50:53 2018 +0200 +++ b/Framework/MySQL/MySQLDatabase.cpp Wed Jul 18 12:27:40 2018 +0200 @@ -81,6 +81,19 @@ } + MySQLDatabase::~MySQLDatabase() + { + try + { + Close(); + } + catch (Orthanc::OrthancException&) + { + // Ignore possible exceptions due to connection loss + } + } + + void MySQLDatabase::LogError() { if (mysql_ != NULL) @@ -118,6 +131,13 @@ LOG(ERROR) << "Cannot initialize the MySQL connector"; throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); } + + if (parameters_.GetUnixSocket().empty()) + { + // Fallback to TCP connection if no UNIX socket is provided + unsigned int protocol = MYSQL_PROTOCOL_TCP; + mysql_options(mysql_, MYSQL_OPT_PROTOCOL, (unsigned int *) &protocol); + } const char* socket = (parameters_.GetUnixSocket().empty() ? NULL : parameters_.GetUnixSocket().c_str());