diff --git a/executor/prepared.go b/executor/prepared.go index c5fdd5c1bf404..832252a82ec93 100644 --- a/executor/prepared.go +++ b/executor/prepared.go @@ -117,7 +117,7 @@ func (e *PrepareExec) Next(ctx context.Context, req *chunk.Chunk) error { ) if sqlParser, ok := e.ctx.(sqlexec.SQLParser); ok { // FIXME: ok... yet another parse API, may need some api interface clean. - stmts, err = sqlParser.ParseSQL(e.sqlText, charset, collation) + stmts, _, err = sqlParser.ParseSQL(ctx, e.sqlText, charset, collation) } else { p := parser.New() p.SetParserConfig(vars.BuildParserConfig()) diff --git a/session/session.go b/session/session.go index da871b1179de9..b0c33080cd107 100644 --- a/session/session.go +++ b/session/session.go @@ -1069,6 +1069,8 @@ func (s *session) getTiDBTableValue(name, val string) (string, error) { return validatedVal, nil } +var _ sqlexec.SQLParser = &session{} + func (s *session) ParseSQL(ctx context.Context, sql, charset, collation string) ([]ast.StmtNode, []error, error) { if span := opentracing.SpanFromContext(ctx); span != nil && span.Tracer() != nil { span1 := span.Tracer().StartSpan("session.ParseSQL", opentracing.ChildOf(span.Context())) diff --git a/util/sqlexec/restricted_sql_executor.go b/util/sqlexec/restricted_sql_executor.go index e350118a77715..4d714a474806e 100644 --- a/util/sqlexec/restricted_sql_executor.go +++ b/util/sqlexec/restricted_sql_executor.go @@ -96,7 +96,7 @@ type SQLExecutor interface { // But a session already has a parser bind in it, so we define this interface and use session as its implementation, // thus avoid allocating new parser. See session.SQLParser for more information. type SQLParser interface { - ParseSQL(sql, charset, collation string) ([]ast.StmtNode, error) + ParseSQL(ctx context.Context, sql, charset, collation string) ([]ast.StmtNode, []error, error) } // Statement is an interface for SQL execution.