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

Method commitCreateTable

src/Databases/DatabaseOnDisk.cpp:305–326  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

303}
304
305void DatabaseOnDisk::commitCreateTable(const ASTCreateQuery & query, const StoragePtr & table,
306 const String & table_metadata_tmp_path, const String & table_metadata_path,
307 ContextPtr query_context)
308{
309 auto db_disk = getDisk();
310 try
311 {
312 createDirectories();
313
314 /// Add a table to the map of known tables.
315 attachTable(query_context, query.getTable(), table, getTableDataPath(query));
316
317 /// If it was ATTACH query and file with table metadata already exist
318 /// (so, ATTACH is done after DETACH), then rename atomically replaces old file with new one.
319 db_disk->replaceFile(table_metadata_tmp_path, table_metadata_path);
320 }
321 catch (...)
322 {
323 db_disk->removeFileIfExists(table_metadata_tmp_path);
324 throw;
325 }
326}
327
328void DatabaseOnDisk::detachTablePermanently(ContextPtr query_context, const String & table_name)
329{

Callers

nothing calls this directly

Calls 3

getTableMethod · 0.45
replaceFileMethod · 0.45
removeFileIfExistsMethod · 0.45

Tested by

no test coverage detected