summaryrefslogtreecommitdiff
path: root/libpqpp/connection.cpp
diff options
context:
space:
mode:
authorrandomdan <randomdan@localhost>2013-01-27 00:02:16 +0000
committerrandomdan <randomdan@localhost>2013-01-27 00:02:16 +0000
commit67cd4ca02d2581e8498c44bb640ea923a4ddc553 (patch)
tree0ee2e936d58e2064ff9b795ec96612212d0676cf /libpqpp/connection.cpp
parentDefault to string binding instead of throwing an error (diff)
downloadlibdbpp-postgresql-67cd4ca02d2581e8498c44bb640ea923a4ddc553.tar.bz2
libdbpp-postgresql-67cd4ca02d2581e8498c44bb640ea923a4ddc553.tar.xz
libdbpp-postgresql-67cd4ca02d2581e8498c44bb640ea923a4ddc553.zip
Fix issues with PQ connection errors not being handled correctly
Diffstat (limited to 'libpqpp/connection.cpp')
-rw-r--r--libpqpp/connection.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/libpqpp/connection.cpp b/libpqpp/connection.cpp
index d07b9d2..7c26ecb 100644
--- a/libpqpp/connection.cpp
+++ b/libpqpp/connection.cpp
@@ -89,6 +89,15 @@ PQ::Connection::bulkUpdateStyle() const
void
PQ::Connection::ping() const
{
+ if (PQstatus(conn) != CONNECTION_OK) {
+ if (inTx()) {
+ throw ConnectionError();
+ }
+ PQreset(conn);
+ if (PQstatus(conn) != CONNECTION_OK) {
+ throw ConnectionError();
+ }
+ }
}