@@ -24,17 +24,15 @@ OFD locks are fully compatible with POSIX advisory locks.
24
24
25
25
On BSD Unixes, this module uses
26
26
[ BSD locks] ( https://man.freebsd.org/cgi/man.cgi?query=flock&sektion=2 ) .
27
- On BSD, these locks are fully compatible with POSIX advisory locks.
28
- However, concurrency is reduced with BSD locks
27
+ On BSD, macOS, and illumos, these locks are fully compatible with POSIX advisory locks;
28
+ on Linux and z/OS, they are fully functional, but incompatible with POSIX advisory locks.
29
+ However, concurrency is always reduced with BSD locks
29
30
(` BEGIN IMMEDIATE ` behaves the same as ` BEGIN EXCLUSIVE ` ).
31
+ You can opt into BSD locks with the ` sqlite3_flock ` build tag.
30
32
31
33
On Windows, this module uses ` LockFileEx ` and ` UnlockFileEx ` ,
32
34
like SQLite.
33
35
34
- On Linux and z/OS, BSD locks are fully functional,
35
- but incompatible with POSIX advisory locks (and SQLite).
36
- You can opt into BSD locks with the ` sqlite3_flock ` build tag.
37
-
38
36
On all other platforms, file locking is not supported, and you must use
39
37
[ ` nolock=1 ` ] ( https://sqlite.org/uri.html#urinolock )
40
38
(or [ ` immutable=1 ` ] ( https://sqlite.org/uri.html#uriimmutable ) )
@@ -44,7 +42,7 @@ with `nolock=1` you must disable connection pooling by calling
44
42
[ ` db.SetMaxOpenConns(1) ` ] ( https://pkg.go.dev/database/sql#DB.SetMaxOpenConns ) .
45
43
46
44
You can use [ ` vfs.SupportsFileLocking ` ] ( https://pkg.go.dev/github.com/ncruces/go-sqlite3/vfs#SupportsFileLocking )
47
- to check if your platform supports file locking.
45
+ to check if your build supports file locking.
48
46
49
47
### Write-Ahead Logging
50
48
@@ -56,28 +54,37 @@ To allow `mmap` to work, each connection needs to reserve up to 4GB of address s
56
54
To limit the amount of address space each connection needs,
57
55
use [ ` WithMemoryLimitPages ` ] ( ../tests/testcfg/testcfg.go ) .
58
56
59
- On Windows and BSD, [ WAL] ( https://sqlite.org/wal.html ) support is
57
+ On Windows, and with BSD locks , [ WAL] ( https://sqlite.org/wal.html ) support is
60
58
[ limited] ( https://sqlite.org/wal.html#noshm ) .
61
59
` EXCLUSIVE ` locking mode can be set to create, read, and write WAL databases.\
62
60
To use ` EXCLUSIVE ` locking mode with the
63
61
[ ` database/sql ` ] ( https://pkg.go.dev/database/sql ) driver
64
62
you must disable connection pooling by calling
65
63
[ ` db.SetMaxOpenConns(1) ` ] ( https://pkg.go.dev/database/sql#DB.SetMaxOpenConns ) .
66
64
67
- On all other platforms, where file locking is not supported, WAL mode does not work .
65
+ On all other platforms, where file locking is not supported, WAL mode is disabled .
68
66
69
67
You can use [ ` vfs.SupportsSharedMemory ` ] ( https://pkg.go.dev/github.com/ncruces/go-sqlite3/vfs#SupportsSharedMemory )
70
- to check if your platform supports shared memory.
68
+ to check if your build supports shared memory.
71
69
72
70
### Batch-Atomic Write
73
71
74
72
On 64-bit Linux, this module supports [ batch-atomic writes] ( https://sqlite.org/cgi/src/technote/714 )
75
73
with the F2FS filesystem.
76
74
77
- ### Build tags
75
+ ### Build Tags
78
76
79
77
The VFS can be customized with a few build tags:
80
- - ` sqlite3_flock ` forces the use of BSD locks; it can be used on macOS to test the BSD locking implementation.
78
+ - ` sqlite3_flock ` forces the use of BSD locks; it can be used on z/OS for locking support,
79
+ and elsewhere to test the BSD locks.
81
80
- ` sqlite3_nosys ` prevents importing [ ` x/sys ` ] ( https://pkg.go.dev/golang.org/x/sys ) ;
82
81
disables locking _ and_ shared memory on all platforms.
83
82
- ` sqlite3_noshm ` disables shared memory on all platforms.
83
+
84
+ > [ !CAUTION]
85
+ > If file locking is incompatible with POSIX advisory locks,
86
+ > accessing databases concurrently with this package and other SQLite implementations
87
+ > is unsafe, and will eventually corrupt data.
88
+ > This will only be the case if you explicitly opt into BSD locks with ` sqlite3_flock ` .
89
+ > The SQLite [ ` unix-flock ` ] ( https://sqlite.org/compile.html#enable_locking_style ) VFS
90
+ > is always compatible with ` sqlite3_flock ` .
0 commit comments