Represents a connection to PostgreSQL database. More...
#include <Database.h>
Public Member Functions | |
Database (Database const &) | |
Database & | operator= (Database const &) |
Database (Database &&other) | |
Move constructs Database from other Database. | |
Database & | operator= (Database &&other) |
Move assigns from other Database. | |
Database (std::string const &conninfo, bool synchr=false) | |
Connects to database. | |
void | regist (std::string const &name, std::string const &sql, IStatement *st) |
Prepares server side prepared statement. | |
void | unregist (std::string const &name, IStatement *st) |
Deallocates server side prepared statement. | |
void | begin_transaction () |
Starts a transaction on this connection. | |
void | commit_transaction () |
Commits a transaction on this connection. | |
void | rollback_transaction () |
Rollbacks a transaction on this connection. | |
void | savepoint (std::string const &name) |
Creates a savepoint in transaction. | |
void | rollback_to_savepoint (std::string const &name) |
Rollbacks current transaction to given savepoint. | |
void | analyze () |
Runs ANALYZE on database. | |
void | set_schema (std::string schema) |
Sets search path on this connection. | |
void | create_schema (std::string const &schema) |
Create schema with given name. | |
bool | in_transaction () |
bool | in_failed_transaction () |
PGconn * | get_db () |
Retrieve underlying PGconn* from this connection. | |
void | add_cursor (ICursor *curs) |
Adds a cursor to cursor collection. | |
void | remove_cursor (ICursor *curs) |
Removes a cursor from cursor collection. | |
bool | is_cursor (ICursor *curs) const |
virtual | ~Database () |
Data Fields | |
boost::signal< void(PGresult const &)> & | notice_signal () |
Friends | |
void | noticeReceiver (void *arg, PGresult const *res) |
Represents a connection to PostgreSQL database.
Definition at line 21 of file Database.h.
psql::Database::Database | ( | Database const & | ) |
psql::Database::Database | ( | Database && | other | ) |
psql::Database::Database | ( | std::string const & | conninfo, |
bool | synchr = false |
||
) |
Connects to database.
conninfo | connection info string (see libpq documentation) |
synchr | whether connection is synchronous |
Definition at line 94 of file Database.cpp.
psql::Database::~Database | ( | ) | [virtual] |
Definition at line 169 of file Database.cpp.
void psql::Database::add_cursor | ( | ICursor * | curs | ) |
Adds a cursor to cursor collection.
Cursor class does this automatically, so you shouldn't need to call this.
curs |
Definition at line 74 of file Database.cpp.
void psql::Database::analyze | ( | ) |
Runs ANALYZE on database.
Definition at line 43 of file Database.cpp.
void psql::Database::begin_transaction | ( | ) |
Starts a transaction on this connection.
Definition at line 11 of file Database.cpp.
void psql::Database::commit_transaction | ( | ) |
Commits a transaction on this connection.
Definition at line 16 of file Database.cpp.
void psql::Database::create_schema | ( | std::string const & | schema | ) |
Create schema with given name.
schema | name of the schema to create |
Definition at line 55 of file Database.cpp.
PGconn * psql::Database::get_db | ( | ) |
Retrieve underlying PGconn* from this connection.
Definition at line 120 of file Database.cpp.
bool psql::Database::in_failed_transaction | ( | ) |
Definition at line 67 of file Database.cpp.
bool psql::Database::in_transaction | ( | ) |
Definition at line 60 of file Database.cpp.
bool psql::Database::is_cursor | ( | ICursor * | curs | ) | const |
curs |
Definition at line 84 of file Database.cpp.
void psql::Database::regist | ( | std::string const & | name, |
std::string const & | sql, | ||
IStatement * | st | ||
) |
Prepares server side prepared statement.
psql::Statement class does this automatically so you probably shouldn't call this.
name | statement name |
sql | statement sql |
st | pointer to statement |
Definition at line 175 of file Database.cpp.
void psql::Database::remove_cursor | ( | ICursor * | curs | ) |
Removes a cursor from cursor collection.
Cursor class does this automatically, so you shouldn't need to call this.
curs |
Definition at line 79 of file Database.cpp.
void psql::Database::rollback_to_savepoint | ( | std::string const & | name | ) |
Rollbacks current transaction to given savepoint.
name | savepoint name |
Definition at line 38 of file Database.cpp.
void psql::Database::rollback_transaction | ( | ) |
Rollbacks a transaction on this connection.
Definition at line 23 of file Database.cpp.
void psql::Database::savepoint | ( | std::string const & | name | ) |
Creates a savepoint in transaction.
name | savepoint name |
Definition at line 30 of file Database.cpp.
void psql::Database::set_schema | ( | std::string | schema | ) |
Sets search path on this connection.
schema | search path (can be single schema or comma separated search path) |
Definition at line 48 of file Database.cpp.
void psql::Database::unregist | ( | std::string const & | name, |
IStatement * | st | ||
) |
Deallocates server side prepared statement.
psql::Statement class does this automatically so you probably shouldn't call this.
name | statement name |
st | pointer to statement |
Definition at line 190 of file Database.cpp.
void noticeReceiver | ( | void * | arg, |
PGresult const * | res | ||
) | [friend] |
Definition at line 89 of file Database.cpp.
boost::signal< void(const PGresult &)> & psql::Database::notice_signal |
Definition at line 113 of file Database.h.