Skip to content

privilege/privileges: refactor the data struct for user privilege data #61719

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

Open
wants to merge 2 commits into
base: release-8.5-20250606-v8.5.2
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pkg/ddl/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -6101,7 +6101,7 @@ func (e *executor) DropResourceGroup(ctx sessionctx.Context, stmt *ast.DropResou
if checker == nil {
return errors.New("miss privilege checker")
}
user, matched := checker.MatchUserResourceGroupName(groupName.L)
user, matched := checker.MatchUserResourceGroupName(ctx.GetRestrictedSQLExecutor(), groupName.L)
if matched {
err = errors.Errorf("user [%s] depends on the resource group to drop", user)
return err
Expand Down
1 change: 1 addition & 0 deletions pkg/privilege/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ go_library(
"//pkg/sessionctx",
"//pkg/sessionctx/variable",
"//pkg/types",
"//pkg/util/sqlexec",
],
)
3 changes: 2 additions & 1 deletion pkg/privilege/privilege.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"github.com/pingcap/tidb/pkg/sessionctx"
"github.com/pingcap/tidb/pkg/sessionctx/variable"
"github.com/pingcap/tidb/pkg/types"
"github.com/pingcap/tidb/pkg/util/sqlexec"
)

type keyType int
Expand Down Expand Up @@ -91,7 +92,7 @@ type Manager interface {
MatchIdentity(user, host string, skipNameResolve bool) (string, string, bool)

// MatchUserResourceGroupName matches a user with specified resource group name
MatchUserResourceGroupName(resourceGroupName string) (string, bool)
MatchUserResourceGroupName(exec sqlexec.RestrictedSQLExecutor, resourceGroupName string) (string, bool)

// DBIsVisible returns true is the database is visible to current user.
DBIsVisible(activeRole []*auth.RoleIdentity, db string) bool
Expand Down
1 change: 1 addition & 0 deletions pkg/privilege/privileges/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ go_library(
"//pkg/util/sqlescape",
"//pkg/util/sqlexec",
"//pkg/util/stringutil",
"@com_github_google_btree//:btree",
"@com_github_lestrrat_go_jwx_v2//jwk",
"@com_github_lestrrat_go_jwx_v2//jws",
"@com_github_lestrrat_go_jwx_v2//jwt",
Expand Down
Loading