@@ -2,7 +2,6 @@ package sqlite3
2
2
3
3
import (
4
4
"context"
5
- "errors"
6
5
"math/rand"
7
6
"runtime"
8
7
"strconv"
@@ -25,7 +24,7 @@ type Txn struct {
25
24
// https://sqlite.org/lang_transaction.html
26
25
func (c * Conn ) Begin () Txn {
27
26
// BEGIN even if interrupted.
28
- err := c .txnExecInterrupted (`BEGIN DEFERRED` )
27
+ err := c .exec (`BEGIN DEFERRED` )
29
28
if err != nil {
30
29
panic (err )
31
30
}
@@ -120,7 +119,7 @@ func (tx Txn) Commit() error {
120
119
//
121
120
// https://sqlite.org/lang_transaction.html
122
121
func (tx Txn ) Rollback () error {
123
- return tx .c .txnExecInterrupted (`ROLLBACK` )
122
+ return tx .c .exec (`ROLLBACK` )
124
123
}
125
124
126
125
// Savepoint is a marker within a transaction
@@ -143,7 +142,7 @@ func (c *Conn) Savepoint() Savepoint {
143
142
// Names can be reused, but this makes catching bugs more likely.
144
143
name = QuoteIdentifier (name + "_" + strconv .Itoa (int (rand .Int31 ())))
145
144
146
- err := c .txnExecInterrupted (`SAVEPOINT ` + name )
145
+ err := c .exec (`SAVEPOINT ` + name )
147
146
if err != nil {
148
147
panic (err )
149
148
}
@@ -199,7 +198,7 @@ func (s Savepoint) Release(errp *error) {
199
198
return
200
199
}
201
200
// ROLLBACK and RELEASE even if interrupted.
202
- err := s .c .txnExecInterrupted (`ROLLBACK TO ` + s .name + `; RELEASE ` + s .name )
201
+ err := s .c .exec (`ROLLBACK TO ` + s .name + `; RELEASE ` + s .name )
203
202
if err != nil {
204
203
panic (err )
205
204
}
@@ -212,17 +211,7 @@ func (s Savepoint) Release(errp *error) {
212
211
// https://sqlite.org/lang_transaction.html
213
212
func (s Savepoint ) Rollback () error {
214
213
// ROLLBACK even if interrupted.
215
- return s .c .txnExecInterrupted (`ROLLBACK TO ` + s .name )
216
- }
217
-
218
- func (c * Conn ) txnExecInterrupted (sql string ) error {
219
- err := c .Exec (sql )
220
- if errors .Is (err , INTERRUPT ) {
221
- old := c .SetInterrupt (context .Background ())
222
- defer c .SetInterrupt (old )
223
- err = c .Exec (sql )
224
- }
225
- return err
214
+ return s .c .exec (`ROLLBACK TO ` + s .name )
226
215
}
227
216
228
217
// TxnState determines the transaction state of a database.
0 commit comments