Merge pull request #6547 from influxdata/js-6543-parse-fill-bad-query
Fix parseFill to check for fill ident before attempting to parse an expressionpull/7032/head
commit
155ef811ad
|
@ -112,6 +112,7 @@ With this release the systemd configuration files for InfluxDB will use the syst
|
|||
- [#7080](https://github.com/influxdata/influxdb/pull/7080): Ensure IDs can't clash when managing Continuous Queries.
|
||||
- [#6990](https://github.com/influxdata/influxdb/issues/6990): Fix panic parsing empty key
|
||||
- [#7084](https://github.com/influxdata/influxdb/pull/7084): Tombstone memory improvements
|
||||
- [#6543](https://github.com/influxdata/influxdb/issues/6543): Fix parseFill to check for fill ident before attempting to parse an expression.
|
||||
|
||||
## v0.13.0 [2016-05-12]
|
||||
|
||||
|
|
|
@ -2071,24 +2071,23 @@ func (p *Parser) parseDimension() (*Dimension, error) {
|
|||
// parseFill parses the fill call and its options.
|
||||
func (p *Parser) parseFill() (FillOption, interface{}, error) {
|
||||
// Parse the expression first.
|
||||
tok, _, lit := p.scanIgnoreWhitespace()
|
||||
p.unscan()
|
||||
if tok != IDENT || strings.ToLower(lit) != "fill" {
|
||||
return NullFill, nil, nil
|
||||
}
|
||||
|
||||
expr, err := p.ParseExpr()
|
||||
if err != nil {
|
||||
p.unscan()
|
||||
return NullFill, nil, nil
|
||||
return NullFill, nil, err
|
||||
}
|
||||
lit, ok := expr.(*Call)
|
||||
fill, ok := expr.(*Call)
|
||||
if !ok {
|
||||
p.unscan()
|
||||
return NullFill, nil, nil
|
||||
}
|
||||
if strings.ToLower(lit.Name) != "fill" {
|
||||
p.unscan()
|
||||
return NullFill, nil, nil
|
||||
}
|
||||
if len(lit.Args) != 1 {
|
||||
return NullFill, nil, errors.New("fill must be a function call")
|
||||
} else if len(fill.Args) != 1 {
|
||||
return NullFill, nil, errors.New("fill requires an argument, e.g.: 0, null, none, previous")
|
||||
}
|
||||
switch lit.Args[0].String() {
|
||||
switch fill.Args[0].String() {
|
||||
case "null":
|
||||
return NullFill, nil, nil
|
||||
case "none":
|
||||
|
@ -2096,7 +2095,7 @@ func (p *Parser) parseFill() (FillOption, interface{}, error) {
|
|||
case "previous":
|
||||
return PreviousFill, nil, nil
|
||||
default:
|
||||
switch num := lit.Args[0].(type) {
|
||||
switch num := fill.Args[0].(type) {
|
||||
case *IntegerLiteral:
|
||||
return NumberFill, num.Val, nil
|
||||
case *NumberLiteral:
|
||||
|
|
|
@ -2152,6 +2152,7 @@ func TestParser_ParseStatement(t *testing.T) {
|
|||
{s: `SELECT count(foo + sum(bar)) FROM cpu`, err: `expected field argument in count()`},
|
||||
{s: `SELECT (count(foo + sum(bar))) FROM cpu`, err: `expected field argument in count()`},
|
||||
{s: `SELECT sum(value) + count(foo + sum(bar)) FROM cpu`, err: `binary expressions cannot mix aggregates and raw fields`},
|
||||
{s: `SELECT mean(value) FROM cpu FILL + value`, err: `fill must be a function call`},
|
||||
// See issues https://github.com/influxdata/influxdb/issues/1647
|
||||
// and https://github.com/influxdata/influxdb/issues/4404
|
||||
//{s: `DELETE`, err: `found EOF, expected FROM at line 1, char 8`},
|
||||
|
|
Loading…
Reference in New Issue