Skip to content

Commit 2f6cd8d

Browse files
committed
Docs.
1 parent e027e05 commit 2f6cd8d

File tree

2 files changed

+39
-14
lines changed

2 files changed

+39
-14
lines changed

README.md

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,17 +65,20 @@ db.QueryRow(`SELECT sqlite_version()`).Scan(&version)
6565
This module replaces the SQLite [OS Interface](https://sqlite.org/vfs.html)
6666
(aka VFS) with a [pure Go](vfs/) implementation,
6767
which has advantages and disadvantages.
68-
6968
Read more about the Go VFS design [here](vfs/README.md).
7069

70+
Because each database connection executes within a Wasm sandboxed environment,
71+
memory usage will be higher than alternatives.
72+
7173
### Testing
7274

7375
This project aims for [high test coverage](https://github.com/ncruces/go-sqlite3/wiki/Test-coverage-report).
7476
It also benefits greatly from [SQLite's](https://sqlite.org/testing.html) and
75-
[wazero's](https://tetrate.io/blog/introducing-wazero-from-tetrate/#:~:text=Rock%2Dsolid%20test%20approach) thorough testing.
77+
[wazero's](https://tetrate.io/blog/introducing-wazero-from-tetrate/#:~:text=Rock%2Dsolid%20test%20approach)
78+
thorough testing.
7679

7780
Every commit is [tested](https://github.com/ncruces/go-sqlite3/wiki/Support-matrix) on
78-
Linux (amd64/arm64/386/riscv64/ppc64le/s390x), macOS (amd64/arm64),
81+
Linux (amd64/arm64/386/riscv64/ppc64le/s390x), macOS (arm64/amd64),
7982
Windows (amd64), FreeBSD (amd64/arm64), OpenBSD (amd64), NetBSD (amd64/arm64),
8083
DragonFly BSD (amd64), illumos (amd64), and Solaris (amd64).
8184

@@ -84,12 +87,21 @@ The Go VFS is tested by running SQLite's
8487

8588
### Performance
8689

87-
Perfomance of the [`database/sql`](https://pkg.go.dev/database/sql) driver is
90+
Performance of the [`database/sql`](https://pkg.go.dev/database/sql) driver is
8891
[competitive](https://github.com/cvilsmeier/go-sqlite-bench) with alternatives.
8992

90-
The Wasm and VFS layers are also tested by running SQLite's
93+
The Wasm and VFS layers are also benchmarked by running SQLite's
9194
[speedtest1](https://github.com/sqlite/sqlite/blob/master/test/speedtest1.c).
9295

96+
### Concurrency
97+
98+
This module behaves similarly to SQLite in [multi-thread](https://sqlite.org/threadsafe.html) mode:
99+
it is goroutine-safe, provided that no single database connection, or object derived from it,
100+
is used concurrently by multiple goroutines.
101+
102+
The [`database/sql`](https://pkg.go.dev/database/sql) driver is safe to use concurrently,
103+
according to its documentation.
104+
93105
### FAQ, issues, new features
94106

95107
For questions, please see [Discussions](https://github.com/ncruces/go-sqlite3/discussions/categories/q-a).

vfs/README.md

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,30 @@ It replaces the default SQLite VFS with a **pure Go** implementation,
66
and exposes [interfaces](https://pkg.go.dev/github.com/ncruces/go-sqlite3/vfs#VFS)
77
that should allow you to implement your own [custom VFSes](#custom-vfses).
88

9-
Since it is a from scratch reimplementation,
9+
See the [support matrix](https://github.com/ncruces/go-sqlite3/wiki/Support-matrix)
10+
for the list of supported OS and CPU architectures.
11+
12+
Since this is a from scratch reimplementation,
1013
there are naturally some ways it deviates from the original.
14+
It's also not as battle tested as the original.
1115

12-
The main differences are [file locking](#file-locking) and [WAL mode](#write-ahead-logging) support.
16+
The main differences to be aware of are
17+
[file locking](#file-locking) and
18+
[WAL mode](#write-ahead-logging) support.
1319

1420
### File Locking
1521

16-
POSIX advisory locks, which SQLite uses on Unix, are
17-
[broken by design](https://github.com/sqlite/sqlite/blob/b74eb0/src/os_unix.c#L1073-L1161).
22+
POSIX advisory locks,
23+
which SQLite uses on [Unix](https://github.com/sqlite/sqlite/blob/5d60f4/src/os_unix.c#L13-L14),
24+
are [broken by design](https://github.com/sqlite/sqlite/blob/5d60f4/src/os_unix.c#L1074-L1162).
1825
Instead, on Linux and macOS, this package uses
1926
[OFD locks](https://www.gnu.org/software/libc/manual/html_node/Open-File-Description-Locks.html)
2027
to synchronize access to database files.
2128

2229
This package can also use
2330
[BSD locks](https://man.freebsd.org/cgi/man.cgi?query=flock&sektion=2),
24-
albeit with reduced concurrency (`BEGIN IMMEDIATE` behaves like `BEGIN EXCLUSIVE`).
31+
albeit with reduced concurrency (`BEGIN IMMEDIATE` behaves like `BEGIN EXCLUSIVE`,
32+
[docs](https://sqlite.org/lang_transaction.html#immediate)).
2533
BSD locks are the default on BSD and illumos,
2634
but you can opt into them with the `sqlite3_flock` build tag.
2735

@@ -44,11 +52,11 @@ to check if your build supports file locking.
4452

4553
### Write-Ahead Logging
4654

47-
On Unix, this package may use `mmap` to implement
55+
On Unix, this package uses `mmap` to implement
4856
[shared-memory for the WAL-index](https://sqlite.org/wal.html#implementation_of_shared_memory_for_the_wal_index),
4957
like SQLite.
5058

51-
On Windows, this package may use `MapViewOfFile`, like SQLite.
59+
On Windows, this package uses `MapViewOfFile`, like SQLite.
5260

5361
You can also opt into a cross-platform, in-process, memory sharing implementation
5462
with the `sqlite3_dotlk` build tag.
@@ -63,6 +71,11 @@ you must disable connection pooling by calling
6371
You can use [`vfs.SupportsSharedMemory`](https://pkg.go.dev/github.com/ncruces/go-sqlite3/vfs#SupportsSharedMemory)
6472
to check if your build supports shared memory.
6573

74+
### Blocking Locks
75+
76+
On Windows and macOS, this package implements
77+
[Wal-mode blocking locks](https://sqlite.org/src/doc/tip/doc/wal-lock.md).
78+
6679
### Batch-Atomic Write
6780

6881
On Linux, this package may support
@@ -94,8 +107,8 @@ The VFS can be customized with a few build tags:
94107
> [`unix-flock` VFS](https://sqlite.org/compile.html#enable_locking_style);
95108
> `sqlite3_dotlk` builds are compatible with the
96109
> [`unix-dotfile` VFS](https://sqlite.org/compile.html#enable_locking_style).
97-
> If incompatible file locking is used, accessing databases concurrently with
98-
> _other_ SQLite libraries will eventually corrupt data.
110+
> Accessing databases concurrently using incompatible implementations
111+
> will eventually corrupt data.
99112
100113
### Custom VFSes
101114

0 commit comments

Comments
 (0)