ClickHouse/src/Storages/StorageMySQL.h

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

73 lines
1.8 KiB
C++
Raw Normal View History

#pragma once
#include "config.h"
#if USE_MYSQL
#include <Storages/IStorage.h>
#include <Storages/MySQL/MySQLSettings.h>
2021-09-02 13:01:26 +00:00
#include <Storages/ExternalDataSourceConfiguration.h>
#include <mysqlxx/PoolWithFailover.h>
namespace Poco
{
class Logger;
}
2017-12-13 16:46:57 +00:00
namespace DB
{
2017-12-26 21:34:06 +00:00
/** Implements storage in the MySQL database.
* Use ENGINE = mysql(host_port, database_name, table_name, user_name, password)
* Read only.
*/
class StorageMySQL final : public IStorage, WithContext
{
public:
2017-12-26 21:34:06 +00:00
StorageMySQL(
2019-12-04 16:06:55 +00:00
const StorageID & table_id_,
mysqlxx::PoolWithFailover && pool_,
2019-08-03 11:02:40 +00:00
const std::string & remote_database_name_,
const std::string & remote_table_name_,
bool replace_query_,
2019-08-03 11:02:40 +00:00
const std::string & on_duplicate_clause_,
const ColumnsDescription & columns_,
2019-08-24 21:20:20 +00:00
const ConstraintsDescription & constraints_,
2021-04-23 12:18:23 +00:00
const String & comment,
ContextPtr context_,
const MySQLSettings & mysql_settings_);
2017-12-26 21:34:06 +00:00
std::string getName() const override { return "MySQL"; }
2020-08-03 13:54:14 +00:00
Pipe read(
2017-12-26 21:34:06 +00:00
const Names & column_names,
const StorageSnapshotPtr & storage_snapshot,
SelectQueryInfo & query_info,
ContextPtr context,
QueryProcessingStage::Enum processed_stage,
size_t max_block_size,
unsigned num_streams) override;
2021-07-23 19:33:59 +00:00
SinkToStoragePtr write(const ASTPtr & query, const StorageMetadataPtr & /*metadata_snapshot*/, ContextPtr context) override;
2021-12-27 14:41:37 +00:00
static StorageMySQLConfiguration getConfiguration(ASTs engine_args, ContextPtr context_, MySQLBaseSettings & storage_settings);
2021-09-02 13:01:26 +00:00
private:
2021-07-23 19:33:59 +00:00
friend class StorageMySQLSink;
2017-12-26 21:34:06 +00:00
std::string remote_database_name;
std::string remote_table_name;
bool replace_query;
std::string on_duplicate_clause;
2017-12-26 21:34:06 +00:00
MySQLSettings mysql_settings;
2021-03-27 14:35:44 +00:00
mysqlxx::PoolWithFailoverPtr pool;
Poco::Logger * log;
};
2017-12-26 21:34:06 +00:00
}
#endif