aboutsummaryrefslogtreecommitdiff
path: root/sqlite.go
diff options
context:
space:
mode:
authorJan Mercl <0xjnml@gmail.com>2020-01-01 12:05:39 +0100
committerJan Mercl <0xjnml@gmail.com>2020-01-01 12:05:39 +0100
commit141c3f22b73a14d118abcb04b1d6766d6591fad9 (patch)
tree812324599c4c5d155e29c97825bc6324d48eb87b /sqlite.go
parentef38ac9c3be91d0b0c15bdcfa89e0469f7150ba0 (diff)
fix forgotten TODO
Diffstat (limited to 'sqlite.go')
-rw-r--r--sqlite.go22
1 files changed, 15 insertions, 7 deletions
diff --git a/sqlite.go b/sqlite.go
index 54549cf..73c3cd1 100644
--- a/sqlite.go
+++ b/sqlite.go
@@ -171,9 +171,10 @@ type rows struct {
pstmt crt.Intptr
doStep bool
+ empty bool
}
-func newRows(c *conn, pstmt crt.Intptr, allocs []crt.Intptr) (r *rows, err error) {
+func newRows(c *conn, pstmt crt.Intptr, allocs []crt.Intptr, empty bool) (r *rows, err error) {
defer func() {
if err != nil {
c.finalize(pstmt)
@@ -218,6 +219,10 @@ func (r *rows) Columns() (c []string) {
//
// Next should return io.EOF when there are no more rows.
func (r *rows) Next(dest []driver.Value) (err error) {
+ if r.empty {
+ return io.EOF
+ }
+
rc := bin.DSQLITE_ROW
if r.doStep {
if rc, err = r.c.step(r.pstmt); err != nil {
@@ -480,7 +485,7 @@ func (s *stmt) query(ctx context.Context, args []driver.NamedValue) (r driver.Ro
switch rc & 0xff {
case bin.DSQLITE_ROW:
- if r, err = newRows(s.c, pstmt, allocs); err != nil {
+ if r, err = newRows(s.c, pstmt, allocs, false); err != nil {
return err
}
@@ -492,16 +497,19 @@ func (s *stmt) query(ctx context.Context, args []driver.NamedValue) (r driver.Ro
return s.c.errstr(int32(rc))
}
+ if *(*byte)(unsafe.Pointer(uintptr(psql))) == 0 {
+ if r, err = newRows(s.c, pstmt, allocs, true); err != nil {
+ return err
+ }
+
+ pstmt = 0
+ }
return nil
}(); err != nil {
return nil, err
}
}
- if r != nil {
- return r, nil
- }
-
- panic("TODO")
+ return r, err
}
type tx struct {