Skip to content

Commit

Permalink
fix: add rolconnlimit column in pg_roles, add pg_auth_members to supp…
Browse files Browse the repository at this point in the history
…ort \du (#13540)
  • Loading branch information
yezizp2012 authored Nov 21, 2023
1 parent 9aaa518 commit 343fd34
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 3 deletions.
13 changes: 10 additions & 3 deletions e2e_test/batch/catalog/pg_roles.slt.part
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions src/frontend/src/catalog/system_catalog/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) },
Expand Down
2 changes: 2 additions & 0 deletions src/frontend/src/catalog/system_catalog/pg_catalog/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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::*;
Expand Down
Original file line number Diff line number Diff line change
@@ -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<BuiltinView> = 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),
});
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ pub static PG_ROLES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
(DataType::Boolean, "rolcreatedb"),
(DataType::Boolean, "rolcanlogin"),
(DataType::Boolean, "rolreplication"),
(DataType::Int32, "rolconnlimit"),
(DataType::Timestamptz, "rolvaliduntil"),
(DataType::Boolean, "rolbypassrls"),
(DataType::Varchar, "rolpassword"),
Expand All @@ -46,6 +47,7 @@ pub static PG_ROLES: LazyLock<BuiltinView> = 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 \
Expand Down

0 comments on commit 343fd34

Please sign in to comment.