| 303 | } |
| 304 | |
| 305 | void 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 | |
| 328 | void DatabaseOnDisk::detachTablePermanently(ContextPtr query_context, const String & table_name) |
| 329 | { |
nothing calls this directly
no test coverage detected