1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-07-04 04:42:30 +03:00

clang format apply

This commit is contained in:
Leonid Fedorov
2022-01-21 16:43:49 +00:00
parent 6b6411229f
commit 04752ec546
1376 changed files with 393460 additions and 412662 deletions

View File

@ -30,112 +30,107 @@ using namespace std;
namespace utils
{
LibMySQL::LibMySQL() : fCon(NULL), fRes(NULL)
{
}
LibMySQL::~LibMySQL()
{
if (fRes)
{
mysql_free_result(fRes);
}
if (fRes)
{
mysql_free_result(fRes);
}
fRes = NULL;
fRes = NULL;
if (fCon)
{
mysql_close(fCon);
}
if (fCon)
{
mysql_close(fCon);
}
fCon = NULL;
fCon = NULL;
}
int LibMySQL::init(const char* h, unsigned int p, const char* u, const char* w, const char* d)
{
int ret = 0;
int ret = 0;
fCon = mysql_init(NULL);
fCon = mysql_init(NULL);
config::Config* cf = config::Config::makeConfig();
const string TLSCA = cf->getConfig("CrossEngineSupport", "TLSCA");
const string TLSClientCert = cf->getConfig("CrossEngineSupport", "TLSClientCert");
const string TLSClientKey = cf->getConfig("CrossEngineSupport", "TLSClientKey");
config::Config* cf = config::Config::makeConfig();
const string TLSCA = cf->getConfig("CrossEngineSupport", "TLSCA");
const string TLSClientCert = cf->getConfig("CrossEngineSupport", "TLSClientCert");
const string TLSClientKey = cf->getConfig("CrossEngineSupport", "TLSClientKey");
if (!(TLSCA.empty() || TLSClientCert.empty() || TLSClientKey.empty()))
if (!(TLSCA.empty() || TLSClientCert.empty() || TLSClientKey.empty()))
{
mysql_ssl_set(fCon, TLSClientKey.c_str(), TLSClientCert.c_str(), TLSCA.c_str(), NULL, NULL);
}
if (fCon != NULL)
{
unsigned int tcp_option = MYSQL_PROTOCOL_TCP;
mysql_options(fCon, MYSQL_OPT_PROTOCOL, &tcp_option);
if (mysql_real_connect(fCon, h, u, w, d, p, NULL, 0) == NULL)
{
mysql_ssl_set(fCon, TLSClientKey.c_str(), TLSClientCert.c_str(),
TLSCA.c_str(), NULL, NULL);
}
if (fCon != NULL)
{
unsigned int tcp_option = MYSQL_PROTOCOL_TCP;
mysql_options(fCon, MYSQL_OPT_PROTOCOL, &tcp_option);
if (mysql_real_connect(fCon, h, u, w, d, p, NULL, 0) == NULL)
{
fErrStr = "fatal error running mysql_real_connect() in libmysql_client lib";
ret = mysql_errno(fCon);
}
else
{
mysql_set_character_set(fCon, "utf8");
}
fErrStr = "fatal error running mysql_real_connect() in libmysql_client lib";
ret = mysql_errno(fCon);
}
else
{
fErrStr = "fatal error running mysql_init() in libmysql_client lib";
ret = -1;
mysql_set_character_set(fCon, "utf8");
}
}
else
{
fErrStr = "fatal error running mysql_init() in libmysql_client lib";
ret = -1;
}
return ret;
return ret;
}
int LibMySQL::run(const char* query, bool resultExpected)
{
int ret = 0;
if (mysql_real_query(fCon, query, strlen(query)) != 0)
{
fErrStr = "fatal error runing mysql_real_query() in libmysql_client lib";
ret = -1;
return ret;
}
fRes = mysql_use_result(fCon);
if (fRes == NULL && resultExpected)
{
fErrStr = "fatal error running mysql_use_result() or empty result set in libmysql_client lib";
ret = -1;
}
int ret = 0;
if (mysql_real_query(fCon, query, strlen(query)) != 0)
{
fErrStr = "fatal error runing mysql_real_query() in libmysql_client lib";
ret = -1;
return ret;
}
fRes = mysql_use_result(fCon);
if (fRes == NULL && resultExpected)
{
fErrStr = "fatal error running mysql_use_result() or empty result set in libmysql_client lib";
ret = -1;
}
return ret;
}
void LibMySQL::handleMySqlError(const char* errStr, int errCode)
{
ostringstream oss;
ostringstream oss;
if (getErrno())
{
oss << errStr << " (" << getErrno() << ")";
oss << " (" << getErrorMsg() << ")";
}
else
{
oss << errStr << " (" << errCode << ")";
oss << " (unknown)";
}
if (getErrno())
{
oss << errStr << " (" << getErrno() << ")";
oss << " (" << getErrorMsg() << ")";
}
else
{
oss << errStr << " (" << errCode << ")";
oss << " (unknown)";
}
throw logging::IDBExcept(oss.str(), logging::ERR_CROSS_ENGINE_CONNECT);
throw logging::IDBExcept(oss.str(), logging::ERR_CROSS_ENGINE_CONNECT);
return;
return;
}
} // namespace
} // namespace utils