1#pragma once
2
3#include <Storages/StorageURL.h>
4#include <Common/XDBCBridgeHelper.h>
5
6
7namespace DB
8{
9
10/** Implements storage in the XDBC database.
11 * Use ENGINE = xdbc(connection_string, table_name)
12 * Example ENGINE = odbc('dsn=test', table)
13 * Read only.
14 */
15class StorageXDBC : public IStorageURLBase
16{
17public:
18
19 BlockInputStreams read(const Names & column_names,
20 const SelectQueryInfo & query_info,
21 const Context & context,
22 QueryProcessingStage::Enum processed_stage,
23 size_t max_block_size,
24 unsigned num_streams) override;
25
26
27 StorageXDBC(const std::string & database_name_,
28 const std::string & table_name_,
29 const std::string & remote_database_name,
30 const std::string & remote_table_name,
31 const ColumnsDescription & columns_,
32 const Context & context_, BridgeHelperPtr bridge_helper_);
33
34private:
35
36 BridgeHelperPtr bridge_helper;
37 std::string remote_database_name;
38 std::string remote_table_name;
39
40 Poco::Logger * log;
41
42 std::string getReadMethod() const override;
43
44 std::vector<std::pair<std::string, std::string>> getReadURIParams(const Names & column_names,
45 const SelectQueryInfo & query_info,
46 const Context & context,
47 QueryProcessingStage::Enum & processed_stage,
48 size_t max_block_size) const override;
49
50 std::function<void(std::ostream &)> getReadPOSTDataCallback(const Names & column_names,
51 const SelectQueryInfo & query_info,
52 const Context & context,
53 QueryProcessingStage::Enum & processed_stage,
54 size_t max_block_size) const override;
55
56 Block getHeaderBlock(const Names & column_names) const override;
57
58 std::string getName() const override;
59};
60
61}
62