From f82216807ea248386b2a32df13d91f4ee046f11e Mon Sep 17 00:00:00 2001 From: "Sascha L. Teichmann" Date: Mon, 1 Sep 2014 14:28:12 +0200 Subject: [PATCH] Improved error handling of SQLite spatial queries a bit. --- sqlite.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/sqlite.go b/sqlite.go index 103544b..38dbb05 100644 --- a/sqlite.go +++ b/sqlite.go @@ -333,21 +333,24 @@ func (ss *SqliteSession) interleavedSpatialQuery(first, second []byte, done chan rows *sql.Rows ) if rows, err = rangeStmt.Query(zmin, zmax); err != nil { + log.Printf("Error in range query: %s", err) return } for rows.Next() { var zcode int64 var data []byte if err = rows.Scan(&zcode, &data); err != nil { - log.Printf("Error in range query: %s", err) - break + log.Printf("Error in scanning row: %s", err) + rows.Close() + return } c := common.InterleavedToCoord(zcode) if cub.Contains(c) { var encodedKey []byte if encodedKey, err = common.EncodeStringToBytes(common.CoordToPlain(c)); err != nil { log.Printf("Key encoding failed: %s", err) - break + rows.Close() + return } select { case blocks <- Block{Key: encodedKey, Data: data}: @@ -409,13 +412,14 @@ func (ss *SqliteSession) plainSpatialQuery(first, second []byte, done chan struc // Ordering should not be necessary. from, to := order(common.CoordToPlain(a), common.CoordToPlain(b)) if rows, err = rangeStmt.Query(from, to); err != nil { + log.Printf("Error in range query: %s", err) return } for rows.Next() { var key int64 var data []byte if err = rows.Scan(&key, &data); err != nil { - log.Printf("Error in range query: %s", err) + log.Printf("Error in scanning row: %s", err) break } var encodedKey []byte