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(query): show grants support where/limit option #15607

Merged
merged 6 commits into from
May 24, 2024

Conversation

TCeason
Copy link
Collaborator

@TCeason TCeason commented May 22, 2024

I hereby agree to the terms of the CLA available at: https://docs.databend.com/dev/policies/cla/

Summary

  1. support table_function show_grants
  2. remove show grants plan, bind show grants stmt with rewrite query
  3. add rewritekind::showgrants
  4. support SHOW GRANTS ON <OBJECT_TYPE> <OBJECT_NAME>

Usage:

SHOW GRANTS ON <object_type> <object_name> [LIKE '<pattern>' | WHERE <expr>] | [LIMIT <limit>];
SHOW GRANTS FOR [ USER | ROLE ] <name> [LIKE '<pattern>' | WHERE <expr>] | [LIMIT <limit>];

-- table_function
select * from show_grants('role', 'role_name');
select * from show_grants('user', 'user_name');
select * from show_grants('stage', 'stage_name');
select * from show_grants('udf', 'udf_name');
select * from show_grants('table', 'table_name', 'catalog_name', 'db_name');
select * from show_grants('database', 'db_name', 'catalog_name');

Note:

show grants on only support get role that can access the object.

create user b identified by '123';

create function f as (a) -> (a+1);

grant usage on udf f to b;

show grants on udf f;

create role role1;

grant usage on udf f to role role1;

show grants on udf f;
+------------+-------------+-----------+----------+-------+--------+
| privileges | object_name | object_id | grant_to | name  | grants |
+------------+-------------+-----------+----------+-------+--------+
| USAGE      | f           |      NULL | ROLE     | role1 |        |
+------------+-------------+-----------+----------+-------+--------+

Tests

  • Unit Test
  • Logic Test
  • Benchmark Test
  • No Test - Explain why

Type of change

  • Bug Fix (non-breaking change which fixes an issue)
  • New Feature (non-breaking change which adds functionality)
  • Breaking Change (fix or feature that could cause existing functionality not to work as expected)
  • Documentation Update
  • Refactoring
  • Performance Improvement
  • Other (please describe):

This change is Reviewable

1. remove show grants plan, bind show grants stmt with rewrite query

2. support show grants on object <object_name>

3. add rewritekind::showgrants
@TCeason TCeason marked this pull request as draft May 22, 2024 03:26
@github-actions github-actions bot added the pr-feature this PR introduces a new feature to the codebase label May 22, 2024
@TCeason TCeason force-pushed the fix_15451 branch 2 times, most recently from 3c2ca82 to 9ae328a Compare May 22, 2024 07:29
@TCeason TCeason marked this pull request as ready for review May 23, 2024 06:36
@BohuTANG BohuTANG requested a review from drmingdrmer May 23, 2024 09:09
@BohuTANG
Copy link
Member

Involved @drmingdrmer to review the src/meta/api/src/schema_api_impl.rspart.

Copy link
Member

@drmingdrmer drmingdrmer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 1 of 33 files at r1.
Reviewable status: 1 of 33 files reviewed, all discussions resolved (waiting on @flaneur2020)

@BohuTANG BohuTANG merged commit 0604f10 into datafuselabs:main May 24, 2024
75 of 76 checks passed
@TCeason
Copy link
Collaborator Author

TCeason commented May 24, 2024

cc @soyeric128 Doc need add :

Look pr summary:

show grants for 

show grants on 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr-feature this PR introduces a new feature to the codebase
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature: show grants support where expr
4 participants