13#ifndef PQXX_H_PIPELINE
14#define PQXX_H_PIPELINE
16#if !defined(PQXX_HEADER_PRE)
17# error "Include libpqxx headers as <pqxx/header>, not <pqxx/header.hxx>."
24#include "pqxx/transaction_base.hxx"
81 query_id insert(std::string_view) &;
116 [[nodiscard]]
bool is_finished(query_id) const;
127 return retrieve(m_queries.find(qid)).second;
132 std::pair<query_id, result> retrieve();
134 [[nodiscard]]
bool empty() const noexcept {
return std::empty(m_queries); }
149 int retain(
int retain_max = 2) &;
156 struct PQXX_PRIVATE Query
158 explicit Query(std::string_view q) :
159 query{std::make_shared<std::string>(q)}
162 std::shared_ptr<std::string> query;
166 using QueryMap = std::map<query_id, Query>;
173 static constexpr query_id qid_limit() noexcept
179 return (std::numeric_limits<query_id>::max)();
183 PQXX_PRIVATE query_id generate_id();
185 bool have_pending() const noexcept
187 return m_issuedrange.second != m_issuedrange.first;
190 PQXX_PRIVATE
void issue();
193 void set_error_at(query_id qid)
noexcept
201 [[noreturn]] PQXX_PRIVATE
void internal_error(std::string
const &err);
203 PQXX_PRIVATE
bool obtain_result(
bool expect_none =
false);
205 PQXX_PRIVATE
void obtain_dummy();
206 PQXX_PRIVATE
void get_further_available_results();
207 PQXX_PRIVATE
void check_end_results();
210 PQXX_PRIVATE
void receive_if_available();
213 PQXX_PRIVATE
void receive(pipeline::QueryMap::const_iterator stop);
214 std::pair<pipeline::query_id, result> retrieve(pipeline::QueryMap::iterator);
217 std::pair<QueryMap::iterator, QueryMap::iterator> m_issuedrange;
219 int m_num_waiting = 0;
223 bool m_dummy_pending =
false;
226 query_id m_error = qid_limit();
232 internal::encoding_group m_encoding;
234 static constexpr std::string_view s_classname{
"pipeline"};
The home of all libpqxx classes, functions, templates, etc.
Definition array.hxx:27
Processes several queries in FIFO manner, optimized for high throughput.
Definition pipeline.hxx:51
pipeline(transaction_base &t)
Start a pipeline.
Definition pipeline.hxx:60
bool empty() const noexcept
Definition pipeline.hxx:134
pipeline & operator=(pipeline const &)=delete
pipeline(transaction_base &t, std::string_view tname)
Start a pipeline. Assign it a name, for more helpful error messages.
Definition pipeline.hxx:65
pipeline(pipeline const &)=delete
long query_id
Identifying numbers for queries.
Definition pipeline.hxx:54
Result set containing data returned by a query or command.
Definition result.hxx:74
Interface definition (and common code) for "transaction" classes.
Definition transaction_base.hxx:77
Base class for things that monopolise a transaction's attention.
Definition transaction_focus.hxx:29