Skip to content

Commit f0ce3e5

Browse files
committed
Docs.
1 parent 5d5c302 commit f0ce3e5

File tree

2 files changed

+22
-14
lines changed

2 files changed

+22
-14
lines changed

.github/workflows/cross.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,11 @@ echo windows ; GOOS=windows GOARCH=amd64 go build .
1616
echo aix ; GOOS=aix GOARCH=ppc64 go build .
1717
echo js ; GOOS=js GOARCH=wasm go build .
1818
echo wasip1 ; GOOS=wasip1 GOARCH=wasm go build .
19+
echo linux-flock ; GOOS=linux GOARCH=amd64 go build -tags sqlite3_flock .
20+
echo linux-noshm ; GOOS=linux GOARCH=amd64 go build -tags sqlite3_noshm .
21+
echo linux-nosys ; GOOS=linux GOARCH=amd64 go build -tags sqlite3_nosys .
1922
echo darwin-flock ; GOOS=darwin GOARCH=amd64 go build -tags sqlite3_flock .
2023
echo darwin-noshm ; GOOS=darwin GOARCH=amd64 go build -tags sqlite3_noshm .
2124
echo darwin-nosys ; GOOS=darwin GOARCH=amd64 go build -tags sqlite3_nosys .
22-
echo linux-noshm ; GOOS=linux GOARCH=amd64 go build -tags sqlite3_noshm .
23-
echo linux-nosys ; GOOS=linux GOARCH=amd64 go build -tags sqlite3_nosys .
2425
echo windows-nosys ; GOOS=windows GOARCH=amd64 go build -tags sqlite3_nosys .
2526
echo freebsd-nosys ; GOOS=freebsd GOARCH=amd64 go build -tags sqlite3_nosys .

vfs/README.md

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,15 @@ OFD locks are fully compatible with POSIX advisory locks.
2424

2525
On BSD Unixes, this module uses
2626
[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
2930
(`BEGIN IMMEDIATE` behaves the same as `BEGIN EXCLUSIVE`).
31+
You can opt into BSD locks with the `sqlite3_flock` build tag.
3032

3133
On Windows, this module uses `LockFileEx` and `UnlockFileEx`,
3234
like SQLite.
3335

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-
3836
On all other platforms, file locking is not supported, and you must use
3937
[`nolock=1`](https://sqlite.org/uri.html#urinolock)
4038
(or [`immutable=1`](https://sqlite.org/uri.html#uriimmutable))
@@ -44,7 +42,7 @@ with `nolock=1` you must disable connection pooling by calling
4442
[`db.SetMaxOpenConns(1)`](https://pkg.go.dev/database/sql#DB.SetMaxOpenConns).
4543

4644
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.
4846

4947
### Write-Ahead Logging
5048

@@ -56,28 +54,37 @@ To allow `mmap` to work, each connection needs to reserve up to 4GB of address s
5654
To limit the amount of address space each connection needs,
5755
use [`WithMemoryLimitPages`](../tests/testcfg/testcfg.go).
5856

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
6058
[limited](https://sqlite.org/wal.html#noshm).
6159
`EXCLUSIVE` locking mode can be set to create, read, and write WAL databases.\
6260
To use `EXCLUSIVE` locking mode with the
6361
[`database/sql`](https://pkg.go.dev/database/sql) driver
6462
you must disable connection pooling by calling
6563
[`db.SetMaxOpenConns(1)`](https://pkg.go.dev/database/sql#DB.SetMaxOpenConns).
6664

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.
6866

6967
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.
7169

7270
### Batch-Atomic Write
7371

7472
On 64-bit Linux, this module supports [batch-atomic writes](https://sqlite.org/cgi/src/technote/714)
7573
with the F2FS filesystem.
7674

77-
### Build tags
75+
### Build Tags
7876

7977
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.
8180
- `sqlite3_nosys` prevents importing [`x/sys`](https://pkg.go.dev/golang.org/x/sys);
8281
disables locking _and_ shared memory on all platforms.
8382
- `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

Comments
 (0)