#pragma once #include #include #include #include namespace DB { class Context; using DatabaseAndTable = std::pair; class AccessRightsElements; /** Allow to either drop table with all its data (DROP), * or remove information about table (just forget) from server (DETACH), * or just clear all data in table (TRUNCATE). */ class InterpreterDropQuery : public IInterpreter, WithMutableContext { public: InterpreterDropQuery(const ASTPtr & query_ptr_, ContextMutablePtr context_); /// Drop table or database. BlockIO execute() override; static void executeDropQuery(ASTDropQuery::Kind kind, ContextPtr global_context, ContextPtr current_context, const StorageID & target_table_id, bool sync); bool supportsTransactions() const override; private: AccessRightsElements getRequiredAccessForDDLOnCluster() const; ASTPtr query_ptr; BlockIO executeToDatabase(const ASTDropQuery & query); BlockIO executeToDatabaseImpl(const ASTDropQuery & query, DatabasePtr & database, std::vector & uuids_to_wait); BlockIO executeToTable(ASTDropQuery & query); BlockIO executeToTableImpl(ContextPtr context_, ASTDropQuery & query, DatabasePtr & db, UUID & uuid_to_wait); static void waitForTableToBeActuallyDroppedOrDetached(const ASTDropQuery & query, const DatabasePtr & db, const UUID & uuid_to_wait); BlockIO executeToDictionary(const String & database_name, const String & dictionary_name, ASTDropQuery::Kind kind, bool if_exists, bool is_temporary, bool no_ddl_lock); BlockIO executeToTemporaryTable(const String & table_name, ASTDropQuery::Kind kind); }; }