Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent a panic when aggregates are used in an inner query with a raw query #7966

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
- [#7946](https://github.com/influxdata/influxdb/issues/7946): Fix authentication when subqueries are present.
- [#7885](https://github.com/influxdata/influxdb/issues/7885): Fix LIMIT and OFFSET when they are used in a subquery.
- [#7905](https://github.com/influxdata/influxdb/issues/7905): Fix ORDER BY time DESC with ordering series keys.
- [#7966](https://github.com/influxdata/influxdb/pull/7966): Prevent a panic when aggregates are used in an inner query with a raw query.

## v1.2.0 [2017-01-24]

Expand Down
8 changes: 8 additions & 0 deletions cmd/influxd/run/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4740,6 +4740,14 @@ func TestServer_Query_Subqueries(t *testing.T) {
command: `SELECT value FROM (SELECT max(usage_user), usage_user - usage_system AS value FROM cpu GROUP BY host) WHERE time >= '2000-01-01T00:00:00Z' AND time < '2000-01-01T00:00:30Z' AND value > 0`,
exp: `{"results":[{"statement_id":0,"series":[{"name":"cpu","columns":["time","value"],"values":[["2000-01-01T00:00:00Z",40]]}]}]}`,
},
&Query{
params: url.Values{"db": []string{"db0"}},
command: `SELECT mean, host FROM (SELECT mean(usage_user) FROM cpu GROUP BY host) WHERE time >= '2000-01-01T00:00:00Z' AND time < '2000-01-01T00:00:30Z'`,
// TODO(jsternberg): This should return the hosts for each mean()
// value. The query engine is currently limited in a way that
// doesn't allow that to work though so we have to do this.
exp: `{"results":[{"statement_id":0,"series":[{"name":"cpu","columns":["time","mean","host"],"values":[["2000-01-01T00:00:00Z",46,null],["2000-01-01T00:00:00Z",17,null]]}]}]}`,
},
}...)

for i, query := range test.queries {
Expand Down
5 changes: 4 additions & 1 deletion influxql/iterator.go
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,10 @@ func (a *auxIteratorFields) iterator(name string, typ DataType) Iterator {
func (a *auxIteratorFields) send(p Point) (ok bool) {
values := p.aux()
for i, f := range a.fields {
v := values[i]
var v interface{}
if i < len(values) {
v = values[i]
}

tags := p.tags()
tags = tags.Subset(a.dimensions)
Expand Down