summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2017-01-04 00:24:51 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2017-01-04 00:24:51 +0000
commitf7f56c2476561240dfe1e30075ab73022b960562 (patch)
tree5f9e8f235bfcc504a6eace6ab5b2152b15b95659
parentNo need for 1 line wrappers anymore (diff)
downloadlibdbpp-postgresql-f7f56c2476561240dfe1e30075ab73022b960562.tar.bz2
libdbpp-postgresql-f7f56c2476561240dfe1e30075ab73022b960562.tar.xz
libdbpp-postgresql-f7f56c2476561240dfe1e30075ab73022b960562.zip
Tidy clearing of PGresults
-rw-r--r--libpqpp/pq-cursorselectcommand.cpp9
1 files changed, 4 insertions, 5 deletions
diff --git a/libpqpp/pq-cursorselectcommand.cpp b/libpqpp/pq-cursorselectcommand.cpp
index 952da3e..4ee6e80 100644
--- a/libpqpp/pq-cursorselectcommand.cpp
+++ b/libpqpp/pq-cursorselectcommand.cpp
@@ -46,7 +46,7 @@ PQ::CursorSelectCommand::execute()
c->beginTx();
txOpened = true;
}
- execRes = c->checkResult(
+ c->checkResultFree(
PQexecParams(c->conn, s_declare.c_str(), values.size(), NULL, &values.front(), &lengths.front(), NULL, 0),
PGRES_COMMAND_OK);
fetchTuples();
@@ -58,10 +58,6 @@ PQ::CursorSelectCommand::execute()
void
PQ::CursorSelectCommand::fetchTuples()
{
- if (execRes) {
- PQclear(execRes);
- }
- execRes = NULL;
execRes = c->checkResult(PQexec(c->conn, s_fetch.c_str()), PGRES_TUPLES_OK);
nTuples = PQntuples(execRes);
tuple = -1;
@@ -72,6 +68,9 @@ PQ::CursorSelectCommand::fetch()
{
execute();
if ((tuple >= (nTuples - 1)) && (nTuples == fTuples)) {
+ // Delete the previous result set
+ PQclear(execRes);
+ execRes = NULL;
fetchTuples();
}
if (tuple++ < (nTuples - 1)) {