6 #ifndef PGSQL_CONNECTION_H
7 #define PGSQL_CONNECTION_H
13 #include <boost/scoped_ptr.hpp>
152 operator PGresult*()
const {
159 operator bool()
const {
195 if (pgconn_ != NULL) {
204 if (pgconn_ != NULL) {
210 pgconn_ = connection;
217 operator PGconn*()
const {
224 operator bool()
const {
233 class PgSqlConnection;
332 static std::pair<uint32_t, uint32_t>
450 operator PGconn*()
const {
457 operator bool()
const {
477 #endif // PGSQL_CONNECTION_H
isc::asiolink::IOServicePtr io_service_
IOService object, used for all ASIO operations.
PgSqlHolder()
Constructor.
RAII wrapper for PostgreSQL Result sets.
~PgSqlTransaction()
Destructor.
~PgSqlHolder()
Destructor.
const Oid types[PGSQL_MAX_PARAMETERS_IN_QUERY]
OID types.
void startTransaction()
Start a transaction.
void commit()
Commits transaction.
Postgresql connection handle Holder.
ReconnectCtlPtr reconnectCtl()
The reconnect settings.
void colCheck(int col) const
Determines if a column index is valid.
bool compareError(const PgSqlResult &r, const char *error_state)
Checks a result set's SQL state against an error state.
void rowColCheck(int row, int col) const
Determines if both a row and column index are valid.
PgSqlResult(PGresult *result)
Constructor.
static const char DUPLICATE_KEY[]
Define the PgSql error state for a duplicate key error.
void rowCheck(int row) const
Determines if a row index is valid.
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.
int getRows() const
Returns the number of rows in the result set.
void commit()
Commit Transactions.
void startRecoverDbConnection()
The recover connection.
void prepareStatements(const PgSqlTaggedStatement *start_statement, const PgSqlTaggedStatement *end_statement)
Prepare statements.
const uint32_t PG_SCHEMA_VERSION_MINOR
const size_t PGSQL_MAX_PARAMETERS_IN_QUERY
void checkStatementError(const PgSqlResult &r, PgSqlTaggedStatement &statement)
Checks result of the r object.
void rollback()
Rollback Transactions.
PgSqlTransaction(PgSqlConnection &conn)
Constructor.
Common PgSql Connector Pool.
virtual ~PgSqlConnection()
Destructor.
void prepareStatement(const PgSqlTaggedStatement &statement)
Prepare Single Statement.
Defines the logger used by the top-level component of kea-dhcp-ddns.
int getCols() const
Returns the number of columns in the result set.
std::function< bool(ReconnectCtlPtr db_reconnect_ctl)> DbCallback
Defines a callback prototype for propagating events upward.
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.
~PgSqlResult()
Destructor.
std::string getColumnLabel(const int col) const
Fetches the name of the column in a result set.
void openDatabase()
Open Database.
const char * name
Short name of the query.
static std::pair< uint32_t, uint32_t > getVersion(const ParameterMap ¶meters)
Get the schema version.
const size_t OID_NONE
Constants for PostgreSQL data types These are defined by PostgreSQL in , 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 uint32_t PG_SCHEMA_VERSION_MAJOR
Define PostgreSQL backend version: 6.2.
const size_t OID_TIMESTAMP
int nbparams
Number of parameters for a given query.
boost::shared_ptr< IOServiceAccessor > IOServiceAccessorPtr
Pointer to an instance of IOServiceAccessor.
DbCallback callback_
The callback used to recover the connection.
RAII object representing a PostgreSQL transaction.