mirror of
https://github.com/ncruces/go-sqlite3.git
synced 2026-01-11 21:49:13 +00:00
More consistent interrupts.
This commit is contained in:
1
blob.go
1
blob.go
@@ -253,6 +253,7 @@ func (b *Blob) Seek(offset int64, whence int) (int64, error) {
|
|||||||
//
|
//
|
||||||
// https://sqlite.org/c3ref/blob_reopen.html
|
// https://sqlite.org/c3ref/blob_reopen.html
|
||||||
func (b *Blob) Reopen(row int64) error {
|
func (b *Blob) Reopen(row int64) error {
|
||||||
|
b.c.checkInterrupt(b.c.handle)
|
||||||
err := b.c.error(b.c.call("sqlite3_blob_reopen", uint64(b.handle), uint64(row)))
|
err := b.c.error(b.c.call("sqlite3_blob_reopen", uint64(b.handle), uint64(row)))
|
||||||
b.bytes = int64(b.c.call("sqlite3_blob_bytes", uint64(b.handle)))
|
b.bytes = int64(b.c.call("sqlite3_blob_bytes", uint64(b.handle)))
|
||||||
b.offset = 0
|
b.offset = 0
|
||||||
|
|||||||
1
conn.go
1
conn.go
@@ -204,6 +204,7 @@ func (c *Conn) PrepareFlags(sql string, flags PrepareFlag) (stmt *Stmt, tail str
|
|||||||
tailPtr := c.arena.new(ptrlen)
|
tailPtr := c.arena.new(ptrlen)
|
||||||
sqlPtr := c.arena.string(sql)
|
sqlPtr := c.arena.string(sql)
|
||||||
|
|
||||||
|
c.checkInterrupt(c.handle)
|
||||||
r := c.call("sqlite3_prepare_v3", uint64(c.handle),
|
r := c.call("sqlite3_prepare_v3", uint64(c.handle),
|
||||||
uint64(sqlPtr), uint64(len(sql)+1), uint64(flags),
|
uint64(sqlPtr), uint64(len(sql)+1), uint64(flags),
|
||||||
uint64(stmtPtr), uint64(tailPtr))
|
uint64(stmtPtr), uint64(tailPtr))
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/ncruces/go-sqlite3"
|
"github.com/ncruces/go-sqlite3"
|
||||||
_ "github.com/ncruces/go-sqlite3/embed"
|
_ "github.com/ncruces/go-sqlite3/embed"
|
||||||
@@ -148,7 +149,10 @@ func TestConn_SetInterrupt(t *testing.T) {
|
|||||||
defer stmt.Close()
|
defer stmt.Close()
|
||||||
|
|
||||||
db.SetInterrupt(ctx)
|
db.SetInterrupt(ctx)
|
||||||
go cancel()
|
go func() {
|
||||||
|
time.Sleep(time.Millisecond)
|
||||||
|
cancel()
|
||||||
|
}()
|
||||||
|
|
||||||
// Interrupting works.
|
// Interrupting works.
|
||||||
err = stmt.Exec()
|
err = stmt.Exec()
|
||||||
|
|||||||
Reference in New Issue
Block a user