Skip to content

Commit

Permalink
sql: add version gate for system privs during DROP ROLE
Browse files Browse the repository at this point in the history
Release note (bug fix): Fixed a bug that could happen when dropping a
user/role before the upgrade to v22.2 was finalized.
  • Loading branch information
rafiss committed Dec 12, 2022
1 parent ff69f98 commit 95eb136
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pkg/sql/drop_role.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"sort"
"strings"

"github.com/cockroachdb/cockroach/pkg/clusterversion"
"github.com/cockroachdb/cockroach/pkg/security/username"
"github.com/cockroachdb/cockroach/pkg/sql/catalog"
"github.com/cockroachdb/cockroach/pkg/sql/catalog/catpb"
Expand Down Expand Up @@ -586,6 +587,9 @@ func addDependentPrivilegesFromSystemPrivileges(
privilegeObjectFormatter *tree.FmtCtx,
userNamesToDependentPrivileges map[username.SQLUsername][]objectAndType,
) (retErr error) {
if !p.ExecCfg().Settings.Version.IsActive(ctx, clusterversion.V22_2SystemPrivilegesTable) {
return nil
}
names := make([]string, len(usernames))
for i, username := range usernames {
names[i] = username.Normalized()
Expand Down

0 comments on commit 95eb136

Please sign in to comment.