summaryrefslogtreecommitdiff
path: root/libpqpp/pq-cursorselectcommand.cpp
diff options
context:
space:
mode:
authorDan Goodliffe <daniel.goodliffe@pressassociation.com>2017-01-03 15:03:05 +0000
committerDan Goodliffe <daniel.goodliffe@pressassociation.com>2017-01-03 15:16:54 +0000
commit40772ae759fe26acc69bebefa0eda173dbd981e4 (patch)
tree7afa52df382f8e8ee091dbb7acafee175403c9fb /libpqpp/pq-cursorselectcommand.cpp
parentOnly set unlogged for mocked tables on server versions 9.5 and above (diff)
downloadlibdbpp-postgresql-40772ae759fe26acc69bebefa0eda173dbd981e4.tar.bz2
libdbpp-postgresql-40772ae759fe26acc69bebefa0eda173dbd981e4.tar.xz
libdbpp-postgresql-40772ae759fe26acc69bebefa0eda173dbd981e4.zip
Refactor to remove some duplication
Diffstat (limited to 'libpqpp/pq-cursorselectcommand.cpp')
-rw-r--r--libpqpp/pq-cursorselectcommand.cpp11
1 files changed, 2 insertions, 9 deletions
diff --git a/libpqpp/pq-cursorselectcommand.cpp b/libpqpp/pq-cursorselectcommand.cpp
index 29e29f5..fbc14eb 100644
--- a/libpqpp/pq-cursorselectcommand.cpp
+++ b/libpqpp/pq-cursorselectcommand.cpp
@@ -1,12 +1,11 @@
#include "pq-cursorselectcommand.h"
#include "pq-connection.h"
-#include "pq-column.h"
#include "pq-error.h"
#include <compileTimeFormatter.h>
PQ::CursorSelectCommand::CursorSelectCommand(Connection * conn, const std::string & sql, unsigned int no) :
DB::Command(sql),
- DB::SelectCommand(sql),
+ PQ::SelectBase(sql),
PQ::Command(conn, sql, no),
executed(false),
txOpened(false),
@@ -19,9 +18,6 @@ PQ::CursorSelectCommand::CursorSelectCommand(Connection * conn, const std::strin
PQ::CursorSelectCommand::~CursorSelectCommand()
{
- if (execRes) {
- PQclear(execRes);
- }
if (executed && PQtransactionStatus(c->conn) != PQTRANS_INERROR) {
c->checkResultFree((PQexec(c->conn, s_close.c_str())), PGRES_COMMAND_OK);
}
@@ -65,10 +61,7 @@ PQ::CursorSelectCommand::execute()
PQexecParams(c->conn, s_declare.c_str(), values.size(), NULL, &values.front(), &lengths.front(), NULL, 0),
PGRES_COMMAND_OK);
fetchTuples();
- unsigned int nFields = PQnfields(execRes);
- for (unsigned int f = 0; f < nFields; f += 1) {
- insertColumn(DB::ColumnPtr(new Column(this, f)));
- }
+ createColumns(execRes);
executed = true;
}
}