Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support \du when using psql #13519

Closed
neverchanje opened this issue Nov 20, 2023 · 2 comments · Fixed by #14044
Closed

feat: support \du when using psql #13519

neverchanje opened this issue Nov 20, 2023 · 2 comments · Fixed by #14044
Assignees
Labels
help wanted Issues that need help from contributors type/feature
Milestone

Comments

@neverchanje
Copy link
Contributor

neverchanje commented Nov 20, 2023

Is your feature request related to a problem? Please describe.

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 !~ '^pg_'
ORDER BY 1

Error: "Item not found: Invalid column: rolconnlimit"

The rest of features are all supported, except the missing rolconnlimit column.

The \du command is typically used to check the attributes/privileges of users. It's necessary for the feature richness of our user management subsystem.

Describe the solution you'd like

Add rolconnlimit to pg_catalog.pg_roles.

Describe alternatives you've considered

No response

Additional context

Please feel free to reassign this task to others, Thx!

@yezizp2012
Copy link
Member

yezizp2012 commented Nov 21, 2023

In higher version of psql, the internal query generated by \du is as follows:

SELECT r.rolname, r.rolsuper, r.rolinherit,
  r.rolcreaterole, r.rolcreatedb, r.rolcanlogin,
  r.rolconnlimit, r.rolvaliduntil,
  ARRAY(SELECT b.rolname
        FROM pg_catalog.pg_auth_members m
        JOIN pg_catalog.pg_roles b ON (m.roleid = b.oid)
        WHERE m.member = r.oid) as memberof
, r.rolreplication
, r.rolbypassrls
FROM pg_catalog.pg_roles r
WHERE r.rolname !~ '^pg_'
ORDER BY 1;

After #13540 , we still need to support expression ArraySubquery:

Feature is not yet implemented: unsupported expression ArraySubquery(Query { with: None, body: Select(Select { distinct: All, projection: [UnnamedExpr(CompoundIdentifier([Ident { value: "b", quote_style: None }, Ident { value: "rolname", quote_style: None }]))], from: [TableWithJoins { relation: Table { name: ObjectName([Ident { value: "pg_catalog", quote_style: None }, Ident { value: "pg_auth_members", quote_style: None }]), alias: Some(TableAlias { name: Ident { value: "m", quote_style: None }, columns: [] }), for_system_time_as_of_proctime: false }, joins: [Join { relation: Table { name: ObjectName([Ident { value: "pg_catalog", quote_style: None }, Ident { value: "pg_roles", quote_style: None }]), alias: Some(TableAlias { name: Ident { value: "b", quote_style: None }, columns: [] }), for_system_time_as_of_proctime: false }, join_operator: Inner(On(Nested(BinaryOp { left: CompoundIdentifier([Ident { value: "m", quote_style: None }, Ident { value: "roleid", quote_style: None }]), op: Eq, right: CompoundIdentifier([Ident { value: "b", quote_style: None }, Ident { value: "oid", quote_style: None }]) }))) }] }], lateral_views: [], selection: Some(BinaryOp { left: CompoundIdentifier([Ident { value: "m", quote_style: None }, Ident { value: "member", quote_style: None }]), op: Eq, right: CompoundIdentifier([Ident { value: "r", quote_style: None }, Ident { value: "oid", quote_style: None }]) }), group_by: [], having: None }), order_by: [], limit: None, offset: None, fetch: None })

@fuyufjh
Copy link
Member

fuyufjh commented Nov 21, 2023

  ARRAY(SELECT b.rolname
        FROM pg_catalog.pg_auth_members m
        JOIN pg_catalog.pg_roles b ON (m.roleid = b.oid)
        WHERE m.member = r.oid) as memberof

Note that r.oid here is a correlated variable from outside, and it should be unnested to ARRAY_AGG I think. cc. @chenzl25 Can you please take a look?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Issues that need help from contributors type/feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants