From 6290a149902fdd5541899ec87e93c5a24ffddfe0 Mon Sep 17 00:00:00 2001 From: Nuno Cruces Date: Wed, 26 Mar 2025 19:02:14 +0000 Subject: [PATCH] Fix interrupt race. --- stmt.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/stmt.go b/stmt.go index 50dd5e3..8713f9d 100644 --- a/stmt.go +++ b/stmt.go @@ -110,7 +110,10 @@ func (s *Stmt) Step() bool { s.err = INTERRUPT return false } + return s.step() +} +func (s *Stmt) step() bool { rc := res_t(s.c.call("sqlite3_step", stk_t(s.handle))) switch rc { case _ROW: @@ -135,7 +138,11 @@ func (s *Stmt) Err() error { // Exec is a convenience function that repeatedly calls [Stmt.Step] until it returns false, // then calls [Stmt.Reset] to reset the statement and get any error that occurred. func (s *Stmt) Exec() error { - for s.Step() { + if s.c.interrupt.Err() != nil { + return INTERRUPT + } + // TODO: implement this in C. + for s.step() { } return s.Reset() }