risingwave_frontend/catalog/system_catalog/rw_catalog/
rw_databases.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 RwDatabases {
24 #[primary_key]
25 id: i32,
26 name: String,
27 owner: i32,
28 acl: Vec<String>,
29 resource_group: String,
30 barrier_interval_ms: Option<i32>,
31 checkpoint_frequency: Option<i64>,
32}
33
34#[system_catalog(table, "rw_catalog.rw_databases")]
35fn read(reader: &SysCatalogReaderImpl) -> Result<Vec<RwDatabases>> {
36 let catalog_reader = reader.catalog_reader.read_guard();
37 let user_reader = reader.user_info_reader.read_guard();
38 let users = user_reader.get_all_users();
39 let username_map = user_reader.get_user_name_map();
40
41 Ok(catalog_reader
42 .iter_databases()
43 .map(|db| RwDatabases {
44 id: db.id().as_i32_id(),
45 name: db.name().into(),
46 owner: db.owner() as i32,
47 acl: get_acl_items(db.id(), false, &users, username_map),
48 resource_group: db.resource_group.clone(),
49 barrier_interval_ms: db.barrier_interval_ms.map(|v| v as i32),
50 checkpoint_frequency: db.checkpoint_frequency.map(|v| v as i64),
51 })
52 .collect())
53}