diff options
author | EuAndreh <eu@euandre.org> | 2024-10-04 18:28:34 -0300 |
---|---|---|
committer | EuAndreh <eu@euandre.org> | 2024-10-05 03:03:29 -0300 |
commit | c7f1ec84eba5213ef5927b8c6300f43c47884da1 (patch) | |
tree | 3b2934d53fb4f13d6da07be5daccb9c3db0b4e43 /tests/functional/extension.go | |
parent | Makefile: Store and return bench timing data (diff) | |
download | golite-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 'tests/functional/extension.go')
-rw-r--r-- | tests/functional/extension.go | 79 |
1 files changed, 0 insertions, 79 deletions
diff --git a/tests/functional/extension.go b/tests/functional/extension.go deleted file mode 100644 index 81c4494..0000000 --- a/tests/functional/extension.go +++ /dev/null @@ -1,79 +0,0 @@ -package main - -import ( - "database/sql" - "fmt" - "log" - "os" - "reflect" - - "golite" -) - - - -func fatalif(err error) { - if err != nil { - log.Fatal(err) - } -} - -func eq(given any, expected any) { - if !reflect.DeepEqual(given, expected) { - fmt.Fprintf(os.Stderr, "given != expected\n") - fmt.Fprintf(os.Stderr, "given: %#v\n", given) - fmt.Fprintf(os.Stderr, "expected: %#v\n", expected) - } -} - - - -func main() { - driver := golite.SQLiteDriver{ - Extensions: []string{ - "streq", - }, - } - sql.Register("sqlite3-streq", &driver) - - db, err := sql.Open("sqlite3-streq", ":memory:") - fatalif(err) - defer db.Close() - - rows, err := db.Query(` - SELECT str, n FROM ( - SELECT 'hello' as str, 1 as n - UNION - SELECT 'not' as str, 2 as n - UNION - SELECT 'hello' as str, 3 as n - ) WHERE streq(str, 'hello'); - `) - fatalif(err) - defer rows.Close() - - type pairT struct{ - str string - id int - } - var pairs []pairT - for rows.Next() { - var pair pairT - err := rows.Scan(&pair.str, &pair.id) - fatalif(err) - pairs = append(pairs, pair) - } - fatalif(rows.Err()) - - expected := []pairT{ - pairT{ - str: "hello", - id: 1, - }, - pairT{ - str: "hello", - id: 3, - }, - } - eq(pairs, expected) -} |