CARMA C++
carma::dbms::PostgresDBConnection Class Reference

an DBConnection implementation for PostgreSQL More...

#include <carma/dbms/PostgresDBConnection.h>

Inheritance diagram for carma::dbms::PostgresDBConnection:
carma::dbms::DBConnection

Public Member Functions

void beginTransaction () const
 begin a transaction More...
 
virtual void commitTransaction () const
 commit a transaction More...
 
virtual std::string createMonitorDataTable (const monitorTableAverageType &averageType, const monitorTableDataType dataType, const std::string &tag, const std::string *const location) const
 create a monitor data table More...
 
virtual bool inTransaction () const
 is a transaction being executed? More...
 
bool isDBUp () const
 destructor More...
 
void loadDataFromFile (const std::string &filename, const std::string &table, const std::string &user, const bool &useTransactions, const bool &useProductionDB) const
 
void loadDataFromFiles (const file2TableMap &file2Table, const std::string &user, const bool &useTransactions, const bool &useProductionDB) const
 
 PostgresDBConnection (const bool &useProductionDB, const string *const odbcini)
 constructor More...
 
virtual void rollBackTransaction () const
 rollback a transaction More...
 
- Public Member Functions inherited from carma::dbms::DBConnection
virtual std::string caseSensitiveSearchModifier () const
 get the modifier necessary for a case-sensitive text search More...
 
void closeConnection ()
 close the ODBC database connection More...
 
virtual std::string createMonitorDataTable (const MonitorAverageType &averageType, const MonitorAggregateType &aggType, const std::string &tag, const std::string *const location=NULL) const =0
 create a monitor data table More...
 
carma::dbms::Table databaseInfo (const std::string &database="") const
 get info on the database More...
 
std::string dataSource () const
 is this object using the production database? More...
 
virtual void deleteFromMonitorIndexTable (const std::string &whereClause) const
 delete rows from the MONITOR_INDEX_TABLE More...
 
virtual void dropScratchTable (const std::string &table) const
 drop a table from the scratch database More...
 
virtual void execSQLDropTable (const std::string &tableName) const
 drop a table. More...
 
virtual carma::dbms::Table execSQLSelect (const std::string &statement, const std::string &resultTableName="RESULT TABLE") const
 execute a SELECT query More...
 
virtual carma::dbms::Table execSQLSelect (const std::vector< std::string > &columnNames, const std::string &tableName, const std::string &whereClause="", const std::string &orderByClause="", const std::string &groupByClause="", const std::string &havingClause="", const std::string &resultTableName="RESULT TABLE") const
 execute a SELECT query More...
 
virtual void * getAggregate (const std::string &column, const std::string &table, const std::string &function, carma::dbms::Table::ColumnType &type) const
 get the specified aggregate value of the specified column from the specified table. More...
 
Table getLogMessages (const carma::util::frameType &start, const carma::util::frameType &end=carma::util::Time::computeCurrentFrame(), const std::string *matchString=NULL) const
 get the log messages in the specified frameCount range. More...
 
virtual long getRowCount (const std::string &tableName) const
 get the number of rows in the specified table More...
 
void insertLogMessage (const std::string &message, const carma::util::frameType &frameCount=carma::util::Time::computeCurrentFrame()) const
 add a log message to the Log table More...
 
virtual bool isDBUp ()
 is the RDBMS in question up and accepting connections More...
 
virtual void loadDataFromFile (const std::string &filename, const std::string &table, const bool &useTransactions, const int &linesToIgnore=0, const std::string &columnDelimiter="\t") const =0
 load data into a table from a disk file. More...
 
virtual void loadDataFromFiles (const file2TableMap &file2Table, const bool &useTransactions, const int &linesToIgnore=0, const std::string &columnDelimiter="\t") const =0
 load data into tables from disk files. More...
 
virtual unsigned maxColumnsPerTable () const =0
 the maximum number of columns the RDBMS allows in a table More...
 
virtual unsigned maxTablesPerJoin () const =0
 the maximum number of tables the RDBMS allows in a join More...
 
virtual void monitorDataTableHasBeenPopulated (const std::string &tableName, const MonitorAverageType &averageType) const
 performs tasks after a monitor data table has been completely populated. More...
 
void odbcInfo () const
 print various details about ODBC support More...
 
std::string rdbmsName () const
 get the name of the RDBMS associated with this object More...
 
virtual void repairMonitorDataTable (const std::string &tableName) const =0
 attempt to repair a corrupt monitor data table More...
 
bool tableExists (const std::string &table, const std::string &database) const
 does the specified table exist in the specified database? More...
 
virtual ~DBConnection ()
 destructor, derived classes may want to override More...
 

Static Public Attributes

static const std::string ODBC_DATASRC
 
static const std::string RDBMS
 
static const std::string TEST_ODBC_DATASRC
 

Additional Inherited Members

- Public Types inherited from carma::dbms::DBConnection
typedef std::map< std::string,
std::string > 
file2TableMap
 type to map data file names to tables they should be loaded into More...
 
