2019-07-04 18:55:20 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <Processors/Formats/IRowOutputFormat.h>
|
|
|
|
#include <Core/Block.h>
|
|
|
|
|
2020-08-13 12:07:02 +00:00
|
|
|
#include <Core/MySQL/Authentication.h>
|
|
|
|
#include <Core/MySQL/PacketsGeneric.h>
|
|
|
|
#include <Core/MySQL/PacketsConnection.h>
|
|
|
|
#include <Core/MySQL/PacketsProtocolText.h>
|
2019-07-04 18:55:20 +00:00
|
|
|
#include <Formats/FormatSettings.h>
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
|
|
|
class IColumn;
|
|
|
|
class IDataType;
|
|
|
|
class WriteBuffer;
|
|
|
|
|
|
|
|
/** A stream for outputting data in a binary line-by-line format.
|
|
|
|
*/
|
2021-06-01 12:20:52 +00:00
|
|
|
class MySQLOutputFormat final : public IOutputFormat, WithContext
|
2019-07-04 18:55:20 +00:00
|
|
|
{
|
|
|
|
public:
|
2019-12-25 19:17:41 +00:00
|
|
|
MySQLOutputFormat(WriteBuffer & out_, const Block & header_, const FormatSettings & settings_);
|
2019-07-04 18:55:20 +00:00
|
|
|
|
|
|
|
String getName() const override { return "MySQLOutputFormat"; }
|
|
|
|
|
2021-06-01 12:20:52 +00:00
|
|
|
void setContext(ContextPtr context_)
|
2019-12-25 19:17:41 +00:00
|
|
|
{
|
2021-04-10 23:33:54 +00:00
|
|
|
context = context_;
|
|
|
|
packet_endpoint = std::make_unique<MySQLProtocol::PacketEndpoint>(out, const_cast<uint8_t &>(getContext()->mysql.sequence_id)); /// TODO: fix it
|
2019-12-25 19:17:41 +00:00
|
|
|
}
|
|
|
|
|
2019-07-04 18:55:20 +00:00
|
|
|
void consume(Chunk) override;
|
|
|
|
void finalize() override;
|
2019-08-02 12:41:21 +00:00
|
|
|
void flush() override;
|
2019-08-05 09:35:46 +00:00
|
|
|
void doWritePrefix() override { initialize(); }
|
|
|
|
|
|
|
|
void initialize();
|
|
|
|
|
2019-07-04 18:55:20 +00:00
|
|
|
private:
|
|
|
|
bool initialized = false;
|
|
|
|
|
2020-08-13 12:41:36 +00:00
|
|
|
std::unique_ptr<MySQLProtocol::PacketEndpoint> packet_endpoint;
|
2019-07-04 18:55:20 +00:00
|
|
|
FormatSettings format_settings;
|
2019-12-01 11:21:43 +00:00
|
|
|
DataTypes data_types;
|
2021-03-09 14:46:52 +00:00
|
|
|
Serializations serializations;
|
2019-07-04 18:55:20 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|