2012-05-21 20:38:34 +00:00
|
|
|
#pragma once
|
|
|
|
|
2017-04-01 09:19:00 +00:00
|
|
|
#include <Core/Block.h>
|
|
|
|
#include <DataStreams/IBlockOutputStream.h>
|
2018-02-14 15:11:39 +00:00
|
|
|
#include <Common/Throttler.h>
|
2019-03-07 23:11:41 +00:00
|
|
|
#include <IO/ConnectionTimeouts.h>
|
2012-05-21 20:38:34 +00:00
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
2017-01-31 18:39:01 +00:00
|
|
|
class Connection;
|
|
|
|
class ReadBuffer;
|
|
|
|
struct Settings;
|
2016-01-11 21:46:36 +00:00
|
|
|
|
|
|
|
|
2017-01-31 18:39:01 +00:00
|
|
|
/** Allow to execute INSERT query on remote server and send data for it.
|
2012-05-21 20:38:34 +00:00
|
|
|
*/
|
|
|
|
class RemoteBlockOutputStream : public IBlockOutputStream
|
|
|
|
{
|
|
|
|
public:
|
2019-03-07 23:11:41 +00:00
|
|
|
RemoteBlockOutputStream(Connection & connection_,
|
|
|
|
const ConnectionTimeouts & timeouts,
|
|
|
|
const String & query_,
|
2020-03-24 22:26:24 +00:00
|
|
|
const Settings * settings_ = nullptr,
|
|
|
|
const ClientInfo * client_info_ = nullptr);
|
2012-05-21 20:38:34 +00:00
|
|
|
|
2018-02-19 00:45:32 +00:00
|
|
|
Block getHeader() const override { return header; }
|
2012-05-21 20:38:34 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
void write(const Block & block) override;
|
|
|
|
void writeSuffix() override;
|
2014-09-18 19:49:31 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
/// Send pre-serialized and possibly pre-compressed block of data, that will be read from 'input'.
|
|
|
|
void writePrepared(ReadBuffer & input, size_t size = 0);
|
2012-05-21 20:38:34 +00:00
|
|
|
|
2018-02-14 15:11:39 +00:00
|
|
|
~RemoteBlockOutputStream() override;
|
|
|
|
|
2012-05-21 20:38:34 +00:00
|
|
|
private:
|
2017-04-01 07:20:54 +00:00
|
|
|
Connection & connection;
|
|
|
|
String query;
|
|
|
|
const Settings * settings;
|
2020-03-24 22:26:24 +00:00
|
|
|
const ClientInfo * client_info;
|
2018-02-19 00:45:32 +00:00
|
|
|
Block header;
|
2018-02-14 15:11:39 +00:00
|
|
|
bool finished = false;
|
2012-05-21 20:38:34 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|