mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-16 11:22:12 +00:00
b2cfa70541
481 -> 230
52 lines
1.8 KiB
C++
52 lines
1.8 KiB
C++
#pragma once
|
|
|
|
#include <base/types.h>
|
|
#include <Parsers/IAST.h>
|
|
#include <Storages/IStorage_fwd.h>
|
|
#include <Databases/IDatabase.h>
|
|
#include <mutex>
|
|
|
|
|
|
/// General functionality for several different database engines.
|
|
|
|
namespace DB
|
|
{
|
|
|
|
void applyMetadataChangesToCreateQuery(const ASTPtr & query, const StorageInMemoryMetadata & metadata);
|
|
ASTPtr getCreateQueryFromStorage(const StoragePtr & storage, const ASTPtr & ast_storage, bool only_ordinary, uint32_t max_parser_depth, bool throw_on_error);
|
|
|
|
class Context;
|
|
|
|
/// A base class for databases that manage their own list of tables.
|
|
class DatabaseWithOwnTablesBase : public IDatabase, protected WithContext
|
|
{
|
|
public:
|
|
bool isTableExist(const String & table_name, ContextPtr context) const override;
|
|
|
|
StoragePtr tryGetTable(const String & table_name, ContextPtr context) const override;
|
|
|
|
bool empty() const override;
|
|
|
|
void attachTable(ContextPtr context, const String & table_name, const StoragePtr & table, const String & relative_table_path) override;
|
|
|
|
StoragePtr detachTable(ContextPtr context, const String & table_name) override;
|
|
|
|
DatabaseTablesIteratorPtr getTablesIterator(ContextPtr context, const FilterByNameFunction & filter_by_table_name) const override;
|
|
|
|
void shutdown() override;
|
|
|
|
~DatabaseWithOwnTablesBase() override;
|
|
|
|
protected:
|
|
Tables tables;
|
|
Poco::Logger * log;
|
|
|
|
DatabaseWithOwnTablesBase(const String & name_, const String & logger, ContextPtr context);
|
|
|
|
void attachTableUnlocked(const String & table_name, const StoragePtr & table, std::unique_lock<std::mutex> & lock);
|
|
StoragePtr detachTableUnlocked(const String & table_name, std::unique_lock<std::mutex> & lock);
|
|
StoragePtr getTableUnlocked(const String & table_name, std::unique_lock<std::mutex> & lock) const;
|
|
};
|
|
|
|
}
|