ClickHouse/dbms/Formats/MySQLBlockInputStream.h

40 lines
1.0 KiB
C++
Raw Normal View History

#pragma once
#include <string>
#include <Core/Block.h>
#include <DataStreams/IBlockInputStream.h>
2015-04-16 06:12:35 +00:00
#include <mysqlxx/PoolWithFailover.h>
#include <mysqlxx/Query.h>
2019-02-15 11:46:07 +00:00
#include <Core/ExternalResultDescription.h>
2016-12-08 02:49:04 +00:00
namespace DB
2016-01-12 02:21:15 +00:00
{
/// Allows processing results of a MySQL query as a sequence of Blocks, simplifies chaining
class MySQLBlockInputStream final : public IBlockInputStream
{
public:
MySQLBlockInputStream(
2019-08-03 11:02:40 +00:00
const mysqlxx::PoolWithFailover::Entry & entry_,
const std::string & query_str,
const Block & sample_block,
2019-08-03 11:02:40 +00:00
const UInt64 max_block_size_,
const bool auto_close_ = false);
String getName() const override { return "MySQL"; }
Block getHeader() const override { return description.sample_block.cloneEmpty(); }
private:
Block readImpl() override;
mysqlxx::PoolWithFailover::Entry entry;
mysqlxx::Query query;
mysqlxx::UseQueryResult result;
2019-02-10 16:55:12 +00:00
const UInt64 max_block_size;
const bool auto_close;
ExternalResultDescription description;
};
}