MCPcopy Create free account
hub / github.com/ClickHouse/ClickHouse / executeToTable

Method executeToTable

src/Interpreters/InterpreterUndropQuery.cpp:47–79  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

45}
46
47BlockIO InterpreterUndropQuery::executeToTable(ASTUndropQuery & query)
48{
49 auto table_id = StorageID(query);
50
51 auto context = getContext();
52 if (table_id.database_name.empty())
53 {
54 table_id.database_name = context->getCurrentDatabase();
55 query.setDatabase(table_id.database_name);
56 }
57
58 auto guard = DatabaseCatalog::instance().getDDLGuard(table_id.database_name, table_id.table_name, nullptr);
59
60 auto database = DatabaseCatalog::instance().getDatabase(table_id.database_name);
61 if (database->getEngineName() == "Replicated")
62 throw Exception(ErrorCodes::SUPPORT_IS_DISABLED, "Replicated database does not support UNDROP query");
63 if (database->isTableExist(table_id.table_name, getContext()))
64 throw Exception(
65 ErrorCodes::TABLE_ALREADY_EXISTS, "Cannot undrop table, {} already exists", table_id);
66
67 database->checkMetadataFilenameAvailability(table_id.table_name);
68
69#if CLICKHOUSE_CLOUD
70 if (SharedDatabaseCatalog::shouldReplicateQuery(getContext(), query_ptr))
71 {
72 SharedDatabaseCatalog::instance().undropTable(database->getUUID(), table_id.table_name);
73 return {};
74 }
75#endif
76
77 DatabaseCatalog::instance().undropTable(table_id);
78 return {};
79}
80
81AccessRightsElements InterpreterUndropQuery::getRequiredAccessForDDLOnCluster() const
82{

Callers

nothing calls this directly

Calls 13

getCurrentDatabaseMethod · 0.80
getDDLGuardMethod · 0.80
undropTableMethod · 0.80
StorageIDClass · 0.70
ExceptionClass · 0.70
getContextFunction · 0.50
emptyMethod · 0.45
setDatabaseMethod · 0.45
getDatabaseMethod · 0.45
getEngineNameMethod · 0.45
isTableExistMethod · 0.45

Tested by

no test coverage detected