summaryrefslogtreecommitdiff
path: root/vendor/github.com/ncruces/go-sqlite3
diff options
context:
space:
mode:
authorLibravatar Daenney <daenney@users.noreply.github.com>2024-08-30 17:02:24 +0200
committerLibravatar GitHub <noreply@github.com>2024-08-30 17:02:24 +0200
commit1e0c858a05a627f76f3b6311e9e8ef35a654c161 (patch)
tree517c081a859ee61326f2d44582b276c3d1b469be /vendor/github.com/ncruces/go-sqlite3
parent[security] Implement `allowFiles` fs for better isolation of ffmpeg / ffprobe... (diff)
downloadgotosocial-1e0c858a05a627f76f3b6311e9e8ef35a654c161.tar.xz
[chore] Upgrade ncruces/go-sqlite3 to v0.18.1 (#3253)
Contains a fix for locking behaviour on the BSDs.
Diffstat (limited to 'vendor/github.com/ncruces/go-sqlite3')
-rw-r--r--vendor/github.com/ncruces/go-sqlite3/README.md14
-rw-r--r--vendor/github.com/ncruces/go-sqlite3/vfs/shm_bsd.go12
2 files changed, 25 insertions, 1 deletions
diff --git a/vendor/github.com/ncruces/go-sqlite3/README.md b/vendor/github.com/ncruces/go-sqlite3/README.md
index f6ceed14c..698b50bed 100644
--- a/vendor/github.com/ncruces/go-sqlite3/README.md
+++ b/vendor/github.com/ncruces/go-sqlite3/README.md
@@ -12,6 +12,20 @@ It wraps a [Wasm](https://webassembly.org/) [build](embed/) 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 [^1].
+### Getting started
+
+Using the [`database/sql`](https://pkg.go.dev/database/sql) driver:
+```go
+
+import "database/sql"
+import _ "github.com/ncruces/go-sqlite3/driver"
+import _ "github.com/ncruces/go-sqlite3/embed"
+
+var version string
+db, _ := sql.Open("sqlite3", "file:demo.db")
+db.QueryRow(`SELECT sqlite_version()`).Scan(&version)
+```
+
### Packages
- [`github.com/ncruces/go-sqlite3`](https://pkg.go.dev/github.com/ncruces/go-sqlite3)
diff --git a/vendor/github.com/ncruces/go-sqlite3/vfs/shm_bsd.go b/vendor/github.com/ncruces/go-sqlite3/vfs/shm_bsd.go
index 65674ed2e..089401156 100644
--- a/vendor/github.com/ncruces/go-sqlite3/vfs/shm_bsd.go
+++ b/vendor/github.com/ncruces/go-sqlite3/vfs/shm_bsd.go
@@ -121,8 +121,8 @@ func (s *vfsShm) shmOpen() (rc _ErrorCode) {
// Find a shared file, increase the reference count.
for _, g := range vfsShmFiles {
if g != nil && os.SameFile(fi, g.info) {
- g.refs++
s.vfsShmFile = g
+ g.refs++
return _OK
}
}
@@ -207,15 +207,22 @@ func (s *vfsShm) shmLock(offset, n int32, flags _ShmFlag) _ErrorCode {
case flags&_SHM_UNLOCK != 0:
for i := offset; i < offset+n; i++ {
if s.lock[i] {
+ if s.vfsShmFile.lock[i] == 0 {
+ panic(util.AssertErr())
+ }
if s.vfsShmFile.lock[i] <= 0 {
s.vfsShmFile.lock[i] = 0
} else {
s.vfsShmFile.lock[i]--
}
+ s.lock[i] = false
}
}
case flags&_SHM_SHARED != 0:
for i := offset; i < offset+n; i++ {
+ if s.lock[i] {
+ panic(util.AssertErr())
+ }
if s.vfsShmFile.lock[i] < 0 {
return _BUSY
}
@@ -226,6 +233,9 @@ func (s *vfsShm) shmLock(offset, n int32, flags _ShmFlag) _ErrorCode {
}
case flags&_SHM_EXCLUSIVE != 0:
for i := offset; i < offset+n; i++ {
+ if s.lock[i] {
+ panic(util.AssertErr())
+ }
if s.vfsShmFile.lock[i] != 0 {
return _BUSY
}