25 #ifndef LSST_MWI_PERSISTENCE_DBSTORAGEIMPL_H
26 #define LSST_MWI_PERSISTENCE_DBSTORAGEIMPL_H
46 #include <boost/shared_array.hpp>
47 #include <mysql/mysql.h>
59 namespace persistence {
61 namespace dafBase = lsst::daf::base;
62 namespace pexPolicy = lsst::pex::policy;
64 class LogicalLocation;
99 std::string
const& templateName,
100 bool mayAlreadyExist);
101 virtual void dropTable(std::string
const& tableName);
104 virtual void executeSql(std::string
const& sqlStatement);
107 template <
typename T>
108 void setColumn(std::string
const& columnName, T
const& value);
114 std::vector<std::string>
const& tableNameList);
115 virtual void outColumn(std::string
const& columnName,
bool isExpr);
116 template <
typename T>
void outParam(std::string
const& columnName,
117 T* location,
bool isExpr);
118 template <
typename T>
void condParam(std::string
const& paramName,
120 virtual void orderBy(std::string
const& expression);
121 virtual void groupBy(std::string
const& expression);
123 virtual void query(
void);
124 virtual bool next(
void);
131 std::string
quote(std::string
const&
name);
132 void stError(std::string
const& text);
133 void error(std::string
const& text,
bool mysqlCaused =
true);
149 typedef std::tr1::unordered_map<std::string, BoundVar>
BoundVarMap;
176 void DbStorageImpl::setColumn<std::string>(std::string
const& columnName,
177 std::string
const& value);
179 void DbStorageImpl::setColumn<dafBase::DateTime>(std::string
const& columnName,
183 void DbStorageImpl::outParam<std::string>(std::string
const& columnName,
184 std::string* location,
bool isExpr);
186 void DbStorageImpl::outParam<dafBase::DateTime>(std::string
const& columnName,
191 std::string
const& DbStorageImpl::getColumnByPos<std::string>(
int pos);
194 DbStorageImpl::getColumnByPos<dafBase::DateTime>(
int pos);
std::vector< boost::shared_array< char > > _bindingMemory
Memory for bound variables.
virtual void setQueryWhere(std::string const &whereClause)
Class for handling dates/times, including MJD, UTC, and TAI.
table::Key< std::string > name
virtual void setTableForInsert(std::string const &tableName)
void outParam(std::string const &columnName, T *location, bool isExpr)
void setColumn(std::string const &columnName, T const &value)
std::vector< std::string > _queryTables
Names of tables to select from.
virtual void executeSql(std::string const &sqlStatement)
Class for logical location of a persisted Persistable instance.
virtual void endTransaction(void)
virtual void setPolicy(pexPolicy::Policy::Ptr policy)
boost::shared_array< unsigned long > _fieldLengths
Space for lengths of result fields.
virtual void finishQuery(void)
virtual void outColumn(std::string const &columnName, bool isExpr)
boost::shared_ptr< Policy > Ptr
int _numResultFields
Number of result fields.
virtual void groupBy(std::string const &expression)
void * allocateMemory(size_t size)
virtual void startSession(std::string const &location)
Class for database storage.
virtual ~DbStorageImpl(void)
T const & getColumnByPos(int pos)
MYSQL * _db
MySQL database connection pointer.
virtual void startTransaction(void)
std::tr1::unordered_map< std::string, BoundVar > BoundVarMap
void error(std::string const &text, bool mysqlCaused=true)
bool columnIsNull(int pos)
virtual void setRetrieveLocation(LogicalLocation const &location)
MYSQL_STMT * _statement
Prepared query statement.
void condParam(std::string const ¶mName, T const &value)
boost::shared_array< my_bool > _fieldNulls
Space for null flags of result fields.
Interface for DateTime class.
virtual void setTableListForQuery(std::vector< std::string > const &tableNameList)
MYSQL_FIELD * _resultFields
Query result field metadata.
Class for implementation of database storage.
virtual void orderBy(std::string const &expression)
virtual void truncateTable(std::string const &tableName)
std::string _location
Database location string saved for use by raw MySQL interface.
virtual void setColumnToNull(std::string const &columnName)
std::string quote(std::string const &name)
virtual void createTableFromTemplate(std::string const &tableName, std::string const &templateName, bool mayAlreadyExist)
void stError(std::string const &text)
BoundVarMap _inputVars
Input variable bindings.
BoundVarMap _outputVars
Output variable bindings.
Citizen is a class that should be among all LSST classes base classes, and handles basic memory manag...
virtual void setPersistLocation(LogicalLocation const &location)
void executeQuery(std::string const &query)
virtual void dropTable(std::string const &tableName)
bool _readonly
Remember if we are supposed to be read-only.
std::vector< std::string > _outColumns
virtual void insertRow(void)
std::string _insertTable
Name of table into which to insert.
virtual void setTableForQuery(std::string const &tableName, bool isExpr)