comparison 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
comparison
equal deleted inserted replaced
44:95f0f57f8920 46:6a574d810b98
79 mysql_(NULL) 79 mysql_(NULL)
80 { 80 {
81 } 81 }
82 82
83 83
84 MySQLDatabase::~MySQLDatabase()
85 {
86 try
87 {
88 Close();
89 }
90 catch (Orthanc::OrthancException&)
91 {
92 // Ignore possible exceptions due to connection loss
93 }
94 }
95
96
84 void MySQLDatabase::LogError() 97 void MySQLDatabase::LogError()
85 { 98 {
86 if (mysql_ != NULL) 99 if (mysql_ != NULL)
87 { 100 {
88 LOG(ERROR) << "MySQL error (" << mysql_errno(mysql_) 101 LOG(ERROR) << "MySQL error (" << mysql_errno(mysql_)
115 mysql_ = mysql_init(NULL); 128 mysql_ = mysql_init(NULL);
116 if (mysql_ == NULL) 129 if (mysql_ == NULL)
117 { 130 {
118 LOG(ERROR) << "Cannot initialize the MySQL connector"; 131 LOG(ERROR) << "Cannot initialize the MySQL connector";
119 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); 132 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError);
133 }
134
135 if (parameters_.GetUnixSocket().empty())
136 {
137 // Fallback to TCP connection if no UNIX socket is provided
138 unsigned int protocol = MYSQL_PROTOCOL_TCP;
139 mysql_options(mysql_, MYSQL_OPT_PROTOCOL, (unsigned int *) &protocol);
120 } 140 }
121 141
122 const char* socket = (parameters_.GetUnixSocket().empty() ? NULL : 142 const char* socket = (parameters_.GetUnixSocket().empty() ? NULL :
123 parameters_.GetUnixSocket().c_str()); 143 parameters_.GetUnixSocket().c_str());
124 144