Skip to content

Commit

Permalink
u
Browse files Browse the repository at this point in the history
Signed-off-by: Weizhen Wang <wangweizhen@pingcap.com>
  • Loading branch information
hawkingrei committed Sep 5, 2022
1 parent 9fad171 commit fbd0027
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions planner/core/logical_plan_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -4920,14 +4920,15 @@ func (b *PlanBuilder) BuildDataSourceFromView(ctx context.Context, dbName model.
}
return nil, err
}

pm := privilege.GetPrivilegeManager(b.ctx)
if viewDepth != 0 &&
b.ctx.GetSessionVars().StmtCtx.InExplainStmt &&
pm != nil &&
!pm.RequestVerification(b.ctx.GetSessionVars().ActiveRoles, dbName.L, tableInfo.Name.L, "", mysql.SelectPriv) {
return nil, ErrViewNoExplain
}
if tableInfo.View.Security == model.SecurityDefiner {
if pm := privilege.GetPrivilegeManager(b.ctx); pm != nil {
if viewDepth != 0 &&
b.ctx.GetSessionVars().StmtCtx.InExplainStmt &&
!pm.RequestVerification(b.ctx.GetSessionVars().ActiveRoles, dbName.L, tableInfo.Name.L, "", mysql.SelectPriv) {
return nil, ErrViewNoExplain
}
if pm != nil {
for _, v := range b.visitInfo {
if !pm.RequestVerificationWithUser(v.db, v.table, v.column, v.privilege, tableInfo.View.Definer) {
return nil, ErrViewInvalid.GenWithStackByArgs(dbName.O, tableInfo.Name.O)
Expand Down

0 comments on commit fbd0027

Please sign in to comment.