#include #include #include #include #include #include #include #include #include namespace DB { NamesAndTypesList StorageSystemRoles::getNamesAndTypes() { NamesAndTypesList names_and_types{ {"name", std::make_shared()}, {"id", std::make_shared()}, {"storage", std::make_shared()}, }; return names_and_types; } void StorageSystemRoles::fillData(MutableColumns & res_columns, ContextPtr context, const SelectQueryInfo &) const { context->checkAccess(AccessType::SHOW_ROLES); const auto & access_control = context->getAccessControlManager(); std::vector ids = access_control.findAll(); size_t column_index = 0; auto & column_name = assert_cast(*res_columns[column_index++]); auto & column_id = assert_cast(*res_columns[column_index++]).getData(); auto & column_storage = assert_cast(*res_columns[column_index++]); auto add_row = [&](const String & name, const UUID & id, const String & storage_name) { column_name.insertData(name.data(), name.length()); column_id.push_back(id.toUnderType()); column_storage.insertData(storage_name.data(), storage_name.length()); }; for (const auto & id : ids) { auto role = access_control.tryRead(id); if (!role) continue; auto storage = access_control.findStorage(id); if (!storage) continue; add_row(role->getName(), id, storage->getStorageName()); } } }