summaryrefslogtreecommitdiff
path: root/libpqpp/pq-bulkselectcommand.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'libpqpp/pq-bulkselectcommand.cpp')
-rw-r--r--libpqpp/pq-bulkselectcommand.cpp13
1 files changed, 5 insertions, 8 deletions
diff --git a/libpqpp/pq-bulkselectcommand.cpp b/libpqpp/pq-bulkselectcommand.cpp
index 298261e..303ed53 100644
--- a/libpqpp/pq-bulkselectcommand.cpp
+++ b/libpqpp/pq-bulkselectcommand.cpp
@@ -10,21 +10,20 @@
PQ::BulkSelectCommand::BulkSelectCommand(Connection * conn, const std::string & sql,
const PQ::CommandOptionsCPtr & pqco, const DB::CommandOptionsCPtr & opts) :
DB::Command(sql),
- PQ::SelectBase(sql, pqco), PQ::PreparedStatement(conn, sql, opts), executed(false)
+ PQ::SelectBase(sql, pqco), PQ::PreparedStatement(conn, sql, opts)
{
}
void
PQ::BulkSelectCommand::execute()
{
- if (!executed) {
+ if (!execRes) {
execRes = c->checkResult(PQexecPrepared(c->conn, prepare(), static_cast<int>(values.size()), values.data(),
lengths.data(), formats.data(), binary),
PGRES_TUPLES_OK);
- nTuples = static_cast<decltype(nTuples)>(PQntuples(execRes));
+ nTuples = static_cast<decltype(nTuples)>(PQntuples(execRes.get()));
tuple = static_cast<decltype(tuple)>(-1);
- createColumns(execRes);
- executed = true;
+ createColumns();
}
}
@@ -36,9 +35,7 @@ PQ::BulkSelectCommand::fetch()
return true;
}
else {
- PQclear(execRes);
- execRes = nullptr;
- executed = false;
+ execRes.reset();
return false;
}
}