From f1b84527943c32b13c12cc97acfd4fd78ad63b77 Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Thu, 15 Sep 2011 21:58:20 +0000 Subject: [PATCH] sqlite: report rtree index creation failure - patch from kkaefer - closes #884 --- plugins/input/sqlite/sqlite_datasource.cpp | 17 +++++++++++++++-- plugins/input/sqlite/sqlite_types.hpp | 10 +++++++++- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/plugins/input/sqlite/sqlite_datasource.cpp b/plugins/input/sqlite/sqlite_datasource.cpp index ddbb71a79..710322849 100644 --- a/plugins/input/sqlite/sqlite_datasource.cpp +++ b/plugins/input/sqlite/sqlite_datasource.cpp @@ -540,11 +540,24 @@ void sqlite_datasource::bind() const (sqlite3_bind_double(stmt, 5 , bbox.maxy() ) != SQLITE_OK)) { throw datasource_exception("invalid value for for extent while generating index"); } - - sqlite3_step(stmt); + + int res = sqlite3_step(stmt); + if (res != SQLITE_DONE) { + std::ostringstream s; + s << "SQLite Plugin: inserting bbox into rtree index failed: " + << "error code " << sqlite3_errcode(*(*dataset_)) << ": '" + << sqlite3_errmsg(*(*dataset_)) << "' query was: " << spatial_index_insert_sql; + throw datasource_exception(s.str()); + } sqlite3_reset(stmt); } } + else { + std::ostringstream index_error; + index_error << "SQLite Plugin: encountered invalid bbox at '" + << key_field_ << "' == " << rs->column_integer64(1); + throw datasource_exception(index_error.str()); + } } } diff --git a/plugins/input/sqlite/sqlite_types.hpp b/plugins/input/sqlite/sqlite_types.hpp index c2dc5238d..7c5727254 100644 --- a/plugins/input/sqlite/sqlite_types.hpp +++ b/plugins/input/sqlite/sqlite_types.hpp @@ -58,7 +58,15 @@ public: bool step_next () { - return (sqlite3_step (stmt_) == SQLITE_ROW); + int status = sqlite3_step (stmt_); + if (status != SQLITE_ROW && status != SQLITE_DONE) { + std::ostringstream s; + s << "SQLite Plugin: retrieving next row failed"; + std::string msg(sqlite3_errmsg(sqlite3_db_handle(stmt_))); + if (msg != "unknown error") s << ": " << msg; + throw mapnik::datasource_exception(s.str()); + } + return status == SQLITE_ROW; } int column_count ()