risingwave_frontend/catalog/system_catalog/rw_catalog/
rw_schemas.rs1use risingwave_common::types::Fields;
16use risingwave_frontend_macro::system_catalog;
17use risingwave_pb::user::grant_privilege::Object;
18
19use crate::catalog::OwnedByUserCatalog;
20use crate::catalog::system_catalog::{SysCatalogReaderImpl, get_acl_items};
21use crate::error::Result;
22
23#[derive(Fields)]
24struct RwSchema {
25 #[primary_key]
26 id: i32,
27 name: String,
28 owner: i32,
29 acl: Vec<String>,
30}
31
32#[system_catalog(table, "rw_catalog.rw_schemas")]
33fn read_rw_schema_info(reader: &SysCatalogReaderImpl) -> Result<Vec<RwSchema>> {
34 let catalog_reader = reader.catalog_reader.read_guard();
35 let schemas = catalog_reader.iter_schemas(&reader.auth_context.database)?;
36 let user_reader = reader.user_info_reader.read_guard();
37 let users = user_reader.get_all_users();
38 let username_map = user_reader.get_user_name_map();
39
40 Ok(schemas
41 .map(|schema| RwSchema {
42 id: schema.id() as i32,
43 name: schema.name(),
44 owner: schema.owner() as i32,
45 acl: get_acl_items(&Object::SchemaId(schema.id()), false, &users, username_map),
46 })
47 .collect())
48}