ClickHouse/src/IO/MySQLPacketPayloadWriteBuffer.h

37 lines
721 B
C++
Raw Normal View History

2020-08-13 08:17:33 +00:00
#pragma once
#include <IO/WriteBuffer.h>
namespace DB
{
/** Writing packets.
* https://dev.mysql.com/doc/internals/en/mysql-packet.html
*/
2020-08-13 12:41:36 +00:00
class MySQLPacketPayloadWriteBuffer : public WriteBuffer
2020-08-13 08:17:33 +00:00
{
public:
2020-08-13 12:41:36 +00:00
MySQLPacketPayloadWriteBuffer(WriteBuffer & out_, size_t payload_length_, uint8_t & sequence_id_);
2020-08-13 08:17:33 +00:00
bool remainingPayloadSize() const { return total_left; }
2020-08-13 08:17:33 +00:00
protected:
void nextImpl() override;
private:
WriteBuffer & out;
uint8_t & sequence_id;
size_t total_left = 0;
size_t payload_length = 0;
size_t bytes_written = 0;
bool eof = false;
void startNewPacket();
/// Sets working buffer to the rest of current packet payload.
void setWorkingBuffer();
};
}