mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-09-21 01:00:48 +00:00
Removed link-time dependency [#METR-17973].
This commit is contained in:
parent
687958aa0b
commit
9facd5bc56
@ -5,7 +5,6 @@
|
||||
#include <ext/range.hpp>
|
||||
#include <mysqlxx/Pool.h>
|
||||
#include <Poco/Util/AbstractConfiguration.h>
|
||||
#include <strconvert/escape.h>
|
||||
#include "writeParenthesisedString.h"
|
||||
|
||||
|
||||
@ -79,6 +78,28 @@ public:
|
||||
private:
|
||||
Logger * log = &Logger::get("MySQLDictionarySource");
|
||||
|
||||
|
||||
static std::string quoteForLike(const std::string s)
|
||||
{
|
||||
std::string tmp;
|
||||
tmp.reserve(s.size());
|
||||
|
||||
for (auto c : s)
|
||||
{
|
||||
if (c == '%' || c == '_' || c == '\\')
|
||||
tmp.push_back('\\');
|
||||
tmp.push_back(c);
|
||||
}
|
||||
|
||||
std::string res;
|
||||
{
|
||||
WriteBufferFromString out(res);
|
||||
writeQuoted(tmp, out);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
mysqlxx::DateTime getLastModification() const
|
||||
{
|
||||
mysqlxx::DateTime update_time{std::time(nullptr)};
|
||||
@ -89,7 +110,7 @@ private:
|
||||
try
|
||||
{
|
||||
auto connection = pool.Get();
|
||||
auto query = connection->query("SHOW TABLE STATUS LIKE '" + strconvert::escaped_for_like(table) + "'");
|
||||
auto query = connection->query("SHOW TABLE STATUS LIKE " + quoteForLike(table));
|
||||
|
||||
LOG_TRACE(log, query.str());
|
||||
|
||||
|
@ -146,7 +146,7 @@ public:
|
||||
|
||||
Dictionaries(const bool throw_on_error)
|
||||
: Dictionaries(throw_on_error,
|
||||
Application::instance().config()
|
||||
Poco::Util::Application::instance().config()
|
||||
.getInt("builtin_dictionaries_reload_interval", 3600))
|
||||
{}
|
||||
|
||||
|
@ -1,16 +1,17 @@
|
||||
#pragma once
|
||||
|
||||
#include <math.h> // log2()
|
||||
#include <openssl/md5.h>
|
||||
|
||||
#include <boost/algorithm/string.hpp>
|
||||
|
||||
#include <Poco/NumberParser.h>
|
||||
#include <Poco/StringTokenizer.h>
|
||||
#include <Poco/ByteOrder.h>
|
||||
|
||||
#include <DB/IO/WriteHelpers.h>
|
||||
|
||||
#include <common/DateLUT.h>
|
||||
#include <strconvert/hash64.h>
|
||||
#include <statdaemons/RegionsHierarchy.h>
|
||||
#include <statdaemons/TechDataHierarchy.h>
|
||||
#include <statdaemons/Interests.h>
|
||||
@ -187,7 +188,18 @@ struct AttributeHashBase : public IAttributeMetadata
|
||||
{
|
||||
BinaryData parse(const std::string & s) const
|
||||
{
|
||||
return strconvert::hash64(s);
|
||||
union
|
||||
{
|
||||
unsigned char char_data[16];
|
||||
Poco::UInt64 uint64_data;
|
||||
} buf;
|
||||
|
||||
MD5_CTX ctx;
|
||||
MD5_Init(&ctx);
|
||||
MD5_Update(&ctx, reinterpret_cast<const unsigned char *>(s.data()), s.size());
|
||||
MD5_Final(buf.char_data, &ctx);
|
||||
|
||||
return Poco::ByteOrder::flipBytes(buf.uint64_data);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -12,8 +12,6 @@
|
||||
#include <Poco/SharedPtr.h>
|
||||
|
||||
#include <common/logger_useful.h>
|
||||
#include <statdaemons/daemon.h>
|
||||
|
||||
#include <mysqlxx/Connection.h>
|
||||
|
||||
|
||||
@ -151,7 +149,7 @@ public:
|
||||
if (first)
|
||||
first = false;
|
||||
else
|
||||
Daemon::instance().sleep(MYSQLXX_POOL_SLEEP_ON_CONNECT_FAIL);
|
||||
::sleep(MYSQLXX_POOL_SLEEP_ON_CONNECT_FAIL);
|
||||
|
||||
app.logger().information("MYSQL: Reconnecting to " + pool->description);
|
||||
data->conn.connect(
|
||||
@ -242,7 +240,7 @@ public:
|
||||
cfg.getInt("mysql_rw_timeout",
|
||||
MYSQLXX_DEFAULT_RW_TIMEOUT));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param db_ Имя БД
|
||||
* @param server_ Хост для подключения
|
||||
@ -306,7 +304,7 @@ public:
|
||||
}
|
||||
|
||||
lock.unlock();
|
||||
Daemon::instance().sleep(MYSQLXX_POOL_SLEEP_ON_CONNECT_FAIL);
|
||||
::sleep(MYSQLXX_POOL_SLEEP_ON_CONNECT_FAIL);
|
||||
lock.lock();
|
||||
}
|
||||
}
|
||||
@ -367,7 +365,7 @@ private:
|
||||
Poco::FastMutex lock;
|
||||
/** Описание соединения. */
|
||||
std::string description;
|
||||
|
||||
|
||||
/** Параметры подключения. **/
|
||||
std::string db;
|
||||
std::string server;
|
||||
@ -428,10 +426,6 @@ private:
|
||||
{
|
||||
app.logger().error(e.what());
|
||||
delete conn;
|
||||
|
||||
if (Daemon::instance().isCancelled())
|
||||
throw Poco::Exception("Daemon is cancelled while trying to connect to MySQL server.");
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user