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
1 change: 1 addition & 0 deletions ast/ast.go
Original file line number Diff line number Diff line change
Expand Up @@ -1164,6 +1164,7 @@ func (s *ShowPrivilegesQuery) statementNode() {}
type ShowCreateQuotaQuery struct {
Position token.Position `json:"-"`
Name string `json:"name,omitempty"`
Plural bool `json:"plural,omitempty"` // more than one name was given
Format string `json:"format,omitempty"`
}

Expand Down
8 changes: 6 additions & 2 deletions internal/explain/explain.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,11 +205,15 @@ func Node(sb *strings.Builder, node interface{}, depth int) {
case *ast.ShowPrivilegesQuery:
fmt.Fprintf(sb, "%sShowPrivilegesQuery\n", indent)
case *ast.ShowCreateQuotaQuery:
kw := "QUOTA"
if n.Plural {
kw = "QUOTAS"
}
if n.Format != "" {
fmt.Fprintf(sb, "%sSHOW CREATE QUOTA query (children 1)\n", indent)
fmt.Fprintf(sb, "%sSHOW CREATE %s query (children 1)\n", indent, kw)
fmt.Fprintf(sb, "%s Identifier %s\n", indent, n.Format)
} else {
fmt.Fprintf(sb, "%sSHOW CREATE QUOTA query\n", indent)
fmt.Fprintf(sb, "%sSHOW CREATE %s query\n", indent, kw)
}
case *ast.CreateQuotaQuery:
fmt.Fprintf(sb, "%sCreateQuotaQuery\n", indent)
Expand Down
13 changes: 13 additions & 0 deletions parser/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,12 @@ func (p *Parser) parseStatement() ast.Statement {
if p.peek.Token == token.IDENT && strings.ToUpper(p.peek.Value) == "ROLE" {
return p.parseAlterRole()
}
// ALTER QUOTA is printed like CREATE QUOTA
if p.peek.Token == token.IDENT && strings.ToUpper(p.peek.Value) == "QUOTA" {
pos := p.current.Pos
p.nextToken()
return p.parseCreateQuota(pos)
}
// ALTER HANDLER is printed like CREATE HANDLER
if p.peek.Token == token.IDENT && strings.ToUpper(p.peek.Value) == "HANDLER" {
pos := p.current.Pos
Expand Down Expand Up @@ -7506,6 +7512,13 @@ func (p *Parser) parseShow() ast.Statement {
query.Name = p.current.Value
p.nextToken()
}
for p.currentIs(token.COMMA) {
query.Plural = true
p.nextToken()
if p.currentIs(token.IDENT) || p.current.Token.IsKeyword() {
p.nextToken()
}
}
// Parse FORMAT clause if present
if p.currentIs(token.FORMAT) {
p.nextToken()
Expand Down
29 changes: 1 addition & 28 deletions parser/testdata/01297_create_quota/metadata.json
Original file line number Diff line number Diff line change
@@ -1,28 +1 @@
{
"explain_todo": {
"stmt104": true,
"stmt105": true,
"stmt106": true,
"stmt16": true,
"stmt247": true,
"stmt249": true,
"stmt252": true,
"stmt254": true,
"stmt256": true,
"stmt260": true,
"stmt279": true,
"stmt280": true,
"stmt285": true,
"stmt288": true,
"stmt45": true,
"stmt46": true,
"stmt47": true,
"stmt69": true,
"stmt70": true,
"stmt71": true,
"stmt72": true,
"stmt73": true,
"stmt97": true,
"stmt98": true
}
}
{}
Loading