aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEuAndreh <eu@euandre.org>2024-10-04 18:28:34 -0300
committerEuAndreh <eu@euandre.org>2024-10-05 03:03:29 -0300
commitc7f1ec84eba5213ef5927b8c6300f43c47884da1 (patch)
tree3b2934d53fb4f13d6da07be5daccb9c3db0b4e43 /src
parentMakefile: Store and return bench timing data (diff)
downloadgolite-c7f1ec84eba5213ef5927b8c6300f43c47884da1.tar.gz
golite-c7f1ec84eba5213ef5927b8c6300f43c47884da1.tar.xz
Remove support for dynamically loading extensions
Defer to the user to (statically) include the extension with the rest of the code, and manually registering it, as described in [0]. If support for dynamic libraries and run-time dynamism in general is desired, one shouldn't be looking for it in C or Go, who aren't the greatest bastions of such dynamism, and instead consider more appropriate languages, like Common Lisp or Smalltalk. [0]: https://sqlite.org/loadext.html#statically_linking_a_run_time_loadable_extension
Diffstat (limited to 'src')
-rw-r--r--src/golite.go70
1 files changed, 0 insertions, 70 deletions
diff --git a/src/golite.go b/src/golite.go
index cfc1484..d40d393 100644
--- a/src/golite.go
+++ b/src/golite.go
@@ -1128,7 +1128,6 @@ const (
// SQLiteDriver implements driver.Driver.
type SQLiteDriver struct {
- Extensions []string
ConnectHook func(*SQLiteConn) error
}
@@ -2134,13 +2133,6 @@ func (d *SQLiteDriver) Open(dsn string) (driver.Conn, error) {
}
}
- if len(d.Extensions) > 0 {
- if err := conn.loadExtensions(d.Extensions); err != nil {
- conn.Close()
- return nil, err
- }
- }
-
if d.ConnectHook != nil {
if err := d.ConnectHook(conn); err != nil {
conn.Close()
@@ -2791,68 +2783,6 @@ func (s *SQLiteStmt) ExecContext(ctx context.Context, args []driver.NamedValue)
return s.exec(ctx, args)
}
-func (c *SQLiteConn) loadExtensions(extensions []string) error {
- rv := C.sqlite3_enable_load_extension(c.db, 1)
- if rv != C.SQLITE_OK {
- return errors.New(C.GoString(C.sqlite3_errmsg(c.db)))
- }
-
- for _, extension := range extensions {
- if err := c.loadExtension(extension, nil); err != nil {
- C.sqlite3_enable_load_extension(c.db, 0)
- return err
- }
- }
-
- rv = C.sqlite3_enable_load_extension(c.db, 0)
- if rv != C.SQLITE_OK {
- return errors.New(C.GoString(C.sqlite3_errmsg(c.db)))
- }
-
- return nil
-}
-
-// LoadExtension load the sqlite3 extension.
-func (c *SQLiteConn) LoadExtension(lib string, entry string) error {
- rv := C.sqlite3_enable_load_extension(c.db, 1)
- if rv != C.SQLITE_OK {
- return errors.New(C.GoString(C.sqlite3_errmsg(c.db)))
- }
-
- if err := c.loadExtension(lib, &entry); err != nil {
- C.sqlite3_enable_load_extension(c.db, 0)
- return err
- }
-
- rv = C.sqlite3_enable_load_extension(c.db, 0)
- if rv != C.SQLITE_OK {
- return errors.New(C.GoString(C.sqlite3_errmsg(c.db)))
- }
-
- return nil
-}
-
-func (c *SQLiteConn) loadExtension(lib string, entry *string) error {
- clib := C.CString(lib)
- defer C.free(unsafe.Pointer(clib))
-
- var centry *C.char
- if entry != nil {
- centry = C.CString(*entry)
- defer C.free(unsafe.Pointer(centry))
- }
-
- var errMsg *C.char
- defer C.sqlite3_free(unsafe.Pointer(errMsg))
-
- rv := C.sqlite3_load_extension(c.db, clib, centry, &errMsg)
- if rv != C.SQLITE_OK {
- return errors.New(C.GoString(errMsg))
- }
-
- return nil
-}
-
// ColumnTableName returns the table that is the origin of a particular result
// column in a SELECT statement.
//