diff --git a/src/PqResultImpl.cpp b/src/PqResultImpl.cpp index 3b12892f..5cd7d668 100644 --- a/src/PqResultImpl.cpp +++ b/src/PqResultImpl.cpp @@ -63,7 +63,7 @@ PqResultImpl::~PqResultImpl() { PqResultImpl::_cache::_cache() : initialized_(false), ncols_(0), nparams_(0) {} -void PqResultImpl::_cache::set(PGresult* spec) { +void PqResultImpl::_cache::set(PGresult* spec, bool enforce_result) { // always: should be fast if (nparams_ == 0) { nparams_ = PQnparams(spec); @@ -83,7 +83,7 @@ void PqResultImpl::_cache::set(PGresult* spec) { return; } - initialized_ = true; + initialized_ = enforce_result; names_ = new_names; oids_ = new_oids; types_ = get_column_types(oids_, names_); @@ -248,7 +248,7 @@ void PqResultImpl::prepare() { } pSpec_ = spec; - cache.set(spec); + cache.set(spec, false); } void PqResultImpl::init(bool params_have_rows) { @@ -532,7 +532,7 @@ bool PqResultImpl::step_run() { } if (need_cache_reset) { - cache.set(pRes_); + cache.set(pRes_, true); } if (status == PGRES_SINGLE_TUPLE) { diff --git a/src/PqResultImpl.h b/src/PqResultImpl.h index e707a52d..15424666 100644 --- a/src/PqResultImpl.h +++ b/src/PqResultImpl.h @@ -34,7 +34,7 @@ class PqResultImpl : boost::noncopyable, public PqResultSource { int nparams_; _cache(); - void set(PGresult* spec); + void set(PGresult* spec, bool enforce_result); static std::vector get_column_names(PGresult* spec); static DATA_TYPE get_column_type_from_oid(const Oid type);