diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2017-01-04 00:24:51 +0000 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2017-01-04 00:24:51 +0000 |
commit | 37bfbff0f33b37fd6737d2911611c398964e8af7 (patch) | |
tree | 39f786c6f48e39e94c8b9fe42baa0749172157a8 /libpqpp/pq-cursorselectcommand.cpp | |
parent | No need for 1 line wrappers anymore (diff) | |
download | libdbpp-postgresql-37bfbff0f33b37fd6737d2911611c398964e8af7.tar.bz2 libdbpp-postgresql-37bfbff0f33b37fd6737d2911611c398964e8af7.tar.xz libdbpp-postgresql-37bfbff0f33b37fd6737d2911611c398964e8af7.zip |
Tidy clearing of PGresults
Diffstat (limited to 'libpqpp/pq-cursorselectcommand.cpp')
-rw-r--r-- | libpqpp/pq-cursorselectcommand.cpp | 9 |
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)) { |