1#pragma once
2
3#include <mutex>
4#include <unordered_set>
5#include <Databases/DatabasesCommon.h>
6#include <Databases/IDatabase.h>
7#include <Storages/IStorage_fwd.h>
8
9
10namespace Poco
11{
12 class Logger;
13}
14
15
16namespace DB
17{
18
19/* Database to store StorageDictionary tables
20 * automatically creates tables for all dictionaries
21 */
22class DatabaseDictionary : public IDatabase
23{
24public:
25 DatabaseDictionary(const String & name_);
26
27 String getEngineName() const override
28 {
29 return "Dictionary";
30 }
31
32 bool isTableExist(
33 const Context & context,
34 const String & table_name) const override;
35
36 StoragePtr tryGetTable(
37 const Context & context,
38 const String & table_name) const override;
39
40 DatabaseTablesIteratorPtr getTablesIterator(const Context & context, const FilterByNameFunction & filter_by_table_name = {}) override;
41
42 bool empty(const Context & context) const override;
43
44 ASTPtr getCreateDatabaseQuery() const override;
45
46 void shutdown() override;
47
48protected:
49 ASTPtr getCreateTableQueryImpl(const Context & context, const String & table_name, bool throw_on_error) const override;
50
51private:
52 mutable std::mutex mutex;
53
54 Poco::Logger * log;
55
56 Tables listTables(const Context & context, const FilterByNameFunction & filter_by_name);
57};
58
59}
60