aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/clickhouse/src/IO/MySQLPacketPayloadReadBuffer.h
blob: f90a34ba934e94f1146fab7616f13bdda593f703 (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
#pragma once

#include <IO/ReadBuffer.h>

namespace DB
{

/** Reading packets.
 *  Internally, it calls (if no more data) next() method of the underlying ReadBufferFromPocoSocket, and sets the working buffer to the rest part of the current packet payload.
 */
class MySQLPacketPayloadReadBuffer : public ReadBuffer
{
private:
    ReadBuffer & in;
    uint8_t & sequence_id;

    bool has_read_header = false;

    // Size of packet which is being read now.
    size_t payload_length = 0;

    // Offset in packet payload.
    size_t offset = 0;

protected:
    bool nextImpl() override;

public:
    MySQLPacketPayloadReadBuffer(ReadBuffer & in_, uint8_t & sequence_id_);
};

}