mirror of
https://github.com/ncruces/go-sqlite3.git
synced 2026-01-12 05:59:14 +00:00
FCNTL_NULL_IO.
This commit is contained in:
@@ -109,7 +109,7 @@ func (c *Conn) FileControl(schema string, op FcntlOpcode, arg ...any) (any, erro
|
||||
default:
|
||||
return nil, MISUSE
|
||||
|
||||
case FCNTL_RESET_CACHE:
|
||||
case FCNTL_RESET_CACHE, FCNTL_NULL_IO:
|
||||
rc = res_t(c.call("sqlite3_file_control",
|
||||
stk_t(c.handle), stk_t(schemaPtr),
|
||||
stk_t(op), 0))
|
||||
|
||||
1
const.go
1
const.go
@@ -280,6 +280,7 @@ const (
|
||||
FCNTL_DATA_VERSION FcntlOpcode = 35
|
||||
FCNTL_RESERVE_BYTES FcntlOpcode = 38
|
||||
FCNTL_RESET_CACHE FcntlOpcode = 42
|
||||
FCNTL_NULL_IO FcntlOpcode = 43
|
||||
)
|
||||
|
||||
// LimitCategory are the available run-time limit categories.
|
||||
|
||||
@@ -114,6 +114,7 @@ func TestConn_FileControl(t *testing.T) {
|
||||
t.Errorf("got %v, want MISUSE", err)
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("FCNTL_RESET_CACHE", func(t *testing.T) {
|
||||
o, err := db.FileControl("", sqlite3.FCNTL_RESET_CACHE)
|
||||
if err != nil {
|
||||
@@ -237,6 +238,16 @@ func TestConn_FileControl(t *testing.T) {
|
||||
t.Errorf("got %v, want LOCK_EXCLUSIVE", o)
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("FCNTL_NULL_IO", func(t *testing.T) {
|
||||
o, err := db.FileControl("", sqlite3.FCNTL_NULL_IO)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if o != nil {
|
||||
t.Errorf("got %v, want nil", o)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func TestConn_Limit(t *testing.T) {
|
||||
|
||||
@@ -234,6 +234,7 @@ const (
|
||||
_FCNTL_CKSM_FILE _FcntlOpcode = 41
|
||||
_FCNTL_RESET_CACHE _FcntlOpcode = 42
|
||||
_FCNTL_NULL_IO _FcntlOpcode = 43
|
||||
_FCNTL_BLOCK_ON_CONNECT _FcntlOpcode = 44
|
||||
)
|
||||
|
||||
// https://sqlite.org/c3ref/c_shm_exclusive.html
|
||||
@@ -246,6 +247,6 @@ const (
|
||||
_SHM_EXCLUSIVE _ShmFlag = 8
|
||||
|
||||
_SHM_NLOCK = 8
|
||||
_SHM_BASE = 120
|
||||
_SHM_BASE = (22 + _SHM_NLOCK) * 4
|
||||
_SHM_DMS = _SHM_BASE + _SHM_NLOCK
|
||||
)
|
||||
|
||||
@@ -26,7 +26,6 @@ type vfsShm struct {
|
||||
ptrs []ptr_t
|
||||
stack [1]stk_t
|
||||
fileLock bool
|
||||
blocking bool
|
||||
sync.Mutex
|
||||
}
|
||||
|
||||
|
||||
@@ -381,6 +381,10 @@ func vfsFileControlImpl(ctx context.Context, mod api.Module, file File, op _Fcnt
|
||||
file.SetDB(ctx.Value(util.ConnKey{}))
|
||||
return _OK
|
||||
}
|
||||
|
||||
case _FCNTL_NULL_IO:
|
||||
file.Close()
|
||||
return _OK
|
||||
}
|
||||
|
||||
return _NOTFOUND
|
||||
|
||||
Reference in New Issue
Block a user