Skip to content

Commit b1495bd

Browse files
committed
Build tags, docs.
1 parent 2d91760 commit b1495bd

File tree

9 files changed

+46
-24
lines changed

9 files changed

+46
-24
lines changed

.github/workflows/go.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,12 @@ jobs:
4747
- name: Test
4848
run: go test -v ./...
4949

50+
- name: Test no locks
51+
run: go test -v -tags sqlite3_nolock .
52+
if: matrix.os == 'ubuntu-latest'
53+
5054
- name: Test BSD locks
51-
run: go test -v -tags sqlite3_bsd ./...
55+
run: go test -v -tags sqlite3_flock ./...
5256
if: matrix.os == 'macos-latest'
5357

5458
- name: Coverage report
@@ -58,6 +62,6 @@ jobs:
5862
amend: 'true'
5963
reuse-go: 'true'
6064
if: |
61-
matrix.os == 'ubuntu-latest' &&
62-
github.event_name == 'push'
65+
github.event_name == 'push' &&
66+
matrix.os == 'ubuntu-latest'
6367
continue-on-error: true

README.md

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -57,29 +57,25 @@ On Linux, macOS and illumos, this module uses
5757
to synchronize access to database files.
5858
OFD locks are fully compatible with process-associated POSIX advisory locks.
5959

60-
On BSD Unixes, this module uses
60+
On BSD Unixes, this module may use
6161
[BSD locks](https://man.freebsd.org/cgi/man.cgi?query=flock&sektion=2).
62-
BSD locks may _not_ be compatible with process-associated POSIX advisory locks
63-
(they are on FreeBSD).
62+
BSD locks may _not_ be compatible with process-associated POSIX advisory locks.
6463

6564
##### TL;DR
6665

6766
In all platforms for which this package builds,
68-
it is safe to use it to access databases concurrently from multiple goroutines.
69-
70-
Additionally, on Windows, Linux, macOS, illumos and FreeBSD,
71-
it is _also_ safe to use it to access databases concurrently
67+
it should be safe to use it to access databases concurrently,
68+
from multiple goroutines, processes, and
7269
with _other_ implementations of SQLite.
7370

74-
On other BSDs, where this might be unsafe,
75-
[this test](vfs/lock_test.go) should fail.
71+
If the package does not build for your platform,
72+
see [this](vfs/README.md#portability).
7673

7774
#### Testing
7875

7976
The pure Go VFS is tested by running SQLite's
8077
[mptest](https://github.com/sqlite/sqlite/blob/master/mptest/mptest.c)
81-
on Linux, macOS and Windows;
82-
BSD code paths are tested on macOS using the `sqlite3_bsd` build tag.
78+
on Linux, macOS and Windows.
8379
Performance is tested by running
8480
[speedtest1](https://github.com/sqlite/sqlite/blob/master/test/speedtest1.c).
8581

vfs/README.md

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,30 @@
22

33
This package implements the SQLite [OS Interface](https://www.sqlite.org/vfs.html) (aka VFS).
44

5-
It replaces the default VFS with a pure Go implementation,
6-
that is tested on Linux, macOS and Windows,
7-
but which should also work on illumos and the various BSDs.
5+
It replaces the default SQLite VFS with a pure Go implementation.
86

9-
It also exposes interfaces that should allow you to implement your own custom VFSes.
7+
It also exposes interfaces that should allow you to implement your own custom VFSes.
8+
9+
## Portability
10+
11+
This package is tested on Linux, macOS and Windows,
12+
but it should also work on FreeBSD and illumos
13+
(code paths for those plaforms are tested on macOS and Linux, respectively).
14+
15+
In all platforms for which this package builds,
16+
it should be safe to use it to access databases concurrently,
17+
from multiple goroutines, processes, and
18+
with _other_ implementations of SQLite.
19+
20+
If the package does not build for your platform,
21+
you may try to use the `sqlite3_flock` and `sqlite3_nolock` build tags.
22+
These are only minimally tested and concurrency test failures should be expected.
23+
24+
The `sqlite3_flock` tag uses
25+
[BSD locks](https://man.freebsd.org/cgi/man.cgi?query=flock&sektion=2).
26+
It should be safe to access databases concurrently from multiple goroutines and processes,
27+
but **not** with _other_ implementations of SQLite
28+
(_unless_ these are _also_ configured to use `flock`).
29+
30+
The `sqlite3_nolock` tag uses no locking at all.
31+
Database corruption is the likely result from concurrent write access.

vfs/os_bsd.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//go:build freebsd || openbsd || netbsd || dragonfly || (darwin && sqlite3_bsd)
1+
//go:build sqlite3_flock || freebsd
22

33
package vfs
44

vfs/os_darwin.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//go:build !sqlite3_bsd
1+
//go:build !sqlite3_flock
22

33
package vfs
44

vfs/os_nolock.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//go:build sqlite3_nolock && solaris && !illumos
1+
//go:build sqlite3_nolock && unix && !(linux || darwin || freebsd || illumos)
22

33
package vfs
44

vfs/os_ofd.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//go:build linux || illumos
1+
//go:build (linux || illumos) && !sqlite3_flock
22

33
package vfs
44

vfs/os_std_alloc.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//go:build !linux && (!darwin || sqlite3_bsd)
1+
//go:build !linux && (!darwin || sqlite3_flock)
22

33
package vfs
44

vfs/os_std_sync.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//go:build !linux && (!darwin || sqlite3_bsd)
1+
//go:build !linux && (!darwin || sqlite3_flock)
22

33
package vfs
44

0 commit comments

Comments
 (0)