It returns the create table statement (even if table is detached)
| 536 | |
| 537 | /// It returns the create table statement (even if table is detached) |
| 538 | ASTPtr DatabaseOnDisk::getCreateTableQueryImpl(const String & table_name, ContextPtr, bool throw_on_error) const |
| 539 | { |
| 540 | ASTPtr ast; |
| 541 | StoragePtr storage = tryGetTable(table_name, getContext()); |
| 542 | bool has_table = storage != nullptr; |
| 543 | bool is_system_storage = false; |
| 544 | if (has_table) |
| 545 | is_system_storage = storage->isSystemStorage(); |
| 546 | |
| 547 | try |
| 548 | { |
| 549 | ast = getCreateQueryFromMetadata(table_name, throw_on_error); |
| 550 | } |
| 551 | catch (const Exception & e) |
| 552 | { |
| 553 | if (!has_table && e.code() == ErrorCodes::FILE_DOESNT_EXIST && throw_on_error) |
| 554 | throw Exception(ErrorCodes::CANNOT_GET_CREATE_TABLE_QUERY, "Table {} doesn't exist", backQuote(table_name)); |
| 555 | if (!is_system_storage && throw_on_error) |
| 556 | throw; |
| 557 | } |
| 558 | if (!ast && is_system_storage) |
| 559 | ast = getCreateQueryFromStorage(table_name, storage, throw_on_error); |
| 560 | return ast; |
| 561 | } |
| 562 | |
| 563 | ASTPtr DatabaseOnDisk::getCreateDatabaseQueryImpl() const |
| 564 | { |
nothing calls this directly
no test coverage detected