sql/parser: use RoleSpec for ALTER ROLE#71498
Conversation
d3a0500 to
361894f
Compare
ab63652 to
6c103fd
Compare
Release note (sql change): CURRENT_USER and SESSION_USER can now be used as the role identifier in ALTER ROLE statements. Release note (backward-incompatible change): Placeholder values (e.g. `$1`) can no longer be used for role names in ALTER ROLE statements.
This is done mostly so that all of our "role" syntax is consistent, so that in the future we don't accidentally forget to use RoleSpec since somebody refers to the wrong implementation. Release note (backward-incompatible change): Placeholders (e.g. `$1`) can no longer be used for role names in CREATE/DROP ROLE statements.
All username normalization now happens through RoleSpec. This removes the special logic in create_role that was validating usernames. Release note: None
6c103fd to
1c8ef7c
Compare
|
this is ready for another look -- i added a refactor commit that moves the username validation, so easier to review this separately also @RichardJCai you said you had a nit but i didn't see the comment |
pkg/sql/alter_role.go
Outdated
| return err | ||
| } | ||
| if name == "" { | ||
| if n.roleName.Normalized() == "" { |
There was a problem hiding this comment.
Sorry my reviewable comment didn't go through for some reason. My nit is that you can use IsUndefined() here I think.
RichardJCai
left a comment
There was a problem hiding this comment.
Reviewed 5 of 11 files at r1, 17 of 23 files at r2, 20 of 22 files at r3, 4 of 4 files at r4, all commit messages.
Reviewable status:complete! 0 of 0 LGTMs obtained (waiting on @rafiss)
pkg/sql/alter_role.go, line 543 at r4 (raw file):
return true, security.MakeSQLUsernameFromPreNormalizedString(""), nil } if n.roleName.Normalized() == "" {
Can use IsUndefined()
Release note: None
1c8ef7c to
2175ad7
Compare
rafiss
left a comment
There was a problem hiding this comment.
tftr!
bors r=RichardJCai
Reviewable status:
complete! 0 of 0 LGTMs obtained (waiting on @rafiss and @RichardJCai)
pkg/sql/alter_role.go, line 151 at r4 (raw file):
Previously, RichardJCai (Richard Cai) wrote…
Sorry my reviewable comment didn't go through for some reason. My nit is that you can use
IsUndefined()here I think.
fixed
|
Build succeeded: |
|
@rafiss, what was the reason to break backwards-compatibility here? This broke CC and will probably break some customers as well. I assume there was some really compelling reason why we had to do this? |
|
Huh, it's a bit surprising that CC is using a pre-alpha version of CockroachDB. I heard about the CC issue -- but in a normal upgrade this change would be evident in backward-incompatible change release notes. This change was done to support the Theoretically we could still support placeholders for this with a bit of extra work, but here was my rationale for not doing so:
With all of the above, I was almost getting to the point where I thought it was an accident that we ever did allow placeholders here. I'd honestly be pretty surprised if many customers were relying on this. There is somewhat compelling evidence for this not being widely used in our telemetry data -- let me know if you'd like me to share that with you separately. Additionally, I'm working on a little bit of guidance for when backwards-incompatible changes are OK. There are quite a few other SQL bugfixes we'd like to do, but the fix itself would have incompatibility implications. @jordanlewis and I have been thinking of multi-dimensional criteria including "ease of discovering the change," "ease of fixing the incompatibility," and "severity of not accounting for the change." This change was made before we discussed this kind of guidance, but to apply that framework:
All that being said, if these arguments are not swaying you, let me know, and I can spend a bit of time trying to re-add placeholder support here. |
|
Thanks for the detailed justification. It sounds like your team has thought this through carefully, which was the main thing I wanted to verify. I'm content to let your team own the decision. |
This commit contains the non-trivial changes required to backport cockroachdb#72579. server.user_login.store_client_pre_hashed_passwords.enabled's default value was changed to false. Changing the default required updating some of the tests to clear and set the setting. The logic tests were adjusted to account for the lack of cockroachdb#71498. cockroachdb#71498 changed the AST representation of the role name to an identifier. This is mostly transparent to users, but it changes the normalized representation. Release note (sql change): This backports the server.user_login.store_client_pre_hashed_passwords.enabled setting. The backported default value is false. In 22.1 the default is true.
Release note (sql change): CURRENT_USER and SESSION_USER can now be used
as the role identifier in ALTER ROLE statements.
Release note (backward-incompatible change): Placeholder values (e.g.
$1)can no longer be used for role names in ALTER ROLE statements.
Release note (backward-incompatible change): Placeholders (e.g.
$1)can no longer be used for role names in CREATE/DROP ROLE statements.