Skip to content

Patch for Go issue 4459 #37

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
gwenn opened this issue Jan 13, 2013 · 0 comments
Closed

Patch for Go issue 4459 #37

gwenn opened this issue Jan 13, 2013 · 0 comments

Comments

@gwenn
Copy link

gwenn commented Jan 13, 2013

Hello,
A patch can be applied to go-sqlite3 to fix issue 4459 (https://code.google.com/p/go/issues/detail?id=4459):

diff --git a/sqlite3.go b/sqlite3.go
index 0a21d23..6070617 100644
--- a/sqlite3.go
+++ b/sqlite3.go
@@ -136,7 +136,7 @@ func (c *SQLiteConn) Close() error {
        }
        rv := C.sqlite3_close(c.db)
        if rv != C.SQLITE_OK {
-               return errors.New("sqlite succeeded without returning a database")
+               return errors.New("error while closing sqlite database connection")
        }
        c.db = nil
        return nil
@@ -170,6 +170,9 @@ func (s *SQLiteStmt) Close() error {
                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)))

The error messages may be improved...
Regards

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants