From 073c0de63e29d71e3e69d68f23db917fc61fafac Mon Sep 17 00:00:00 2001 From: Alexey Milovidov Date: Sat, 19 Mar 2016 04:06:36 +0300 Subject: [PATCH] Database engines: development [#METR-19997]. --- dbms/include/DB/Databases/DatabaseOrdinary.h | 2 +- dbms/include/DB/Databases/IDatabase.h | 2 +- dbms/src/Databases/DatabaseOrdinary.cpp | 5 +++-- dbms/src/Interpreters/InterpreterRenameQuery.cpp | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/dbms/include/DB/Databases/DatabaseOrdinary.h b/dbms/include/DB/Databases/DatabaseOrdinary.h index b85fedce905..3cabaff860e 100644 --- a/dbms/include/DB/Databases/DatabaseOrdinary.h +++ b/dbms/include/DB/Databases/DatabaseOrdinary.h @@ -39,7 +39,7 @@ public: void attachTable(const String & table_name, const StoragePtr & table) override; StoragePtr detachTable(const String & table_name) override; - void renameTable(const String & table_name, IDatabase & to_database, const String & to_table_name) override; + void renameTable(const Context & context, const String & table_name, IDatabase & to_database, const String & to_table_name) override; ASTPtr getCreateQuery(const String & table_name) const override; diff --git a/dbms/include/DB/Databases/IDatabase.h b/dbms/include/DB/Databases/IDatabase.h index 34738f24f86..d6ba23a37ed 100644 --- a/dbms/include/DB/Databases/IDatabase.h +++ b/dbms/include/DB/Databases/IDatabase.h @@ -66,7 +66,7 @@ public: virtual StoragePtr detachTable(const String & name) = 0; /// Переименовать таблицу и, возможно, переместить таблицу в другую БД. - virtual void renameTable(const String & name, IDatabase & to_database, const String & to_name) = 0; + virtual void renameTable(const Context & context, const String & name, IDatabase & to_database, const String & to_name) = 0; /// Получить запрос CREATE TABLE для таблицы. Может выдавать информацию и для detached таблиц, для которых есть метаданные. virtual ASTPtr getCreateQuery(const String & name) const = 0; diff --git a/dbms/src/Databases/DatabaseOrdinary.cpp b/dbms/src/Databases/DatabaseOrdinary.cpp index 82fde6e1552..3f76f96b61a 100644 --- a/dbms/src/Databases/DatabaseOrdinary.cpp +++ b/dbms/src/Databases/DatabaseOrdinary.cpp @@ -442,7 +442,8 @@ static ASTPtr getCreateQueryImpl(const String & path, const String & table_name) } -void DatabaseOrdinary::renameTable(const String & table_name, IDatabase & to_database, const String & to_table_name) +void DatabaseOrdinary::renameTable( + const Context & context, const String & table_name, IDatabase & to_database, const String & to_table_name) { DatabaseOrdinary * to_database_concrete = typeid_cast(&to_database); @@ -457,7 +458,7 @@ void DatabaseOrdinary::renameTable(const String & table_name, IDatabase & to_dat /// Уведомляем таблицу о том, что она переименовывается. Если таблица не поддерживает переименование - кинется исключение. try { - table->rename(path + "data/" + escapeForFileName(to_database_concrete->name) + "/", + table->rename(context.getPath() + "/data/" + escapeForFileName(to_database_concrete->name) + "/", to_database_concrete->name, to_table_name); } diff --git a/dbms/src/Interpreters/InterpreterRenameQuery.cpp b/dbms/src/Interpreters/InterpreterRenameQuery.cpp index d731fb4198c..c0c91784878 100644 --- a/dbms/src/Interpreters/InterpreterRenameQuery.cpp +++ b/dbms/src/Interpreters/InterpreterRenameQuery.cpp @@ -102,7 +102,7 @@ BlockIO InterpreterRenameQuery::execute() context.assertTableDoesntExist(elem.to_database_name, elem.to_table_name); context.getDatabase(elem.from_database_name)->renameTable( - elem.from_table_name, *context.getDatabase(elem.to_database_name), elem.to_table_name); + context, elem.from_table_name, *context.getDatabase(elem.to_database_name), elem.to_table_name); } return {};