BOSS 6.6.4.p03
BESIII Offline Software System
|
#include <MysqlConnection.h>
Public Member Functions | |
MysqlConnection (std::ostream *out=0, std::ostream *errOut=0) | |
virtual | ~MysqlConnection () |
virtual bool | open (const std::string &host, const std::string &userid, const std::string &password, const std::string &dbName) |
virtual bool | open (const std::string &parms) |
virtual bool | close () |
virtual bool | isConnected () |
Return true iff open has been done with no matching close. | |
std::ostream * | getOut () const |
std::ostream * | getErrOut () const |
virtual MATCH | matchSchema (Rdb *rdb, bool matchDbName=true) |
virtual bool | insertRow (const std::string &tableName, const StringVector &colNames, const StringVector &values, int *auto_value=0, const StringVector *nullCols=0) |
virtual unsigned int | update (const std::string &tableName, const StringVector &colNames, const StringVector &values, const Assertion *where=0, const StringVector *nullCols=0) |
virtual ResultHandle * | select (const std::string &tableName, const StringVector &getCols, const StringVector &orderCols, const Assertion *where=0, int rowLimit=0, int rowOffset=0) |
virtual ResultHandle * | dbRequest (const std::string &request) |
virtual bool | compileAssertion (const Assertion *a, std::string &sqlString) const |
virtual void | disableModify (bool disable) |
virtual Visitor::VisitorState | visitRdb (Rdb *) |
This method says if the visitor is recursive or not. | |
virtual Visitor::VisitorState | visitTable (Table *) |
virtual Visitor::VisitorState | visitColumn (Column *) |
virtual Visitor::VisitorState | visitIndex (Index *) |
virtual Visitor::VisitorState | visitAssertion (Assertion *) |
virtual VisitorState | visitInsertNew (InsertNew *) |
virtual VisitorState | visitSupersede (Supersede *) |
virtual VisitorState | visitQuery (Query *) |
virtual VisitorState | visitSet (Set *) |
virtual VisitorState | visitInterRow (InterRow *) |
Public Member Functions inherited from rdbModel::Connection | |
Connection () | |
virtual | ~Connection () |
virtual bool | open (const std::string &host, const std::string &userid, const std::string &password, const std::string &dbName)=0 |
virtual bool | close ()=0 |
virtual bool | open (const std::string &parms)=0 |
virtual bool | isConnected ()=0 |
Return true iff open has been done with no matching close. | |
virtual std::ostream * | getOut () const =0 |
virtual std::ostream * | getErrOut () const =0 |
virtual MATCH | matchSchema (Rdb *rdb, bool matchDbName=true)=0 |
virtual bool | insertRow (const std::string &tableName, const StringVector &colNames, const StringVector &values, int *auto_value=0, const StringVector *nullCols=0)=0 |
virtual unsigned int | update (const std::string &tableName, const StringVector &colNames, const StringVector &values, const Assertion *where=0, const StringVector *nullCols=0)=0 |
virtual ResultHandle * | select (const std::string &tableName, const StringVector &getCols, const StringVector &orderCols, const Assertion *where=0, int rowLimit=0, int rowOffset=0)=0 |
virtual void | disableModify (bool disable)=0 |
virtual ResultHandle * | dbRequest (const std::string &request)=0 |
virtual bool | compileAssertion (const Assertion *a, std::string &sqlString) const =0 |
virtual VisitorState | visitRdb (Rdb *)=0 |
This method says if the visitor is recursive or not. | |
virtual VisitorState | visitTable (Table *)=0 |
virtual VisitorState | visitColumn (Column *)=0 |
virtual VisitorState | visitIndex (Index *)=0 |
virtual VisitorState | visitAssertion (Assertion *)=0 |
virtual VisitorState | visitInsertNew (InsertNew *)=0 |
virtual VisitorState | visitSupersede (Supersede *)=0 |
virtual VisitorState | visitQuery (Query *)=0 |
virtual VisitorState | visitSet (Set *)=0 |
virtual VisitorState | visitInterRow (InterRow *)=0 |
Additional Inherited Members | |
Public Types inherited from rdbModel::Visitor | |
enum | VisitorState { VCONTINUE = 0 , VDONE , VBRANCHDONE , VERROR , VERRORABORT } |
Class to handle connection to a MySQL database
Initial design will just use host, password, userid passed in. Will be up to caller to insure that the userid has the right privilages for the operations caller intends to do.
Definition at line 32 of file MysqlConnection.h.
rdbModel::MysqlConnection::MysqlConnection | ( | std::ostream * | out = 0 , |
std::ostream * | errOut = 0 |
||
) |
Open a connection Allowed operations will depend on userid, etc., specified return true if successful
Definition at line 69 of file MysqlConnection.cxx.
|
virtual |
Definition at line 90 of file MysqlConnection.cxx.
|
virtual |
Close the current open connection , if any. Return true if there was a connection to close and it was closed successfully
Implements rdbModel::Connection.
Definition at line 78 of file MysqlConnection.cxx.
Referenced by main(), and ~MysqlConnection().
|
virtual |
compile method for assertions. Use it internally, but also make it publicly available so assertions belonging to a table can save the compiled version.
Implements rdbModel::Connection.
Definition at line 462 of file MysqlConnection.cxx.
|
virtual |
Transmit raw request of any form to our other end. If it is a request that returns results, those results will be stored in a newly-allocated ResultHandle and dbRequest will return a pointer to it. Otherwise dbRequest will return a null pointer. Throw an exception if request fails for any reason.
Implements rdbModel::Connection.
Definition at line 408 of file MysqlConnection.cxx.
Referenced by main().
|
inlinevirtual |
Turn select and update into no-ops: output SQL string for debugging but don't change db
Implements rdbModel::Connection.
Definition at line 137 of file MysqlConnection.h.
Referenced by main().
|
inlinevirtual |
|
inlinevirtual |
|
virtual |
Typical derived class will form a syntactically correct INSERT statement from the input arguments and issue it to the dbms. Return true if row was inserted successfully If auto_value is non-zero and the table has an auto-increment column, its value will be returned. If nullCols is non-zero, insertRow will treat each string in the vector as a column name whose value should be set to NULL
Might also want to add a routine for INSERT ... SELECT
Implements rdbModel::Connection.
Definition at line 215 of file MysqlConnection.cxx.
|
inlinevirtual |
Return true iff open has been done with no matching close.
Implements rdbModel::Connection.
Definition at line 54 of file MysqlConnection.h.
Check to what degree local schema definition is compatible with remote db accessed via this connection. By default check db names match, but this may be disabled.
If match is successful, may also want to cache information about some things; for example, rows for which agent = "service"
Implements rdbModel::Connection.
Definition at line 190 of file MysqlConnection.cxx.
Referenced by main().
|
virtual |
Implements rdbModel::Connection.
Definition at line 96 of file MysqlConnection.cxx.
Referenced by dbRequest(), main(), and open().
|
virtual |
Parameter is normally path for an xml file descrbing the connection parameters
Implements rdbModel::Connection.
Definition at line 162 of file MysqlConnection.cxx.
|
virtual |
Support only for relatively simple SELECT, involving just one table.
tableName | |
getCols | vector of columns to be retrieved |
where | ptr to an Assertion object |
rowLimit | max number of rows to return |
rowOffset | offset for first row returned among those satisfying conditions; ignored if 0. |
Implements rdbModel::Connection.
Definition at line 329 of file MysqlConnection.cxx.
|
virtual |
Generic UPDATE. Return value is number of rows changed.
Implements rdbModel::Connection.
Definition at line 274 of file MysqlConnection.cxx.
|
virtual |
|
virtual |
Implements rdbModel::Visitor.
Definition at line 684 of file MysqlConnection.cxx.
|
virtual |
Implements rdbModel::Visitor.
Definition at line 835 of file MysqlConnection.cxx.
|
virtual |
Implements rdbModel::Visitor.
Definition at line 844 of file MysqlConnection.cxx.
|
virtual |
Implements rdbModel::Visitor.
Definition at line 860 of file MysqlConnection.cxx.
|
virtual |
Implements rdbModel::Visitor.
Definition at line 852 of file MysqlConnection.cxx.
|
virtual |
This method says if the visitor is recursive or not.
This method sets if the visitor is recursive or not
Implements rdbModel::Visitor.
Definition at line 608 of file MysqlConnection.cxx.
|
virtual |
Implements rdbModel::Visitor.
Definition at line 856 of file MysqlConnection.cxx.
|
virtual |
Implements rdbModel::Visitor.
Definition at line 848 of file MysqlConnection.cxx.
|
virtual |
Implements rdbModel::Visitor.
Definition at line 641 of file MysqlConnection.cxx.