ClickHouse/dbms/src/Databases/DatabaseAtomic.h

58 lines
1.8 KiB
C++
Raw Normal View History

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,
2019-12-02 19:11:18 +00:00
const String & to_table_name) override;
2019-11-11 14:28:28 +00:00
2020-01-22 11:30:11 +00:00
//void removeTable(const Context & context, const String & table_name) override;
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;
String getTableDataPath(const String & table_name) const override;
String getTableDataPath(const ASTCreateQuery & query) const override;
2019-11-11 11:34:03 +00:00
2020-03-19 21:14:52 +00:00
inline static String getPathForUUID(const UUID & uuid)
{
const size_t uuid_prefix_len = 3;
return toString(uuid).substr(0, uuid_prefix_len) + '/' + toString(uuid) + '/';
}
2019-11-11 11:34:03 +00:00
void drop(const Context & /*context*/) override;
2020-01-22 11:30:11 +00:00
void loadStoredObjects(Context & context, bool has_force_restore_data_flag) override;
void shutdown() 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
//TODO store path in DatabaseWithOwnTables::tables
std::map<String, String> table_name_to_path;
2020-01-22 11:30:11 +00:00
2019-10-23 13:46:38 +00:00
};
}