diff --git a/ast/ast.go b/ast/ast.go index 8fef5608e..cb4cb5f63 100644 --- a/ast/ast.go +++ b/ast/ast.go @@ -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 diff --git a/internal/explain/explain.go b/internal/explain/explain.go index 419abd4f0..496e79984 100644 --- a/internal/explain/explain.go +++ b/internal/explain/explain.go @@ -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: diff --git a/parser/parser.go b/parser/parser.go index f5657a4f3..ca36230c9 100644 --- a/parser/parser.go +++ b/parser/parser.go @@ -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 + 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: diff --git a/parser/testdata/01033_quota_dcl/metadata.json b/parser/testdata/01033_quota_dcl/metadata.json index ef120d978..9e26dfeeb 100644 --- a/parser/testdata/01033_quota_dcl/metadata.json +++ b/parser/testdata/01033_quota_dcl/metadata.json @@ -1 +1 @@ -{"todo": true} +{} \ No newline at end of file