diff --git a/session/session.go b/session/session.go index 828651999fc2b..fc4d34c4f22d9 100644 --- a/session/session.go +++ b/session/session.go @@ -1047,7 +1047,12 @@ func (s *session) execute(ctx context.Context, sql string) (recordSets []sqlexec } else { sessionExecuteParseDurationGeneral.Observe(durParse.Seconds()) } - + if len(stmtNodes) == 0 { + if s.txn.pending() { + s.txn.changeToInvalid() + } + return recordSets, nil + } var tempStmtNodes []ast.StmtNode compiler := executor.Compiler{Ctx: s} multiQuery := len(stmtNodes) > 1