This commit is contained in:
Alexander Tokmakov 2019-10-30 15:17:52 +03:00
parent 5059c78e81
commit a3b4762cde
7 changed files with 25 additions and 11 deletions

View File

@ -1,4 +1,5 @@
#include <Databases/DatabaseAtomic.h>
#include <Databases/DatabaseOnDisk.h>
namespace DB
@ -9,6 +10,12 @@ DatabaseAtomic::DatabaseAtomic(String name_, String metadata_path_, const Contex
{
}
void DatabaseAtomic::renameTable(const Context & context, const String & table_name, IDatabase & to_database,
const String & to_table_name, TableStructureWriteLockHolder & lock)
{
//TODO
DatabaseOnDisk::renameTable<DatabaseAtomic>(*this, context, table_name, to_database, to_table_name, lock);
}
}

View File

@ -15,6 +15,12 @@ public:
String getEngineName() const override { return "Atomic"; }
void renameTable(const Context & context,
const String & table_name,
IDatabase & to_database,
const String & to_table_name,
TableStructureWriteLockHolder &) override;
};

View File

@ -126,7 +126,7 @@ ASTPtr parseCreateQueryFromMetadataFile(const String & filepath, Poco::Logger *
std::pair<String, StoragePtr> createTableFromAST(
ASTCreateQuery ast_create_query,
const String & database_name,
const String & database_data_path,
const String & database_data_path_relative,
Context & context,
bool has_force_restore_data_flag)
{
@ -149,12 +149,13 @@ std::pair<String, StoragePtr> createTableFromAST(
ColumnsDescription columns = InterpreterCreateQuery::getColumnsDescription(*ast_create_query.columns_list->columns, context);
ConstraintsDescription constraints = InterpreterCreateQuery::getConstraintsDescription(ast_create_query.columns_list->constraints);
String table_data_path_relative = database_data_path_relative + escapeForFileName(ast_create_query.table) + '/';
return
{
ast_create_query.table,
StorageFactory::instance().get(
ast_create_query,
database_data_path, ast_create_query.table, database_name, context, context.getGlobalContext(),
table_data_path_relative, ast_create_query.table, database_name, context, context.getGlobalContext(),
columns, constraints,
true, has_force_restore_data_flag)
};

View File

@ -24,7 +24,7 @@ ASTPtr parseCreateQueryFromMetadataFile(const String & filepath, Poco::Logger *
std::pair<String, StoragePtr> createTableFromAST(
ASTCreateQuery ast_create_query,
const String & database_name,
const String & database_data_path,
const String & database_data_path_relative,
Context & context,
bool has_force_restore_data_flag);

View File

@ -56,7 +56,7 @@ static void loadDatabase(
bool force_restore_data)
{
/// There may exist .sql file with database creation statement.
/// Or, if it is absent, then database with default engine is created.
/// Or, if it is absent, then database with Ordinary engine is created.
String database_attach_query;
String database_metadata_file = database_path + ".sql";
@ -67,7 +67,8 @@ static void loadDatabase(
readStringUntilEOF(database_attach_query, in);
}
else
database_attach_query = "ATTACH DATABASE " + backQuoteIfNeed(database);
//FIXME
database_attach_query = "ATTACH DATABASE " + backQuoteIfNeed(database) + " ENGINE = Atomic";
executeCreateQuery(database_attach_query, context, database,
database_metadata_file, force_restore_data);

View File

@ -1180,9 +1180,7 @@ void MergeTreeData::rename(
const String & /*new_path_to_db*/, const String & new_database_name,
const String & new_table_name, TableStructureWriteLockHolder &)
{
auto old_file_db_name = escapeForFileName(database_name);
auto new_file_db_name = escapeForFileName(new_database_name);
auto old_file_table_name = escapeForFileName(table_name);
auto new_file_table_name = escapeForFileName(new_table_name);
auto disks = storage_policy->getDisks();
@ -1212,7 +1210,7 @@ void MergeTreeData::rename(
database_name = new_database_name;
table_name = new_table_name;
relative_data_path = "data/" + old_file_db_name + '/' + old_file_table_name + '/';
relative_data_path = "data/" + new_file_db_name + '/' + new_file_table_name + '/';
}
void MergeTreeData::dropAllData()

View File

@ -25,11 +25,12 @@ try
names_and_types.emplace_back("a", std::make_shared<DataTypeUInt64>());
names_and_types.emplace_back("b", std::make_shared<DataTypeUInt8>());
StoragePtr table = StorageLog::create("./", "test", "test", ColumnsDescription{names_and_types}, ConstraintsDescription{}, 1048576);
table->startup();
auto context = Context::createGlobal();
context.makeGlobalContext();
context.setPath("./");
StoragePtr table = StorageLog::create("./", "test", "test", ColumnsDescription{names_and_types}, ConstraintsDescription{}, 1048576, context);
table->startup();
/// write into it
{