6 #ifndef PGSQL_CONNECTION_H 7 #define PGSQL_CONNECTION_H 12 #include <boost/scoped_ptr.hpp> 93 if (pgconn_ != NULL) {
102 if (pgconn_ != NULL) {
108 pgconn_ = connection;
115 operator PGconn*()
const {
122 operator bool()
const {
201 static const char DUPLICATE_KEY[];
203 static const char NULL_KEY[];
222 io_service_accessor_(io_accessor), io_service_(),
223 transaction_ref_count_(0) {
239 static std::pair<uint32_t, uint32_t>
276 std::string getConnParameters();
305 void startTransaction();
310 bool isTransactionStarted()
const;
344 void createSavepoint(
const std::string&
name);
355 void rollbackToSavepoint(
const std::string& name);
368 void executeSQL(
const std::string& sql);
377 bool compareError(
const PgSqlResult& r,
const char* error_state);
408 if (!io_service_ && io_service_accessor_) {
409 io_service_ = (*io_service_accessor_)();
410 io_service_accessor_.reset();
414 io_service_->post(std::bind(callback_, reconnectCtl()));
459 ConsumeResultRowFun process_result_row);
502 operator PGconn*()
const {
509 operator bool()
const {
530 void setIntParameterValue(
const std::string& name, int64_t min, int64_t max, T& value);
561 #endif // PGSQL_CONNECTION_H std::function< bool(util::ReconnectCtlPtr db_reconnect_ctl)> DbCallback
Defines a callback prototype for propagating events upward.
isc::asiolink::IOServicePtr io_service_
IOService object, used for all ASIO operations.
PgSqlHolder()
Constructor.
RAII wrapper for PostgreSQL Result sets.
~PgSqlHolder()
Destructor.
const Oid types[PGSQL_MAX_PARAMETERS_IN_QUERY]
OID types.
Postgresql connection handle Holder.
boost::shared_ptr< PgSqlResult > PgSqlResultPtr
int transaction_ref_count_
Reference counter for transactions.
boost::shared_ptr< IOService > IOServicePtr
Defines a smart pointer to an IOService instance.
IOServiceAccessorPtr io_service_accessor_
Accessor function which returns the IOService that can be used to recover the connection.
Common database connection class.
boost::shared_ptr< PgSqlConnection > PgSqlConnectionPtr
Defines a pointer to a PgSqlConnection.
void startRecoverDbConnection()
The recover connection.
const size_t PGSQL_MAX_PARAMETERS_IN_QUERY
static bool warned_about_tls
Emit the TLS support warning only once.
Common PgSql Connector Pool.
Defines the logger used by the top-level component of kea-lfc.
void setConnection(PGconn *connection)
Sets the connection to the value given.
Define a PostgreSQL statement.
PgSqlConnection(const ParameterMap ¶meters, IOServiceAccessorPtr io_accessor=IOServiceAccessorPtr(), DbCallback callback=DbCallback())
Constructor.
const char * text
Text representation of the actual query.
const char * name
Short name of the query.
const uint32_t PGSQL_SCHEMA_VERSION_MAJOR
Define the PostgreSQL backend version.
const size_t OID_NONE
Constants for PostgreSQL data types These are defined by PostgreSQL in <catalog/pg_type.h>, but including this file is extraordinarily convoluted, so we'll use these to fill-in.
std::map< std::string, std::string > ParameterMap
Database configuration parameter map.
PgSqlHolder conn_
PgSql connection handle.
const size_t OID_TIMESTAMP
std::function< void(PgSqlResult &, int)> ConsumeResultRowFun
Function invoked to process fetched row.
int nbparams
Number of parameters for a given query.
boost::shared_ptr< IOServiceAccessor > IOServiceAccessorPtr
Pointer to an instance of IOServiceAccessor.
const uint32_t PGSQL_SCHEMA_VERSION_MINOR
RAII object representing a PostgreSQL transaction.