mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-17 11:52:27 +00:00
37 lines
715 B
C++
37 lines
715 B
C++
#pragma once
|
|
|
|
#include <IO/WriteBuffer.h>
|
|
|
|
namespace DB
|
|
{
|
|
|
|
/** Writing packets.
|
|
* https://dev.mysql.com/doc/internals/en/mysql-packet.html
|
|
*/
|
|
class MySQLPacketPayloadWriteBuffer : public WriteBuffer
|
|
{
|
|
public:
|
|
MySQLPacketPayloadWriteBuffer(WriteBuffer & out_, size_t payload_length_, uint8_t & sequence_id_);
|
|
|
|
bool remainingPayloadSize() { return total_left; }
|
|
|
|
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();
|
|
};
|
|
|
|
}
|