Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions ast/ast.go
Original file line number Diff line number Diff line change
Expand Up @@ -620,6 +620,15 @@ func (e *ExistsQuery) Pos() token.Position { return e.Position }
func (e *ExistsQuery) End() token.Position { return e.Position }
func (e *ExistsQuery) statementNode() {}

// ShowPrivilegesQuery represents a SHOW PRIVILEGES statement.
type ShowPrivilegesQuery struct {
Position token.Position `json:"-"`
}

func (s *ShowPrivilegesQuery) Pos() token.Position { return s.Position }
func (s *ShowPrivilegesQuery) End() token.Position { return s.Position }
func (s *ShowPrivilegesQuery) statementNode() {}

// -----------------------------------------------------------------------------
// Expressions

Expand Down
2 changes: 2 additions & 0 deletions internal/explain/explain.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ func Node(sb *strings.Builder, node interface{}, depth int) {
explainExplainQuery(sb, n, indent, depth)
case *ast.ShowQuery:
explainShowQuery(sb, n, indent)
case *ast.ShowPrivilegesQuery:
fmt.Fprintf(sb, "%sShowPrivilegesQuery\n", indent)
case *ast.UseQuery:
explainUseQuery(sb, n, indent)
case *ast.DescribeQuery:
Expand Down
16 changes: 12 additions & 4 deletions parser/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -2612,13 +2612,21 @@ func (p *Parser) parseDescribe() *ast.DescribeQuery {
return desc
}

func (p *Parser) parseShow() *ast.ShowQuery {
show := &ast.ShowQuery{
Position: p.current.Pos,
}
func (p *Parser) parseShow() ast.Statement {
pos := p.current.Pos

p.nextToken() // skip SHOW

// Handle SHOW PRIVILEGES first - it has its own statement type
if p.currentIs(token.IDENT) && strings.ToUpper(p.current.Value) == "PRIVILEGES" {
p.nextToken()
return &ast.ShowPrivilegesQuery{Position: pos}
}

show := &ast.ShowQuery{
Position: pos,
}

switch p.current.Token {
case token.TABLES:
show.ShowType = ast.ShowTables
Expand Down
2 changes: 1 addition & 1 deletion parser/testdata/01271_show_privileges/metadata.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"todo": true}
{}