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
10 changes: 10 additions & 0 deletions ast/ast.go
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,16 @@ func (s *ShowPrivilegesQuery) Pos() token.Position { return s.Position }
func (s *ShowPrivilegesQuery) End() token.Position { return s.Position }
func (s *ShowPrivilegesQuery) statementNode() {}

// ShowCreateQuotaQuery represents a SHOW CREATE QUOTA statement.
type ShowCreateQuotaQuery struct {
Position token.Position `json:"-"`
Name string `json:"name,omitempty"`
}

func (s *ShowCreateQuotaQuery) Pos() token.Position { return s.Position }
func (s *ShowCreateQuotaQuery) End() token.Position { return s.Position }
func (s *ShowCreateQuotaQuery) 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 @@ -117,6 +117,8 @@ func Node(sb *strings.Builder, node interface{}, depth int) {
explainShowQuery(sb, n, indent)
case *ast.ShowPrivilegesQuery:
fmt.Fprintf(sb, "%sShowPrivilegesQuery\n", indent)
case *ast.ShowCreateQuotaQuery:
fmt.Fprintf(sb, "%sSHOW CREATE QUOTA query\n", indent)
case *ast.UseQuery:
explainUseQuery(sb, n, indent)
case *ast.DescribeQuery:
Expand Down
16 changes: 10 additions & 6 deletions parser/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -2642,16 +2642,20 @@ func (p *Parser) parseShow() ast.Statement {
if p.currentIs(token.DATABASE) {
show.ShowType = ast.ShowCreateDB
p.nextToken()
} else if p.currentIs(token.IDENT) && strings.ToUpper(p.current.Value) == "QUOTA" {
// SHOW CREATE QUOTA <name>
p.nextToken()
name := ""
if p.currentIs(token.IDENT) || p.current.Token.IsKeyword() {
name = p.current.Value
p.nextToken()
}
return &ast.ShowCreateQuotaQuery{Position: pos, Name: name}
} else {
show.ShowType = ast.ShowCreate
// Handle SHOW CREATE TABLE, SHOW CREATE QUOTA, etc.
// Handle SHOW CREATE TABLE, etc.
if p.currentIs(token.TABLE) {
p.nextToken()
} else if p.currentIs(token.DEFAULT) || (p.currentIs(token.IDENT) && strings.ToUpper(p.current.Value) == "QUOTA") {
// SHOW CREATE QUOTA default - skip QUOTA keyword
if p.currentIs(token.IDENT) && strings.ToUpper(p.current.Value) == "QUOTA" {
p.nextToken()
}
}
}
case token.SETTINGS:
Expand Down
2 changes: 1 addition & 1 deletion parser/testdata/01033_quota_dcl/metadata.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"todo": true}
{}