1#pragma once
2
3#include <Core/Types.h>
4#include <Parsers/ASTFunction.h>
5#include <Parsers/IAST.h>
6#include <Storages/IStorage_fwd.h>
7#include <Databases/IDatabase.h>
8#include <mutex>
9
10
11/// General functionality for several different database engines.
12
13namespace DB
14{
15
16class Context;
17
18/// A base class for databases that manage their own list of tables.
19class DatabaseWithOwnTablesBase : public IDatabase
20{
21public:
22 bool isTableExist(
23 const Context & context,
24 const String & table_name) const override;
25
26 StoragePtr tryGetTable(
27 const Context & context,
28 const String & table_name) const override;
29
30 bool empty(const Context & context) const override;
31
32 void attachTable(const String & table_name, const StoragePtr & table) override;
33
34 StoragePtr detachTable(const String & table_name) override;
35
36 DatabaseTablesIteratorPtr getTablesIterator(const Context & context, const FilterByNameFunction & filter_by_table_name = {}) override;
37
38 void shutdown() override;
39
40 virtual ~DatabaseWithOwnTablesBase() override;
41
42protected:
43 mutable std::mutex mutex;
44 Tables tables;
45 Dictionaries dictionaries;
46 Poco::Logger * log;
47
48 DatabaseWithOwnTablesBase(const String & name_, const String & logger);
49};
50
51}
52