2015-01-27 13:00:20 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <DB/Core/Block.h>
|
|
|
|
#include <DB/DataStreams/IProfilingBlockInputStream.h>
|
2016-04-10 02:32:59 +00:00
|
|
|
#include <DB/Dictionaries/ExternalResultDescription.h>
|
2015-01-27 13:00:20 +00:00
|
|
|
#include <mysqlxx/Query.h>
|
2015-04-16 06:12:35 +00:00
|
|
|
#include <mysqlxx/PoolWithFailover.h>
|
2015-01-27 13:00:20 +00:00
|
|
|
#include <string>
|
|
|
|
|
|
|
|
|
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
|
|
|
|
class MySQLBlockInputStream final : public IProfilingBlockInputStream
|
2015-01-27 13:00:20 +00:00
|
|
|
{
|
|
|
|
public:
|
2015-10-13 15:38:08 +00:00
|
|
|
MySQLBlockInputStream(
|
2016-04-10 02:29:45 +00:00
|
|
|
const mysqlxx::PoolWithFailover::Entry & entry, const std::string & query_str, const Block & sample_block,
|
2016-12-08 02:49:04 +00:00
|
|
|
const size_t max_block_size);
|
2015-01-27 13:00:20 +00:00
|
|
|
|
2015-06-08 20:22:02 +00:00
|
|
|
String getName() const override { return "MySQL"; }
|
2015-01-27 13:00:20 +00:00
|
|
|
|
2016-12-08 02:49:04 +00:00
|
|
|
String getID() const override;
|
2015-01-27 13:00:20 +00:00
|
|
|
|
|
|
|
private:
|
2016-12-08 02:49:04 +00:00
|
|
|
Block readImpl() override;
|
2015-01-27 13:00:20 +00:00
|
|
|
|
2015-10-13 15:38:08 +00:00
|
|
|
static void insertDefaultValue(IColumn * const column, const IColumn & sample_column)
|
2015-01-27 13:00:20 +00:00
|
|
|
{
|
2015-10-13 15:38:08 +00:00
|
|
|
column->insertFrom(sample_column, 0);
|
2015-01-27 13:00:20 +00:00
|
|
|
}
|
|
|
|
|
2015-03-18 12:09:49 +00:00
|
|
|
mysqlxx::PoolWithFailover::Entry entry;
|
2015-01-27 13:00:20 +00:00
|
|
|
mysqlxx::Query query;
|
|
|
|
mysqlxx::UseQueryResult result;
|
2016-12-08 02:49:04 +00:00
|
|
|
const size_t max_block_size;
|
2016-04-10 02:32:59 +00:00
|
|
|
ExternalResultDescription description;
|
2015-01-27 13:00:20 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|