ClickHouse/dbms/Interpreters/InterpreterRenameQuery.h
Ivan 97f2a2213e
Move all folders inside /dbms one level up (#9974)
* Move some code outside dbms/src folder
* Fix paths
2020-04-02 02:51:21 +03:00

47 lines
1.0 KiB
C++

#pragma once
#include <Interpreters/IInterpreter.h>
#include <Parsers/IAST_fwd.h>
namespace DB
{
class Context;
class AccessRightsElements;
/// To avoid deadlocks, we must acquire locks for tables in same order in any different RENAMES.
struct UniqueTableName
{
String database_name;
String table_name;
UniqueTableName(const String & database_name_, const String & table_name_)
: database_name(database_name_), table_name(table_name_) {}
bool operator< (const UniqueTableName & rhs) const
{
return std::tie(database_name, table_name) < std::tie(rhs.database_name, rhs.table_name);
}
};
using TableGuards = std::map<UniqueTableName, std::unique_ptr<DDLGuard>>;
/** Rename one table
* or rename many tables at once.
*/
class InterpreterRenameQuery : public IInterpreter
{
public:
InterpreterRenameQuery(const ASTPtr & query_ptr_, Context & context_);
BlockIO execute() override;
private:
AccessRightsElements getRequiredAccess() const;
ASTPtr query_ptr;
Context & context;
};
}