From 81a88cec734d2ebe34310f92150b944eb38b0634 Mon Sep 17 00:00:00 2001 From: Sven Engelhardt Date: Thu, 1 Mar 2012 17:52:03 +0100 Subject: [PATCH] database/sql expects io.EOF after all rows have been Next'ed Return io.EOF, so rows.Next() will automatically call rows.Close() after all results have been returned. --- sqlite3.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sqlite3.go b/sqlite3.go index 69aa89f..02e7107 100644 --- a/sqlite3.go +++ b/sqlite3.go @@ -19,9 +19,10 @@ _sqlite3_bind_blob(sqlite3_stmt *stmt, int n, void *p, int np) { */ import "C" import ( - "errors" "database/sql" "database/sql/driver" + "errors" + "io" "unsafe" ) @@ -247,6 +248,9 @@ func (rc *SQLiteRows) Columns() []string { func (rc *SQLiteRows) Next(dest []driver.Value) error { rv := C.sqlite3_step(rc.s.s) + if rv == C.SQLITE_DONE { + return io.EOF + } if rv != C.SQLITE_ROW { return errors.New(C.GoString(C.sqlite3_errmsg(rc.s.c.db))) }