From bac96d1b62dde949412a998cb0c3231ad179d870 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Tue, 3 Jan 2017 15:03:05 +0000 Subject: Refactor to remove some duplication --- libpqpp/pq-cursorselectcommand.cpp | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) (limited to 'libpqpp/pq-cursorselectcommand.cpp') 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 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; } } -- cgit v1.2.3