| 607 | } |
| 608 | |
| 609 | std::vector<std::pair<ASTPtr, StoragePtr>> DatabaseWithOwnTablesBase::getTablesForBackup(const FilterByNameFunction & filter, const ContextPtr & local_context) const |
| 610 | { |
| 611 | std::vector<std::pair<ASTPtr, StoragePtr>> res; |
| 612 | |
| 613 | for (auto it = getTablesIterator(local_context, filter, /*skip_not_loaded=*/false); it->isValid(); it->next()) |
| 614 | { |
| 615 | auto storage = it->table(); |
| 616 | if (!storage) |
| 617 | continue; /// Probably the table has been just dropped. |
| 618 | |
| 619 | auto create_table_query = tryGetCreateTableQuery(it->name(), local_context); |
| 620 | if (!create_table_query) |
| 621 | { |
| 622 | LOG_WARNING(log, "Couldn't get a create query for table {}.{}", |
| 623 | backQuoteIfNeed(getDatabaseName()), backQuoteIfNeed(it->name())); |
| 624 | continue; |
| 625 | } |
| 626 | |
| 627 | auto * create = create_table_query->as<ASTCreateQuery>(); |
| 628 | if (create->getTable() != it->name()) |
| 629 | { |
| 630 | /// Probably the database has been just renamed. Use the older name for backup to keep the backup consistent. |
| 631 | LOG_WARNING(log, "Got a create query with unexpected name {} for table {}.{}", |
| 632 | backQuoteIfNeed(create->getTable()), backQuoteIfNeed(getDatabaseName()), backQuoteIfNeed(it->name())); |
| 633 | create_table_query = create_table_query->clone(); |
| 634 | create = create_table_query->as<ASTCreateQuery>(); |
| 635 | create->setTable(it->name()); |
| 636 | } |
| 637 | |
| 638 | storage->applyMetadataChangesToCreateQueryForBackup(create_table_query); |
| 639 | res.emplace_back(create_table_query, storage); |
| 640 | } |
| 641 | |
| 642 | return res; |
| 643 | } |
| 644 | |
| 645 | void DatabaseWithOwnTablesBase::createTableRestoredFromBackup(const ASTPtr & create_table_query, ContextMutablePtr local_context, std::shared_ptr<IRestoreCoordination>, UInt64) |
| 646 | { |
nothing calls this directly
no test coverage detected