Skip to content

Commit 2ab5f7d

Browse files
committed
handle invalid statements
1 parent ee57b76 commit 2ab5f7d

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

atlas/socket/handler.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -560,8 +560,13 @@ func (s *Socket) PerformExecute(ctx context.Context, cmd *commands.CommandString
560560
return
561561
}
562562

563-
if !s.activeStmts[execute.id].query.IsQueryReadOnly() && !s.inTransaction {
564-
err = s.rollbackAutoTransaction(ctx, errors.New("cannot execute a non-read-only query outside transaction"))
563+
if smt, ok := s.activeStmts[execute.id]; ok {
564+
if !smt.query.IsQueryReadOnly() && !s.inTransaction {
565+
err = s.rollbackAutoTransaction(ctx, errors.New("cannot execute a non-read-only query outside transaction"))
566+
return
567+
}
568+
} else {
569+
err = s.rollbackAutoTransaction(ctx, errors.New("unknown statement"))
565570
return
566571
}
567572

0 commit comments

Comments
 (0)