13 #ifndef PQXX_H_PIPELINE
14 #define PQXX_H_PIPELINE
16 #include "pqxx/compiler-public.hxx"
17 #include "pqxx/compiler-internal-pre.hxx"
23 #include "pqxx/transaction_base.hxx"
58 const std::string &Name=std::string{});
69 query_id insert(const std::
string &);
99 bool is_finished(query_id) const;
109 {
return retrieve(m_queries.find(qid)).second; }
113 std::pair<query_id, result> retrieve();
115 bool empty() const noexcept {
return m_queries.empty(); }
129 int retain(
int retain_max=2);
136 class PQXX_PRIVATE Query
139 explicit Query(
const std::string &q) : m_query{q}, m_res{} {}
141 const result &get_result() const noexcept {
return m_res; }
142 void set_result(
const result &r) noexcept { m_res = r; }
143 const std::string &get_query() const noexcept {
return m_query; }
150 using QueryMap = std::map<query_id,Query>;
156 static constexpr query_id qid_limit() noexcept
162 return (std::numeric_limits<query_id>::max)();
166 PQXX_PRIVATE query_id generate_id();
168 bool have_pending() const noexcept
169 {
return m_issuedrange.second != m_issuedrange.first; }
171 PQXX_PRIVATE
void issue();
174 void set_error_at(query_id qid) noexcept
175 {
if (qid < m_error) m_error = qid; }
178 [[noreturn]] PQXX_PRIVATE
void internal_error(
const std::string &err);
180 PQXX_PRIVATE
bool obtain_result(
bool expect_none=
false);
182 PQXX_PRIVATE
void obtain_dummy();
183 PQXX_PRIVATE
void get_further_available_results();
184 PQXX_PRIVATE
void check_end_results();
187 PQXX_PRIVATE
void receive_if_available();
190 PQXX_PRIVATE
void receive(pipeline::QueryMap::const_iterator stop);
191 std::pair<pipeline::query_id, result>
192 retrieve(pipeline::QueryMap::iterator);
195 std::pair<QueryMap::iterator,QueryMap::iterator> m_issuedrange;
197 int m_num_waiting = 0;
201 bool m_dummy_pending =
false;
204 query_id m_error = qid_limit();
209 #include "pqxx/compiler-internal-post.hxx"
PQXX_PURE size_type size() const noexcept
Definition: result.cxx:94
void complete()
Wait for all ongoing or pending operations to complete.
Definition: pipeline.cxx:85
Private namespace for libpqxx's internal use; do not access.
Definition: connection_base.hxx:43
pipeline(const pipeline &)=delete
bool empty() const noexcept
Definition: pipeline.hxx:115
Processes several queries in FIFO manner, optimized for high throughput.
Definition: pipeline.hxx:48
bool is_finished(query_id) const
Is result for given query available?
Definition: pipeline.cxx:123
Result set containing data returned by a query or command.
Definition: result.hxx:69
void resume()
Resume retained query emission (harmless when not needed)
Definition: pipeline.cxx:158
query_id insert(const std::string &)
Add query to the pipeline.
Definition: pipeline.cxx:62
void flush()
Forget all ongoing or pending operations and retrieved results.
Definition: pipeline.cxx:97
Exception class for failed queries.
Definition: except.hxx:130
encoding_group enc_group(int libpq_enc_id)
Definition: encodings.cxx:637
int retain(int retain_max=2)
Set maximum number of queries to retain before issuing them to the backend.
Definition: pipeline.cxx:142
std::string separated_list(const std::string &sep, ITER begin, ITER end, ACCESS access)
Represent sequence of values as a string, joined by a given separator.
Definition: util.hxx:95
Internal error in libpqxx library.
Definition: except.hxx:207
Exception class for lost or failed backend connection.
Definition: except.hxx:118
std::pair< query_id, result > retrieve()
Retrieve oldest unretrieved result (possibly wait for one)
Definition: pipeline.cxx:134
const row at(size_type) const
Definition: result.cxx:131
Helper base class: object descriptions for error messages and such.
Definition: util.hxx:233
Definition: transaction_base.hxx:43
std::string to_string(const field &Obj)
Convert a field to a string.
Definition: result.cxx:451
~pipeline() noexcept
Definition: pipeline.cxx:43
long query_id
Definition: pipeline.hxx:51
Something is out of range, similar to std::out_of_range.
Definition: except.hxx:251
Interface definition (and common code) for "transaction" classes.
Definition: transaction_base.hxx:136
The home of all libpqxx classes, functions, templates, etc.
Definition: array.hxx:25
void cancel()
Cancel ongoing query, if any.
Definition: pipeline.cxx:111