mirror of
https://github.com/ncruces/go-sqlite3.git
synced 2026-01-12 05:59:14 +00:00
Tweaks, docs.
This commit is contained in:
2
.github/workflows/repro.sh
vendored
2
.github/workflows/repro.sh
vendored
@@ -19,5 +19,5 @@ mkdir -p tools/
|
|||||||
wait
|
wait
|
||||||
|
|
||||||
sqlite3/download.sh # Download SQLite
|
sqlite3/download.sh # Download SQLite
|
||||||
embed/build.sh # Build WASM
|
embed/build.sh # Build Wasm
|
||||||
git diff --exit-code # Check diffs
|
git diff --exit-code # Check diffs
|
||||||
@@ -8,7 +8,7 @@ Go module `github.com/ncruces/go-sqlite3` is `cgo`-free [SQLite](https://sqlite.
|
|||||||
It provides a [`database/sql`](https://pkg.go.dev/database/sql) compatible driver,
|
It provides a [`database/sql`](https://pkg.go.dev/database/sql) compatible driver,
|
||||||
as well as direct access to most of the [C SQLite API](https://sqlite.org/cintro.html).
|
as well as direct access to most of the [C SQLite API](https://sqlite.org/cintro.html).
|
||||||
|
|
||||||
It wraps a [WASM](https://webassembly.org/) build of SQLite, and uses [wazero](https://wazero.io/) as the runtime.\
|
It wraps a [Wasm](https://webassembly.org/) build of SQLite, and uses [wazero](https://wazero.io/) as the runtime.\
|
||||||
Go, wazero and [`x/sys`](https://pkg.go.dev/golang.org/x/sys) are the _only_ runtime dependencies.
|
Go, wazero and [`x/sys`](https://pkg.go.dev/golang.org/x/sys) are the _only_ runtime dependencies.
|
||||||
|
|
||||||
### Packages
|
### Packages
|
||||||
@@ -77,7 +77,7 @@ This has benefits, but also comes with some drawbacks.
|
|||||||
|
|
||||||
#### Write-Ahead Logging
|
#### Write-Ahead Logging
|
||||||
|
|
||||||
Because WASM does not support shared memory,
|
Because Wasm does not support shared memory,
|
||||||
[WAL](https://sqlite.org/wal.html) support is [limited](https://sqlite.org/wal.html#noshm).
|
[WAL](https://sqlite.org/wal.html) support is [limited](https://sqlite.org/wal.html#noshm).
|
||||||
|
|
||||||
To work around this limitation, SQLite is [patched](sqlite3/locking_mode.patch)
|
To work around this limitation, SQLite is [patched](sqlite3/locking_mode.patch)
|
||||||
@@ -131,7 +131,7 @@ on Linux, macOS, Windows and FreeBSD.
|
|||||||
Perfomance of the [`database/sql`](https://pkg.go.dev/database/sql) driver is
|
Perfomance of the [`database/sql`](https://pkg.go.dev/database/sql) driver is
|
||||||
[competitive](https://github.com/cvilsmeier/go-sqlite-bench) with alternatives.
|
[competitive](https://github.com/cvilsmeier/go-sqlite-bench) with alternatives.
|
||||||
|
|
||||||
The WASM and VFS layers are also tested by running SQLite's
|
The Wasm and VFS layers are also tested by running SQLite's
|
||||||
[speedtest1](https://github.com/sqlite/sqlite/blob/master/test/speedtest1.c).
|
[speedtest1](https://github.com/sqlite/sqlite/blob/master/test/speedtest1.c).
|
||||||
|
|
||||||
### Alternatives
|
### Alternatives
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# Embeddable WASM build of SQLite
|
# Embeddable Wasm build of SQLite
|
||||||
|
|
||||||
This folder includes an embeddable WASM build of SQLite 3.45.1 for use with
|
This folder includes an embeddable Wasm build of SQLite 3.45.1 for use with
|
||||||
[`github.com/ncruces/go-sqlite3`](https://pkg.go.dev/github.com/ncruces/go-sqlite3).
|
[`github.com/ncruces/go-sqlite3`](https://pkg.go.dev/github.com/ncruces/go-sqlite3).
|
||||||
|
|
||||||
The following optional features are compiled in:
|
The following optional features are compiled in:
|
||||||
|
|||||||
@@ -15,14 +15,14 @@ import (
|
|||||||
"github.com/tetratelabs/wazero/api"
|
"github.com/tetratelabs/wazero/api"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Configure SQLite WASM.
|
// Configure SQLite Wasm.
|
||||||
//
|
//
|
||||||
// Importing package embed initializes these
|
// Importing package embed initializes [Binary]
|
||||||
// with an appropriate build of SQLite:
|
// with an appropriate build of SQLite:
|
||||||
//
|
//
|
||||||
// import _ "github.com/ncruces/go-sqlite3/embed"
|
// import _ "github.com/ncruces/go-sqlite3/embed"
|
||||||
var (
|
var (
|
||||||
Binary []byte // WASM binary to load.
|
Binary []byte // Wasm binary to load.
|
||||||
Path string // Path to load the binary from.
|
Path string // Path to load the binary from.
|
||||||
|
|
||||||
RuntimeConfig wazero.RuntimeConfig
|
RuntimeConfig wazero.RuntimeConfig
|
||||||
@@ -274,7 +274,7 @@ func (a *arena) new(size uint64) uint32 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (a *arena) bytes(b []byte) uint32 {
|
func (a *arena) bytes(b []byte) uint32 {
|
||||||
if b == nil {
|
if (*[0]byte)(b) == nil {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
ptr := a.new(uint64(len(b)))
|
ptr := a.new(uint64(len(b)))
|
||||||
|
|||||||
@@ -57,8 +57,8 @@
|
|||||||
#define SQLITE_ENABLE_ATOMIC_WRITE
|
#define SQLITE_ENABLE_ATOMIC_WRITE
|
||||||
#define SQLITE_ENABLE_BATCH_ATOMIC_WRITE
|
#define SQLITE_ENABLE_BATCH_ATOMIC_WRITE
|
||||||
|
|
||||||
// Because WASM does not support shared memory,
|
// Because Wasm does not support shared memory,
|
||||||
// SQLite disables WAL for WASM builds.
|
// SQLite disables WAL for Wasm builds.
|
||||||
// We patch SQLite to use exclusive locking mode instead.
|
// We patch SQLite to use exclusive locking mode instead.
|
||||||
// https://sqlite.org/wal.html#noshm
|
// https://sqlite.org/wal.html#noshm
|
||||||
#undef SQLITE_OMIT_WAL
|
#undef SQLITE_OMIT_WAL
|
||||||
|
|||||||
Reference in New Issue
Block a user