2019-10-23 13:46:38 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <Databases/DatabasesCommon.h>
|
2020-01-22 11:30:11 +00:00
|
|
|
#include <Core/BackgroundSchedulePool.h>
|
2019-10-23 13:46:38 +00:00
|
|
|
|
|
|
|
#include <Databases/DatabaseOrdinary.h>
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
2019-11-11 11:34:03 +00:00
|
|
|
class DatabaseAtomic : public DatabaseOrdinary
|
2019-10-23 13:46:38 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
2020-01-22 11:30:11 +00:00
|
|
|
DatabaseAtomic(String name_, String metadata_path_, Context & context_);
|
2019-10-23 13:46:38 +00:00
|
|
|
|
|
|
|
String getEngineName() const override { return "Atomic"; }
|
|
|
|
|
2019-11-11 14:28:28 +00:00
|
|
|
void renameTable(
|
|
|
|
const Context & context,
|
|
|
|
const String & table_name,
|
|
|
|
IDatabase & to_database,
|
2020-03-31 20:38:05 +00:00
|
|
|
const String & to_table_name,
|
|
|
|
bool exchange) override;
|
2019-11-11 14:28:28 +00:00
|
|
|
|
2020-03-20 00:07:52 +00:00
|
|
|
void dropTable(const Context & context, const String & table_name, bool no_delay) override;
|
2020-01-22 11:30:11 +00:00
|
|
|
|
2020-03-20 12:45:06 +00:00
|
|
|
void attachTable(const String & name, const StoragePtr & table, const String & relative_table_path) override;
|
2019-11-11 11:34:03 +00:00
|
|
|
StoragePtr detachTable(const String & name) override;
|
|
|
|
|
2019-12-25 21:17:49 +00:00
|
|
|
String getTableDataPath(const String & table_name) const override;
|
|
|
|
String getTableDataPath(const ASTCreateQuery & query) const override;
|
2019-11-11 11:34:03 +00:00
|
|
|
|
|
|
|
void drop(const Context & /*context*/) override;
|
|
|
|
|
2020-04-01 22:41:29 +00:00
|
|
|
DatabaseTablesIteratorPtr getTablesIterator(const FilterByNameFunction & filter_by_table_name) override;
|
|
|
|
|
2020-04-10 00:08:43 +00:00
|
|
|
void loadStoredObjects(Context & context, bool has_force_restore_data_flag) override;
|
|
|
|
|
2020-04-10 23:02:15 +00:00
|
|
|
void assertCanBeDetached(bool cleenup);
|
|
|
|
|
2020-04-13 14:09:56 +00:00
|
|
|
UUID tryGetTableUUID(const String & table_name) const override;
|
|
|
|
|
2019-11-11 11:34:03 +00:00
|
|
|
private:
|
2020-03-23 00:12:13 +00:00
|
|
|
void commitAlterTable(const StorageID & table_id, const String & table_metadata_tmp_path, const String & table_metadata_path) override;
|
|
|
|
void commitCreateTable(const ASTCreateQuery & query, const StoragePtr & table,
|
|
|
|
const String & table_metadata_tmp_path, const String & table_metadata_path) override;
|
2020-01-27 20:31:39 +00:00
|
|
|
|
2020-03-30 19:15:18 +00:00
|
|
|
void assertDetachedTableNotInUse(const UUID & uuid);
|
2020-04-10 00:08:43 +00:00
|
|
|
typedef std::unordered_map<UUID, StoragePtr> DetachedTables;
|
2020-04-06 23:22:44 +00:00
|
|
|
DetachedTables cleenupDetachedTables();
|
2020-03-30 19:15:18 +00:00
|
|
|
|
2020-04-10 00:08:43 +00:00
|
|
|
void tryCreateSymlink(const String & table_name, const String & actual_data_path);
|
|
|
|
void tryRemoveSymlink(const String & table_name);
|
|
|
|
|
2020-01-27 20:31:39 +00:00
|
|
|
//TODO store path in DatabaseWithOwnTables::tables
|
2020-04-10 00:08:43 +00:00
|
|
|
typedef std::unordered_map<String, String> NameToPathMap;
|
|
|
|
NameToPathMap table_name_to_path;
|
2020-01-27 20:31:39 +00:00
|
|
|
|
2020-04-06 23:22:44 +00:00
|
|
|
DetachedTables detached_tables;
|
2020-04-10 00:08:43 +00:00
|
|
|
const String path_to_table_symlinks;
|
2019-10-23 13:46:38 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|