diff --git a/config.go b/config.go index 3921fe9..153fbd6 100644 --- a/config.go +++ b/config.go @@ -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)) diff --git a/const.go b/const.go index 522f68b..e4fc829 100644 --- a/const.go +++ b/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. diff --git a/tests/config_test.go b/tests/config_test.go index 4272ad3..f8492d3 100644 --- a/tests/config_test.go +++ b/tests/config_test.go @@ -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) { diff --git a/vfs/const.go b/vfs/const.go index b789d12..11afb12 100644 --- a/vfs/const.go +++ b/vfs/const.go @@ -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 ) diff --git a/vfs/shm_windows.go b/vfs/shm_windows.go index 7cc5b2a..0be523a 100644 --- a/vfs/shm_windows.go +++ b/vfs/shm_windows.go @@ -26,7 +26,6 @@ type vfsShm struct { ptrs []ptr_t stack [1]stk_t fileLock bool - blocking bool sync.Mutex } diff --git a/vfs/vfs.go b/vfs/vfs.go index c70507c..2656ddb 100644 --- a/vfs/vfs.go +++ b/vfs/vfs.go @@ -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