From 11216f730451a292847505d464294ed7cf2c05c4 Mon Sep 17 00:00:00 2001 From: Jan Mercl <0xjnml@gmail.com> Date: Tue, 13 Jun 2017 15:18:34 +0200 Subject: Do not use fixed heap on Linux. Updates #12. modified: all_test.go modified: generator.go modified: internal/bin/bin_linux_386.go modified: internal/bin/bin_linux_amd64.go modified: main.c modified: sqlite.go modified: sqlite_go18.go --- all_test.go | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'all_test.go') diff --git a/all_test.go b/all_test.go index ae09653..0697a0a 100644 --- a/all_test.go +++ b/all_test.go @@ -312,3 +312,39 @@ func TestIssue11(t *testing.T) { t.Fatal(err) } } + +// https://github.com/cznic/sqlite/issues/12 +func TestMemDB(t *testing.T) { + // Verify we can create out-of-the heap memory DB instance. + db, err := sql.Open(driverName, "file::memory:") + if err != nil { + t.Fatal(err) + } + + defer func() { + db.Close() + }() + + v := strings.Repeat("a", 1024) + if _, err := db.Exec(` + create table t(s string); + begin; + `); err != nil { + t.Fatal(err) + } + + s, err := db.Prepare("insert into t values(?)") + if err != nil { + t.Fatal(err) + } + + // Heap used to be fixed at 32MB. + for i := 0; i < (64<<20)/len(v); i++ { + if _, err := s.Exec(v); err != nil { + t.Fatalf("%v * %v= %v: %v", i, len(v), i*len(v), err) + } + } + if _, err := db.Exec(`commit;`); err != nil { + t.Fatal(err) + } +} -- cgit v1.2.3-70-g09d2 From fdc87f0039c9297e4abef584aa5c01ba8f186c6d Mon Sep 17 00:00:00 2001 From: Jan Mercl <0xjnml@gmail.com> Date: Tue, 13 Jun 2017 16:01:51 +0200 Subject: all_test.go/TestIssue11: Do not panic, use t.Fatal instead. Updates #12. modified: all_test.go --- all_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'all_test.go') diff --git a/all_test.go b/all_test.go index 0697a0a..3406c44 100644 --- a/all_test.go +++ b/all_test.go @@ -300,7 +300,7 @@ func TestIssue11(t *testing.T) { BEGIN; `, ); err != nil { - panic(err) + t.Fatal(err) } for i := 0; i < N; i++ { -- cgit v1.2.3-70-g09d2