Skip to content

Commit

Permalink
fix #2215: allow keyword default to be unquoted
Browse files Browse the repository at this point in the history
InfluxDB creates a default retention policy named "default".  DEFAULT is
also a keyword in the language.  This required double quoting "default"
in the ALTER RETENTION POLICY statement.  This commit makes the parser
accept it unquoted for that one statement.
  • Loading branch information
dgnorton committed Apr 9, 2015
1 parent 301c3a3 commit a67e9a8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
15 changes: 9 additions & 6 deletions influxql/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
5 changes: 5 additions & 0 deletions influxql/parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down

0 comments on commit a67e9a8

Please sign in to comment.