Skip to content

Commit

Permalink
add option for show grant
Browse files Browse the repository at this point in the history
  • Loading branch information
imtbkcat committed Apr 12, 2019
1 parent 0eb2a34 commit e39ae52
Show file tree
Hide file tree
Showing 4 changed files with 3,401 additions and 3,343 deletions.
16 changes: 14 additions & 2 deletions ast/dml.go
Original file line number Diff line number Diff line change
Expand Up @@ -1782,8 +1782,9 @@ type ShowStmt struct {
Column *ColumnName // Used for `desc table column`.
Flag int // Some flag parsed from sql, such as FULL.
Full bool
User *auth.UserIdentity // Used for show grants/create user.
IfNotExists bool // Used for `show create database if not exists`
User *auth.UserIdentity // Used for show grants/create user.
Roles []*auth.RoleIdentity // Used for show grants .. using
IfNotExists bool // Used for `show create database if not exists`

// GlobalScope is used by `show variables` and `show bindings`
GlobalScope bool
Expand Down Expand Up @@ -1858,6 +1859,17 @@ func (n *ShowStmt) Restore(ctx *RestoreCtx) error {
return errors.Annotate(err, "An error occurred while restore ShowStmt.User")
}
}
if n.Roles != nil {
ctx.WriteKeyWord(" USING ")
for i, r := range n.Roles {
if err := r.Restore(ctx); err != nil {
return errors.Annotate(err, "An error occurred while restore ShowStmt.User")
}
if i != len(n.Roles)-1 {
ctx.WriteKeyWord(", ")
}
}
}
case ShowMasterStatus:
ctx.WriteKeyWord("MASTER STATUS")
case ShowProcessList:
Expand Down
Loading

0 comments on commit e39ae52

Please sign in to comment.