-
Notifications
You must be signed in to change notification settings - Fork 763
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
[ISSUE-2894][PATCH-1] Add parser on GRANT .. TO database
.table
#2901
[ISSUE-2894][PATCH-1] Add parser on GRANT .. TO database
.table
#2901
Conversation
Thanks for the contribution! Please review the labels and make any necessary changes. |
database
.table
Codecov Report
@@ Coverage Diff @@
## main #2901 +/- ##
======================================
Coverage 68% 68%
======================================
Files 635 636 +1
Lines 33599 33680 +81
======================================
+ Hits 22885 23006 +121
+ Misses 10714 10674 -40
Continue to review full report at Codecov.
|
d5d61a6
to
3fbcaa5
Compare
database
.table
database
.table
3fbcaa5
to
3f52661
Compare
@@ -233,4 +233,21 @@ impl Catalog for OverlaidCatalog { | |||
} | |||
} | |||
} | |||
|
|||
async fn exists_table( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How these codes is shown in this patch, I rember that it's in another patch
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in the earlier days there's only exists_database
but no exists_table
yet, there's another PR working on this?
if it's true i'd avoid adding exists_table func in this PR to avoid conflicting q.q
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've reverted the changes on the catalog trait, plz help review again
There is a suggesstion and a question: Suggesstion: Question: |
the privileges is both granted to the user and role? 🤔 in mysql the privileges one user finally gets is the privileges she directly get granted add the user's roles' privileges
yes, we'd also add the logic about grant the privileges to roles in the future pull requests |
360ace9
to
b2e78d1
Compare
Privileges are granted to roles, and roles are granted to users.
|
Not true. Updated: |
it's right, when a role is dropped, the user stil has his own privileges left: consider a scenary like a user has got a role with after dropping the role, she stil remains the |
If the
|
The follow model is more simple for us(ClickHouse did them too, see):
|
the user privilege + role privileges is commonly used in the popular DBMS? 🤔 it's also available in clickhouse: https://clickhouse.com/docs/en/sql-reference/statements/grant/
a GRANT statement can works to imo RBAC is powerful but it has a bit higher bar than the user privileges, it has its own scenary 🤔 |
For many DBMS, user and role is called object, and the privileges can grant to object, I guess they keep it, but it's more complex. |
in the current code base, adding
user privilege + rbac has more complexity than the RBAC only solution at last, but RBAC has more complexity than the user privilege upfront 🤔 |
@@ -51,6 +73,40 @@ impl Interpreter for GrantPrivilegeInterpreter { | |||
_input_stream: Option<SendableDataBlockStream>, | |||
) -> Result<SendableDataBlockStream> { | |||
let plan = self.plan.clone(); | |||
|
|||
// *.`table` is not allowed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
case by case match is more complex, but not quite sure if there is a regular check for the pattern?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or we can first to check database_pattern and then table_pattern
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it seems we can seperate the grant object (global, database, or table) in the parsing phase
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how about adding a GrantObject enum on this?
it'd has three hands:
- Global
- Database(String)
- Table(Option, String) // if the database is not specified, taking the current db in session
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@BohuTANG I've refactored out an GrantObject enum, and checked *.table
as invalid syntax in the parsing phase
please help review again when you get time 🤝
ffa3a14
to
43592e7
Compare
e798ac3
to
3671b5e
Compare
3671b5e
to
4462dd5
Compare
/lgtm |
Wait for another reviewer approval |
I hereby agree to the terms of the CLA available at: https://databend.rs/policies/cla/
Summary
database
.table
maybe in another PR:
Changelog
Related Issues
Fixes #2894
Test Plan
Unit Tests
Stateless Tests