1 | #include <Databases/IDatabase.h> |
2 | #include <DataTypes/DataTypeString.h> |
3 | #include <Interpreters/Context.h> |
4 | #include <Storages/System/StorageSystemDatabases.h> |
5 | |
6 | |
7 | namespace DB |
8 | { |
9 | |
10 | NamesAndTypesList StorageSystemDatabases::getNamesAndTypes() |
11 | { |
12 | return { |
13 | {"name" , std::make_shared<DataTypeString>()}, |
14 | {"engine" , std::make_shared<DataTypeString>()}, |
15 | {"data_path" , std::make_shared<DataTypeString>()}, |
16 | {"metadata_path" , std::make_shared<DataTypeString>()}, |
17 | }; |
18 | } |
19 | |
20 | void StorageSystemDatabases::fillData(MutableColumns & res_columns, const Context & context, const SelectQueryInfo &) const |
21 | { |
22 | auto databases = context.getDatabases(); |
23 | for (const auto & database : databases) |
24 | { |
25 | if (context.hasDatabaseAccessRights(database.first)) |
26 | { |
27 | res_columns[0]->insert(database.first); |
28 | res_columns[1]->insert(database.second->getEngineName()); |
29 | res_columns[2]->insert(context.getPath() + database.second->getDataPath()); |
30 | res_columns[3]->insert(database.second->getMetadataPath()); |
31 | } |
32 | } |
33 | } |
34 | |
35 | } |
36 | |