2016-04-10 04:00:00 +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>
|
2018-12-10 15:25:45 +00:00
|
|
|
#include <Poco/Data/RecordSet.h>
|
2018-08-10 04:02:56 +00:00
|
|
|
#include <Poco/Data/Session.h>
|
|
|
|
#include <Poco/Data/Statement.h>
|
2019-02-15 11:46:07 +00:00
|
|
|
#include <Core/ExternalResultDescription.h>
|
2016-04-10 04:00:00 +00:00
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
/// Allows processing results of a query to ODBC source as a sequence of Blocks, simplifies chaining
|
2019-01-23 14:48:50 +00:00
|
|
|
class ODBCBlockInputStream final : public IBlockInputStream
|
2016-04-10 04:00:00 +00:00
|
|
|
{
|
|
|
|
public:
|
2017-04-01 07:20:54 +00:00
|
|
|
ODBCBlockInputStream(
|
2019-02-10 16:55:12 +00:00
|
|
|
Poco::Data::Session && session, const std::string & query_str, const Block & sample_block, const UInt64 max_block_size);
|
2016-04-10 04:00:00 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
String getName() const override { return "ODBC"; }
|
2016-04-10 04:00:00 +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
|
|
|
|
2016-04-10 04:00:00 +00:00
|
|
|
private:
|
2017-04-01 07:20:54 +00:00
|
|
|
Block readImpl() override;
|
2016-04-10 04:00:00 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
Poco::Data::Session session;
|
|
|
|
Poco::Data::Statement statement;
|
|
|
|
Poco::Data::RecordSet result;
|
|
|
|
Poco::Data::RecordSet::Iterator iterator;
|
2016-04-10 04:00:00 +00:00
|
|
|
|
2019-02-10 16:55:12 +00:00
|
|
|
const UInt64 max_block_size;
|
2017-04-01 07:20:54 +00:00
|
|
|
ExternalResultDescription description;
|
2017-05-15 14:16:10 +00:00
|
|
|
|
|
|
|
Poco::Logger * log;
|
2016-04-10 04:00:00 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|