ClickHouse/src/Databases/IDatabase.cpp

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

42 lines
1.6 KiB
C++
Raw Normal View History

#include <Databases/IDatabase.h>
#include <Storages/IStorage.h>
#include <Parsers/ASTCreateQuery.h>
#include <Common/quoteString.h>
namespace DB
{
namespace ErrorCodes
{
extern const int UNKNOWN_TABLE;
extern const int CANNOT_BACKUP_TABLE;
extern const int CANNOT_RESTORE_TABLE;
}
StoragePtr IDatabase::getTable(const String & name, ContextPtr context) const
{
if (auto storage = tryGetTable(name, context))
return storage;
2022-06-27 20:48:27 +00:00
throw Exception(ErrorCodes::UNKNOWN_TABLE, "Table {}.{} doesn't exist", backQuoteIfNeed(getDatabaseName()), backQuoteIfNeed(name));
}
std::vector<std::pair<ASTPtr, StoragePtr>> IDatabase::getTablesForBackup(const FilterByNameFunction &, const ContextPtr &) const
{
/// Cannot backup any table because IDatabase doesn't own any tables.
throw Exception(ErrorCodes::CANNOT_BACKUP_TABLE,
2022-06-22 22:56:41 +00:00
"Database engine {} does not support backups, cannot backup tables in database {}",
getEngineName(), backQuoteIfNeed(getDatabaseName()));
}
2022-06-22 22:56:41 +00:00
void IDatabase::createTableRestoredFromBackup(const ASTPtr & create_table_query, ContextMutablePtr, std::shared_ptr<IRestoreCoordination>, UInt64)
{
/// Cannot restore any table because IDatabase doesn't own any tables.
throw Exception(ErrorCodes::CANNOT_RESTORE_TABLE,
"Database engine {} does not support restoring tables, cannot restore table {}.{}",
getEngineName(), backQuoteIfNeed(getDatabaseName()),
backQuoteIfNeed(create_table_query->as<const ASTCreateQuery &>().getTable()));
}
}