#include #include #include #include #include #include #include #include namespace DB { NamesAndTypesList StorageSystemEnabledRoles::getNamesAndTypes() { NamesAndTypesList names_and_types{ {"role_name", std::make_shared()}, {"with_admin_option", std::make_shared()}, {"is_current", std::make_shared()}, {"is_default", std::make_shared()}, }; return names_and_types; } void StorageSystemEnabledRoles::fillData(MutableColumns & res_columns, ContextPtr context, const SelectQueryInfo &) const { auto roles_info = context->getRolesInfo(); auto user = context->getUser(); size_t column_index = 0; auto & column_role_name = assert_cast(*res_columns[column_index++]); auto & column_admin_option = assert_cast(*res_columns[column_index++]).getData(); auto & column_is_current = assert_cast(*res_columns[column_index++]).getData(); auto & column_is_default = assert_cast(*res_columns[column_index++]).getData(); auto add_row = [&](const String & role_name, bool admin_option, bool is_current, bool is_default) { column_role_name.insertData(role_name.data(), role_name.length()); column_admin_option.push_back(admin_option); column_is_current.push_back(is_current); column_is_default.push_back(is_default); }; for (const auto & role_id : roles_info->enabled_roles) { const String & role_name = roles_info->names_of_roles.at(role_id); bool admin_option = roles_info->enabled_roles_with_admin_option.count(role_id); bool is_current = roles_info->current_roles.count(role_id); bool is_default = user->default_roles.match(role_id); add_row(role_name, admin_option, is_current, is_default); } } }