Skip to content

Commit

Permalink
Merge pull request #15881 from cuongdo/fix_show_grants
Browse files Browse the repository at this point in the history
sql: fix SHOW GRANTS * on empty database
  • Loading branch information
cuongdo authored May 12, 2017
2 parents be5890c + 428a2e1 commit c3c50e3
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pkg/sql/show.go
Original file line number Diff line number Diff line change
Expand Up @@ -715,6 +715,9 @@ func (p *planner) ShowGrants(ctx context.Context, n *parser.ShowGrants) (planNod

}
}
if len(paramHolders) == 0 {
return v, nil
}
tableGrants := fmt.Sprintf(`SELECT TABLE_NAME, GRANTEE, PRIVILEGE_TYPE FROM information_schema.table_privileges
WHERE (TABLE_SCHEMA, TABLE_NAME) IN (%s)`, strings.Join(paramHolders, ","))
if n.Grantees != nil {
Expand Down
16 changes: 16 additions & 0 deletions pkg/sql/testdata/logic_test/grant_table
Original file line number Diff line number Diff line change
Expand Up @@ -334,3 +334,19 @@ Table User Privileges
t millie ALL
t root ALL
t2 root ALL

statement ok
CREATE DATABASE empty

query TTT colnames
SHOW GRANTS ON empty.*
----
Table User Privileges

query TTT colnames
SHOW GRANTS ON empty.*, b.*
----
Table User Privileges
t millie ALL
t root ALL
t2 root ALL

0 comments on commit c3c50e3

Please sign in to comment.