2022-04-30 09:46:42 +00:00
|
|
|
#include <Databases/IDatabase.h>
|
2022-05-31 09:33:23 +00:00
|
|
|
#include <Storages/IStorage.h>
|
|
|
|
#include <Parsers/ASTCreateQuery.h>
|
2022-04-30 09:46:42 +00:00
|
|
|
#include <Common/quoteString.h>
|
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
|
|
|
namespace ErrorCodes
|
|
|
|
{
|
|
|
|
extern const int UNKNOWN_TABLE;
|
2022-05-29 19:53:56 +00:00
|
|
|
extern const int CANNOT_BACKUP_TABLE;
|
2022-05-31 09:33:23 +00:00
|
|
|
extern const int CANNOT_RESTORE_TABLE;
|
2022-04-30 09:46:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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));
|
2022-04-30 09:46:42 +00:00
|
|
|
}
|
|
|
|
|
2022-06-23 10:17:54 +00:00
|
|
|
std::vector<std::pair<ASTPtr, StoragePtr>> IDatabase::getTablesForBackup(const FilterByNameFunction &, const ContextPtr &) const
|
2022-05-29 19:53:56 +00:00
|
|
|
{
|
2022-06-24 19:29:38 +00:00
|
|
|
/// Cannot backup any table because IDatabase doesn't own any tables.
|
2022-05-31 09:33:23 +00:00
|
|
|
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-05-29 19:53:56 +00:00
|
|
|
}
|
|
|
|
|
2022-06-22 22:56:41 +00:00
|
|
|
void IDatabase::createTableRestoredFromBackup(const ASTPtr & create_table_query, ContextMutablePtr, std::shared_ptr<IRestoreCoordination>, UInt64)
|
2022-05-29 19:53:56 +00:00
|
|
|
{
|
2022-05-31 09:33:23 +00:00
|
|
|
/// 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()));
|
2022-05-29 19:53:56 +00:00
|
|
|
}
|
|
|
|
|
2022-04-30 09:46:42 +00:00
|
|
|
}
|