1 | #include <Databases/DatabaseOnDisk.h> |
2 | #include <ext/scope_guard.h> |
3 | |
4 | namespace DB |
5 | { |
6 | |
7 | |
8 | class DatabaseWithDictionaries : public DatabaseOnDisk |
9 | { |
10 | public: |
11 | void attachDictionary(const String & name, const Context & context) override; |
12 | |
13 | void detachDictionary(const String & name, const Context & context) override; |
14 | |
15 | void createDictionary(const Context & context, |
16 | const String & dictionary_name, |
17 | const ASTPtr & query) override; |
18 | |
19 | void removeDictionary(const Context & context, const String & dictionary_name) override; |
20 | |
21 | StoragePtr tryGetTable(const Context & context, const String & table_name) const override; |
22 | |
23 | DatabaseTablesIteratorPtr getTablesWithDictionaryTablesIterator(const Context & context, const FilterByNameFunction & filter_by_dictionary_name = {}) override; |
24 | |
25 | DatabaseDictionariesIteratorPtr getDictionariesIterator(const Context & context, const FilterByNameFunction & filter_by_dictionary_name = {}) override; |
26 | |
27 | bool isDictionaryExist(const Context & context, const String & dictionary_name) const override; |
28 | |
29 | void shutdown() override; |
30 | |
31 | ~DatabaseWithDictionaries() override; |
32 | |
33 | protected: |
34 | DatabaseWithDictionaries(const String & name, const String & metadata_path_, const String & logger) |
35 | : DatabaseOnDisk(name, metadata_path_, logger) {} |
36 | |
37 | void attachToExternalDictionariesLoader(Context & context); |
38 | void detachFromExternalDictionariesLoader(); |
39 | |
40 | StoragePtr getDictionaryStorage(const Context & context, const String & table_name) const; |
41 | |
42 | ASTPtr getCreateDictionaryQueryImpl(const Context & context, |
43 | const String & dictionary_name, |
44 | bool throw_on_error) const override; |
45 | |
46 | private: |
47 | ext::scope_guard database_as_config_repo_for_external_loader; |
48 | }; |
49 | |
50 | } |
51 | |