1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
#include <memory>
#include <Databases/IDatabase.h>
#include <Storages/IStorage.h>
#include <Parsers/ASTCreateQuery.h>
#include <Common/quoteString.h>
#include <Interpreters/DatabaseCatalog.h>
#include <Common/NamePrompter.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;
TableNameHints hints(this->shared_from_this(), context);
std::vector<String> names = hints.getHints(name);
if (names.empty())
throw Exception(ErrorCodes::UNKNOWN_TABLE, "Table {}.{} does not exist", backQuoteIfNeed(getDatabaseName()), backQuoteIfNeed(name));
else
throw Exception(ErrorCodes::UNKNOWN_TABLE, "Table {}.{} does not exist. Maybe you meant {}?", backQuoteIfNeed(getDatabaseName()), backQuoteIfNeed(name), backQuoteIfNeed(names[0]));
}
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()));
}
}
|