Commit f5bd5897 authored by gwenn's avatar gwenn

Prepared statements created by the FTS module should not be finalized.

parent a52244ac
......@@ -401,6 +401,7 @@ func (cc *CompletionCache) complete(tbl, prefix string) ([]string, error) {
if err != nil {
return nil, err
}
defer s.Finalize()
var names []string
if err = s.Select(func(s *sqlite.Stmt) error {
name, _ := s.ScanText(0)
......
......@@ -20,6 +20,7 @@ func createCache(t *testing.T) *CompletionCache {
func TestPragmaNames(t *testing.T) {
cc := createCache(t)
defer cc.Close()
pragmas, err := cc.CompletePragma("fo")
assert.Tf(t, err == nil, "%v", err)
assert.Equalf(t, 3, len(pragmas), "got %d pragmas; expected %d", len(pragmas), 3)
......@@ -27,6 +28,7 @@ func TestPragmaNames(t *testing.T) {
}
func TestFuncNames(t *testing.T) {
cc := createCache(t)
defer cc.Close()
funcs, err := cc.CompleteFunc("su")
assert.Tf(t, err == nil, "%v", err)
assert.Equal(t, 2, len(funcs), "got %d functions; expected %d", len(funcs), 2)
......@@ -34,6 +36,7 @@ func TestFuncNames(t *testing.T) {
}
func TestCmdNames(t *testing.T) {
cc := createCache(t)
defer cc.Close()
cmds, err := cc.CompleteCmd(".h")
assert.Tf(t, err == nil, "%v", err)
assert.Equal(t, 2, len(cmds), "got %d commands; expected %d", len(cmds), 2)
......@@ -44,6 +47,7 @@ func TestCache(t *testing.T) {
assert.Tf(t, err == nil, "%v", err)
defer db.Close()
cc := createCache(t)
defer cc.Close()
err = cc.Update(db)
assert.Tf(t, err == nil, "%v", err)
}
......@@ -161,6 +161,7 @@ func main() {
}()
completionCache, err := shell.CreateCache()
check(err)
defer completionCache.Close()
state.SetWordCompleter(func(line string, pos int) (string, []string, string) {
return completion(completionCache, line, pos)
})
......
......@@ -537,8 +537,8 @@ func (c *Conn) Close() error {
} else {
Log(C.SQLITE_MISUSE, "Dangling statement (not finalize): \""+C.GoString(C.sqlite3_sql(stmt))+"\"")
}
C.sqlite3_finalize(stmt)
stmt = C.sqlite3_next_stmt(c.db, nil)
//C.sqlite3_finalize(stmt)
stmt = C.sqlite3_next_stmt(c.db, stmt)
}
rv := C.sqlite3_close(c.db)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment