diff --git a/influxql/parser.go b/influxql/parser.go index 13880d24a27..d4f961da006 100644 --- a/influxql/parser.go +++ b/influxql/parser.go @@ -293,19 +293,22 @@ func (p *Parser) parseAlterRetentionPolicyStatement() (*AlterRetentionPolicyStat stmt := &AlterRetentionPolicyStatement{} // Parse the retention policy name. - ident, err := p.parseIdent() - if err != nil { - return nil, err + tok, pos, lit := p.scanIgnoreWhitespace() + if tok == DEFAULT { + stmt.Name = "default" + } else if tok == IDENT { + stmt.Name = lit + } else { + return nil, newParseError(tokstr(tok, lit), []string{"identifier"}, pos) } - stmt.Name = ident // Consume the required ON token. - if tok, pos, lit := p.scanIgnoreWhitespace(); tok != ON { + if tok, pos, lit = p.scanIgnoreWhitespace(); tok != ON { return nil, newParseError(tokstr(tok, lit), []string{"ON"}, pos) } // Parse the database name. - ident, err = p.parseIdent() + ident, err := p.parseIdent() if err != nil { return nil, err } diff --git a/influxql/parser_test.go b/influxql/parser_test.go index 5682fd1a057..0ac08992993 100644 --- a/influxql/parser_test.go +++ b/influxql/parser_test.go @@ -895,6 +895,11 @@ func TestParser_ParseStatement(t *testing.T) { s: `ALTER RETENTION POLICY policy1 ON testdb REPLICATION 4`, stmt: newAlterRetentionPolicyStatement("policy1", "testdb", -1, 4, false), }, + // ALTER default retention policy unquoted + { + s: `ALTER RETENTION POLICY default ON testdb REPLICATION 4`, + stmt: newAlterRetentionPolicyStatement("default", "testdb", -1, 4, false), + }, // SHOW STATS {