diff options
Diffstat (limited to 'libpqpp/pq-column.cpp')
-rw-r--r-- | libpqpp/pq-column.cpp | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/libpqpp/pq-column.cpp b/libpqpp/pq-column.cpp index bb09c45..92107e8 100644 --- a/libpqpp/pq-column.cpp +++ b/libpqpp/pq-column.cpp @@ -7,10 +7,18 @@ PQ::Column::Column(const SelectBase * s, unsigned int i) : DB::Column(PQfname(s->execRes, i), i), sc(s), - oid(PQftype(sc->execRes, colNo)) + oid(PQftype(sc->execRes, colNo)), + buf(nullptr) { } +PQ::Column::~Column() +{ + if (buf) { + PQfreemem(buf); + } +} + bool PQ::Column::isNull() const { @@ -67,6 +75,16 @@ PQ::Column::apply(DB::HandleField & h) const case 1184: //TIMESTAMPTZOID: h.timestamp(boost::posix_time::time_from_string(PQgetvalue(sc->execRes, sc->tuple, colNo))); break; + case 17: //BYTEAOID + { + if (buf) { + PQfreemem(buf); + } + size_t len; + buf = PQunescapeBytea((unsigned char *)PQgetvalue(sc->execRes, sc->tuple, colNo), &len); + h.blob(DB::Blob(buf, len)); + break; + } default: h.string(PQgetvalue(sc->execRes, sc->tuple, colNo), PQgetlength(sc->execRes, sc->tuple, colNo)); } |