summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libpqpp/command.cpp2
-rw-r--r--libpqpp/connection.cpp12
-rw-r--r--libpqpp/connection.h4
-rw-r--r--libpqpp/modifycommand.cpp6
-rw-r--r--libpqpp/selectcommand.cpp2
5 files changed, 15 insertions, 11 deletions
diff --git a/libpqpp/command.cpp b/libpqpp/command.cpp
index a7dd1fd..419d953 100644
--- a/libpqpp/command.cpp
+++ b/libpqpp/command.cpp
@@ -48,7 +48,7 @@ PQ::Command::prepare() const
}
}
c->checkResultFree(PQprepare(
- c->conn, stmntName.c_str(), psql.c_str(), values.size(), NULL), PGRES_COMMAND_OK, __PRETTY_FUNCTION__);
+ c->conn, stmntName.c_str(), psql.c_str(), values.size(), NULL), PGRES_COMMAND_OK);
prepared = true;
}
}
diff --git a/libpqpp/connection.cpp b/libpqpp/connection.cpp
index 1805ff7..ef8e72d 100644
--- a/libpqpp/connection.cpp
+++ b/libpqpp/connection.cpp
@@ -4,7 +4,7 @@
#include "modifycommand.h"
static void
-noNoticeProcessor(void * arg, const char * message)
+noNoticeProcessor(void *, const char *)
{
}
@@ -28,7 +28,7 @@ int
PQ::Connection::beginTx() const
{
if (txDepth == 0) {
- checkResultFree(PQexec(conn, "BEGIN"), PGRES_COMMAND_OK, __PRETTY_FUNCTION__);
+ checkResultFree(PQexec(conn, "BEGIN"), PGRES_COMMAND_OK);
}
return ++txDepth;
}
@@ -37,7 +37,7 @@ int
PQ::Connection::commitTx() const
{
if (--txDepth == 0) {
- checkResultFree(PQexec(conn, "COMMIT"), PGRES_COMMAND_OK, __PRETTY_FUNCTION__);
+ checkResultFree(PQexec(conn, "COMMIT"), PGRES_COMMAND_OK);
}
return txDepth;
}
@@ -46,7 +46,7 @@ int
PQ::Connection::rollbackTx() const
{
if (--txDepth == 0) {
- checkResultFree(PQexec(conn, "ROLLBACK"), PGRES_COMMAND_OK, __PRETTY_FUNCTION__);
+ checkResultFree(PQexec(conn, "ROLLBACK"), PGRES_COMMAND_OK);
}
return txDepth;
}
@@ -94,7 +94,7 @@ PQ::Connection::checkResultInt(PGresult * res, int expected)
}
void
-PQ::Connection::checkResult(PGresult * res, int expected, const char * doing) const
+PQ::Connection::checkResult(PGresult * res, int expected) const
{
if (!checkResultInt(res, expected)) {
PQclear(res);
@@ -103,7 +103,7 @@ PQ::Connection::checkResult(PGresult * res, int expected, const char * doing) co
}
void
-PQ::Connection::checkResultFree(PGresult * res, int expected, const char * doing) const
+PQ::Connection::checkResultFree(PGresult * res, int expected) const
{
if (!checkResultInt(res, expected)) {
PQclear(res);
diff --git a/libpqpp/connection.h b/libpqpp/connection.h
index 8dafe84..4b9b28e 100644
--- a/libpqpp/connection.h
+++ b/libpqpp/connection.h
@@ -21,8 +21,8 @@ namespace PQ {
DB::SelectCommand * newSelectCommand(const std::string & sql) const;
DB::ModifyCommand * newModifyCommand(const std::string & sql) const;
- void checkResult(PGresult * res, int expected, const char * doing) const;
- void checkResultFree(PGresult * res, int expected, const char * doing) const;
+ void checkResult(PGresult * res, int expected) const;
+ void checkResultFree(PGresult * res, int expected) const;
PGconn * conn;
diff --git a/libpqpp/modifycommand.cpp b/libpqpp/modifycommand.cpp
index 14bfb16..ae7abeb 100644
--- a/libpqpp/modifycommand.cpp
+++ b/libpqpp/modifycommand.cpp
@@ -1,4 +1,5 @@
#include "modifycommand.h"
+#include "error.h"
#include <stdlib.h>
#include "connection.h"
@@ -18,9 +19,12 @@ PQ::ModifyCommand::execute(bool anc)
{
prepare();
PGresult * res = PQexecPrepared(c->conn, stmntName.c_str(), values.size(), &values.front(), &lengths.front(), &formats.front(), 0);
- c->checkResult(res, PGRES_COMMAND_OK, __PRETTY_FUNCTION__);
+ c->checkResult(res, PGRES_COMMAND_OK);
unsigned int rows = atoi(PQcmdTuples(res));
PQclear(res);
+ if (rows == 0 && !anc) {
+ throw Error("No rows affected");
+ }
return rows;
}
diff --git a/libpqpp/selectcommand.cpp b/libpqpp/selectcommand.cpp
index 603cffd..6ed0d5a 100644
--- a/libpqpp/selectcommand.cpp
+++ b/libpqpp/selectcommand.cpp
@@ -30,7 +30,7 @@ PQ::SelectCommand::execute()
if (!executed) {
prepare();
execRes = PQexecPrepared(c->conn, stmntName.c_str(), values.size(), &values.front(), &lengths.front(), &formats.front(), 0);
- c->checkResult(execRes, PGRES_TUPLES_OK, __PRETTY_FUNCTION__);
+ c->checkResult(execRes, PGRES_TUPLES_OK);
unsigned int nFields = PQnfields(execRes);
fields.resize(nFields);
for (unsigned int f = 0; f < nFields; f += 1) {