Skip to content

Commit 6290a14

Browse files
committed
Fix interrupt race.
1 parent 9486411 commit 6290a14

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

stmt.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,10 @@ func (s *Stmt) Step() bool {
110110
s.err = INTERRUPT
111111
return false
112112
}
113+
return s.step()
114+
}
113115

116+
func (s *Stmt) step() bool {
114117
rc := res_t(s.c.call("sqlite3_step", stk_t(s.handle)))
115118
switch rc {
116119
case _ROW:
@@ -135,7 +138,11 @@ func (s *Stmt) Err() error {
135138
// Exec is a convenience function that repeatedly calls [Stmt.Step] until it returns false,
136139
// then calls [Stmt.Reset] to reset the statement and get any error that occurred.
137140
func (s *Stmt) Exec() error {
138-
for s.Step() {
141+
if s.c.interrupt.Err() != nil {
142+
return INTERRUPT
143+
}
144+
// TODO: implement this in C.
145+
for s.step() {
139146
}
140147
return s.Reset()
141148
}

0 commit comments

Comments
 (0)