ClickHouse/src/Storages/StoragePostgreSQL.h

62 lines
1.5 KiB
C++
Raw Normal View History

#pragma once
#include "config_core.h"
#if USE_LIBPQXX
#include <boost/noncopyable.hpp>
#include <Interpreters/Context.h>
#include <Storages/IStorage.h>
#include <Core/PostgreSQL/PoolWithFailover.h>
2021-09-01 17:59:11 +00:00
#include <Storages/ExternalDataSourceConfiguration.h>
namespace Poco
{
class Logger;
}
2021-01-11 10:23:44 +00:00
namespace DB
{
2020-11-25 21:06:33 +00:00
class StoragePostgreSQL final : public IStorage, boost::noncopyable
{
public:
StoragePostgreSQL(
const StorageID & table_id_,
2021-05-07 11:18:49 +00:00
postgres::PoolWithFailoverPtr pool_,
2021-03-15 14:37:31 +00:00
const String & remote_table_name_,
const ColumnsDescription & columns_,
const ConstraintsDescription & constraints_,
2021-04-23 12:18:23 +00:00
const String & comment,
2021-08-24 12:29:42 +00:00
const String & remote_table_schema_ = "",
const String & on_conflict = "");
String getName() const override { return "PostgreSQL"; }
Pipe read(
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;
2020-11-25 14:52:11 +00:00
2021-09-01 17:59:11 +00:00
static StoragePostgreSQLConfiguration getConfiguration(ASTs engine_args, ContextPtr context);
private:
2020-11-25 14:52:11 +00:00
friend class PostgreSQLBlockOutputStream;
String remote_table_name;
String remote_table_schema;
2021-08-24 12:29:42 +00:00
String on_conflict;
2021-03-27 20:14:02 +00:00
postgres::PoolWithFailoverPtr pool;
Poco::Logger * log;
2020-11-25 14:52:11 +00:00
};
2020-12-21 19:20:56 +00:00
}
#endif