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 9, 2019
1 parent cdceeb2 commit a3c4982
Show file tree
Hide file tree
Showing 4 changed files with 2,879 additions and 2,821 deletions.
16 changes: 14 additions & 2 deletions ast/dml.go
Original file line number Diff line number Diff line change
Expand Up @@ -1771,8 +1771,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 @@ -1847,6 +1848,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 a3c4982

Please sign in to comment.