diff --git a/e2e_test/batch/catalog/pg_roles.slt.part b/e2e_test/batch/catalog/pg_roles.slt.part index d6408278f3028..52ad90ccdb4f0 100644 --- a/e2e_test/batch/catalog/pg_roles.slt.part +++ b/e2e_test/batch/catalog/pg_roles.slt.part @@ -1,4 +1,11 @@ -query ITTTTTTT -select * from pg_roles where rolname = 'root'; +query +SELECT r.rolname, r.rolsuper, r.rolinherit, + r.rolcreaterole, r.rolcreatedb, r.rolcanlogin, + r.rolconnlimit, r.rolvaliduntil +, r.rolreplication +, r.rolbypassrls +FROM pg_catalog.pg_roles r +WHERE r.rolname = 'root' +ORDER BY 1; ---- -1 root t t t t t t NULL t ******** +root t t t t t -1 NULL t t \ No newline at end of file diff --git a/src/frontend/src/catalog/system_catalog/mod.rs b/src/frontend/src/catalog/system_catalog/mod.rs index 230476412c65c..897171cfd38b4 100644 --- a/src/frontend/src/catalog/system_catalog/mod.rs +++ b/src/frontend/src/catalog/system_catalog/mod.rs @@ -352,6 +352,7 @@ prepare_sys_catalog! { { BuiltinCatalog::View(&PG_KEYWORDS) }, { BuiltinCatalog::View(&PG_ATTRDEF) }, { BuiltinCatalog::View(&PG_ROLES) }, + { BuiltinCatalog::View(&PG_AUTH_MEMBERS) }, { BuiltinCatalog::View(&PG_SHDESCRIPTION) }, { BuiltinCatalog::View(&PG_TABLESPACE) }, { BuiltinCatalog::View(&PG_STAT_ACTIVITY) }, diff --git a/src/frontend/src/catalog/system_catalog/pg_catalog/mod.rs b/src/frontend/src/catalog/system_catalog/pg_catalog/mod.rs index ace8bd03cf33e..24442d816f50f 100644 --- a/src/frontend/src/catalog/system_catalog/pg_catalog/mod.rs +++ b/src/frontend/src/catalog/system_catalog/pg_catalog/mod.rs @@ -15,6 +15,7 @@ pub mod pg_am; pub mod pg_attrdef; pub mod pg_attribute; +pub mod pg_auth_members; pub mod pg_cast; pub mod pg_class; pub mod pg_collation; @@ -49,6 +50,7 @@ pub mod pg_views; pub use pg_am::*; pub use pg_attrdef::*; pub use pg_attribute::*; +pub use pg_auth_members::*; pub use pg_cast::*; pub use pg_class::*; pub use pg_collation::*; diff --git a/src/frontend/src/catalog/system_catalog/pg_catalog/pg_auth_members.rs b/src/frontend/src/catalog/system_catalog/pg_catalog/pg_auth_members.rs new file mode 100644 index 0000000000000..e531bebf873d4 --- /dev/null +++ b/src/frontend/src/catalog/system_catalog/pg_catalog/pg_auth_members.rs @@ -0,0 +1,39 @@ +// Copyright 2023 RisingWave Labs +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +use std::sync::LazyLock; + +use risingwave_common::catalog::PG_CATALOG_SCHEMA_NAME; +use risingwave_common::types::DataType; + +use crate::catalog::system_catalog::{infer_dummy_view_sql, BuiltinView, SystemCatalogColumnsDef}; + +pub const PG_AUTH_MEMBERS_COLUMNS: &[SystemCatalogColumnsDef<'_>] = &[ + (DataType::Int32, "oid"), + (DataType::Int32, "roleid"), + (DataType::Int32, "member"), + (DataType::Int32, "grantor"), + (DataType::Boolean, "admin_option"), + (DataType::Boolean, "inherit_option"), + (DataType::Boolean, "set_option"), +]; + +/// The catalog `pg_auth_members` shows the membership relations between roles. Any non-circular set of relationships is allowed. +/// Ref: [`https://www.postgresql.org/docs/current/catalog-pg-auth-members.html`] +pub static PG_AUTH_MEMBERS: LazyLock = LazyLock::new(|| BuiltinView { + name: "pg_auth_members", + schema: PG_CATALOG_SCHEMA_NAME, + columns: PG_AUTH_MEMBERS_COLUMNS, + sql: infer_dummy_view_sql(PG_AUTH_MEMBERS_COLUMNS), +}); diff --git a/src/frontend/src/catalog/system_catalog/pg_catalog/pg_roles.rs b/src/frontend/src/catalog/system_catalog/pg_catalog/pg_roles.rs index aece805a13bdd..09fc5ff0f3fc6 100644 --- a/src/frontend/src/catalog/system_catalog/pg_catalog/pg_roles.rs +++ b/src/frontend/src/catalog/system_catalog/pg_catalog/pg_roles.rs @@ -34,6 +34,7 @@ pub static PG_ROLES: LazyLock = LazyLock::new(|| BuiltinView { (DataType::Boolean, "rolcreatedb"), (DataType::Boolean, "rolcanlogin"), (DataType::Boolean, "rolreplication"), + (DataType::Int32, "rolconnlimit"), (DataType::Timestamptz, "rolvaliduntil"), (DataType::Boolean, "rolbypassrls"), (DataType::Varchar, "rolpassword"), @@ -46,6 +47,7 @@ pub static PG_ROLES: LazyLock = LazyLock::new(|| BuiltinView { create_db AS rolcreatedb, \ can_login AS rolcanlogin, \ true AS rolreplication, \ + -1 AS rolconnlimit, \ NULL::timestamptz AS rolvaliduntil, \ true AS rolbypassrls, \ '********' AS rolpassword \