Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ast: add role support show grant (pingcap#272)
Browse files Browse the repository at this point in the history
* add option for show grant

* fix tab

* address comment
Lingyu Song authored and kennytm committed Apr 12, 2019
1 parent 0c51d3b commit 00eef86
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
@@ -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
@@ -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.WritePlain(", ")
}
}
}
case ShowMasterStatus:
ctx.WriteKeyWord("MASTER STATUS")
case ShowProcessList:
Loading

0 comments on commit 00eef86

Please sign in to comment.