@@ -2,7 +2,6 @@ package sqlite3
22
33import (
44 "context"
5- "errors"
65 "math/rand"
76 "runtime"
87 "strconv"
@@ -25,7 +24,7 @@ type Txn struct {
2524// https://sqlite.org/lang_transaction.html
2625func (c * Conn ) Begin () Txn {
2726 // BEGIN even if interrupted.
28- err := c .txnExecInterrupted (`BEGIN DEFERRED` )
27+ err := c .exec (`BEGIN DEFERRED` )
2928 if err != nil {
3029 panic (err )
3130 }
@@ -120,7 +119,7 @@ func (tx Txn) Commit() error {
120119//
121120// https://sqlite.org/lang_transaction.html
122121func (tx Txn ) Rollback () error {
123- return tx .c .txnExecInterrupted (`ROLLBACK` )
122+ return tx .c .exec (`ROLLBACK` )
124123}
125124
126125// Savepoint is a marker within a transaction
@@ -143,7 +142,7 @@ func (c *Conn) Savepoint() Savepoint {
143142 // Names can be reused, but this makes catching bugs more likely.
144143 name = QuoteIdentifier (name + "_" + strconv .Itoa (int (rand .Int31 ())))
145144
146- err := c .txnExecInterrupted (`SAVEPOINT ` + name )
145+ err := c .exec (`SAVEPOINT ` + name )
147146 if err != nil {
148147 panic (err )
149148 }
@@ -199,7 +198,7 @@ func (s Savepoint) Release(errp *error) {
199198 return
200199 }
201200 // 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 )
203202 if err != nil {
204203 panic (err )
205204 }
@@ -212,17 +211,7 @@ func (s Savepoint) Release(errp *error) {
212211// https://sqlite.org/lang_transaction.html
213212func (s Savepoint ) Rollback () error {
214213 // 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 )
226215}
227216
228217// TxnState determines the transaction state of a database.
0 commit comments