aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/clickhouse/src/Core/MySQL/IMySQLReadPacket.h
blob: b6c3d59f5eef69bcce21f140f5ac417cda0f9c5d (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
#pragma once

#include <IO/ReadBuffer.h>

namespace DB
{

namespace MySQLProtocol
{

class IMySQLReadPacket
{
public:
    IMySQLReadPacket() = default;

    virtual ~IMySQLReadPacket() = default;

    IMySQLReadPacket(IMySQLReadPacket &&) = default;

    virtual void readPayload(ReadBuffer & in, uint8_t & sequence_id);

    virtual void readPayloadWithUnpacked(ReadBuffer & in);

protected:
    virtual void readPayloadImpl(ReadBuffer & buf) = 0;
};

class LimitedReadPacket : public IMySQLReadPacket
{
public:
    void readPayload(ReadBuffer & in, uint8_t & sequence_id) override;

    void readPayloadWithUnpacked(ReadBuffer & in) override;
};

uint64_t readLengthEncodedNumber(ReadBuffer & buffer);
uint64_t readLengthEncodedNumber(ReadBuffer & buffer, UInt16 & bytes_read);
void readLengthEncodedString(String & s, ReadBuffer & buffer);

}

}