From 1e0c858a05a627f76f3b6311e9e8ef35a654c161 Mon Sep 17 00:00:00 2001 From: Daenney Date: Fri, 30 Aug 2024 17:02:24 +0200 Subject: [PATCH] [chore] Upgrade ncruces/go-sqlite3 to v0.18.1 (#3253) Contains a fix for locking behaviour on the BSDs. --- go.mod | 2 +- go.sum | 4 ++-- vendor/github.com/ncruces/go-sqlite3/README.md | 14 ++++++++++++++ .../github.com/ncruces/go-sqlite3/vfs/shm_bsd.go | 12 +++++++++++- vendor/modules.txt | 2 +- 5 files changed, 29 insertions(+), 5 deletions(-) diff --git a/go.mod b/go.mod index e0c0b2d9f..28c1a4e09 100644 --- a/go.mod +++ b/go.mod @@ -45,7 +45,7 @@ require ( github.com/miekg/dns v1.1.62 github.com/minio/minio-go/v7 v7.0.75 github.com/mitchellh/mapstructure v1.5.0 - github.com/ncruces/go-sqlite3 v0.18.0 + github.com/ncruces/go-sqlite3 v0.18.1 github.com/oklog/ulid v1.3.1 github.com/prometheus/client_golang v1.20.2 github.com/spf13/cobra v1.8.1 diff --git a/go.sum b/go.sum index 0ffca9fca..d76d57b49 100644 --- a/go.sum +++ b/go.sum @@ -442,8 +442,8 @@ github.com/moul/http2curl v1.0.0 h1:dRMWoAtb+ePxMlLkrCbAqh4TlPHXvoGUSQ323/9Zahs= github.com/moul/http2curl v1.0.0/go.mod h1:8UbvGypXm98wA/IqH45anm5Y2Z6ep6O31QGOAZ3H0fQ= github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA= github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= -github.com/ncruces/go-sqlite3 v0.18.0 h1:aH7WGzOC0CYpUPG1LdFg7JApybiuXgYUE2itzLBwhPM= -github.com/ncruces/go-sqlite3 v0.18.0/go.mod h1:eEOyZnW1dGTJ+zDpMuzfYamEUBtdFz5zeYhqLBtHxvM= +github.com/ncruces/go-sqlite3 v0.18.1 h1:iN8IMZV5EMxpH88NUac9vId23eTKNFUhP7jgY0EBbNc= +github.com/ncruces/go-sqlite3 v0.18.1/go.mod h1:eEOyZnW1dGTJ+zDpMuzfYamEUBtdFz5zeYhqLBtHxvM= github.com/ncruces/go-strftime v0.1.9 h1:bY0MQC28UADQmHmaF5dgpLmImcShSi2kHU9XLdhx/f4= github.com/ncruces/go-strftime v0.1.9/go.mod h1:Fwc5htZGVVkseilnfgOVb9mKy6w1naJmn9CehxcKcls= github.com/ncruces/julianday v1.0.0 h1:fH0OKwa7NWvniGQtxdJRxAgkBMolni2BjDHaWTxqt7M= 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 } diff --git a/vendor/modules.txt b/vendor/modules.txt index 0f0fc7ff6..612d8a0f7 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -526,7 +526,7 @@ github.com/modern-go/reflect2 # github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 ## explicit github.com/munnerz/goautoneg -# github.com/ncruces/go-sqlite3 v0.18.0 +# github.com/ncruces/go-sqlite3 v0.18.1 ## explicit; go 1.21 github.com/ncruces/go-sqlite3 github.com/ncruces/go-sqlite3/driver