diff --git a/go.mod b/go.mod index a94500d69..bae440989 100644 --- a/go.mod +++ b/go.mod @@ -54,7 +54,7 @@ require ( github.com/miekg/dns v1.1.66 github.com/minio/minio-go/v7 v7.0.92 github.com/mitchellh/mapstructure v1.5.0 - github.com/ncruces/go-sqlite3 v0.25.2 + github.com/ncruces/go-sqlite3 v0.26.0 github.com/oklog/ulid v1.3.1 github.com/pquerna/otp v1.5.0 github.com/rivo/uniseg v0.4.7 diff --git a/go.sum b/go.sum index 5122770f3..9e58407f9 100644 --- a/go.sum +++ b/go.sum @@ -328,6 +328,8 @@ github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= github.com/ncruces/go-sqlite3 v0.25.2 h1:suu3C7y92hPqozqO8+w3K333Q1VhWyN6K3JJKXdtC2U= github.com/ncruces/go-sqlite3 v0.25.2/go.mod h1:46HIzeCQQ+aNleAxCli+vpA2tfh7ttSnw24kQahBc1o= +github.com/ncruces/go-sqlite3 v0.26.0 h1:dY6ASfuhSEbtSge6kJwjyJVC7bXCpgEVOycmdboKJek= +github.com/ncruces/go-sqlite3 v0.26.0/go.mod h1:46HIzeCQQ+aNleAxCli+vpA2tfh7ttSnw24kQahBc1o= 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 94fd9950b..dd81b291c 100644 --- a/vendor/github.com/ncruces/go-sqlite3/README.md +++ b/vendor/github.com/ncruces/go-sqlite3/README.md @@ -30,10 +30,10 @@ db.QueryRow(`SELECT sqlite_version()`).Scan(&version) - [`github.com/ncruces/go-sqlite3`](https://pkg.go.dev/github.com/ncruces/go-sqlite3) wraps the [C SQLite API](https://sqlite.org/cintro.html) - ([example usage](https://pkg.go.dev/github.com/ncruces/go-sqlite3#example-package)). + ([example](https://pkg.go.dev/github.com/ncruces/go-sqlite3#example-package)). - [`github.com/ncruces/go-sqlite3/driver`](https://pkg.go.dev/github.com/ncruces/go-sqlite3/driver) provides a [`database/sql`](https://pkg.go.dev/database/sql) driver - ([example usage](https://pkg.go.dev/github.com/ncruces/go-sqlite3/driver#example-package)). + ([example](https://pkg.go.dev/github.com/ncruces/go-sqlite3/driver#example-package)). - [`github.com/ncruces/go-sqlite3/embed`](https://pkg.go.dev/github.com/ncruces/go-sqlite3/embed) embeds a build of SQLite into your application. - [`github.com/ncruces/go-sqlite3/vfs`](https://pkg.go.dev/github.com/ncruces/go-sqlite3/vfs) @@ -44,12 +44,19 @@ db.QueryRow(`SELECT sqlite_version()`).Scan(&version) ### Advanced features - [incremental BLOB I/O](https://sqlite.org/c3ref/blob_open.html) + ([example](https://pkg.go.dev/github.com/ncruces/go-sqlite3/ext/blobio#example-package)) - [nested transactions](https://sqlite.org/lang_savepoint.html) + ([example](https://pkg.go.dev/github.com/ncruces/go-sqlite3/driver#example-Savepoint)) - [custom functions](https://sqlite.org/c3ref/create_function.html) + ([example](https://pkg.go.dev/github.com/ncruces/go-sqlite3#example-Conn.CreateFunction)) - [virtual tables](https://sqlite.org/vtab.html) + ([example](https://pkg.go.dev/github.com/ncruces/go-sqlite3#example-CreateModule)) - [custom VFSes](https://sqlite.org/vfs.html) + ([examples](vfs/README.md#custom-vfses)) - [online backup](https://sqlite.org/backup.html) + ([example](https://pkg.go.dev/github.com/ncruces/go-sqlite3/driver#Conn)) - [JSON support](https://sqlite.org/json1.html) + ([example](https://pkg.go.dev/github.com/ncruces/go-sqlite3/driver#example-package-Json)) - [math functions](https://sqlite.org/lang_mathfunc.html) - [full-text search](https://sqlite.org/fts5.html) - [geospatial search](https://sqlite.org/geopoly.html) @@ -57,7 +64,6 @@ db.QueryRow(`SELECT sqlite_version()`).Scan(&version) - [statistics functions](https://pkg.go.dev/github.com/ncruces/go-sqlite3/ext/stats) - [encryption at rest](vfs/adiantum/README.md) - [many extensions](ext/README.md) -- [custom VFSes](vfs/README.md#custom-vfses) - [and more…](embed/README.md) ### Caveats @@ -77,10 +83,19 @@ It also benefits greatly from [SQLite's](https://sqlite.org/testing.html) and [wazero's](https://tetrate.io/blog/introducing-wazero-from-tetrate/#:~:text=Rock%2Dsolid%20test%20approach) thorough testing. -Every commit is [tested](https://github.com/ncruces/go-sqlite3/wiki/Support-matrix) on -Linux (amd64/arm64/386/riscv64/ppc64le/s390x), macOS (arm64/amd64), -Windows (amd64), FreeBSD (amd64/arm64), OpenBSD (amd64), NetBSD (amd64/arm64), -DragonFly BSD (amd64), illumos (amd64), and Solaris (amd64). +Every commit is tested on: +* Linux: amd64, arm64, 386, riscv64, ppc64le, s390x +* macOS: amd64, arm64 +* Windows: amd64 +* BSD: + * FreeBSD: amd64, arm64 + * OpenBSD: amd64 + * NetBSD: amd64, arm64 + * DragonFly BSD: amd64 +* illumos: amd64 +* Solaris: amd64 + +Certain operating system and CPU combinations have some limitations. See the [support matrix](https://github.com/ncruces/go-sqlite3/wiki/Support-matrix) for a complete overview. The Go VFS is tested by running SQLite's [mptest](https://github.com/sqlite/sqlite/blob/master/mptest/mptest.c). @@ -118,4 +133,4 @@ and features we're working on, planning to work on, or asking for help with. - [`modernc.org/sqlite`](https://pkg.go.dev/modernc.org/sqlite) - [`crawshaw.io/sqlite`](https://pkg.go.dev/crawshaw.io/sqlite) - [`github.com/mattn/go-sqlite3`](https://pkg.go.dev/github.com/mattn/go-sqlite3) -- [`github.com/zombiezen/go-sqlite`](https://pkg.go.dev/github.com/zombiezen/go-sqlite) \ No newline at end of file +- [`github.com/zombiezen/go-sqlite`](https://pkg.go.dev/github.com/zombiezen/go-sqlite) diff --git a/vendor/github.com/ncruces/go-sqlite3/config.go b/vendor/github.com/ncruces/go-sqlite3/config.go index 3921fe98a..153fbd654 100644 --- a/vendor/github.com/ncruces/go-sqlite3/config.go +++ b/vendor/github.com/ncruces/go-sqlite3/config.go @@ -109,7 +109,7 @@ func (c *Conn) FileControl(schema string, op FcntlOpcode, arg ...any) (any, erro default: return nil, MISUSE - case FCNTL_RESET_CACHE: + case FCNTL_RESET_CACHE, FCNTL_NULL_IO: rc = res_t(c.call("sqlite3_file_control", stk_t(c.handle), stk_t(schemaPtr), stk_t(op), 0)) diff --git a/vendor/github.com/ncruces/go-sqlite3/const.go b/vendor/github.com/ncruces/go-sqlite3/const.go index 522f68bfb..e4fc8297c 100644 --- a/vendor/github.com/ncruces/go-sqlite3/const.go +++ b/vendor/github.com/ncruces/go-sqlite3/const.go @@ -280,6 +280,7 @@ const ( FCNTL_DATA_VERSION FcntlOpcode = 35 FCNTL_RESERVE_BYTES FcntlOpcode = 38 FCNTL_RESET_CACHE FcntlOpcode = 42 + FCNTL_NULL_IO FcntlOpcode = 43 ) // LimitCategory are the available run-time limit categories. diff --git a/vendor/github.com/ncruces/go-sqlite3/context.go b/vendor/github.com/ncruces/go-sqlite3/context.go index abee4ec1e..7caf58626 100644 --- a/vendor/github.com/ncruces/go-sqlite3/context.go +++ b/vendor/github.com/ncruces/go-sqlite3/context.go @@ -177,12 +177,15 @@ func (ctx Context) ResultPointer(ptr any) { // // https://sqlite.org/c3ref/result_blob.html func (ctx Context) ResultJSON(value any) { - data, err := json.Marshal(value) + err := json.NewEncoder(callbackWriter(func(p []byte) (int, error) { + ctx.ResultRawText(p[:len(p)-1]) // remove the newline + return 0, nil + })).Encode(value) + if err != nil { ctx.ResultError(err) return // notest } - ctx.ResultRawText(data) } // ResultValue sets the result of the function to a copy of [Value]. diff --git a/vendor/github.com/ncruces/go-sqlite3/embed/README.md b/vendor/github.com/ncruces/go-sqlite3/embed/README.md index 1a2d575bb..ba279a60b 100644 --- a/vendor/github.com/ncruces/go-sqlite3/embed/README.md +++ b/vendor/github.com/ncruces/go-sqlite3/embed/README.md @@ -1,6 +1,6 @@ # Embeddable Wasm build of SQLite -This folder includes an embeddable Wasm build of SQLite 3.49.2 for use with +This folder includes an embeddable Wasm build of SQLite 3.50.0 for use with [`github.com/ncruces/go-sqlite3`](https://pkg.go.dev/github.com/ncruces/go-sqlite3). The following optional features are compiled in: diff --git a/vendor/github.com/ncruces/go-sqlite3/embed/build.sh b/vendor/github.com/ncruces/go-sqlite3/embed/build.sh index 88e12be31..c96a18653 100644 --- a/vendor/github.com/ncruces/go-sqlite3/embed/build.sh +++ b/vendor/github.com/ncruces/go-sqlite3/embed/build.sh @@ -14,9 +14,9 @@ trap 'rm -f sqlite3.tmp' EXIT -o sqlite3.wasm "$ROOT/sqlite3/main.c" \ -I"$ROOT/sqlite3/libc" -I"$ROOT/sqlite3" \ -mexec-model=reactor \ - -msimd128 -mmutable-globals -mmultivalue \ - -mbulk-memory -mreference-types \ - -mnontrapping-fptoint -msign-ext \ + -mmutable-globals -mnontrapping-fptoint \ + -msimd128 -mbulk-memory -msign-ext \ + -mreference-types -mmultivalue \ -fno-stack-protector -fno-stack-clash-protection \ -Wl,--stack-first \ -Wl,--import-undefined \ @@ -28,6 +28,6 @@ trap 'rm -f sqlite3.tmp' EXIT "$BINARYEN/wasm-ctor-eval" -g -c _initialize sqlite3.wasm -o sqlite3.tmp "$BINARYEN/wasm-opt" -g --strip --strip-producers -c -O3 \ sqlite3.tmp -o sqlite3.wasm --low-memory-unused \ - --enable-simd --enable-mutable-globals --enable-multivalue \ - --enable-bulk-memory --enable-reference-types \ - --enable-nontrapping-float-to-int --enable-sign-ext \ No newline at end of file + --enable-mutable-globals --enable-nontrapping-float-to-int \ + --enable-simd --enable-bulk-memory --enable-sign-ext \ + --enable-reference-types --enable-multivalue \ No newline at end of file diff --git a/vendor/github.com/ncruces/go-sqlite3/embed/sqlite3.wasm b/vendor/github.com/ncruces/go-sqlite3/embed/sqlite3.wasm index 44f667926..c596e63e4 100644 Binary files a/vendor/github.com/ncruces/go-sqlite3/embed/sqlite3.wasm and b/vendor/github.com/ncruces/go-sqlite3/embed/sqlite3.wasm differ diff --git a/vendor/github.com/ncruces/go-sqlite3/stmt.go b/vendor/github.com/ncruces/go-sqlite3/stmt.go index 7fa2a504d..363b45af2 100644 --- a/vendor/github.com/ncruces/go-sqlite3/stmt.go +++ b/vendor/github.com/ncruces/go-sqlite3/stmt.go @@ -367,11 +367,9 @@ func (s *Stmt) BindPointer(param int, ptr any) error { // // https://sqlite.org/c3ref/bind_blob.html func (s *Stmt) BindJSON(param int, value any) error { - data, err := json.Marshal(value) - if err != nil { - return err - } - return s.BindRawText(param, data) + return json.NewEncoder(callbackWriter(func(p []byte) (int, error) { + return 0, s.BindRawText(param, p[:len(p)-1]) // remove the newline + })).Encode(value) } // BindValue binds a copy of value to the prepared statement. @@ -751,3 +749,7 @@ func (s *Stmt) columns(count int64) ([]byte, ptr_t, error) { return util.View(s.c.mod, typePtr, count), dataPtr, nil } + +type callbackWriter func(p []byte) (int, error) + +func (fn callbackWriter) Write(p []byte) (int, error) { return fn(p) } diff --git a/vendor/github.com/ncruces/go-sqlite3/vfs/const.go b/vendor/github.com/ncruces/go-sqlite3/vfs/const.go index b789d1203..11afb1254 100644 --- a/vendor/github.com/ncruces/go-sqlite3/vfs/const.go +++ b/vendor/github.com/ncruces/go-sqlite3/vfs/const.go @@ -234,6 +234,7 @@ const ( _FCNTL_CKSM_FILE _FcntlOpcode = 41 _FCNTL_RESET_CACHE _FcntlOpcode = 42 _FCNTL_NULL_IO _FcntlOpcode = 43 + _FCNTL_BLOCK_ON_CONNECT _FcntlOpcode = 44 ) // https://sqlite.org/c3ref/c_shm_exclusive.html @@ -246,6 +247,6 @@ const ( _SHM_EXCLUSIVE _ShmFlag = 8 _SHM_NLOCK = 8 - _SHM_BASE = 120 + _SHM_BASE = (22 + _SHM_NLOCK) * 4 _SHM_DMS = _SHM_BASE + _SHM_NLOCK ) diff --git a/vendor/github.com/ncruces/go-sqlite3/vfs/file.go b/vendor/github.com/ncruces/go-sqlite3/vfs/file.go index 65409823c..8e65ca660 100644 --- a/vendor/github.com/ncruces/go-sqlite3/vfs/file.go +++ b/vendor/github.com/ncruces/go-sqlite3/vfs/file.go @@ -13,22 +13,28 @@ import ( type vfsOS struct{} func (vfsOS) FullPathname(path string) (string, error) { - path, err := filepath.Abs(path) + link, err := evalSymlinks(path) if err != nil { return "", err } - return path, testSymlinks(filepath.Dir(path)) + full, err := filepath.Abs(link) + if err == nil && link != path { + err = _OK_SYMLINK + } + return full, err } -func testSymlinks(path string) error { - p, err := filepath.EvalSymlinks(path) +func evalSymlinks(path string) (string, error) { + var file string + _, err := os.Lstat(path) + if errors.Is(err, fs.ErrNotExist) { + path, file = filepath.Split(path) + } + path, err = filepath.EvalSymlinks(path) if err != nil { - return err + return "", err } - if p != path { - return _OK_SYMLINK - } - return nil + return filepath.Join(path, file), nil } func (vfsOS) Delete(path string, syncDir bool) error { diff --git a/vendor/github.com/ncruces/go-sqlite3/vfs/memdb/memdb.go b/vendor/github.com/ncruces/go-sqlite3/vfs/memdb/memdb.go index 419fd1c64..94347f1cc 100644 --- a/vendor/github.com/ncruces/go-sqlite3/vfs/memdb/memdb.go +++ b/vendor/github.com/ncruces/go-sqlite3/vfs/memdb/memdb.go @@ -28,9 +28,8 @@ func (memVFS) Open(name string, flags vfs.OpenFlag) (vfs.File, vfs.OpenFlag, err // // We refuse to open all other file types, // but returning OPEN_MEMORY means SQLite won't ask us to. - const types = vfs.OPEN_MAIN_DB | - vfs.OPEN_TEMP_DB | - vfs.OPEN_TEMP_JOURNAL + const types = vfs.OPEN_MAIN_DB | vfs.OPEN_TEMP_DB | + vfs.OPEN_TRANSIENT_DB | vfs.OPEN_TEMP_JOURNAL if flags&types == 0 { // notest // OPEN_MEMORY return nil, flags, sqlite3.CANTOPEN diff --git a/vendor/github.com/ncruces/go-sqlite3/vfs/shm_windows.go b/vendor/github.com/ncruces/go-sqlite3/vfs/shm_windows.go index 7cc5b2a23..0be523ad6 100644 --- a/vendor/github.com/ncruces/go-sqlite3/vfs/shm_windows.go +++ b/vendor/github.com/ncruces/go-sqlite3/vfs/shm_windows.go @@ -26,7 +26,6 @@ type vfsShm struct { ptrs []ptr_t stack [1]stk_t fileLock bool - blocking bool sync.Mutex } diff --git a/vendor/github.com/ncruces/go-sqlite3/vfs/vfs.go b/vendor/github.com/ncruces/go-sqlite3/vfs/vfs.go index c70507caa..2656ddb49 100644 --- a/vendor/github.com/ncruces/go-sqlite3/vfs/vfs.go +++ b/vendor/github.com/ncruces/go-sqlite3/vfs/vfs.go @@ -381,6 +381,10 @@ func vfsFileControlImpl(ctx context.Context, mod api.Module, file File, op _Fcnt file.SetDB(ctx.Value(util.ConnKey{})) return _OK } + + case _FCNTL_NULL_IO: + file.Close() + return _OK } return _NOTFOUND diff --git a/vendor/modules.txt b/vendor/modules.txt index 80fd676ee..dfeb502bd 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -713,7 +713,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.25.2 +# github.com/ncruces/go-sqlite3 v0.26.0 ## explicit; go 1.23.0 github.com/ncruces/go-sqlite3 github.com/ncruces/go-sqlite3/driver