-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
sql: support SHOW GRANTS
for functions
#88773
Conversation
2a654f5
to
4110cbc
Compare
pkg/sql/delegate/show_grants.go
Outdated
privilege_type, | ||
is_grantable::boolean | ||
FROM "".information_schema.role_routine_grants | ||
WHERE reverse(split_part(reverse(specific_name), '_', 1))::INT > 100000 |
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'm not including any builtin functions cause thinking it would just explode the SHOW GRANTS
output without adding much user experience value since anyone can execute a builtin.
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.
look pretty good! just some small comments
Reviewable status: complete! 0 of 0 LGTMs obtained (waiting on @chengxiong-ruan and @rafiss)
pkg/sql/delegate/show_grants.go
line 105 at r1 (raw file):
) ` //
missing comment?
pkg/sql/delegate/show_grants.go
line 116 at r1 (raw file):
is_grantable::boolean FROM "".information_schema.role_routine_grants WHERE reverse(split_part(reverse(specific_name), '_', 1))::INT > 100000
could you make the 100000
reference CockroachPredefinedOIDMax
just in case that constant ever changes?
pkg/sql/logictest/testdata/logic_test/udf
line 627 at r1 (raw file):
query TTTTTTTTTT colnames SELECT * FROM information_schema.role_routine_grants
is it useful to still keep the test on infromation_schema to make sure that metadata is correct too?
pkg/sql/logictest/testdata/logic_test/udf
line 634 at r1 (raw file):
query TTTTTTB colnames SHOW GRANTS ON FUNCTION test_priv_f1, test_priv_f2, test_priv_f3
hm, i am a bit confused. how did this work without any change to sql.y to support ON FUNCTION
?
4110cbc
to
58e8f6e
Compare
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.
Reviewable status: complete! 0 of 0 LGTMs obtained (waiting on @rafiss)
pkg/sql/delegate/show_grants.go
line 105 at r1 (raw file):
Previously, rafiss (Rafi Shamim) wrote…
missing comment?
fixed. good eyes.
pkg/sql/delegate/show_grants.go
line 116 at r1 (raw file):
Previously, rafiss (Rafi Shamim) wrote…
could you make the
100000
referenceCockroachPredefinedOIDMax
just in case that constant ever changes?
fixed, use CRDB_MAX_PREDEFINED_OID
as a pattern in the query string to replace with and added a helper function to get the actual query.
pkg/sql/logictest/testdata/logic_test/udf
line 627 at r1 (raw file):
Previously, rafiss (Rafi Shamim) wrote…
is it useful to still keep the test on infromation_schema to make sure that metadata is correct too?
good point, I added them back.
pkg/sql/logictest/testdata/logic_test/udf
line 634 at r1 (raw file):
Previously, rafiss (Rafi Shamim) wrote…
hm, i am a bit confused. how did this work without any change to sql.y to support
ON FUNCTION
?
yeah, FUNCTION
is one of object types in the grant_targets
list :
cockroach/pkg/sql/parser/sql.y
Line 7812 in ae38d90
| FUNCTION function_with_argtypes_list |
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.
nice!
Reviewable status: complete! 0 of 0 LGTMs obtained (waiting on @chengxiong-ruan and @rafiss)
pkg/sql/delegate/show_grants.go
line 116 at r1 (raw file):
Previously, chengxiong-ruan (Chengxiong Ruan) wrote…
fixed, use
CRDB_MAX_PREDEFINED_OID
as a pattern in the query string to replace with and added a helper function to get the actual query.
i'll leave it up to you, but did you find that more readable than
var udfQuery = fmt.Sprintf(..., oidext.CockroachPredefinedOIDMax)
just want to make sure you considered that
pkg/sql/logictest/testdata/logic_test/udf
line 634 at r1 (raw file):
Previously, chengxiong-ruan (Chengxiong Ruan) wrote…
yeah,
FUNCTION
is one of object types in thegrant_targets
list :cockroach/pkg/sql/parser/sql.y
Line 7812 in ae38d90
| FUNCTION function_with_argtypes_list
ah thanks for explaining
Previously, rafiss (Rafi Shamim) wrote…
yeah, for some reason part of me wanted to be consistent with the other query strings being |
Backport resolves cockroachdb#88495 Release note (sql change): Previously `SHOW GRANTS` only supports db, schema, table and types. This commit add supports for UDFs, so that `SHOW GRANTS` returns UDFs privileges infos, and statements like `SHOW GRANTS ON FUNCTION <udf name/signatures>` are now supported Full function signature must be provided if the function name is not unique. Release justification: low risk GA blocker.
58e8f6e
to
588d477
Compare
TFTR! |
Build succeeded: |
Backport resolves #88495
Release note (sql change): Previously
SHOW GRANTS
only supportsdb, schema, table and types. This commit add supports for UDFs,
so that
SHOW GRANTS
returns UDFs privileges infos, and statementslike
SHOW GRANTS ON FUNCTION <udf name/signatures>
are now supportedFull function signature must be provided if the function name is
not unique.
Release justification: low risk GA blocker.