Skip to content

Commit

Permalink
Merge pull request #6255 from influxdata/js-6248-strings-in-select-panic
Browse files Browse the repository at this point in the history
Throw an error when an invalid expression is used with aux iterators
  • Loading branch information
jsternberg committed Apr 7, 2016
2 parents 5327a75 + d176c8b commit 61aa298
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 12 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
### Bugfixes

- [#6206](https://github.com/influxdata/influxdb/issues/6206): Handle nil values from the tsm1 cursor correctly.
- [#6248](https://github.com/influxdata/influxdb/issues/6248): Panic using incorrectly quoted "queries" field key.

## v0.12.0 [2016-04-05]
### Release Notes
Expand Down
31 changes: 19 additions & 12 deletions influxql/select.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,20 +110,27 @@ func buildAuxIterators(fields Fields, ic IteratorCreator, opt IteratorOptions) (

// Generate iterators for each field.
itrs := make([]Iterator, len(fields))
for i, f := range fields {
expr := Reduce(f.Expr, nil)
switch expr := expr.(type) {
case *VarRef:
itrs[i] = aitr.Iterator(expr.Val)
case *BinaryExpr:
itr, err := buildExprIterator(expr, aitr, opt)
if err != nil {
return nil, fmt.Errorf("error constructing iterator for field '%s': %s", f.String(), err)
if err := func() error {
for i, f := range fields {
expr := Reduce(f.Expr, nil)
switch expr := expr.(type) {
case *VarRef:
itrs[i] = aitr.Iterator(expr.Val)
case *BinaryExpr:
itr, err := buildExprIterator(expr, aitr, opt)
if err != nil {
return fmt.Errorf("error constructing iterator for field '%s': %s", f.String(), err)
}
itrs[i] = itr
default:
return fmt.Errorf("invalid expression type: %T", expr)
}
itrs[i] = itr
default:
panic("unreachable")
}
return nil
}(); err != nil {
Iterators(Iterators(itrs).filterNonNil()).Close()
aitr.Close()
return nil, err
}

// Background the primary iterator since there is no reader for it.
Expand Down
4 changes: 4 additions & 0 deletions influxql/select_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2021,6 +2021,10 @@ func TestSelect_InvalidQueries(t *testing.T) {
q: `SELECT 'value' FROM cpu`,
err: `invalid expression type: *influxql.StringLiteral`,
},
{
q: `SELECT 'value', value FROM cpu`,
err: `invalid expression type: *influxql.StringLiteral`,
},
}

for i, tt := range tests {
Expand Down

0 comments on commit 61aa298

Please sign in to comment.