Skip to content

Commit b46f480

Browse files
committed
FCNTL_NULL_IO.
1 parent 040a026 commit b46f480

File tree

6 files changed

+19
-3
lines changed

6 files changed

+19
-3
lines changed

config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ func (c *Conn) FileControl(schema string, op FcntlOpcode, arg ...any) (any, erro
109109
default:
110110
return nil, MISUSE
111111

112-
case FCNTL_RESET_CACHE:
112+
case FCNTL_RESET_CACHE, FCNTL_NULL_IO:
113113
rc = res_t(c.call("sqlite3_file_control",
114114
stk_t(c.handle), stk_t(schemaPtr),
115115
stk_t(op), 0))

const.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,7 @@ const (
280280
FCNTL_DATA_VERSION FcntlOpcode = 35
281281
FCNTL_RESERVE_BYTES FcntlOpcode = 38
282282
FCNTL_RESET_CACHE FcntlOpcode = 42
283+
FCNTL_NULL_IO FcntlOpcode = 43
283284
)
284285

285286
// LimitCategory are the available run-time limit categories.

tests/config_test.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ func TestConn_FileControl(t *testing.T) {
114114
t.Errorf("got %v, want MISUSE", err)
115115
}
116116
})
117+
117118
t.Run("FCNTL_RESET_CACHE", func(t *testing.T) {
118119
o, err := db.FileControl("", sqlite3.FCNTL_RESET_CACHE)
119120
if err != nil {
@@ -237,6 +238,16 @@ func TestConn_FileControl(t *testing.T) {
237238
t.Errorf("got %v, want LOCK_EXCLUSIVE", o)
238239
}
239240
})
241+
242+
t.Run("FCNTL_NULL_IO", func(t *testing.T) {
243+
o, err := db.FileControl("", sqlite3.FCNTL_NULL_IO)
244+
if err != nil {
245+
t.Fatal(err)
246+
}
247+
if o != nil {
248+
t.Errorf("got %v, want nil", o)
249+
}
250+
})
240251
}
241252

242253
func TestConn_Limit(t *testing.T) {

vfs/const.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,7 @@ const (
234234
_FCNTL_CKSM_FILE _FcntlOpcode = 41
235235
_FCNTL_RESET_CACHE _FcntlOpcode = 42
236236
_FCNTL_NULL_IO _FcntlOpcode = 43
237+
_FCNTL_BLOCK_ON_CONNECT _FcntlOpcode = 44
237238
)
238239

239240
// https://sqlite.org/c3ref/c_shm_exclusive.html
@@ -246,6 +247,6 @@ const (
246247
_SHM_EXCLUSIVE _ShmFlag = 8
247248

248249
_SHM_NLOCK = 8
249-
_SHM_BASE = 120
250+
_SHM_BASE = (22 + _SHM_NLOCK) * 4
250251
_SHM_DMS = _SHM_BASE + _SHM_NLOCK
251252
)

vfs/shm_windows.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ type vfsShm struct {
2626
ptrs []ptr_t
2727
stack [1]stk_t
2828
fileLock bool
29-
blocking bool
3029
sync.Mutex
3130
}
3231

vfs/vfs.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,10 @@ func vfsFileControlImpl(ctx context.Context, mod api.Module, file File, op _Fcnt
381381
file.SetDB(ctx.Value(util.ConnKey{}))
382382
return _OK
383383
}
384+
385+
case _FCNTL_NULL_IO:
386+
file.Close()
387+
return _OK
384388
}
385389

386390
return _NOTFOUND

0 commit comments

Comments
 (0)