diff options
-rw-r--r-- | libpqpp/pq-column.cpp | 4 | ||||
-rw-r--r-- | libpqpp/pq-column.h | 6 | ||||
-rw-r--r-- | libpqpp/pq-cursorselectcommand.cpp | 3 | ||||
-rw-r--r-- | libpqpp/pq-cursorselectcommand.h | 8 | ||||
-rw-r--r-- | libpqpp/pq-selectbase.cpp | 9 | ||||
-rw-r--r-- | libpqpp/pq-selectbase.h | 20 |
6 files changed, 37 insertions, 13 deletions
diff --git a/libpqpp/pq-column.cpp b/libpqpp/pq-column.cpp index 31a3d9b..a073f26 100644 --- a/libpqpp/pq-column.cpp +++ b/libpqpp/pq-column.cpp @@ -1,10 +1,10 @@ #include "pq-column.h" -#include "pq-cursorselectcommand.h" +#include "pq-selectbase.h" #include "pq-error.h" #include <string.h> #include <boost/date_time/posix_time/posix_time.hpp> -PQ::Column::Column(const CursorSelectCommand * s, unsigned int i) : +PQ::Column::Column(const SelectBase * s, unsigned int i) : DB::Column(PQfname(s->execRes, i), i), sc(s), oid(PQftype(sc->execRes, colNo)) diff --git a/libpqpp/pq-column.h b/libpqpp/pq-column.h index 99a37fb..f01ee9a 100644 --- a/libpqpp/pq-column.h +++ b/libpqpp/pq-column.h @@ -5,16 +5,16 @@ #include <libpq-fe.h> namespace PQ { - class CursorSelectCommand; + class SelectBase; class Column : public DB::Column { public: - Column(const CursorSelectCommand *, unsigned int field); + Column(const SelectBase *, unsigned int field); bool isNull() const override; void apply(DB::HandleField &) const override; protected: - const CursorSelectCommand * sc; + const SelectBase * sc; const Oid oid; }; } diff --git a/libpqpp/pq-cursorselectcommand.cpp b/libpqpp/pq-cursorselectcommand.cpp index fe097a5..ab21f66 100644 --- a/libpqpp/pq-cursorselectcommand.cpp +++ b/libpqpp/pq-cursorselectcommand.cpp @@ -9,10 +9,7 @@ PQ::CursorSelectCommand::CursorSelectCommand(Connection * conn, const std::strin PQ::Command(conn, sql, no), executed(false), txOpened(false), - nTuples(0), - tuple(0), fTuples(35), - execRes(NULL), s_declare(mkdeclare()), s_fetch(mkfetch()), s_close(mkclose()) diff --git a/libpqpp/pq-cursorselectcommand.h b/libpqpp/pq-cursorselectcommand.h index aafe4e1..6182d3f 100644 --- a/libpqpp/pq-cursorselectcommand.h +++ b/libpqpp/pq-cursorselectcommand.h @@ -2,6 +2,7 @@ #define PQ_CURSORSELECTCOMMAND_H #include <selectcommand.h> +#include "pq-selectbase.h" #include "pq-command.h" #include <vector> #include <map> @@ -9,7 +10,7 @@ namespace PQ { class Connection; class Column; - class CursorSelectCommand : public DB::SelectCommand, public Command { + class CursorSelectCommand : public DB::SelectCommand, public SelectBase, public Command { public: CursorSelectCommand(Connection *, const std::string & sql, unsigned int no); virtual ~CursorSelectCommand(); @@ -25,13 +26,10 @@ namespace PQ { mutable bool executed; mutable bool txOpened; - int nTuples, tuple, fTuples; - PGresult * execRes; + int fTuples; std::string s_declare; std::string s_fetch; std::string s_close; - - friend class Column; }; } diff --git a/libpqpp/pq-selectbase.cpp b/libpqpp/pq-selectbase.cpp new file mode 100644 index 0000000..1ede6b8 --- /dev/null +++ b/libpqpp/pq-selectbase.cpp @@ -0,0 +1,9 @@ +#include "pq-selectbase.h" + +PQ::SelectBase::SelectBase() : + nTuples(0), + tuple(0), + execRes(NULL) +{ +} + diff --git a/libpqpp/pq-selectbase.h b/libpqpp/pq-selectbase.h new file mode 100644 index 0000000..217a9e7 --- /dev/null +++ b/libpqpp/pq-selectbase.h @@ -0,0 +1,20 @@ +#ifndef PQ_SELECTBASE_H +#define PQ_SELECTBASE_H + +#include <libpq-fe.h> + +namespace PQ { + class SelectBase { + friend class Column; + + protected: + SelectBase(); + ~SelectBase() = default; + + int nTuples, tuple; + PGresult * execRes; + }; +} + +#endif + |