Skip to content
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

inforschema: check the user permission before loading TIKV_REGION_STATUS #38627

Merged
merged 2 commits into from
Oct 25, 2022
Merged
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
16 changes: 10 additions & 6 deletions executor/infoschema_reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -1693,9 +1693,10 @@ func keyColumnUsageInTable(schema *model.DBInfo, table *model.TableInfo) [][]typ
return rows
}

func (e *memtableRetriever) setDataForTiKVRegionStatus(ctx sessionctx.Context) (err error) {
func (e *memtableRetriever) setDataForTiKVRegionStatus(sctx sessionctx.Context) (err error) {
checker := privilege.GetPrivilegeManager(sctx)
var extractorTableIDs []int64
tikvStore, ok := ctx.GetStore().(helper.Storage)
tikvStore, ok := sctx.GetStore().(helper.Storage)
if !ok {
return errors.New("Information about TiKV region status can be gotten only when the storage is TiKV")
}
Expand All @@ -1705,7 +1706,7 @@ func (e *memtableRetriever) setDataForTiKVRegionStatus(ctx sessionctx.Context) (
}
requestByTableRange := false
allRegionsInfo := helper.NewRegionsInfo()
is := ctx.GetDomainInfoSchema().(infoschema.InfoSchema)
is := sctx.GetDomainInfoSchema().(infoschema.InfoSchema)
if e.extractor != nil {
extractor, ok := e.extractor.(*plannercore.TiKVRegionStatusExtractor)
if ok && len(extractor.GetTablesID()) > 0 {
Expand Down Expand Up @@ -1735,12 +1736,15 @@ func (e *memtableRetriever) setDataForTiKVRegionStatus(ctx sessionctx.Context) (
if len(regionTableList) == 0 {
e.setNewTiKVRegionStatusCol(&allRegionsInfo.Regions[i], nil)
}
for j := range regionTableList {
for j, regionTable := range regionTableList {
if checker != nil && !checker.RequestVerification(sctx.GetSessionVars().ActiveRoles, regionTable.DB.Name.L, regionTable.Table.Name.L, "", mysql.AllPrivMask) {
continue
}
if len(extractorTableIDs) == 0 {
e.setNewTiKVRegionStatusCol(&allRegionsInfo.Regions[i], &regionTableList[j])
e.setNewTiKVRegionStatusCol(&allRegionsInfo.Regions[i], &regionTable)
}
if slices.Contains(extractorTableIDs, regionTableList[j].Table.ID) {
e.setNewTiKVRegionStatusCol(&allRegionsInfo.Regions[i], &regionTableList[j])
e.setNewTiKVRegionStatusCol(&allRegionsInfo.Regions[i], &regionTable)
}
}
}
Expand Down