Example #1
0
func (stmt Stmt) Close() error {
	r := C.sqlite3_finalize(stmt.stmt)
	if r != C.SQLITE_OK {
		return driver.ErrBadConn
	}
	return nil
}
Example #2
0
func (s *Stmt) Finalize() error {
	rv := C.sqlite3_finalize(s.stmt)
	if rv != 0 {
		return s.c.error(rv)
	}
	return nil
}
Example #3
0
// Close closes a database connection and any dangling statements.
// (See http://sqlite.org/c3ref/close.html)
func (c *Conn) Close() error {
	if c == nil {
		return errors.New("nil sqlite database")
	}
	if c.db == nil {
		return nil
	}

	c.stmtCache.flush()

	// Dangling statements
	stmt := C.sqlite3_next_stmt(c.db, nil)
	for stmt != nil {
		if C.sqlite3_stmt_busy(stmt) != 0 {
			Log(C.SQLITE_MISUSE, "Dangling statement (not reset): \""+C.GoString(C.sqlite3_sql(stmt))+"\"")
		} 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)
	}

	rv := C.sqlite3_close(c.db)
	if rv != C.SQLITE_OK {
		Log(int(rv), "error while closing Conn")
		return c.error(rv, "Conn.Close")
	}
	c.db = nil
	return nil
}
Example #4
0
func (s *SQLiteStmt) Close() error {
	rv := C.sqlite3_finalize(s.s)
	if rv != C.SQLITE_OK {
		return errors.New(C.GoString(C.sqlite3_errmsg(s.c.db)))
	}
	return nil
}
Example #5
0
func (s *Stmt) Finalize() error {
	if s == nil {
		return errors.New("Finalize called on nil Statement")
	}
	rv := C.sqlite3_finalize(s.stmt)
	if rv != 0 {
		return s.c.error(rv)
	}
	return nil
}
Example #6
0
// Close releases all resources associated with the prepared statement. This
// method can be called at any point in the statement's life cycle.
// [http://www.sqlite.org/c3ref/finalize.html]
func (s *Stmt) Close() error {
	if stmt := s.stmt; stmt != nil {
		*s = Stmt{Tail: s.Tail, conn: s.conn, text: s.text}
		runtime.SetFinalizer(s, nil)
		if rc := C.sqlite3_finalize(stmt); rc != OK {
			return libErr(rc, s.conn.db)
		}
	}
	return nil
}
Example #7
0
File: stmt.go Project: pkf/gosqlite
func (s *Stmt) finalize() error {
	if s == nil {
		return errors.New("nil sqlite statement")
	}
	rv := C.sqlite3_finalize(s.stmt)
	s.stmt = nil
	if rv != C.SQLITE_OK {
		Log(int(rv), "error while finalizing Stmt")
		return s.error(rv, "Stmt.finalize")
	}
	return nil
}
Example #8
0
func (c *SQLiteConn) Close() error {
	s := C.sqlite3_next_stmt(c.db, nil)
	for s != nil {
		C.sqlite3_finalize(s)
		s = C.sqlite3_next_stmt(c.db, nil)
	}
	rv := C.sqlite3_close(c.db)
	if rv != C.SQLITE_OK {
		return errors.New("sqlite succeeded without returning a database")
	}
	c.db = nil
	return nil
}
Example #9
0
// Close the connection.
func (c *SQLiteConn) Close() error {
	s := C.sqlite3_next_stmt(c.db, nil)
	for s != nil {
		C.sqlite3_finalize(s)
		s = C.sqlite3_next_stmt(c.db, nil)
	}
	rv := C.sqlite3_close(c.db)
	if rv != C.SQLITE_OK {
		return ErrNo(rv)
	}
	c.db = nil
	return nil
}
Example #10
0
// Close the connection.
func (c *SQLiteConn) Close() error {
	s := C.sqlite3_next_stmt(c.db, nil)
	for s != nil {
		C.sqlite3_finalize(s)
		s = C.sqlite3_next_stmt(c.db, nil)
	}
	rv := C.sqlite3_close(c.db)
	if rv != C.SQLITE_OK {
		return errors.New("error while closing sqlite database connection")
	}
	c.db = nil
	return nil
}
Example #11
0
File: driver.go Project: rsc/sqlite
func (s *stmt) Close() error {
	if s.rows {
		panic("database/sql/driver: misuse of sqlite driver: Close with active Rows")
	}
	if s.closed {
		panic("database/sql/driver: misuse of sqlite driver: double Close of Stmt")
	}
	s.closed = true
	rv := C.sqlite3_finalize(s.stmt)
	if rv != 0 {
		return s.c.error(rv)
	}
	return nil
}
Example #12
0
// Close the statement.
func (s *SQLiteStmt) Close() error {
	if s.closed {
		return nil
	}
	s.closed = true
	if s.c == nil || s.c.db == nil {
		return errors.New("sqlite statement with already closed database connection")
	}
	rv := C.sqlite3_finalize(s.s)
	if rv != C.SQLITE_OK {
		return errors.New(C.GoString(C.sqlite3_errmsg(s.c.db)))
	}
	return nil
}
Example #13
0
// Close the statement.
func (s *SQLiteStmt) Close() error {
	if s.closed {
		return nil
	}
	s.closed = true
	if s.c == nil || s.c.db == nil {
		return errors.New("sqlite statement with already closed database connection")
	}
	rv := C.sqlite3_finalize(s.s)
	if rv != C.SQLITE_OK {
		return s.c.lastError()
	}
	runtime.SetFinalizer(s, nil)
	return nil
}
Example #14
0
func (s *Stmt) finalize() error {
	if s == nil {
		return errors.New("nil sqlite statement")
	}
	if s.stmt == nil {
		return nil
	}
	if s.c == nil || s.c.db == nil {
		Log(C.SQLITE_MISUSE, "sqlite statement with already closed database connection")
		return errors.New("sqlite statement with already closed database connection")
	}
	rv := C.sqlite3_finalize(s.stmt)
	s.stmt = nil
	if rv != C.SQLITE_OK {
		Log(int32(rv), "error while finalizing Stmt")
		return s.error(rv, "Stmt.finalize")
	}
	return nil
}
Example #15
0
// called to delete a prepared statement
func (h *Statement) Finalize() int {
	return int(C.sqlite3_finalize(h.cptr))
}
Example #16
0
// Finalize is used to delete a prepared statement in the SQLite engine.
func (s *Statement) Finalize() (e error) {
	return SQLiteError(C.sqlite3_finalize(s.cptr))
}
Example #17
0
func (self *sqlStatement) sqlFinalize() int {
	return int(C.sqlite3_finalize(self.handle))
}
Example #18
0
func (s *Statement) Finalize() os.Error {
	if e := Errno(C.sqlite3_finalize(s.cptr)); e != OK {
		return e
	}
	return nil
}