-
-
Notifications
You must be signed in to change notification settings - Fork 238
Closed
Labels
Description
I think the conditions for the panic are:
- Column doesn't exist
- Passed to function
- Column name is also a system variable (?) -
timestamp
Example query:
SELECT
UNIX_TIMESTAMP(A.timestamp)
FROM
A
LIMIT 1;
Where timestamp doesn't exist on Table A. Removing the the function stops the panic, as does selecting a different column that also does not exist (e.g. A.foo).
Note: This is happening in the Grafana SQL expressions feature that uses go-mysql-server (was using main from yesterday of GMS in Grafana and still getting it) -- I have not yet tried to repro it go-mysql-server by itself yet.
Panic segment:
sigpanic: panicmem()
/home/kbrandt/go/pkg/mod/github.com/dolthub/[email protected]/sql/core.go:672 (0x326eca2)
(*MysqlScope).GetValue: val, err := ctx.GetSessionVariable(ctx, name)
/home/kbrandt/go/pkg/mod/github.com/dolthub/[email protected]/sql/expression/variables.go:48 (0x360e073)
(*SystemVar).Eval: val, err := v.Scope.GetValue(ctx, v.Name, v.Collation)
/home/kbrandt/go/pkg/mod/github.com/dolthub/[email protected]/sql/expression/function/date.go:480 (0x3afd68a)
NewUnixTimestamp: date, err := arg.Eval(nil, nil)
/home/kbrandt/go/pkg/mod/github.com/dolthub/[email protected]/sql/functions.go:176 (0x328307e)
FunctionN.NewInstance: return fn.Fn(args...)
/home/kbrandt/go/pkg/mod/github.com/dolthub/[email protected]/sql/planbuilder/scalar.go:170 (0x3cf3c51)
(*Builder).buildScalar: rf, err := f.NewInstance(args)
/home/kbrandt/go/pkg/mod/github.com/dolthub/[email protected]/sql/planbuilder/project.go:177 (0x3ceb9c8)
(*Builder).selectExprToExpression: expr := b.buildScalar(inScope, e.Expr)
/home/kbrandt/go/pkg/mod/github.com/dolthub/[email protected]/sql/planbuilder/project.go:45 (0x3ce9384)
(*Builder).analyzeSelectList: pe := b.selectExprToExpression(inScope, se)
/home/kbrandt/go/pkg/mod/github.com/dolthub/[email protected]/sql/planbuilder/project.go:29 (0x3ce91f0)
(*Builder).analyzeProjectionList: b.analyzeSelectList(inScope, outScope, selectExprs)
/home/kbrandt/go/pkg/mod/github.com/dolthub/[email protected]/sql/planbuilder/select.go:78 (0x3d078a9)
(*Builder).buildSelect: b.analyzeProjectionList(fromScope, projScope, s.SelectExprs)
/home/kbrandt/go/pkg/mod/github.com/dolthub/[email protected]/sql/planbuilder/select.go:36 (0x3d0744f)
(*Builder).buildSelectStmt: return b.buildSelect(inScope, s)
/home/kbrandt/go/pkg/mod/github.com/dolthub/[email protected]/sql/planbuilder/builder.go:224 (0x3c8a3b6)
(*Builder).buildSubquery: outScope = b.buildSelectStmt(inScope, n)
/home/kbrandt/go/pkg/mod/github.com/dolthub/[email protected]/sql/planbuilder/builder.go:213 (0x3c874d3)
(*Builder).build: return b.buildSubquery(inScope, stmt, query, query)
/home/kbrandt/go/pkg/mod/github.com/dolthub/[email protected]/sql/planbuilder/parse.go:86 (0x3cd4b64)
(*Builder).Parse: outScope := b.build(nil, stmt, parsed)
/home/kbrandt/go/pkg/mod/github.com/dolthub/[email protected]/engine.go:641 (0x3ee1a5b)
(*Engine).bindQuery: bound, _, _, qFlags, err = binder.Parse(query, qFlags, false)
/home/kbrandt/go/pkg/mod/github.com/dolthub/[email protected]/engine.go:412 (0x3ede558)
(*Engine).QueryWithBindings: bound, qFlags, err := e.bindQuery(ctx, query, parsed, bindings, binder, qFlags)
/home/kbrandt/go/pkg/mod/github.com/dolthub/[email protected]/engine.go:256 (0x3eddcc4)
(*Engine).Query: return e.QueryWithBindings(ctx, query, nil, nil, nil)
/home/kbrandt/go/src/github.com/grafana/grafana/pkg/expr/sql/db.go:98 (0x3eea475)