#if !defined(ARCADIA_BUILD) # include "config_core.h" #endif #include #include #include #include #include #include #ifdef USE_MYSQL # include # include #endif namespace DB { namespace ErrorCodes { extern const int BAD_ARGUMENTS; } InterpreterExternalDDLQuery::InterpreterExternalDDLQuery(const ASTPtr & query_, Context & context_) : query(query_), context(context_) { } BlockIO InterpreterExternalDDLQuery::execute() { const ASTExternalDDLQuery & external_ddl_query = query->as(); if (external_ddl_query.from->name == "MySQL") { #ifdef USE_MYSQL const ASTs & arguments = external_ddl_query.from->arguments->children; if (arguments.size() != 2 || !arguments[0]->as() || !arguments[1]->as()) throw Exception("MySQL External require two identifier arguments.", ErrorCodes::BAD_ARGUMENTS); #endif if (external_ddl_query.external_ddl->as()) return MySQLInterpreter::InterpreterMySQLDropQuery( external_ddl_query.external_ddl, context, getIdentifierName(arguments[0]), getIdentifierName(arguments[1])).execute(); else if (external_ddl_query.external_ddl->as()) return MySQLInterpreter::InterpreterMySQLRenameQuery( external_ddl_query.external_ddl, context, getIdentifierName(arguments[0]), getIdentifierName(arguments[1])).execute(); else if (external_ddl_query.external_ddl->as()) return MySQLInterpreter::InterpreterMySQLCreateQuery( external_ddl_query.external_ddl, context, getIdentifierName(arguments[0]), getIdentifierName(arguments[1])) .execute(); } return BlockIO(); } }