2016-03-26 03:03:50 +00:00
|
|
|
#pragma once
|
|
|
|
|
2017-04-01 09:19:00 +00:00
|
|
|
#include <Core/Types.h>
|
2019-10-07 14:18:18 +00:00
|
|
|
#include <Parsers/ASTFunction.h>
|
2017-04-01 09:19:00 +00:00
|
|
|
#include <Parsers/IAST.h>
|
2019-05-17 14:34:25 +00:00
|
|
|
#include <Storages/IStorage_fwd.h>
|
2017-04-01 09:19:00 +00:00
|
|
|
#include <Databases/IDatabase.h>
|
2019-08-28 13:21:19 +00:00
|
|
|
#include <mutex>
|
2016-03-26 03:03:50 +00:00
|
|
|
|
2017-05-23 18:33:48 +00:00
|
|
|
|
2017-04-17 11:56:55 +00:00
|
|
|
/// General functionality for several different database engines.
|
2016-03-26 03:03:50 +00:00
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
2017-05-23 18:33:48 +00:00
|
|
|
class Context;
|
|
|
|
|
2018-03-23 20:46:43 +00:00
|
|
|
/// A base class for databases that manage their own list of tables.
|
|
|
|
class DatabaseWithOwnTablesBase : public IDatabase
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
bool isTableExist(
|
|
|
|
const Context & context,
|
|
|
|
const String & table_name) const override;
|
|
|
|
|
|
|
|
StoragePtr tryGetTable(
|
|
|
|
const Context & context,
|
|
|
|
const String & table_name) const override;
|
|
|
|
|
2019-10-10 17:33:01 +00:00
|
|
|
bool empty(const Context & context) const override;
|
2018-03-23 20:46:43 +00:00
|
|
|
|
|
|
|
void attachTable(const String & table_name, const StoragePtr & table) override;
|
|
|
|
|
|
|
|
StoragePtr detachTable(const String & table_name) override;
|
|
|
|
|
2020-03-18 03:27:32 +00:00
|
|
|
DatabaseTablesIteratorPtr getTablesIterator(const Context & context, const FilterByNameFunction & filter_by_table_name) override;
|
2019-10-10 17:33:01 +00:00
|
|
|
|
2018-03-23 20:46:43 +00:00
|
|
|
void shutdown() override;
|
|
|
|
|
2018-03-23 20:56:45 +00:00
|
|
|
virtual ~DatabaseWithOwnTablesBase() override;
|
|
|
|
|
2018-03-23 20:46:43 +00:00
|
|
|
protected:
|
|
|
|
mutable std::mutex mutex;
|
|
|
|
Tables tables;
|
2019-10-10 17:33:01 +00:00
|
|
|
Dictionaries dictionaries;
|
2019-11-06 16:05:04 +00:00
|
|
|
Poco::Logger * log;
|
2018-03-23 20:46:43 +00:00
|
|
|
|
2019-11-06 16:05:04 +00:00
|
|
|
DatabaseWithOwnTablesBase(const String & name_, const String & logger);
|
2020-01-30 12:51:47 +00:00
|
|
|
|
|
|
|
void attachTableUnlocked(const String & table_name, const StoragePtr & table);
|
|
|
|
StoragePtr detachTableUnlocked(const String & table_name);
|
2018-03-23 20:46:43 +00:00
|
|
|
};
|
|
|
|
|
2016-03-26 03:03:50 +00:00
|
|
|
}
|