mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-02 12:32:04 +00:00
42 lines
1.6 KiB
C++
42 lines
1.6 KiB
C++
#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;
|
|
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,
|
|
"Database engine {} does not support backups, cannot backup tables in database {}",
|
|
getEngineName(), backQuoteIfNeed(getDatabaseName()));
|
|
}
|
|
|
|
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()));
|
|
}
|
|
|
|
}
|