Skip to content

Commit

Permalink
Merge branch 'master' of github.com:PDAL/PDAL
Browse files Browse the repository at this point in the history
  • Loading branch information
hobu committed Jun 17, 2013
2 parents 3012ebb + 83d3467 commit daf8ce3
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions include/pdal/drivers/pgpointcloud/common.hpp
Expand Up @@ -83,7 +83,7 @@ inline PGconn* pg_connect(std::string const& connection)
PQconninfoOption *connOptions = PQconninfoParse(connection.c_str(), &errstr);
if ( ! connOptions )
{
throw pdal_error(errstr);
throw pdal_error(errstr);
}

/* connect to database */
Expand All @@ -101,7 +101,8 @@ inline void pg_execute(PGconn* session, std::string const& sql)
PGresult *result = PQexec(session, sql.c_str());
if ( (!result) || (PQresultStatus(result) != PGRES_COMMAND_OK) )
{
throw pdal_error(PQerrorMessage(session));
std::string errmsg = std::string(PQerrorMessage(session));
throw pdal_error(errmsg);
}
PQclear(result);
}
Expand Down Expand Up @@ -137,12 +138,20 @@ inline char* pg_query_once(PGconn* session, std::string const& sql)

inline PGresult* pg_query_result(PGconn* session, std::string const& sql)
{
std::string errmsg;
PGresult *result = PQexec(session, sql.c_str());
if ( ! result )
throw pdal_error(PQerrorMessage(session));
{
errmsg = std::string(PQerrorMessage(session));
throw pdal_error(errmsg);
}

if ( PQresultStatus(result) != PGRES_TUPLES_OK )
throw pdal_error(PQresultErrorMessage(result));
{
errmsg = std::string(PQresultErrorMessage(result));
PQclear(result);
throw pdal_error(errmsg);
}

return result;
}
Expand Down

0 comments on commit daf8ce3

Please sign in to comment.