2017-12-05 13:32:02 +00:00
|
|
|
#pragma once
|
|
|
|
|
2017-12-27 21:45:05 +00:00
|
|
|
#include <ext/shared_ptr_helper.h>
|
|
|
|
|
2017-12-05 13:32:02 +00:00
|
|
|
#include <Storages/IStorage.h>
|
|
|
|
|
|
|
|
|
2017-12-26 21:34:06 +00:00
|
|
|
namespace Poco
|
2017-12-05 13:32:02 +00:00
|
|
|
{
|
2017-12-26 21:34:06 +00:00
|
|
|
namespace Data
|
2017-12-05 13:32:02 +00:00
|
|
|
{
|
2017-12-26 21:34:06 +00:00
|
|
|
class SessionPool;
|
2017-12-05 13:32:02 +00:00
|
|
|
}
|
2017-12-26 21:34:06 +00:00
|
|
|
}
|
2017-12-05 13:32:02 +00:00
|
|
|
|
|
|
|
|
2017-12-26 21:34:06 +00:00
|
|
|
namespace DB
|
|
|
|
{
|
2017-12-05 13:32:02 +00:00
|
|
|
|
2017-12-26 21:34:06 +00:00
|
|
|
/** Implements storage in the ODBC database.
|
|
|
|
* Use ENGINE = odbc(connection_string, table_name)
|
|
|
|
* Example ENGINE = odbc('dsn=test', table)
|
|
|
|
* Read only.
|
|
|
|
*/
|
2017-12-27 21:45:05 +00:00
|
|
|
class StorageODBC : public ext::shared_ptr_helper<StorageODBC>, public IStorage
|
2017-12-26 21:34:06 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
StorageODBC(
|
|
|
|
const std::string & name,
|
|
|
|
const std::string & connection_string,
|
|
|
|
const std::string & remote_database_name,
|
|
|
|
const std::string & remote_table_name,
|
2018-01-25 14:42:39 +00:00
|
|
|
const NamesAndTypesList & columns_);
|
2017-12-26 21:34:06 +00:00
|
|
|
|
|
|
|
std::string getName() const override { return "ODBC"; }
|
|
|
|
std::string getTableName() const override { return name; }
|
|
|
|
|
|
|
|
BlockInputStreams read(
|
|
|
|
const Names & column_names,
|
2017-12-05 13:32:02 +00:00
|
|
|
const SelectQueryInfo & query_info,
|
|
|
|
const Context & context,
|
|
|
|
QueryProcessingStage::Enum & processed_stage,
|
|
|
|
size_t max_block_size,
|
|
|
|
unsigned num_streams) override;
|
|
|
|
|
|
|
|
private:
|
2017-12-26 21:34:06 +00:00
|
|
|
std::string name;
|
|
|
|
std::string remote_database_name;
|
|
|
|
std::string remote_table_name;
|
|
|
|
|
|
|
|
std::shared_ptr<Poco::Data::SessionPool> pool;
|
2017-12-05 13:32:02 +00:00
|
|
|
};
|
|
|
|
}
|