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

Method getTablesForBackup

src/Databases/DatabasesCommon.cpp:609–643  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

607}
608
609std::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
645void DatabaseWithOwnTablesBase::createTableRestoredFromBackup(const ASTPtr & create_table_query, ContextMutablePtr local_context, std::shared_ptr<IRestoreCoordination>, UInt64)
646{

Callers

nothing calls this directly

Calls 10

backQuoteIfNeedFunction · 0.85
tableMethod · 0.80
isValidMethod · 0.45
nextMethod · 0.45
nameMethod · 0.45
getTableMethod · 0.45
cloneMethod · 0.45
setTableMethod · 0.45
emplace_backMethod · 0.45

Tested by

no test coverage detected