Commit 878a8077 authored by gwenn's avatar gwenn

Test Stmt misuse.

parent 7321b68b
......@@ -48,7 +48,6 @@ func TestBlobMisuse(t *testing.T) {
defer db.Close()
bw, err := db.NewBlobReadWriter("main", "test", "content", 0)
//t.Logf("%#v", err)
if bw != nil || err == nil {
t.Errorf("error expected")
}
......
......@@ -370,3 +370,31 @@ func TestScanNull(t *testing.T) {
t.Errorf("Expected nil but got %p\n", ps)
}
}
func TestCloseTwice(t *testing.T) {
db := open(t)
s, err := db.Prepare("SELECT 1")
checkNoError(t, err, "prepare error: %s")
err = s.Finalize()
checkNoError(t, err, "finalize error: %s")
err = s.Finalize()
checkNoError(t, err, "finalize error: %s")
err = db.Close()
checkNoError(t, err, "close error: %s")
err = db.Close()
checkNoError(t, err, "close error: %s")
}
func TestStmtMisuse(t *testing.T) {
db := open(t)
defer db.Close()
s, err := db.Prepare("MISUSE")
if s != nil || err == nil {
t.Error("error expected")
}
err = s.Finalize()
if err == nil {
t.Error("error expected")
}
}
......@@ -902,12 +902,18 @@ func (s *Stmt) Busy() bool {
// Destroy a prepared statement
// (See http://sqlite.org/c3ref/finalize.html)
func (s *Stmt) Finalize() error {
if s == nil {
return errors.New("nil sqlite statement")
}
if s.Cacheable {
return s.c.stmtCache.release(s)
}
return s.finalize()
}
func (s *Stmt) finalize() error {
if s == nil {
return errors.New("nil sqlite statement")
}
rv := C.sqlite3_finalize(s.stmt)
if rv != C.SQLITE_OK {
return s.error(rv)
......
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