summaryrefslogtreecommitdiff
path: root/vendor/github.com/ncruces/go-sqlite3/registry.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/ncruces/go-sqlite3/registry.go')
-rw-r--r--vendor/github.com/ncruces/go-sqlite3/registry.go30
1 files changed, 30 insertions, 0 deletions
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
+}