diff --git a/go.mod b/go.mod index 2eb62c80d..c20cce74d 100644 --- a/go.mod +++ b/go.mod @@ -45,7 +45,7 @@ require ( github.com/miekg/dns v1.1.61 github.com/minio/minio-go/v7 v7.0.73 github.com/mitchellh/mapstructure v1.5.0 - github.com/ncruces/go-sqlite3 v0.17.0 + github.com/ncruces/go-sqlite3 v0.17.1 github.com/oklog/ulid v1.3.1 github.com/prometheus/client_golang v1.19.1 github.com/spf13/cobra v1.8.1 diff --git a/go.sum b/go.sum index 96fa75ee8..42087dc35 100644 --- a/go.sum +++ b/go.sum @@ -443,8 +443,8 @@ github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9G github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= 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/ncruces/go-sqlite3 v0.17.0 h1:tbrmwAF9Iq6O6i8NX+pO7rQYIwIJ4cZ/nZFQyw7GB18= -github.com/ncruces/go-sqlite3 v0.17.0/go.mod h1:Ik98tXgiGdF2HgHYZlEkh84RAC3U3eqgS7PYsmLwLxY= +github.com/ncruces/go-sqlite3 v0.17.1 h1:VxTjDpCn87FaFlKMaAYC1jP7ND0d4UNj+6G4IQDHbgI= +github.com/ncruces/go-sqlite3 v0.17.1/go.mod h1:FnCyui8SlDoL0mQZ5dTouNo7s7jXS0kJv9lBt1GlM9w= 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/conn.go b/vendor/github.com/ncruces/go-sqlite3/conn.go index f170ccf57..39870b140 100644 --- a/vendor/github.com/ncruces/go-sqlite3/conn.go +++ b/vendor/github.com/ncruces/go-sqlite3/conn.go @@ -72,6 +72,9 @@ func newConn(filename string, flags OpenFlag) (conn *Conn, err error) { c.arena = c.newArena(1024) c.ctx = context.WithValue(c.ctx, connKey{}, c) c.handle, err = c.openDB(filename, flags) + if err == nil { + err = initExtensions(c) + } if err != nil { return nil, err } diff --git a/vendor/github.com/ncruces/go-sqlite3/func.go b/vendor/github.com/ncruces/go-sqlite3/func.go index 255584a43..ab486e79a 100644 --- a/vendor/github.com/ncruces/go-sqlite3/func.go +++ b/vendor/github.com/ncruces/go-sqlite3/func.go @@ -31,8 +31,9 @@ func (c *Conn) CollationNeeded(cb func(db *Conn, name string)) error { // // This can be used to load schemas that contain // one or more unknown collating sequences. -func (c *Conn) AnyCollationNeeded() { - c.call("sqlite3_anycollseq_init", uint64(c.handle), 0, 0) +func (c Conn) AnyCollationNeeded() error { + r := c.call("sqlite3_anycollseq_init", uint64(c.handle), 0, 0) + return c.error(r) } // CreateCollation defines a new collating sequence. diff --git a/vendor/github.com/ncruces/go-sqlite3/internal/util/error.go b/vendor/github.com/ncruces/go-sqlite3/internal/util/error.go index 1f5555fd3..2aecac96e 100644 --- a/vendor/github.com/ncruces/go-sqlite3/internal/util/error.go +++ b/vendor/github.com/ncruces/go-sqlite3/internal/util/error.go @@ -104,3 +104,13 @@ func ErrorCodeString(rc uint32) string { } return "sqlite3: unknown error" } + +type ErrorJoiner []error + +func (j *ErrorJoiner) Join(errs ...error) { + for _, err := range errs { + if err != nil { + *j = append(*j, err) + } + } +} diff --git a/vendor/github.com/ncruces/go-sqlite3/registry.go b/vendor/github.com/ncruces/go-sqlite3/registry.go new file mode 100644 index 000000000..043d69eeb --- /dev/null +++ b/vendor/github.com/ncruces/go-sqlite3/registry.go @@ -0,0 +1,30 @@ +package sqlite3 + +import "sync" + +var ( + // +checklocks:extRegistryMtx + extRegistry []func(*Conn) error + extRegistryMtx sync.RWMutex +) + +// AutoExtension causes the entryPoint function to be invoked +// for each new database connection that is created. +// +// https://sqlite.org/c3ref/auto_extension.html +func AutoExtension(entryPoint func(*Conn) error) { + extRegistryMtx.Lock() + defer extRegistryMtx.Unlock() + extRegistry = append(extRegistry, entryPoint) +} + +func initExtensions(c *Conn) error { + extRegistryMtx.RLock() + defer extRegistryMtx.RUnlock() + for _, f := range extRegistry { + if err := f(c); err != nil { + return err + } + } + return nil +} diff --git a/vendor/modules.txt b/vendor/modules.txt index a001cb3d7..7ad1940b4 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -519,7 +519,7 @@ github.com/modern-go/concurrent # github.com/modern-go/reflect2 v1.0.2 ## explicit; go 1.12 github.com/modern-go/reflect2 -# github.com/ncruces/go-sqlite3 v0.17.0 +# github.com/ncruces/go-sqlite3 v0.17.1 ## explicit; go 1.21 github.com/ncruces/go-sqlite3 github.com/ncruces/go-sqlite3/driver