aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore15
-rw-r--r--Makefile86
-rw-r--r--README.md4
-rw-r--r--deps.mk100
-rwxr-xr-xmkdeps.sh29
-rw-r--r--src/acudego.go6
-rw-r--r--tests/acudego.go142
-rw-r--r--tests/benchmarks/exec/acudego.go (renamed from tests/benchmarks/exec.go)14
l---------tests/benchmarks/exec/main.go1
-rw-r--r--tests/benchmarks/query/acudego.go (renamed from tests/benchmarks/query.go)14
l---------tests/benchmarks/query/main.go1
-rw-r--r--tests/functional/json/acudego.go (renamed from tests/functional/json.go)12
l---------tests/functional/json/main.go1
-rw-r--r--tests/functional/libbuild.go19
-rw-r--r--tests/functional/limit/acudego.go (renamed from tests/functional/limit.go)20
l---------tests/functional/limit/main.go1
-rw-r--r--tests/fuzz/api/acudego.go (renamed from tests/fuzz/api.go)4
l---------tests/fuzz/api/main.go1
18 files changed, 241 insertions, 229 deletions
diff --git a/.gitignore b/.gitignore
index a2c3555..d767e4b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,10 +3,11 @@
/src/*cgo*
/tests/*.a
/tests/*.bin
-/tests/functional/*.a
-/tests/functional/*.bin
-/tests/fuzz/*.a
-/tests/fuzz/*.bin
-/tests/benchmarks/*.a
-/tests/benchmarks/*.bin
-/tests/benchmarks/*.txt
+/tests/functional/*/*.a
+/tests/functional/*/*.bin
+/tests/fuzz/*/*.a
+/tests/fuzz/*/*.bin
+/tests/benchmarks/*/*.a
+/tests/benchmarks/*/*.bin
+/tests/benchmarks/*/*.txt
+/tests/fuzz/corpus/
diff --git a/Makefile b/Makefile
index dcaf826..4267fa3 100644
--- a/Makefile
+++ b/Makefile
@@ -17,7 +17,7 @@ MANDIR = $(SHAREDIR)/man
EXEC = ./
## Where to store the installation. Empty by default.
DESTDIR =
-LDLIBS = --static -lacude -lm
+LDLIBS = --static -lsqlite3 -lm
GOCFLAGS = -I $(GOLIBDIR)
GOLDFLAGS = -L $(GOLIBDIR)
@@ -29,18 +29,26 @@ GOLDFLAGS = -L $(GOLIBDIR)
.c.o:
$(CC) $(CFLAGS) -o $@ -c $<
+.go.a:
+ go tool compile $(GOCFLAGS) -I $(@D) -o $@ -p $(*F) \
+ `find $< $$(if [ $(*F) != main ]; then \
+ echo src/$(NAME).go src/version.go; fi) | uniq`
+
+.a.bin:
+ go tool link $(GOLDFLAGS) -L $(@D) -o $@ --extldflags '$(LDLIBS)' $<
+
all:
include deps.mk
-functional-tests.a = $(functional-tests.go:.go=.a)
-functional-tests.bin = $(functional-tests.go:.go=.bin)
-fuzz-targets.a = $(fuzz-targets.go:.go=.a)
-fuzz-targets.bin = $(fuzz-targets.go:.go=.bin)
-benchmarks.a = $(benchmarks.go:.go=.a)
-benchmarks.bin = $(benchmarks.go:.go=.bin)
+libs.a = $(libs.go:.go=.a)
+mains.a = $(mains.go:.go=.a)
+mains.bin = $(mains.go:.go=.bin)
+functional-tests/lib.a = $(functional-tests/lib.go:.go=.a)
+fuzz-targets/lib.a = $(fuzz-targets/lib.go:.go=.a)
+benchmarks/lib.a = $(benchmarks/lib.go:.go=.a)
cgo.go = \
src/_cgo_import.go \
@@ -58,12 +66,6 @@ objects = \
$(cgo.go) \
$(cgo.c) \
$(cgo.o) \
- src/$(NAME).a \
- tests/$(NAME).a \
- tests/main.a \
- $(functional-tests.a) \
- $(fuzz-targets.a) \
- $(benchmarks.a) \
sources = \
src/$(NAME).go \
@@ -73,15 +75,15 @@ sources = \
derived-assets = \
src/version.go \
$(objects) \
- tests/main.bin \
- $(functional-tests.bin) \
- $(fuzz-targets.bin) \
- $(benchmarks.bin) \
+ $(libs.a) \
+ $(mains.a) \
+ $(mains.bin) \
side-assets = \
src/_cgo_export.h \
src/_cgo_main.c \
- tests/benchmarks/*.txt \
+ tests/fuzz/corpus/ \
+ tests/benchmarks/*/main.txt \
@@ -91,11 +93,12 @@ all: $(derived-assets)
$(objects): Makefile deps.mk
+$(libs.a): Makefile deps.mk
+$(libs.a): src/$(NAME).go src/version.go
+$(libs.a): $(cgo.go) $(cgo.o)
$(cgo.go) $(cgo.c) $(cgo.o): src/_cgo_.o
-$(functional-tests.a) $(fuzz-targets.a) $(benchmarks.a): src/$(NAME).a
-
src/_cgo_.o: src/$(NAME).go
go tool cgo --objdir $(@D) src/$(NAME).go
@@ -103,40 +106,25 @@ src/_cgo_.o: src/$(NAME).go
src/_cgo_import.go: src/_cgo_.o
go tool cgo --dynpackage $(NAME) --dynimport src/_cgo_.o --dynout $@
-src/$(NAME).a: $(cgo.go) $(cgo.o) src/version.go
- go tool compile $(GOCFLAGS) -o $@ -p $(*F) $(cgo.go) src/version.go
+src/$(NAME).a tests/$(NAME).a $(functional-tests/lib.a) $(benchmarks/lib.a):
+ go tool compile $(GOCFLAGS) -o $@ -p $(*F) $(cgo.go) src/version.go \
+ `find $*.go | grep -Ev '^src/$(NAME)\.go$$'`
go tool pack r $@ $(cgo.o)
-tests/$(NAME).a: $(cgo.go) $(cgo.o) src/version.go tests/$(NAME).go
- go tool compile $(GOCFLAGS) -o $@ -p $(*F) $(cgo.go) src/version.go $*.go
+$(fuzz-targets/lib.a):
+ go tool compile $(GOCFLAGS) -o $@ -p $(NAME) -d=libfuzzer \
+ $*.go $(cgo.go) src/version.go
go tool pack r $@ $(cgo.o)
-tests/main.a: tests/main.go tests/$(NAME).a
- go tool compile $(GOCFLAGS) -o $@ -p $(*F) -I $(@D) $*.go
-
-tests/main.bin: tests/main.a
- go tool link $(GOLDFLAGS) -o $@ -L $(@D) --extldflags '$(LDLIBS)' $*.a
-
src/version.go: Makefile
echo 'package $(NAME); const Version = "$(VERSION)"' > $@
-$(functional-tests.a) $(benchmarks.a):
- go tool compile $(GOCFLAGS) -o $@ -p main -I src $*.go
-
-$(fuzz-targets.a):
- go tool compile -d=libfuzzer $(GOCFLAGS) -o $@ -p main -I src $*.go
-
-$(functional-tests.bin) $(fuzz-targets.bin) $(benchmarks.bin):
- go tool link $(GOLDFLAGS) -o $@ -L src --extldflags '$(LDLIBS)' $*.a
-
-functional-tests.bin-check = $(functional-tests.go:.go=.bin-check)
tests.bin-check = \
- tests/main.bin-check \
- $(functional-tests.bin-check) \
+ tests/main.bin-check \
+ $(functional-tests/main.go:.go=.bin-check) \
-tests/main.bin-check: tests/main.bin
$(tests.bin-check):
$(EXEC)$*.bin
@@ -162,23 +150,23 @@ check: check-unit check-integration
FUZZSEC=1
-fuzz-targets.bin-check = $(fuzz-targets.go:.go=.bin-check)
-$(fuzz-targets.bin-check):
+fuzz-targets/main.bin-check = $(fuzz-targets/main.go:.go=.bin-check)
+$(fuzz-targets/main.bin-check):
$(EXEC)$*.bin --test.fuzztime=$(FUZZSEC)s \
--test.fuzz='.*' --test.fuzzcachedir=tests/fuzz/corpus
-fuzz: $(fuzz-targets.bin-check)
+fuzz: $(fuzz-targets/main.bin-check)
-benchmarks.bin-check = $(benchmarks.go:.go=.bin-check)
-$(benchmarks.bin-check):
+benchmarks/main.bin-check = $(benchmarks/main.go:.go=.bin-check)
+$(benchmarks/main.bin-check):
rm -f $*.txt
printf '%s\n' '$(EXEC)$*.bin' >> $*.txt
LANG=POSIX.UTF-8 time -p $(EXEC)$*.bin 2>> $*.txt
printf '%s\n' '$*.txt'
-bench: $(benchmarks.bin-check)
+bench: $(benchmarks/main.bin-check)
diff --git a/README.md b/README.md
index 84ec50f..7f63746 100644
--- a/README.md
+++ b/README.md
@@ -506,7 +506,7 @@ For an example, see [dinedal/go-sqlite3-extension-functions](https://github.com/
- Why I'm getting `no such table` error?
- Why is it racy if I use a `sql.Open("acudego", ":memory:")` database?
+ Why is it racy if I use a `sql.Open("acude", ":memory:")` database?
Each connection to `":memory:"` opens a brand new in-memory sql database, so if
the stdlib's sql engine happens to open another connection and you've only
@@ -545,7 +545,7 @@ For an example, see [dinedal/go-sqlite3-extension-functions](https://github.com/
Example:
```go
- db, err := sql.Open("acudego", "file:locked.sqlite?cache=shared")
+ db, err := sql.Open("acude", "file:locked.sqlite?cache=shared")
```
Next, please set the database connections of the SQL package to 1:
diff --git a/deps.mk b/deps.mk
index 8818497..5be3ee3 100644
--- a/deps.mk
+++ b/deps.mk
@@ -1,30 +1,70 @@
-functional-tests.go = \
- tests/functional/json.go \
- tests/functional/libbuild.go \
- tests/functional/limit.go \
-
-fuzz-targets.go = \
- tests/fuzz/api.go \
-
-benchmarks.go = \
- tests/benchmarks/exec.go \
- tests/benchmarks/query.go \
-
-tests/benchmarks/exec.a: tests/benchmarks/exec.go
-tests/benchmarks/query.a: tests/benchmarks/query.go
-tests/functional/json.a: tests/functional/json.go
-tests/functional/libbuild.a: tests/functional/libbuild.go
-tests/functional/limit.a: tests/functional/limit.go
-tests/fuzz/api.a: tests/fuzz/api.go
-tests/benchmarks/exec.bin: tests/benchmarks/exec.a
-tests/benchmarks/query.bin: tests/benchmarks/query.a
-tests/functional/json.bin: tests/functional/json.a
-tests/functional/libbuild.bin: tests/functional/libbuild.a
-tests/functional/limit.bin: tests/functional/limit.a
-tests/fuzz/api.bin: tests/fuzz/api.a
-tests/benchmarks/exec.bin-check: tests/benchmarks/exec.bin
-tests/benchmarks/query.bin-check: tests/benchmarks/query.bin
-tests/functional/json.bin-check: tests/functional/json.bin
-tests/functional/libbuild.bin-check: tests/functional/libbuild.bin
-tests/functional/limit.bin-check: tests/functional/limit.bin
-tests/fuzz/api.bin-check: tests/fuzz/api.bin
+libs.go = \
+ src/acudego.go \
+ tests/acudego.go \
+ tests/benchmarks/exec/acudego.go \
+ tests/benchmarks/query/acudego.go \
+ tests/functional/json/acudego.go \
+ tests/functional/limit/acudego.go \
+ tests/fuzz/api/acudego.go \
+
+mains.go = \
+ tests/benchmarks/exec/main.go \
+ tests/benchmarks/query/main.go \
+ tests/functional/json/main.go \
+ tests/functional/limit/main.go \
+ tests/fuzz/api/main.go \
+ tests/main.go \
+
+functional-tests/lib.go = \
+ tests/functional/json/acudego.go \
+ tests/functional/limit/acudego.go \
+
+functional-tests/main.go = \
+ tests/functional/json/main.go \
+ tests/functional/limit/main.go \
+
+fuzz-targets/lib.go = \
+ tests/fuzz/api/acudego.go \
+
+fuzz-targets/main.go = \
+ tests/fuzz/api/main.go \
+
+benchmarks/lib.go = \
+ tests/benchmarks/exec/acudego.go \
+ tests/benchmarks/query/acudego.go \
+
+benchmarks/main.go = \
+ tests/benchmarks/exec/main.go \
+ tests/benchmarks/query/main.go \
+
+src/acudego.a: src/acudego.go
+tests/acudego.a: tests/acudego.go
+tests/benchmarks/exec/acudego.a: tests/benchmarks/exec/acudego.go
+tests/benchmarks/exec/main.a: tests/benchmarks/exec/main.go
+tests/benchmarks/query/acudego.a: tests/benchmarks/query/acudego.go
+tests/benchmarks/query/main.a: tests/benchmarks/query/main.go
+tests/functional/json/acudego.a: tests/functional/json/acudego.go
+tests/functional/json/main.a: tests/functional/json/main.go
+tests/functional/limit/acudego.a: tests/functional/limit/acudego.go
+tests/functional/limit/main.a: tests/functional/limit/main.go
+tests/fuzz/api/acudego.a: tests/fuzz/api/acudego.go
+tests/fuzz/api/main.a: tests/fuzz/api/main.go
+tests/main.a: tests/main.go
+tests/benchmarks/exec/main.bin: tests/benchmarks/exec/main.a
+tests/benchmarks/query/main.bin: tests/benchmarks/query/main.a
+tests/functional/json/main.bin: tests/functional/json/main.a
+tests/functional/limit/main.bin: tests/functional/limit/main.a
+tests/fuzz/api/main.bin: tests/fuzz/api/main.a
+tests/main.bin: tests/main.a
+tests/benchmarks/exec/main.bin-check: tests/benchmarks/exec/main.bin
+tests/benchmarks/query/main.bin-check: tests/benchmarks/query/main.bin
+tests/functional/json/main.bin-check: tests/functional/json/main.bin
+tests/functional/limit/main.bin-check: tests/functional/limit/main.bin
+tests/fuzz/api/main.bin-check: tests/fuzz/api/main.bin
+tests/main.bin-check: tests/main.bin
+tests/benchmarks/exec/main.a: tests/benchmarks/exec/$(NAME).a
+tests/benchmarks/query/main.a: tests/benchmarks/query/$(NAME).a
+tests/functional/json/main.a: tests/functional/json/$(NAME).a
+tests/functional/limit/main.a: tests/functional/limit/$(NAME).a
+tests/fuzz/api/main.a: tests/fuzz/api/$(NAME).a
+tests/main.a: tests/$(NAME).a
diff --git a/mkdeps.sh b/mkdeps.sh
index 92427c6..e8da8a4 100755
--- a/mkdeps.sh
+++ b/mkdeps.sh
@@ -4,15 +4,26 @@ set -eu
export LANG=POSIX.UTF-8
-find tests/functional/*.go | varlist 'functional-tests.go'
-find tests/fuzz/*.go | varlist 'fuzz-targets.go'
-find tests/benchmarks/*.go | varlist 'benchmarks.go'
-
+libs() {
+ find src tests -name '*.go' | grep -v '/main\.go$' |
+ grep -v '/version\.go$'
+}
-tfiles() {
- find tests/functional/*.go tests/fuzz/*.go tests/benchmarks/*.go | sort
+mains() {
+ find src tests -name '*.go' | grep '/main\.go$'
}
-tfiles | sed 's/^\(.*\)\.go$/\1.a:\t\1.go/'
-tfiles | sed 's/^\(.*\)\.go$/\1.bin:\t\1.a/'
-tfiles | sed 's/^\(.*\)\.go$/\1.bin-check:\t\1.bin/'
+libs | varlist 'libs.go'
+mains | varlist 'mains.go'
+
+find tests/functional/*/*.go -not -name main.go | varlist 'functional-tests/lib.go'
+find tests/functional/*/main.go | varlist 'functional-tests/main.go'
+find tests/fuzz/*/*.go -not -name main.go | varlist 'fuzz-targets/lib.go'
+find tests/fuzz/*/main.go | varlist 'fuzz-targets/main.go'
+find tests/benchmarks/*/*.go -not -name main.go | varlist 'benchmarks/lib.go'
+find tests/benchmarks/*/main.go | varlist 'benchmarks/main.go'
+
+{ libs; mains; } | sort | sed 's/^\(.*\)\.go$/\1.a:\t\1.go/'
+mains | sort | sed 's/^\(.*\)\.go$/\1.bin:\t\1.a/'
+mains | sort | sed 's/^\(.*\)\.go$/\1.bin-check:\t\1.bin/'
+mains | sort | sed 's|^\(.*\)/main\.go$|\1/main.a:\t\1/$(NAME).a|'
diff --git a/src/acudego.go b/src/acudego.go
index 8820356..c9acbcd 100644
--- a/src/acudego.go
+++ b/src/acudego.go
@@ -23,7 +23,7 @@ import (
/*
#include <stdlib.h>
-#include <acude.h>
+#include <sqlite3.h>
void stepTrampoline(sqlite3_context *, int, sqlite3_value **);
void doneTrampoline(sqlite3_context *);
@@ -1053,9 +1053,9 @@ const (
columnTimestamp string = "timestamp"
)
-const driverName = "acudego"
+const DriverName = "acude"
func init() {
- sql.Register(driverName, &SQLiteDriver{})
+ sql.Register(DriverName, &SQLiteDriver{})
}
// Version returns SQLite library version information.
diff --git a/tests/acudego.go b/tests/acudego.go
index cb9e672..de41ca9 100644
--- a/tests/acudego.go
+++ b/tests/acudego.go
@@ -406,7 +406,7 @@ func TestSimpleError(t *testing.T) {
}
func TestCorruptDbErrors(t *testing.T) {
- dirName, err := ioutil.TempDir("", "acudego")
+ dirName, err := ioutil.TempDir("", "FIXME")
if err != nil {
t.Fatal(err)
}
@@ -420,7 +420,7 @@ func TestCorruptDbErrors(t *testing.T) {
f.Write([]byte{1, 2, 3, 4, 5})
f.Close()
- db, err := sql.Open("acudego", dbFileName)
+ db, err := sql.Open(DriverName, dbFileName)
if err == nil {
_, err = db.Exec("drop table foo")
}
@@ -436,13 +436,13 @@ func TestCorruptDbErrors(t *testing.T) {
}
func TestSqlLogicErrors(t *testing.T) {
- dirName, err := ioutil.TempDir("", "acudego")
+ dirName, err := ioutil.TempDir("", "FIXME")
if err != nil {
t.Fatal(err)
}
defer os.RemoveAll(dirName)
- db, err := sql.Open("acudego", ":memory:")
+ db, err := sql.Open(DriverName, ":memory:")
if err != nil {
t.Error(err)
}
@@ -468,7 +468,7 @@ func TestExtendedErrorCodes_ForeignKey(t *testing.T) {
}
defer os.RemoveAll(dirName)
- db, err := sql.Open("acudego", ":memory:")
+ db, err := sql.Open(DriverName, ":memory:")
if err != nil {
t.Error(err)
}
@@ -508,7 +508,7 @@ func TestExtendedErrorCodes_NotNull(t *testing.T) {
}
defer os.RemoveAll(dirName)
- db, err := sql.Open("acudego", ":memory:")
+ db, err := sql.Open(DriverName, ":memory:")
if err != nil {
t.Error(err)
}
@@ -558,7 +558,7 @@ func TestExtendedErrorCodes_Unique(t *testing.T) {
}
defer os.RemoveAll(dirName)
- db, err := sql.Open("acudego", ":memory:")
+ db, err := sql.Open(DriverName, ":memory:")
if err != nil {
t.Error(err)
}
@@ -613,7 +613,7 @@ func TestError_SystemErrno(t *testing.T) {
}
// open a non-existent database in read-only mode so we get an IO error.
- db, err := sql.Open("acudego", "file:nonexistent.db?mode=ro")
+ db, err := sql.Open(DriverName, "file:nonexistent.db?mode=ro")
if err != nil {
t.Fatal(err)
}
@@ -639,7 +639,7 @@ func TestError_SystemErrno(t *testing.T) {
}
func TestBeginTxCancel(t *testing.T) {
- db, err := sql.Open("acudego", ":memory:")
+ db, err := sql.Open(DriverName, ":memory:")
if err != nil {
t.Fatal(err)
}
@@ -698,7 +698,7 @@ func TestBeginTxCancel(t *testing.T) {
}
func TestStmtReadonly(t *testing.T) {
- db, err := sql.Open("acudego", ":memory:")
+ db, err := sql.Open(DriverName, ":memory:")
if err != nil {
t.Fatal(err)
}
@@ -739,7 +739,7 @@ func TestStmtReadonly(t *testing.T) {
}
func TestNamedParams(t *testing.T) {
- db, err := sql.Open("acudego", ":memory:")
+ db, err := sql.Open(DriverName, ":memory:")
if err != nil {
t.Fatal("Failed to open database:", err)
}
@@ -829,7 +829,7 @@ func initDatabase(t *testing.T, db *sql.DB, rowCount int64) {
}
func TestShortTimeout(t *testing.T) {
- db, err := sql.Open("acudego", ":memory:")
+ db, err := sql.Open(DriverName, ":memory:")
if err != nil {
t.Fatal(err)
}
@@ -851,7 +851,7 @@ func TestShortTimeout(t *testing.T) {
}
func TestExecContextCancel(t *testing.T) {
- db, err := sql.Open("acudego", "file:exec?mode=memory&cache=shared")
+ db, err := sql.Open(DriverName, "file:exec?mode=memory&cache=shared")
if err != nil {
t.Fatal(err)
}
@@ -892,7 +892,7 @@ FROM test_table t1 LEFT OUTER JOIN test_table t2`
func TestQueryRowContextCancel(t *testing.T) {
// FIXME: too slow
- db, err := sql.Open("acudego", "file:query?mode=memory&cache=shared")
+ db, err := sql.Open(DriverName, "file:query?mode=memory&cache=shared")
if err != nil {
t.Fatal(err)
}
@@ -924,7 +924,7 @@ func TestQueryRowContextCancel(t *testing.T) {
func TestQueryRowContextCancelParallel(t *testing.T) {
// FIXME: too slow
- db, err := sql.Open("acudego", "file:parallel?mode=memory&cache=shared")
+ db, err := sql.Open(DriverName, "file:parallel?mode=memory&cache=shared")
if err != nil {
t.Fatal(err)
}
@@ -974,7 +974,7 @@ func TestQueryRowContextCancelParallel(t *testing.T) {
}
func TestExecCancel(t *testing.T) {
- db, err := sql.Open("acudego", ":memory:")
+ db, err := sql.Open(DriverName, ":memory:")
if err != nil {
t.Fatal(err)
}
@@ -995,7 +995,7 @@ func TestExecCancel(t *testing.T) {
}
func doTestOpenContext(t *testing.T, url string) (string, error) {
- db, err := sql.Open("acudego", url)
+ db, err := sql.Open(DriverName, url)
if err != nil {
return "Failed to open database:", err
}
@@ -1032,7 +1032,7 @@ func TestFileCopyTruncate(t *testing.T) {
tempFilename := TempFilename(t)
defer os.Remove(tempFilename)
- db, err := sql.Open("acudego", tempFilename)
+ db, err := sql.Open(DriverName, tempFilename)
if err != nil {
t.Fatal("open error:", err)
}
@@ -1125,7 +1125,7 @@ func TestFileCopyTruncate(t *testing.T) {
}
// test copied file
- db, err = sql.Open("acudego", copyFilename)
+ db, err = sql.Open(DriverName, copyFilename)
if err != nil {
t.Fatal("open error:", err)
}
@@ -1188,7 +1188,7 @@ func TestColumnTableName(t *testing.T) {
}
func TestFTS5(t *testing.T) {
- db, err := sql.Open("acudego", ":memory:")
+ db, err := sql.Open(DriverName, ":memory:")
if err != nil {
t.Fatal("Failed to open database:", err)
}
@@ -1292,27 +1292,6 @@ func TestFTS5(t *testing.T) {
}
}
-func TestMathFunctions(t *testing.T) {
- db, err := sql.Open("acudego", ":memory:")
- if err != nil {
- t.Fatal("Failed to open database:", err)
- }
- defer db.Close()
-
- queries := []string{
- `SELECT acos(1)`,
- `SELECT log(10, 100)`,
- `SELECT power(2, 2)`,
- }
-
- for _, query := range queries {
- var result float64
- if err := db.QueryRow(query).Scan(&result); err != nil {
- t.Errorf("invoking math function query %q: %v", query, err)
- }
- }
-}
-
type preUpdateHookDataForTest struct {
databaseName string
tableName string
@@ -1324,7 +1303,7 @@ type preUpdateHookDataForTest struct {
func TestSerializeDeserialize(t *testing.T) {
// Connect to the source database.
- srcDb, err := sql.Open(driverName, "file:src?mode=memory&cache=shared")
+ srcDb, err := sql.Open(DriverName, "file:src?mode=memory&cache=shared")
if err != nil {
t.Fatal("Failed to open the source database:", err)
}
@@ -1335,7 +1314,7 @@ func TestSerializeDeserialize(t *testing.T) {
}
// Connect to the destination database.
- destDb, err := sql.Open(driverName, "file:dst?mode=memory&cache=shared")
+ destDb, err := sql.Open(DriverName, "file:dst?mode=memory&cache=shared")
if err != nil {
t.Fatal("Failed to open the destination database:", err)
}
@@ -1411,7 +1390,7 @@ func TestUnlockNotify(t *testing.T) {
tempFilename := TempFilename(t)
defer os.Remove(tempFilename)
dsn := fmt.Sprintf("file:%s?cache=shared&mode=memory", tempFilename)
- db, err := sql.Open("acudego", dsn)
+ db, err := sql.Open(DriverName, dsn)
if err != nil {
t.Fatal("Failed to open database:", err)
}
@@ -1471,7 +1450,7 @@ func TestUnlockNotifyMany(t *testing.T) {
tempFilename := TempFilename(t)
defer os.Remove(tempFilename)
dsn := fmt.Sprintf("file:%s?cache=shared&mode=memory", tempFilename)
- db, err := sql.Open("acudego", dsn)
+ db, err := sql.Open(DriverName, dsn)
if err != nil {
t.Fatal("Failed to open database:", err)
}
@@ -1537,7 +1516,7 @@ func TestUnlockNotifyDeadlock(t *testing.T) {
tempFilename := TempFilename(t)
defer os.Remove(tempFilename)
dsn := fmt.Sprintf("file:%s?cache=shared&mode=memory", tempFilename)
- db, err := sql.Open("acudego", dsn)
+ db, err := sql.Open(DriverName, dsn)
if err != nil {
t.Fatal("Failed to open database:", err)
}
@@ -1630,7 +1609,7 @@ func TempFilename(t testing.TB) string {
}
func doTestOpen(t *testing.T, url string) (string, error) {
- db, err := sql.Open("acudego", url)
+ db, err := sql.Open(DriverName, url)
if err != nil {
return "Failed to open database:", err
}
@@ -1659,7 +1638,7 @@ func doTestOpen(t *testing.T, url string) (string, error) {
func TestOpenWithVFS(t *testing.T) {
{
uri := fmt.Sprintf("file:%s?mode=memory&vfs=hello", t.Name())
- db, err := sql.Open("acudego", uri)
+ db, err := sql.Open(DriverName, uri)
if err != nil {
t.Fatal("Failed to open", err)
}
@@ -1672,7 +1651,7 @@ func TestOpenWithVFS(t *testing.T) {
{
uri := fmt.Sprintf("file:%s?mode=memory&vfs=unix-none", t.Name())
- db, err := sql.Open("acudego", uri)
+ db, err := sql.Open(DriverName, uri)
if err != nil {
t.Fatal("Failed to open", err)
}
@@ -1695,7 +1674,7 @@ func TestOpenNoCreate(t *testing.T) {
// https://golang.org/pkg/database/sql/#Open
// "Open may just validate its arguments without creating a connection
// to the database. To verify that the data source name is valid, call Ping."
- db, err := sql.Open("acudego", fmt.Sprintf("file:%s?mode=rw", filename))
+ db, err := sql.Open(DriverName, fmt.Sprintf("file:%s?mode=rw", filename))
if err == nil {
defer db.Close()
@@ -1723,7 +1702,7 @@ func TestOpenNoCreate(t *testing.T) {
}
// verify that it works if the mode is "rwc" instead
- db, err = sql.Open("acudego", fmt.Sprintf("file:%s?mode=rwc", filename))
+ db, err = sql.Open(DriverName, fmt.Sprintf("file:%s?mode=rwc", filename))
if err != nil {
t.Fatal(err)
}
@@ -1746,14 +1725,14 @@ func TestReadonly(t *testing.T) {
tempFilename := TempFilename(t)
defer os.Remove(tempFilename)
- db1, err := sql.Open("acudego", "file:"+tempFilename)
+ db1, err := sql.Open(DriverName, "file:"+tempFilename)
if err != nil {
t.Fatal(err)
}
defer db1.Close()
db1.Exec("CREATE TABLE test (x int, y float)")
- db2, err := sql.Open("acudego", "file:"+tempFilename+"?mode=ro")
+ db2, err := sql.Open(DriverName, "file:"+tempFilename+"?mode=ro")
if err != nil {
t.Fatal(err)
}
@@ -1768,7 +1747,7 @@ func TestReadonly(t *testing.T) {
func TestDeferredForeignKey(t *testing.T) {
fname := TempFilename(t)
uri := "file:" + fname + "?_foreign_keys=1&mode=memory"
- db, err := sql.Open("acudego", uri)
+ db, err := sql.Open(DriverName, uri)
if err != nil {
os.Remove(fname)
t.Errorf("sql.Open(\"sqlite3\", %q): %v", uri, err)
@@ -1803,7 +1782,7 @@ func TestDeferredForeignKey(t *testing.T) {
}
func TestClose(t *testing.T) {
- db, err := sql.Open("acudego", ":memory:")
+ db, err := sql.Open(DriverName, ":memory:")
if err != nil {
t.Fatal("Failed to open database:", err)
}
@@ -1827,7 +1806,7 @@ func TestClose(t *testing.T) {
}
func TestInsert(t *testing.T) {
- db, err := sql.Open("acudego", ":memory:")
+ db, err := sql.Open(DriverName, ":memory:")
if err != nil {
t.Fatal("Failed to open database:", err)
}
@@ -1868,7 +1847,7 @@ func TestUpsert(t *testing.T) {
if n < 3024000 {
t.Skip("UPSERT requires sqlite3 >= 3.24.0")
}
- db, err := sql.Open("acudego", ":memory:")
+ db, err := sql.Open(DriverName, ":memory:")
if err != nil {
t.Fatal("Failed to open database:", err)
}
@@ -1911,7 +1890,7 @@ func TestUpsert(t *testing.T) {
}
func TestUpdate(t *testing.T) {
- db, err := sql.Open("acudego", ":memory:")
+ db, err := sql.Open(DriverName, ":memory:")
if err != nil {
t.Fatal("Failed to open database:", err)
}
@@ -1974,7 +1953,7 @@ func TestUpdate(t *testing.T) {
}
func TestDelete(t *testing.T) {
- db, err := sql.Open("acudego", ":memory:")
+ db, err := sql.Open(DriverName, ":memory:")
if err != nil {
t.Fatal("Failed to open database:", err)
}
@@ -2033,7 +2012,7 @@ func TestDelete(t *testing.T) {
}
func TestBooleanRoundtrip(t *testing.T) {
- db, err := sql.Open("acudego", ":memory:")
+ db, err := sql.Open(DriverName, ":memory:")
if err != nil {
t.Fatal("Failed to open database:", err)
}
@@ -2082,7 +2061,7 @@ func TestBooleanRoundtrip(t *testing.T) {
func timezone(t time.Time) string { return t.Format("-07:00") }
func TestTimestamp(t *testing.T) {
- db, err := sql.Open("acudego", ":memory:")
+ db, err := sql.Open(DriverName, ":memory:")
if err != nil {
t.Fatal("Failed to open database:", err)
}
@@ -2182,7 +2161,7 @@ func TestTimestamp(t *testing.T) {
}
func TestBoolean(t *testing.T) {
- db, err := sql.Open("acudego", ":memory:")
+ db, err := sql.Open(DriverName, ":memory:")
if err != nil {
t.Fatal("Failed to open database:", err)
}
@@ -2272,7 +2251,7 @@ func TestBoolean(t *testing.T) {
}
func TestFloat32(t *testing.T) {
- db, err := sql.Open("acudego", ":memory:")
+ db, err := sql.Open(DriverName, ":memory:")
if err != nil {
t.Fatal("Failed to open database:", err)
}
@@ -2307,7 +2286,7 @@ func TestFloat32(t *testing.T) {
}
func TestNull(t *testing.T) {
- db, err := sql.Open("acudego", ":memory:")
+ db, err := sql.Open(DriverName, ":memory:")
if err != nil {
t.Fatal("Failed to open database:", err)
}
@@ -2336,7 +2315,7 @@ func TestNull(t *testing.T) {
}
func TestTransaction(t *testing.T) {
- db, err := sql.Open("acudego", ":memory:")
+ db, err := sql.Open(DriverName, ":memory:")
if err != nil {
t.Fatal("Failed to open database:", err)
}
@@ -2393,7 +2372,7 @@ func TestTransaction(t *testing.T) {
}
func TestWAL(t *testing.T) {
- db, err := sql.Open("acudego", ":memory:")
+ db, err := sql.Open(DriverName, ":memory:")
if err != nil {
t.Fatal("Failed to open database:", err)
}
@@ -2433,7 +2412,7 @@ func TestWAL(t *testing.T) {
func TestTimezoneConversion(t *testing.T) {
zones := []string{"UTC", "US/Central", "US/Pacific", "Local"}
for _, tz := range zones {
- db, err := sql.Open("acudego", "file:tz?mode=memory&_loc="+url.QueryEscape(tz))
+ db, err := sql.Open(DriverName, "file:tz?mode=memory&_loc="+url.QueryEscape(tz))
if err != nil {
t.Fatal("Failed to open database:", err)
}
@@ -2527,7 +2506,7 @@ func TestTimezoneConversion(t *testing.T) {
// TODO: Execer & Queryer currently disabled
// https://github.com/mattn/go-sqlite3/issues/82
func TestExecer(t *testing.T) {
- db, err := sql.Open("acudego", ":memory:")
+ db, err := sql.Open(DriverName, ":memory:")
if err != nil {
t.Fatal("Failed to open database:", err)
}
@@ -2545,7 +2524,7 @@ func TestExecer(t *testing.T) {
}
func TestQueryer(t *testing.T) {
- db, err := sql.Open("acudego", ":memory:")
+ db, err := sql.Open(DriverName, ":memory:")
if err != nil {
t.Fatal("Failed to open database:", err)
}
@@ -2594,7 +2573,7 @@ func TestQueryer(t *testing.T) {
}
func TestStress(t *testing.T) {
- db, err := sql.Open("acudego", ":memory:")
+ db, err := sql.Open(DriverName, ":memory:")
if err != nil {
t.Fatal("Failed to open database:", err)
}
@@ -2629,7 +2608,7 @@ func TestDateTimeLocal(t *testing.T) {
defer os.Remove(tempFilename)
filename1 := tempFilename + "?mode=memory&cache=shared"
filename2 := filename1 + "&_loc=" + zone
- db1, err := sql.Open("acudego", filename2)
+ db1, err := sql.Open(DriverName, filename2)
if err != nil {
t.Fatal("Failed to open database:", err)
}
@@ -2647,7 +2626,7 @@ func TestDateTimeLocal(t *testing.T) {
t.Fatal("Result should have timezone", d)
}
- db2, err := sql.Open("acudego", filename1)
+ db2, err := sql.Open(DriverName, filename1)
if err != nil {
t.Fatal("Failed to open database:", err)
}
@@ -2672,7 +2651,7 @@ func TestDateTimeLocal(t *testing.T) {
}
db2.Exec("INSERT INTO foo VALUES(?);", dt)
- db3, err := sql.Open("acudego", filename2)
+ db3, err := sql.Open(DriverName, filename2)
if err != nil {
t.Fatal("Failed to open database:", err)
}
@@ -2696,7 +2675,7 @@ func TestVersion(t *testing.T) {
}
func TestStringContainingZero(t *testing.T) {
- db, err := sql.Open("acudego", ":memory:")
+ db, err := sql.Open(DriverName, ":memory:")
if err != nil {
t.Fatal("Failed to open database:", err)
}
@@ -2754,7 +2733,7 @@ func (t TimeStamp) Value() (driver.Value, error) {
}
func TestDateTimeNow(t *testing.T) {
- db, err := sql.Open("acudego", ":memory:")
+ db, err := sql.Open(DriverName, ":memory:")
if err != nil {
t.Fatal("Failed to open database:", err)
}
@@ -3038,7 +3017,7 @@ func TestDeclTypes(t *testing.T) {
}
func TestPinger(t *testing.T) {
- db, err := sql.Open("acudego", ":memory:")
+ db, err := sql.Open(DriverName, ":memory:")
if err != nil {
t.Fatal(err)
}
@@ -3149,7 +3128,7 @@ func TestSetFileControlInt(t *testing.T) {
}
func TestNonColumnString(t *testing.T) {
- db, err := sql.Open("acudego", ":memory:")
+ db, err := sql.Open(DriverName, ":memory:")
if err != nil {
t.Fatal(err)
}
@@ -3169,7 +3148,7 @@ func TestNonColumnString(t *testing.T) {
}
func TestNilAndEmptyBytes(t *testing.T) {
- db, err := sql.Open("acudego", ":memory:")
+ db, err := sql.Open(DriverName, ":memory:")
if err != nil {
t.Fatal(err)
}
@@ -3224,7 +3203,7 @@ func TestNilAndEmptyBytes(t *testing.T) {
}
func TestInsertNilByteSlice(t *testing.T) {
- db, err := sql.Open("acudego", ":memory:")
+ db, err := sql.Open(DriverName, ":memory:")
if err != nil {
t.Fatal(err)
}
@@ -3245,7 +3224,7 @@ func TestInsertNilByteSlice(t *testing.T) {
func TestNamedParam(t *testing.T) {
tempFilename := TempFilename(t)
defer os.Remove(tempFilename)
- db, err := sql.Open("acudego", ":memory:")
+ db, err := sql.Open(DriverName, ":memory:")
if err != nil {
t.Fatal("Failed to open database:", err)
}
@@ -3304,7 +3283,7 @@ var tdb *TestDB
func initializeTestDB(t testing.TB) {
tempFilename := TempFilename(t)
- d, err := sql.Open("acudego", tempFilename+"?mode=memory&cache=shared")
+ d, err := sql.Open(DriverName, tempFilename+"?mode=memory&cache=shared")
if err != nil {
os.Remove(tempFilename)
t.Fatal(err)
@@ -3625,7 +3604,6 @@ func MainTest() {
{ "TestFileCopyTruncate", TestFileCopyTruncate },
{ "TestColumnTableName", TestColumnTableName },
{ "TestFTS5", TestFTS5 },
- { "TestMathFunctions", TestMathFunctions },
{ "TestSerializeDeserialize", TestSerializeDeserialize },
{ "TestOpenWithVFS", TestOpenWithVFS },
{ "TestOpenNoCreate", TestOpenNoCreate },
diff --git a/tests/benchmarks/exec.go b/tests/benchmarks/exec/acudego.go
index 0a85b1f..79e7992 100644
--- a/tests/benchmarks/exec.go
+++ b/tests/benchmarks/exec/acudego.go
@@ -1,21 +1,23 @@
-package main
+package acudego
import (
"database/sql"
"flag"
-
- _ "acudego"
)
-var nFlag = flag.Int("n", 1_000_000, "The number of iterations to execute")
+var nFlag = flag.Int(
+ "n",
+ 1_000_000,
+ "The number of iterations to execute",
+)
-func main() {
+func MainTest() {
flag.Parse()
n := *nFlag
- db, err := sql.Open("acudego3", "file:bench.db?mode=memory&cache=shared")
+ db, err := sql.Open(DriverName, "file:bench.db?mode=memory&cache=shared")
if err != nil {
panic(err)
}
diff --git a/tests/benchmarks/exec/main.go b/tests/benchmarks/exec/main.go
new file mode 120000
index 0000000..f67563d
--- /dev/null
+++ b/tests/benchmarks/exec/main.go
@@ -0,0 +1 @@
+../../main.go \ No newline at end of file
diff --git a/tests/benchmarks/query.go b/tests/benchmarks/query/acudego.go
index e9c7b24..3386576 100644
--- a/tests/benchmarks/query.go
+++ b/tests/benchmarks/query/acudego.go
@@ -1,21 +1,23 @@
-package main
+package acudego
import (
"database/sql"
"flag"
-
- _ "acudego"
)
-var nFlag = flag.Int("n", 100_000, "The number of iterations to execute")
+var nFlag = flag.Int(
+ "n",
+ 100_000,
+ "The number of iterations to execute",
+)
-func main() {
+func MainTest() {
flag.Parse()
n := *nFlag
- db, err := sql.Open("acudego", "file:benchdb?mode=memory&cache=shared")
+ db, err := sql.Open(DriverName, "file:benchdb?mode=memory&cache=shared")
if err != nil {
panic(err)
}
diff --git a/tests/benchmarks/query/main.go b/tests/benchmarks/query/main.go
new file mode 120000
index 0000000..f67563d
--- /dev/null
+++ b/tests/benchmarks/query/main.go
@@ -0,0 +1 @@
+../../main.go \ No newline at end of file
diff --git a/tests/functional/json.go b/tests/functional/json/acudego.go
index 352a72c..8f5e923 100644
--- a/tests/functional/json.go
+++ b/tests/functional/json/acudego.go
@@ -1,4 +1,4 @@
-package main
+package acudego
import (
"database/sql"
@@ -7,10 +7,10 @@ import (
"errors"
"log"
"os"
-
- _ "acudego"
)
+
+
type Tag struct {
Name string `json:"name"`
Place string `json:"place"`
@@ -25,11 +25,13 @@ func (t *Tag) Value() (driver.Value, error) {
return string(b), err
}
-func main() {
+
+
+func MainTest() {
os.Remove("json.db")
defer os.Remove("json.db")
- db, err := sql.Open("acudego", "json.db")
+ db, err := sql.Open(DriverName, "json.db")
if err != nil {
log.Fatal(err)
}
diff --git a/tests/functional/json/main.go b/tests/functional/json/main.go
new file mode 120000
index 0000000..f67563d
--- /dev/null
+++ b/tests/functional/json/main.go
@@ -0,0 +1 @@
+../../main.go \ No newline at end of file
diff --git a/tests/functional/libbuild.go b/tests/functional/libbuild.go
deleted file mode 100644
index 860aff9..0000000
--- a/tests/functional/libbuild.go
+++ /dev/null
@@ -1,19 +0,0 @@
-package main
-
-import (
- "database/sql"
-
- _ "acudego"
-)
-
-func main() {
- db, err := sql.Open("acudego", ":memory:")
- if err != nil {
- panic(err)
- }
-
- err = db.Close()
- if err != nil {
- panic(err)
- }
-}
diff --git a/tests/functional/limit.go b/tests/functional/limit/acudego.go
index ab726f6..d47dc27 100644
--- a/tests/functional/limit.go
+++ b/tests/functional/limit/acudego.go
@@ -1,4 +1,4 @@
-package main
+package acudego
import (
"database/sql"
@@ -6,10 +6,10 @@ import (
"log"
"os"
"strings"
-
- "acudego"
)
+
+
func createBulkInsertQuery(n int, start int) (string, []any) {
values := make([]string, n)
args := make([]any, n*2)
@@ -37,7 +37,9 @@ func bulkInsert(db *sql.DB, query string, args []any) error {
return err
}
-func main() {
+
+
+func MainTest() {
const (
num = 400
smallLimit = 100
@@ -49,9 +51,9 @@ func main() {
delete from mylimittable;
`
- var conn *acudego.SQLiteConn
- sql.Register("sqlite3_with_limit", &acudego.SQLiteDriver{
- ConnectHook: func(c *acudego.SQLiteConn) error {
+ var conn *SQLiteConn
+ sql.Register("sqlite3_with_limit", &SQLiteDriver{
+ ConnectHook: func(c *SQLiteConn) error {
conn = c
return nil
},
@@ -82,7 +84,7 @@ func main() {
}
}
- conn.SetLimit(acudego.SQLITE_LIMIT_VARIABLE_NUMBER, smallLimit)
+ conn.SetLimit(SQLITE_LIMIT_VARIABLE_NUMBER, smallLimit)
{
query, args := createBulkInsertQuery(num, num)
err := bulkInsert(db, query, args)
@@ -91,7 +93,7 @@ func main() {
}
}
- conn.SetLimit(acudego.SQLITE_LIMIT_VARIABLE_NUMBER, bigLimit)
+ conn.SetLimit(SQLITE_LIMIT_VARIABLE_NUMBER, bigLimit)
{
query, args := createBulkInsertQuery(500, num+num)
err := bulkInsert(db, query, args)
diff --git a/tests/functional/limit/main.go b/tests/functional/limit/main.go
new file mode 120000
index 0000000..f67563d
--- /dev/null
+++ b/tests/functional/limit/main.go
@@ -0,0 +1 @@
+../../main.go \ No newline at end of file
diff --git a/tests/fuzz/api.go b/tests/fuzz/api/acudego.go
index 0d6db03..7f8e3a0 100644
--- a/tests/fuzz/api.go
+++ b/tests/fuzz/api/acudego.go
@@ -1,4 +1,4 @@
-package main
+package acudego
import (
"os"
@@ -20,7 +20,7 @@ func FuzzAPI(f *testing.F) {
-func main() {
+func MainTest() {
fuzzTargets := []testing.InternalFuzzTarget{
{ "FuzzAPI", FuzzAPI },
}
diff --git a/tests/fuzz/api/main.go b/tests/fuzz/api/main.go
new file mode 120000
index 0000000..f67563d
--- /dev/null
+++ b/tests/fuzz/api/main.go
@@ -0,0 +1 @@
+../../main.go \ No newline at end of file