mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-16 12:44:42 +00:00
fix openssl build
This commit is contained in:
parent
99402fac85
commit
0d3cab3e10
@ -15,6 +15,7 @@
|
||||
namespace DB
|
||||
{
|
||||
using namespace MySQLProtocol;
|
||||
using namespace ReplicationProtocol;
|
||||
|
||||
class MySQLClient
|
||||
{
|
||||
@ -25,6 +26,7 @@ public:
|
||||
bool ping();
|
||||
bool registerSlave(UInt32 slave_id);
|
||||
bool binlogDump(UInt32 slave_id, String binlog_file_name, UInt64 binlog_pos);
|
||||
BinlogEvent readBinlogEvent();
|
||||
String error();
|
||||
|
||||
private:
|
||||
|
@ -1451,13 +1451,7 @@ namespace ReplicationProtocol
|
||||
UInt32 replication_rank;
|
||||
UInt32 master_id;
|
||||
|
||||
RegisterSlave(UInt32 server_id_)
|
||||
: server_id(server_id_)
|
||||
, slaves_mysql_port(0x00)
|
||||
, replication_rank(0x00)
|
||||
, master_id(0x00)
|
||||
{
|
||||
}
|
||||
RegisterSlave(UInt32 server_id_) : server_id(server_id_), slaves_mysql_port(0x00), replication_rank(0x00), master_id(0x00) { }
|
||||
|
||||
void writePayloadImpl(WriteBuffer & buffer) const override
|
||||
{
|
||||
@ -1507,6 +1501,66 @@ namespace ReplicationProtocol
|
||||
protected:
|
||||
size_t getPayloadSize() const override { return 1 + 4 + 2 + 4 + binlog_file_name.size() + 1; }
|
||||
};
|
||||
}
|
||||
|
||||
class BinlogEvent
|
||||
{
|
||||
public:
|
||||
BinlogEvent() = default;
|
||||
|
||||
virtual bool isValid();
|
||||
|
||||
virtual void parseEvents(ReadBuffer & payload);
|
||||
|
||||
virtual ~BinlogEvent();
|
||||
};
|
||||
|
||||
class MySQLBinlogEvent : public BinlogEvent
|
||||
{
|
||||
public:
|
||||
MySQLBinlogEvent() = default;
|
||||
|
||||
void parseEvents(ReadBuffer & payload) override
|
||||
{
|
||||
UInt16 header = 0;
|
||||
payload.readStrict(reinterpret_cast<char *>(&header), 1);
|
||||
}
|
||||
};
|
||||
|
||||
class IFlavor
|
||||
{
|
||||
public:
|
||||
virtual String getName() = 0;
|
||||
|
||||
virtual BinlogEvent readBinlogEvent(ReadBuffer & payload);
|
||||
|
||||
virtual ~IFlavor() = default;
|
||||
};
|
||||
|
||||
class MySQLFlavor : public IFlavor
|
||||
{
|
||||
public:
|
||||
MySQLFlavor() = default;
|
||||
|
||||
BinlogEvent readBinlogEvent(ReadBuffer & payload) override
|
||||
{
|
||||
UInt16 header = 0;
|
||||
payload.readStrict(reinterpret_cast<char *>(&header), 1);
|
||||
switch (header)
|
||||
{
|
||||
case PACKET_EOF:
|
||||
throw Exception("Master maybe lost", ErrorCodes::UNKNOWN_EXCEPTION);
|
||||
case PACKET_ERR:
|
||||
ERR_Packet err;
|
||||
err.readPayloadImpl(payload);
|
||||
throw Exception(err.error_message, ErrorCodes::UNKNOWN_EXCEPTION);
|
||||
}
|
||||
|
||||
MySQLBinlogEvent binlog_event;
|
||||
binlog_event.parseEvents(payload);
|
||||
return binlog_event;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -21,3 +21,6 @@ target_link_libraries (mysql_client PRIVATE dbms)
|
||||
|
||||
add_executable (mysql_protocol mysql_protocol.cpp)
|
||||
target_link_libraries (mysql_protocol PRIVATE dbms)
|
||||
if(USE_SSL)
|
||||
target_include_directories (mysql_protocol SYSTEM PRIVATE ${OPENSSL_INCLUDE_DIR})
|
||||
endif()
|
||||
|
@ -176,7 +176,7 @@ int main(int, char **)
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!client1.binlogDump(slave_id, "", 0))
|
||||
if (!client1.binlogDump(slave_id, "", 315))
|
||||
{
|
||||
std::cerr << "Connect Error: " << client1.error() << std::endl;
|
||||
assert(0);
|
||||
|
Loading…
Reference in New Issue
Block a user