Improved error handling of SQLite spatial queries a bit.

This commit is contained in:
Sascha L. Teichmann 2014-09-01 14:28:12 +02:00
parent f7a8c1fdec
commit f82216807e

View File

@ -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