diff --git a/CHANGELOG b/CHANGELOG index 77e886836..6a3157be6 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -14,6 +14,8 @@ For a complete change history, see the SVN log. Mapnik 0.6.2 Release -------------------- +- PostGIS Plugin: Throw and report errors if SQL execution fails (r1291) (#363) + - PostGIS Plugin: Added missing support for BigInt(int8) postgres datatypes (r1250) (#384) diff --git a/plugins/input/postgis/connection.hpp b/plugins/input/postgis/connection.hpp index 86fac4031..373452a2a 100644 --- a/plugins/input/postgis/connection.hpp +++ b/plugins/input/postgis/connection.hpp @@ -72,10 +72,26 @@ class Connection PGresult *result=0; if (type==1) { - result=PQexecParams(conn_,sql.c_str(),0,0,0,0,0,1); - return boost::shared_ptr(new ResultSet(result)); + result=PQexecParams(conn_,sql.c_str(),0,0,0,0,0,1); } - result=PQexec(conn_,sql.c_str()); + else + { + result=PQexec(conn_,sql.c_str()); + } + if(!result || PQresultStatus(result) != PGRES_TUPLES_OK) + { + std::string s("PSQL error"); + if (conn_ ) + { + std::string msg = PQerrorMessage( conn_ ); + if ( ! msg.empty() ) + { + s += ":\n" + msg.substr( 0, msg.size() - 1 ); + } + } + throw mapnik::datasource_exception( s ); + } + return boost::shared_ptr(new ResultSet(result)); }