2017-06-22 15:44:19 +00:00
|
|
|
#pragma once
|
|
|
|
|
2017-06-23 15:55:45 +00:00
|
|
|
#include <Databases/DatabasesCommon.h>
|
2017-06-22 15:44:19 +00:00
|
|
|
#include <Databases/IDatabase.h>
|
2019-05-17 14:34:25 +00:00
|
|
|
#include <Storages/IStorage_fwd.h>
|
2017-06-22 15:44:19 +00:00
|
|
|
|
2021-04-10 23:33:54 +00:00
|
|
|
#include <mutex>
|
|
|
|
#include <unordered_set>
|
|
|
|
|
2017-06-22 15:44:19 +00:00
|
|
|
|
2017-06-23 15:55:45 +00:00
|
|
|
namespace Poco
|
|
|
|
{
|
2017-06-22 18:00:29 +00:00
|
|
|
class Logger;
|
2017-06-22 15:44:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
|
|
|
/* Database to store StorageDictionary tables
|
|
|
|
* automatically creates tables for all dictionaries
|
|
|
|
*/
|
2021-04-10 23:33:54 +00:00
|
|
|
class DatabaseDictionary final : public IDatabase, WithContext
|
2017-06-22 15:44:19 +00:00
|
|
|
{
|
2017-06-23 15:55:45 +00:00
|
|
|
public:
|
2021-04-10 23:33:54 +00:00
|
|
|
DatabaseDictionary(const String & name_, ContextPtr context_);
|
2018-05-10 15:56:38 +00:00
|
|
|
|
2017-06-22 18:00:29 +00:00
|
|
|
String getEngineName() const override
|
|
|
|
{
|
2017-06-22 15:44:19 +00:00
|
|
|
return "Dictionary";
|
|
|
|
}
|
|
|
|
|
2021-04-10 23:33:54 +00:00
|
|
|
bool isTableExist(const String & table_name, ContextPtr context) const override;
|
2017-06-22 15:44:19 +00:00
|
|
|
|
2021-04-10 23:33:54 +00:00
|
|
|
StoragePtr tryGetTable(const String & table_name, ContextPtr context) const override;
|
2017-06-22 15:44:19 +00:00
|
|
|
|
2021-04-10 23:33:54 +00:00
|
|
|
DatabaseTablesIteratorPtr getTablesIterator(ContextPtr context, const FilterByNameFunction & filter_by_table_name) override;
|
2019-10-10 17:33:01 +00:00
|
|
|
|
2020-04-23 16:51:48 +00:00
|
|
|
bool empty() const override;
|
2017-06-22 15:44:19 +00:00
|
|
|
|
2020-04-23 16:51:48 +00:00
|
|
|
ASTPtr getCreateDatabaseQuery() const override;
|
2018-03-13 13:28:32 +00:00
|
|
|
|
2020-04-12 20:50:32 +00:00
|
|
|
bool shouldBeEmptyOnDetach() const override { return false; }
|
|
|
|
|
2017-06-22 15:44:19 +00:00
|
|
|
void shutdown() override;
|
2018-03-23 19:56:24 +00:00
|
|
|
|
2019-11-01 12:47:55 +00:00
|
|
|
protected:
|
2021-04-10 23:33:54 +00:00
|
|
|
ASTPtr getCreateTableQueryImpl(const String & table_name, ContextPtr context, bool throw_on_error) const override;
|
2019-11-01 12:47:55 +00:00
|
|
|
|
2018-03-23 19:56:24 +00:00
|
|
|
private:
|
|
|
|
Poco::Logger * log;
|
|
|
|
|
2020-04-01 22:41:29 +00:00
|
|
|
Tables listTables(const FilterByNameFunction & filter_by_name);
|
2017-06-22 15:44:19 +00:00
|
|
|
};
|
2017-09-11 12:39:01 +00:00
|
|
|
|
2017-06-22 15:44:19 +00:00
|
|
|
}
|