aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/clickhouse/src/Core/MySQL/PacketsReplication.h
blob: ca89217f3f180a04dd479b335583d69708e20f52 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#pragma once

#include <IO/MySQLPacketPayloadReadBuffer.h>
#include <IO/MySQLPacketPayloadWriteBuffer.h>
#include <Core/MySQL/PacketEndpoint.h>

/// Implementation of MySQL wire protocol.
/// Works only on little-endian architecture.

namespace DB
{

namespace MySQLProtocol
{

namespace Replication
{

/// https://dev.mysql.com/doc/internals/en/com-register-slave.html
class RegisterSlave : public IMySQLWritePacket
{
public:
    UInt32 server_id;
    String slaves_hostname;
    String slaves_users;
    String slaves_password;
    size_t slaves_mysql_port;
    UInt32 replication_rank;
    UInt32 master_id;

protected:
    size_t getPayloadSize() const override;

    void writePayloadImpl(WriteBuffer & buffer) const override;

public:
    RegisterSlave(UInt32 server_id_);
};

/// https://dev.mysql.com/doc/internals/en/com-binlog-dump-gtid.html
class BinlogDumpGTID : public IMySQLWritePacket
{
public:
    UInt16 flags;
    UInt32 server_id;
    String gtid_datas;

protected:
    size_t getPayloadSize() const override;

    void writePayloadImpl(WriteBuffer & buffer) const override;

public:
    BinlogDumpGTID(UInt32 server_id_, String gtid_datas_);
};

}
}

}