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