- Static Public Member Functions inherited from carma::dbms::DBConnection
static std::string createInsertStatement (const std::string &tableName, const std::vector< std::string > columns, const std::vector< std::string > values)
 create an SQL insert statement More...
 
static std::string createInsertStatement (const std::string &tableName, const std::vector< std::string > columns, const std::string values)
 create an SQL insert statement "INSERT INTO " + tableName + "(" More...
 
static std::string createJoinClause (const std::string &leftTable, const std::string &rightTable, const std::string &leftColumn, const std::string &rightColumn="", const std::string &rightTableAlias="", const std::string &indexCol="")
 create a (inner) join clause More...
 
static std::string createJoinClause (const std::string &joinTable, const std::string &onClause)
 create a (inner) join clause More...
 
static bool isUp (const DBConfigurator *dbconf=NULL)
 is the database specified by the dbconf object up and accepting connections? More...
 
- Protected Member Functions inherited from carma::dbms::DBConnection
void closeODBCConnection_ ()
 close a database connection using ODBC, henv_ and hdbc_ are freed here More...
 
void closeODBCConnection_ (SQLHENV henv, SQLHDBC hdbc) const
 
 DBConnection (const carma::dbms::DBConfigurator *dbconf)
 create a DBConnection object. More...
 
void directSQLExec_ (const SQLHSTMT hstmt, const std::string &statement) const
 execute a single SQL statement More...
 
void directSQLExec_ (const std::string &statement) const
 execute a single SQL statement directly More...
 
void directSQLInsert_ (const std::string &statement) const
 perform a single sql insert statement directly (ie, no prepared statements More...
 
void freeSQLStatement_ (const SQLHSTMT &hstmt) const
 free an ODBC statment handle More...
 
carma::dbms::Table odbcResultSetToTable_ (const SQLHSTMT &hstmt) const
 convert an ODBC result set to a carma::dbms::Table object More...
 
void openODBCConnection_ (SQLHENV *henv, SQLHDBC *hdbc)
 open a database connection using ODBC, henv_ and hdbc_ are initialized here More...
 
void openODBCConnection_ ()
 
std::string readPassword_ () const
 read the database user's password so that it can be sent to the ODBC driver as part of the connect string IMPORTANT! Passwords are considered sensitive information and so the files in which they reside should be readable only by the unix account which owns them More...
 
- Protected Attributes inherited from carma::dbms::DBConnection
std::vector< SQLHSTMT > activeStatements
 
std::string dataSource_
 
std::string dbname_
 
std::string dbuser_
 
SQLHDBC hdbc_
 connection and environment handles for ODBC interface More...
 
SQLHENV henv_
 
bool inTxn_
 
log4cpp::Category & logger_
 
std::string odbcConnectString_
 
std::string odbcini_
 odbc config file More...
 
std::string passwordFile_
 
unsigned port_
 
std::string rdbmsName_
 
std::string socket_
 

Detailed Description

an DBConnection implementation for PostgreSQL

Definition at line 28 of file PostgresDBConnection.h.

Constructor & Destructor Documentation

carma::dbms::PostgresDBConnection::PostgresDBConnection ( const bool &  useProductionDB,
const string *const  odbcini 
)

constructor

Member Function Documentation

void carma::dbms::PostgresDBConnection::beginTransaction ( ) const
virtual

begin a transaction

Exceptions
DBConnectionException

Reimplemented from carma::dbms::DBConnection.

virtual void carma::dbms::PostgresDBConnection::commitTransaction ( ) const
virtual

commit a transaction

Exceptions
DBConnectionException

Reimplemented from carma::dbms::DBConnection.

virtual std::string carma::dbms::PostgresDBConnection::createMonitorDataTable ( const monitorTableAverageType &  averageType,
const monitorTableDataType  dataType,
const std::string &  tag,
const std::string *const  location 
) const
virtual

create a monitor data table

Parameters
averageTypethe average type of the table
dataTypethe data type of the table
tagthe tag to be appended to the table name
locationlocation (directory) at which to create the table, if NULL, use the default location determined by the RDBMS
Returns
the name of the created table
Exceptions
DBConnecitonException
virtual bool carma::dbms::PostgresDBConnection::inTransaction ( ) const
virtual

is a transaction being executed?

Returns
true if a transaction is being executed
Exceptions
DBConnectionException

Reimplemented from carma::dbms::DBConnection.

bool carma::dbms::PostgresDBConnection::isDBUp ( ) const

destructor

return true if the DB is up and available for connections this overrides the method in the base class and uses a native connection implementation because for postgres, the ODBCDriverConnect() method hangs if the database cannot be contacted

virtual void carma::dbms::PostgresDBConnection::rollBackTransaction ( ) const
virtual

rollback a transaction

Exceptions
DBConnectionException

Reimplemented from carma::dbms::DBConnection.


The documentation for this class was generated from the following file: