Skip to content

Commit 72977bc

Browse files
authored
Merge branch 'main-2.x' into db/panic-at-the-cursor
2 parents 6a1cc9f + e862501 commit 72977bc

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

influxql/query/select.go

+1-4
Original file line numberDiff line numberDiff line change
@@ -617,11 +617,8 @@ func (b *exprIteratorBuilder) callIterator(ctx context.Context, expr *influxql.C
617617
}
618618
inputs = append(inputs, input)
619619
case *influxql.SubQuery:
620-
// Identify the name of the field we are using.
621-
arg0 := expr.Args[0].(*influxql.VarRef)
622-
623620
opt.Ordered = false
624-
input, err := buildExprIterator(ctx, arg0, b.ic, []influxql.Source{source}, opt, b.selector, false)
621+
input, err := buildExprIterator(ctx, expr.Args[0], b.ic, []influxql.Source{source}, opt, b.selector, false)
625622
if err != nil {
626623
return err
627624
}

influxql/query/select_test.go

+8
Original file line numberDiff line numberDiff line change
@@ -2882,6 +2882,14 @@ func TestSelect(t *testing.T) {
28822882
},
28832883
now: mustParseTime("1970-01-01T00:02:30Z"),
28842884
},
2885+
{
2886+
// This caused a panic in 1.11.7 and earlier versions
2887+
name: "Multiple_Subqueries_Fail",
2888+
q: `SELECT ABS(a_count - b_count) FROM
2889+
(SELECT COUNT(DISTINCT a_id) AS a_count FROM (SELECT last(v0), tag0 AS a_id FROM m0 GROUP BY tag0) FILL(0)),
2890+
(SELECT COUNT(DISTINCT b_id) as b_count FROM (SELECT last(v0), tag0 AS a_id FROM m0 GROUP BY tag0) FILL(0))`,
2891+
err: `invalid expression type: *influxql.Distinct`,
2892+
},
28852893
} {
28862894
t.Run(tt.name, func(t *testing.T) {
28872895
if tt.onlyArch != "" && runtime.GOARCH != tt.onlyArch {

0 commit comments

Comments
 (0)