sqlite: report rtree index creation failure - patch from kkaefer - closes #884

This commit is contained in:
Dane Springmeyer 2011-09-15 21:58:20 +00:00
parent 8e7950c318
commit f1b8452794
2 changed files with 24 additions and 3 deletions

View file

@ -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());
}
}
}

View file

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