From a67e9a8a95e965601a38f9965c10557eae6d47a0 Mon Sep 17 00:00:00 2001 From: David Norton Date: Thu, 9 Apr 2015 16:37:20 -0400 Subject: [PATCH] fix #2215: allow keyword default to be unquoted 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. --- influxql/parser.go | 15 +++++++++------ influxql/parser_test.go | 5 +++++ 2 files changed, 14 insertions(+), 6 deletions(-) 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 {