2020-11-25 21:06:33 +00:00
|
|
|
#pragma once
|
2022-09-28 13:29:29 +00:00
|
|
|
#include "config.h"
|
2020-11-25 21:06:33 +00:00
|
|
|
|
|
|
|
#if USE_LIBPQXX
|
|
|
|
#include <TableFunctions/ITableFunction.h>
|
2021-05-08 14:55:53 +00:00
|
|
|
#include <Core/PostgreSQL/PoolWithFailover.h>
|
2021-09-01 17:59:11 +00:00
|
|
|
#include <Storages/ExternalDataSourceConfiguration.h>
|
2022-12-17 00:30:55 +00:00
|
|
|
#include <Storages/StoragePostgreSQL.h>
|
2020-11-25 21:06:33 +00:00
|
|
|
|
2021-01-11 10:23:44 +00:00
|
|
|
|
2020-11-25 21:06:33 +00:00
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
|
|
|
class TableFunctionPostgreSQL : public ITableFunction
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
static constexpr auto name = "postgresql";
|
|
|
|
std::string getName() const override { return name; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
StoragePtr executeImpl(
|
2021-04-10 23:33:54 +00:00
|
|
|
const ASTPtr & ast_function, ContextPtr context,
|
2023-07-06 08:56:07 +00:00
|
|
|
const std::string & table_name, ColumnsDescription cached_columns, bool is_insert_query) const override;
|
2020-11-25 21:06:33 +00:00
|
|
|
|
|
|
|
const char * getStorageTypeName() const override { return "PostgreSQL"; }
|
|
|
|
|
2023-07-06 08:56:07 +00:00
|
|
|
ColumnsDescription getActualTableStructure(ContextPtr context, bool is_insert_query) const override;
|
2021-04-10 23:33:54 +00:00
|
|
|
void parseArguments(const ASTPtr & ast_function, ContextPtr context) override;
|
2020-11-25 21:06:33 +00:00
|
|
|
|
2021-03-27 20:14:02 +00:00
|
|
|
postgres::PoolWithFailoverPtr connection_pool;
|
2022-12-17 00:30:55 +00:00
|
|
|
std::optional<StoragePostgreSQL::Configuration> configuration;
|
2020-11-25 21:06:33 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|