comparison Framework/MySQL/MySQLParameters.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 b2ff1cd2907a
children 89a114f36c42
comparison
equal deleted inserted replaced
44:95f0f57f8920 46:6a574d810b98
31 host_ = "localhost"; 31 host_ = "localhost";
32 username_.clear(); 32 username_.clear();
33 password_.clear(); 33 password_.clear();
34 database_.clear(); 34 database_.clear();
35 port_ = 3306; 35 port_ = 3306;
36
37 #if defined(_WIN32)
38 unixSocket_.clear();
39 #else
36 unixSocket_ = "/var/run/mysqld/mysqld.sock"; 40 unixSocket_ = "/var/run/mysqld/mysqld.sock";
41 #endif
42
37 lock_ = true; 43 lock_ = true;
38 } 44 }
39 45
40 46
41 MySQLParameters::MySQLParameters() 47 MySQLParameters::MySQLParameters()
104 110
105 void MySQLParameters::SetDatabase(const std::string& database) 111 void MySQLParameters::SetDatabase(const std::string& database)
106 { 112 {
107 if (database.empty()) 113 if (database.empty())
108 { 114 {
109 LOG(ERROR) << "Empty database name"; 115 LOG(ERROR) << "MySQL: Empty database name";
110 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); 116 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
111 } 117 }
112 118
113 for (size_t i = 0; i < database.length(); i++) 119 for (size_t i = 0; i < database.length(); i++)
114 { 120 {
115 if (!isalnum(database [i])) 121 if (!isalnum(database [i]))
116 { 122 {
117 LOG(ERROR) << "Only alphanumeric characters are allowed in a " 123 LOG(ERROR) << "MySQL: Only alphanumeric characters are allowed in a "
118 << "MySQL database name: \"" << database << "\""; 124 << "database name: \"" << database << "\"";
119 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); 125 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
120 } 126 }
121 } 127 }
122 128
123 database_ = database; 129 database_ = database;
137 } 143 }
138 144
139 145
140 void MySQLParameters::SetUnixSocket(const std::string& socket) 146 void MySQLParameters::SetUnixSocket(const std::string& socket)
141 { 147 {
148 #if defined(_WIN32)
149 if (!socket.empty())
150 {
151 LOG(WARNING) << "MySQL: Setting an UNIX socket on Windows has no effect";
152 }
153 #endif
154
142 unixSocket_ = socket; 155 unixSocket_ = socket;
143 } 156 }
144 157
145 158
146 void MySQLParameters::Format(Json::Value& target) const 159 void MySQLParameters::Format(Json::Value& target) const