2015-01-27 13:00:20 +00:00
|
|
|
#pragma once
|
|
|
|
|
2018-12-10 15:25:45 +00:00
|
|
|
#include <string>
|
2017-04-01 09:19:00 +00:00
|
|
|
#include <Core/Block.h>
|
2019-01-23 14:48:50 +00:00
|
|
|
#include <DataStreams/IBlockInputStream.h>
|
2015-04-16 06:12:35 +00:00
|
|
|
#include <mysqlxx/PoolWithFailover.h>
|
2018-12-10 15:25:45 +00:00
|
|
|
#include <mysqlxx/Query.h>
|
2019-02-15 11:46:07 +00:00
|
|
|
#include <Core/ExternalResultDescription.h>
|
2015-01-27 13:00:20 +00:00
|
|
|
|
|
|
|
|
2016-12-08 02:49:04 +00:00
|
|
|
namespace DB
|
2016-01-12 02:21:15 +00:00
|
|
|
{
|
2015-02-10 14:50:43 +00:00
|
|
|
/// Allows processing results of a MySQL query as a sequence of Blocks, simplifies chaining
|
2019-01-23 14:48:50 +00:00
|
|
|
class MySQLBlockInputStream final : public IBlockInputStream
|
2015-01-27 13:00:20 +00:00
|
|
|
{
|
|
|
|
public:
|
2017-04-01 07:20:54 +00:00
|
|
|
MySQLBlockInputStream(
|
2019-08-03 11:02:40 +00:00
|
|
|
const mysqlxx::PoolWithFailover::Entry & entry_,
|
2018-12-10 15:25:45 +00:00
|
|
|
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);
|
2015-01-27 13:00:20 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
String getName() const override { return "MySQL"; }
|
2015-01-27 13:00:20 +00:00
|
|
|
|
2018-10-12 02:41:54 +00:00
|
|
|
Block getHeader() const override { return description.sample_block.cloneEmpty(); }
|
2018-01-06 18:10:44 +00:00
|
|
|
|
2015-01-27 13:00:20 +00:00
|
|
|
private:
|
2017-04-01 07:20:54 +00:00
|
|
|
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;
|
2019-05-23 13:09:07 +00:00
|
|
|
const bool auto_close;
|
2017-04-01 07:20:54 +00:00
|
|
|
ExternalResultDescription description;
|
2015-01-27 13:00:20 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|