ClickHouse/dbms/programs/server/MySQLHandler.h

47 lines
1018 B
C++
Raw Normal View History

2019-03-16 02:08:21 +00:00
#pragma once
#include <Poco/Net/TCPServerConnection.h>
#include <Common/getFQDNOrHostName.h>
#include <Core/MySQLProtocol.h>
2019-03-16 02:08:21 +00:00
#include "IServer.h"
namespace DB
{
/// Handler for MySQL wire protocol connections. Allows to connect to ClickHouse using MySQL client.
2019-04-01 09:59:49 +00:00
class MySQLHandler : public Poco::Net::TCPServerConnection
{
2019-03-16 02:08:21 +00:00
public:
2019-04-01 09:59:49 +00:00
MySQLHandler(IServer & server_, const Poco::Net::StreamSocket & socket_)
: Poco::Net::TCPServerConnection(socket_), server(server_), log(&Poco::Logger::get("MySQLHandler")),
connection_context(server.context()), connection_id(last_connection_id++)
2019-03-16 02:08:21 +00:00
{
}
void run() final;
void comQuery(String payload);
2019-03-16 02:08:21 +00:00
void comFieldList(String payload);
2019-03-16 02:08:21 +00:00
void comPing();
void comInitDB(String payload);
2019-04-01 09:59:49 +00:00
2019-03-16 02:08:21 +00:00
private:
IServer & server;
Poco::Logger * log;
Context connection_context;
MySQLProtocol::PacketSender packet_sender;
2019-03-16 02:08:21 +00:00
uint32_t connection_id = 0;
uint32_t capabilities;
static uint32_t last_connection_id;
};
}