Commit b1086c9c authored by Steven Murray's avatar Steven Murray
Browse files

Catalogue CAPACITY_IN_BYTES now supports 64-bit numbers

parent 82875816
...@@ -61,22 +61,22 @@ target_link_libraries (ctacatalogue ...@@ -61,22 +61,22 @@ target_link_libraries (ctacatalogue
${ORACLE-INSTANTCLIENT_LIBRARIES} ${ORACLE-INSTANTCLIENT_LIBRARIES}
${SQLITE_LIBRARIES}) ${SQLITE_LIBRARIES})
add_custom_command(OUTPUT sqlite_catalogue_schema.sql oracle_catalogue_schema.sql add_custom_command (OUTPUT create_sqlite_catalogue_schema.sql create_oracle_catalogue_schema.sql
COMMAND cat ${CMAKE_CURRENT_SOURCE_DIR}/sqlite_catalogue_schema_header.sql ${CMAKE_CURRENT_SOURCE_DIR}/catalogue_common_schema.sql ${CMAKE_CURRENT_SOURCE_DIR}/sqlite_catalogue_schema_trailer.sql > sqlite_catalogue_schema.sql COMMAND cat ${CMAKE_CURRENT_SOURCE_DIR}/create_sqlite_catalogue_schema_header.sql ${CMAKE_CURRENT_SOURCE_DIR}/catalogue_common_schema.sql ${CMAKE_CURRENT_SOURCE_DIR}/create_sqlite_catalogue_schema_trailer.sql > create_sqlite_catalogue_schema.sql
COMMAND cat ${CMAKE_CURRENT_SOURCE_DIR}/catalogue_common_schema.sql > oracle_catalogue_schema.sql COMMAND cat ${CMAKE_CURRENT_SOURCE_DIR}/create_oracle_catalogue_schema_header.sql ${CMAKE_CURRENT_SOURCE_DIR}/catalogue_common_schema.sql ${CMAKE_CURRENT_SOURCE_DIR}/create_oracle_catalogue_schema_trailer.sql > create_oracle_catalogue_schema.sql
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/sqlite_catalogue_schema_header.sql catalogue_common_schema.sql ${CMAKE_CURRENT_SOURCE_DIR}/sqlite_catalogue_schema_trailer.sql) DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/create_sqlite_catalogue_schema_header.sql catalogue_common_schema.sql ${CMAKE_CURRENT_SOURCE_DIR}/create_sqlite_catalogue_schema_trailer.sql)
install (FILES ${CMAKE_CURRENT_BINARY_DIR}/sqlite_catalogue_schema.sql install (FILES ${CMAKE_CURRENT_BINARY_DIR}/create_sqlite_catalogue_schema.sql
DESTINATION usr/share/cta-${CTA_VERSION}/sql DESTINATION usr/share/cta-${CTA_VERSION}/sql
PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ) PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
install (FILES ${CMAKE_CURRENT_BINARY_DIR}/oracle_catalogue_schema.sql install (FILES ${CMAKE_CURRENT_BINARY_DIR}/create_oracle_catalogue_schema.sql
DESTINATION usr/share/cta-${CTA_VERSION}/sql DESTINATION usr/share/cta-${CTA_VERSION}/sql
PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ) PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
add_custom_command(OUTPUT in_memory_catalogue_schema.cpp add_custom_command(OUTPUT in_memory_catalogue_schema.cpp
COMMAND sed 's/^/\ \ \"/' sqlite_catalogue_schema.sql | sed 's/$$/\"/' > in_memory_catalogue_schema.cpp COMMAND sed 's/^/\ \ \"/' create_sqlite_catalogue_schema.sql | sed 's/$$/\"/' > in_memory_catalogue_schema.cpp
DEPENDS sqlite_catalogue_schema.sql) DEPENDS create_sqlite_catalogue_schema.sql)
add_custom_command(OUTPUT InMemoryCatalogueSchema.cpp add_custom_command(OUTPUT InMemoryCatalogueSchema.cpp
COMMAND sed '/CTA_SQL_SCHEMA/r in_memory_catalogue_schema.cpp' ${CMAKE_CURRENT_SOURCE_DIR}/InMemoryCatalogueSchema.before_SQL.cpp > InMemoryCatalogueSchema.cpp COMMAND sed '/CTA_SQL_SCHEMA/r in_memory_catalogue_schema.cpp' ${CMAKE_CURRENT_SOURCE_DIR}/InMemoryCatalogueSchema.before_SQL.cpp > InMemoryCatalogueSchema.cpp
......
...@@ -147,7 +147,7 @@ void OcciStmt::executeNonQuery() { ...@@ -147,7 +147,7 @@ void OcciStmt::executeNonQuery() {
// getNbAffectedRows // getNbAffectedRows
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
uint64_t OcciStmt::getNbAffectedRows() const { uint64_t OcciStmt::getNbAffectedRows() const {
throw exception::Exception(std::string(__FUNCTION__) + " not implemented"); return m_stmt->getUb8RowCount();
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#include "catalogue/OcciEnvSingleton.hpp" #include "catalogue/OcciEnvSingleton.hpp"
#include "catalogue/OracleCatalogue.hpp" #include "catalogue/OracleCatalogue.hpp"
#include "common/exception/Exception.hpp" #include "common/exception/Exception.hpp"
#include "common/utils/utils.hpp"
namespace cta { namespace cta {
namespace catalogue { namespace catalogue {
...@@ -109,7 +110,7 @@ common::dataStructures::Tape OracleCatalogue::selectTapeForUpdate(const std::str ...@@ -109,7 +110,7 @@ common::dataStructures::Tape OracleCatalogue::selectTapeForUpdate(const std::str
tape.logicalLibraryName = rset->columnText("LOGICAL_LIBRARY_NAME"); tape.logicalLibraryName = rset->columnText("LOGICAL_LIBRARY_NAME");
tape.tapePoolName = rset->columnText("TAPE_POOL_NAME"); tape.tapePoolName = rset->columnText("TAPE_POOL_NAME");
tape.encryptionKey = rset->columnText("ENCRYPTION_KEY"); tape.encryptionKey = rset->columnText("ENCRYPTION_KEY");
tape.capacityInBytes = rset->columnUint64("CAPACITY_IN_BYTES"); tape.capacityInBytes = utils::toUint64(rset->columnText("CAPACITY_IN_BYTES"));
tape.dataOnTapeInBytes = rset->columnUint64("DATA_IN_BYTES"); tape.dataOnTapeInBytes = rset->columnUint64("DATA_IN_BYTES");
tape.lastFSeq = rset->columnUint64("LAST_FSEQ"); tape.lastFSeq = rset->columnUint64("LAST_FSEQ");
tape.disabled = rset->columnUint64("IS_DISABLED"); tape.disabled = rset->columnUint64("IS_DISABLED");
......
...@@ -167,7 +167,7 @@ bool RdbmsCatalogue::adminUserExists(const std::string adminUsername) const { ...@@ -167,7 +167,7 @@ bool RdbmsCatalogue::adminUserExists(const std::string adminUsername) const {
"FROM " "FROM "
"ADMIN_USER " "ADMIN_USER "
"WHERE " "WHERE "
"ADMIN_USER_NAME = :ADMIN_USER_NAME;"; "ADMIN_USER_NAME = :ADMIN_USER_NAME";
std::unique_ptr<DbStmt> stmt(m_conn->createStmt(sql)); std::unique_ptr<DbStmt> stmt(m_conn->createStmt(sql));
stmt->bindString(":ADMIN_USER_NAME", adminUsername); stmt->bindString(":ADMIN_USER_NAME", adminUsername);
std::unique_ptr<DbRset> rset(stmt->executeQuery()); std::unique_ptr<DbRset> rset(stmt->executeQuery());
...@@ -182,7 +182,7 @@ bool RdbmsCatalogue::adminUserExists(const std::string adminUsername) const { ...@@ -182,7 +182,7 @@ bool RdbmsCatalogue::adminUserExists(const std::string adminUsername) const {
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void RdbmsCatalogue::deleteAdminUser(const std::string &username) { void RdbmsCatalogue::deleteAdminUser(const std::string &username) {
try { try {
const char *const sql = "DELETE FROM ADMIN_USER WHERE ADMIN_USER_NAME = :ADMIN_USER_NAME;"; const char *const sql = "DELETE FROM ADMIN_USER WHERE ADMIN_USER_NAME = :ADMIN_USER_NAME";
std::unique_ptr<DbStmt> stmt(m_conn->createStmt(sql)); std::unique_ptr<DbStmt> stmt(m_conn->createStmt(sql));
stmt->bindString(":ADMIN_USER_NAME", username); stmt->bindString(":ADMIN_USER_NAME", username);
stmt->executeNonQuery(); stmt->executeNonQuery();
...@@ -321,7 +321,7 @@ bool RdbmsCatalogue::adminHostExists(const std::string adminHost) const { ...@@ -321,7 +321,7 @@ bool RdbmsCatalogue::adminHostExists(const std::string adminHost) const {
"FROM " "FROM "
"ADMIN_HOST " "ADMIN_HOST "
"WHERE " "WHERE "
"ADMIN_HOST_NAME = :ADMIN_HOST_NAME;"; "ADMIN_HOST_NAME = :ADMIN_HOST_NAME";
std::unique_ptr<DbStmt> stmt(m_conn->createStmt(sql)); std::unique_ptr<DbStmt> stmt(m_conn->createStmt(sql));
stmt->bindString(":ADMIN_HOST_NAME", adminHost); stmt->bindString(":ADMIN_HOST_NAME", adminHost);
std::unique_ptr<DbRset> rset(stmt->executeQuery()); std::unique_ptr<DbRset> rset(stmt->executeQuery());
...@@ -336,7 +336,7 @@ bool RdbmsCatalogue::adminHostExists(const std::string adminHost) const { ...@@ -336,7 +336,7 @@ bool RdbmsCatalogue::adminHostExists(const std::string adminHost) const {
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void RdbmsCatalogue::deleteAdminHost(const std::string &hostName) { void RdbmsCatalogue::deleteAdminHost(const std::string &hostName) {
try { try {
const char *const sql = "DELETE FROM ADMIN_HOST WHERE ADMIN_HOST_NAME = :ADMIN_HOST_NAME;"; const char *const sql = "DELETE FROM ADMIN_HOST WHERE ADMIN_HOST_NAME = :ADMIN_HOST_NAME";
std::unique_ptr<DbStmt> stmt(m_conn->createStmt(sql)); std::unique_ptr<DbStmt> stmt(m_conn->createStmt(sql));
stmt->bindString(":ADMIN_HOST_NAME", hostName); stmt->bindString(":ADMIN_HOST_NAME", hostName);
stmt->executeNonQuery(); stmt->executeNonQuery();
...@@ -478,7 +478,7 @@ bool RdbmsCatalogue::storageClassExists(const std::string &storageClassName) con ...@@ -478,7 +478,7 @@ bool RdbmsCatalogue::storageClassExists(const std::string &storageClassName) con
"FROM " "FROM "
"STORAGE_CLASS " "STORAGE_CLASS "
"WHERE " "WHERE "
"STORAGE_CLASS_NAME = :STORAGE_CLASS_NAME;"; "STORAGE_CLASS_NAME = :STORAGE_CLASS_NAME";
std::unique_ptr<DbStmt> stmt(m_conn->createStmt(sql)); std::unique_ptr<DbStmt> stmt(m_conn->createStmt(sql));
stmt->bindString(":STORAGE_CLASS_NAME", storageClassName); stmt->bindString(":STORAGE_CLASS_NAME", storageClassName);
std::unique_ptr<DbRset> rset(stmt->executeQuery()); std::unique_ptr<DbRset> rset(stmt->executeQuery());
...@@ -497,7 +497,7 @@ void RdbmsCatalogue::deleteStorageClass(const std::string &name) { ...@@ -497,7 +497,7 @@ void RdbmsCatalogue::deleteStorageClass(const std::string &name) {
"DELETE FROM " "DELETE FROM "
"STORAGE_CLASS " "STORAGE_CLASS "
"WHERE " "WHERE "
"STORAGE_CLASS_NAME = :STORAGE_CLASS_NAME;"; "STORAGE_CLASS_NAME = :STORAGE_CLASS_NAME";
std::unique_ptr<DbStmt> stmt(m_conn->createStmt(sql)); std::unique_ptr<DbStmt> stmt(m_conn->createStmt(sql));
stmt->bindString(":STORAGE_CLASS_NAME", name); stmt->bindString(":STORAGE_CLASS_NAME", name);
...@@ -653,7 +653,7 @@ bool RdbmsCatalogue::tapePoolExists(const std::string &tapePoolName) const { ...@@ -653,7 +653,7 @@ bool RdbmsCatalogue::tapePoolExists(const std::string &tapePoolName) const {
"FROM " "FROM "
"TAPE_POOL " "TAPE_POOL "
"WHERE " "WHERE "
"TAPE_POOL_NAME = :TAPE_POOL_NAME;"; "TAPE_POOL_NAME = :TAPE_POOL_NAME";
std::unique_ptr<DbStmt> stmt(m_conn->createStmt(sql)); std::unique_ptr<DbStmt> stmt(m_conn->createStmt(sql));
stmt->bindString(":TAPE_POOL_NAME", tapePoolName); stmt->bindString(":TAPE_POOL_NAME", tapePoolName);
std::unique_ptr<DbRset> rset(stmt->executeQuery()); std::unique_ptr<DbRset> rset(stmt->executeQuery());
...@@ -668,7 +668,7 @@ bool RdbmsCatalogue::tapePoolExists(const std::string &tapePoolName) const { ...@@ -668,7 +668,7 @@ bool RdbmsCatalogue::tapePoolExists(const std::string &tapePoolName) const {
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void RdbmsCatalogue::deleteTapePool(const std::string &name) { void RdbmsCatalogue::deleteTapePool(const std::string &name) {
try { try {
const char *const sql = "DELETE FROM TAPE_POOL WHERE TAPE_POOL_NAME = :TAPE_POOL_NAME;"; const char *const sql = "DELETE FROM TAPE_POOL WHERE TAPE_POOL_NAME = :TAPE_POOL_NAME";
std::unique_ptr<DbStmt> stmt(m_conn->createStmt(sql)); std::unique_ptr<DbStmt> stmt(m_conn->createStmt(sql));
stmt->bindString(":TAPE_POOL_NAME", name); stmt->bindString(":TAPE_POOL_NAME", name);
stmt->executeNonQuery(); stmt->executeNonQuery();
...@@ -825,7 +825,7 @@ void RdbmsCatalogue::deleteArchiveRoute(const std::string &storageClassName, con ...@@ -825,7 +825,7 @@ void RdbmsCatalogue::deleteArchiveRoute(const std::string &storageClassName, con
"ARCHIVE_ROUTE " "ARCHIVE_ROUTE "
"WHERE " "WHERE "
"STORAGE_CLASS_NAME = :STORAGE_CLASS_NAME AND " "STORAGE_CLASS_NAME = :STORAGE_CLASS_NAME AND "
"COPY_NB = :COPY_NB;"; "COPY_NB = :COPY_NB";
std::unique_ptr<DbStmt> stmt(m_conn->createStmt(sql)); std::unique_ptr<DbStmt> stmt(m_conn->createStmt(sql));
stmt->bindString(":STORAGE_CLASS_NAME", storageClassName); stmt->bindString(":STORAGE_CLASS_NAME", storageClassName);
stmt->bindUint64(":COPY_NB", copyNb); stmt->bindUint64(":COPY_NB", copyNb);
...@@ -978,7 +978,7 @@ bool RdbmsCatalogue::logicalLibraryExists(const std::string &logicalLibraryName) ...@@ -978,7 +978,7 @@ bool RdbmsCatalogue::logicalLibraryExists(const std::string &logicalLibraryName)
"FROM " "FROM "
"LOGICAL_LIBRARY " "LOGICAL_LIBRARY "
"WHERE " "WHERE "
"LOGICAL_LIBRARY_NAME = :LOGICAL_LIBRARY_NAME;"; "LOGICAL_LIBRARY_NAME = :LOGICAL_LIBRARY_NAME";
std::unique_ptr<DbStmt> stmt(m_conn->createStmt(sql)); std::unique_ptr<DbStmt> stmt(m_conn->createStmt(sql));
stmt->bindString(":LOGICAL_LIBRARY_NAME", logicalLibraryName); stmt->bindString(":LOGICAL_LIBRARY_NAME", logicalLibraryName);
std::unique_ptr<DbRset> rset(stmt->executeQuery()); std::unique_ptr<DbRset> rset(stmt->executeQuery());
...@@ -993,7 +993,7 @@ bool RdbmsCatalogue::logicalLibraryExists(const std::string &logicalLibraryName) ...@@ -993,7 +993,7 @@ bool RdbmsCatalogue::logicalLibraryExists(const std::string &logicalLibraryName)
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void RdbmsCatalogue::deleteLogicalLibrary(const std::string &name) { void RdbmsCatalogue::deleteLogicalLibrary(const std::string &name) {
try { try {
const char *const sql = "DELETE FROM LOGICAL_LIBRARY WHERE LOGICAL_LIBRARY_NAME = :LOGICAL_LIBRARY_NAME;"; const char *const sql = "DELETE FROM LOGICAL_LIBRARY WHERE LOGICAL_LIBRARY_NAME = :LOGICAL_LIBRARY_NAME";
std::unique_ptr<DbStmt> stmt(m_conn->createStmt(sql)); std::unique_ptr<DbStmt> stmt(m_conn->createStmt(sql));
stmt->bindString(":LOGICAL_LIBRARY_NAME", name); stmt->bindString(":LOGICAL_LIBRARY_NAME", name);
stmt->executeNonQuery(); stmt->executeNonQuery();
...@@ -1092,15 +1092,6 @@ void RdbmsCatalogue::createTape( ...@@ -1092,15 +1092,6 @@ void RdbmsCatalogue::createTape(
"IS_FULL," "IS_FULL,"
"LBP_IS_ON," "LBP_IS_ON,"
"LABEL_DRIVE,"
"LABEL_TIME,"
"LAST_READ_DRIVE,"
"LAST_READ_TIME,"
"LAST_WRITE_DRIVE,"
"LAST_WRITE_TIME,"
"USER_COMMENT," "USER_COMMENT,"
"CREATION_LOG_USER_NAME," "CREATION_LOG_USER_NAME,"
...@@ -1110,7 +1101,7 @@ void RdbmsCatalogue::createTape( ...@@ -1110,7 +1101,7 @@ void RdbmsCatalogue::createTape(
"LAST_UPDATE_USER_NAME," "LAST_UPDATE_USER_NAME,"
"LAST_UPDATE_HOST_NAME," "LAST_UPDATE_HOST_NAME,"
"LAST_UPDATE_TIME)" "LAST_UPDATE_TIME)"
"VALUES(" "VALUES("
":VID," ":VID,"
":LOGICAL_LIBRARY_NAME," ":LOGICAL_LIBRARY_NAME,"
":TAPE_POOL_NAME," ":TAPE_POOL_NAME,"
...@@ -1122,15 +1113,6 @@ void RdbmsCatalogue::createTape( ...@@ -1122,15 +1113,6 @@ void RdbmsCatalogue::createTape(
":IS_FULL," ":IS_FULL,"
":LBP_IS_ON," ":LBP_IS_ON,"
":LABEL_DRIVE,"
":LABEL_TIME,"
":LAST_READ_DRIVE,"
":LAST_READ_TIME,"
":LAST_WRITE_DRIVE,"
":LAST_WRITE_TIME,"
":USER_COMMENT," ":USER_COMMENT,"
":CREATION_LOG_USER_NAME," ":CREATION_LOG_USER_NAME,"
...@@ -1146,22 +1128,13 @@ void RdbmsCatalogue::createTape( ...@@ -1146,22 +1128,13 @@ void RdbmsCatalogue::createTape(
stmt->bindString(":LOGICAL_LIBRARY_NAME", logicalLibraryName); stmt->bindString(":LOGICAL_LIBRARY_NAME", logicalLibraryName);
stmt->bindString(":TAPE_POOL_NAME", tapePoolName); stmt->bindString(":TAPE_POOL_NAME", tapePoolName);
stmt->bindString(":ENCRYPTION_KEY", encryptionKey); stmt->bindString(":ENCRYPTION_KEY", encryptionKey);
stmt->bindUint64(":CAPACITY_IN_BYTES", capacityInBytes); stmt->bindString(":CAPACITY_IN_BYTES", std::to_string(capacityInBytes));
stmt->bindUint64(":DATA_IN_BYTES", 0); stmt->bindUint64(":DATA_IN_BYTES", 0);
stmt->bindUint64(":LAST_FSEQ", 0); stmt->bindUint64(":LAST_FSEQ", 0);
stmt->bindUint64(":IS_DISABLED", disabledValue); stmt->bindUint64(":IS_DISABLED", disabledValue);
stmt->bindUint64(":IS_FULL", fullValue); stmt->bindUint64(":IS_FULL", fullValue);
stmt->bindUint64(":LBP_IS_ON", 0); stmt->bindUint64(":LBP_IS_ON", 0);
stmt->bindString(":LABEL_DRIVE", "");
stmt->bindUint64(":LABEL_TIME", 0);
stmt->bindString(":LAST_READ_DRIVE", "");
stmt->bindUint64(":LAST_READ_TIME", 0);
stmt->bindString(":LAST_WRITE_DRIVE", "");
stmt->bindUint64(":LAST_WRITE_TIME", 0);
stmt->bindString(":USER_COMMENT", comment); stmt->bindString(":USER_COMMENT", comment);
stmt->bindString(":CREATION_LOG_USER_NAME", cliIdentity.username); stmt->bindString(":CREATION_LOG_USER_NAME", cliIdentity.username);
...@@ -1191,7 +1164,7 @@ bool RdbmsCatalogue::tapeExists(const std::string &vid) const { ...@@ -1191,7 +1164,7 @@ bool RdbmsCatalogue::tapeExists(const std::string &vid) const {
"FROM " "FROM "
"TAPE " "TAPE "
"WHERE " "WHERE "
"VID = :VID;"; "VID = :VID";
std::unique_ptr<DbStmt> stmt(m_conn->createStmt(sql)); std::unique_ptr<DbStmt> stmt(m_conn->createStmt(sql));
stmt->bindString(":VID", vid); stmt->bindString(":VID", vid);
std::unique_ptr<DbRset> rset(stmt->executeQuery()); std::unique_ptr<DbRset> rset(stmt->executeQuery());
...@@ -1206,7 +1179,7 @@ bool RdbmsCatalogue::tapeExists(const std::string &vid) const { ...@@ -1206,7 +1179,7 @@ bool RdbmsCatalogue::tapeExists(const std::string &vid) const {
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void RdbmsCatalogue::deleteTape(const std::string &vid) { void RdbmsCatalogue::deleteTape(const std::string &vid) {
try { try {
const char *const sql = "DELETE FROM TAPE WHERE VID = :VID;"; const char *const sql = "DELETE FROM TAPE WHERE VID = :VID";
std::unique_ptr<DbStmt> stmt(m_conn->createStmt(sql)); std::unique_ptr<DbStmt> stmt(m_conn->createStmt(sql));
stmt->bindString(":VID", vid); stmt->bindString(":VID", vid);
stmt->executeNonQuery(); stmt->executeNonQuery();
...@@ -1319,8 +1292,7 @@ std::list<common::dataStructures::Tape> RdbmsCatalogue::getTapes(const TapeSearc ...@@ -1319,8 +1292,7 @@ std::list<common::dataStructures::Tape> RdbmsCatalogue::getTapes(const TapeSearc
if(!searchCriteria.vid.empty()) stmt->bindString(":VID", searchCriteria.vid); if(!searchCriteria.vid.empty()) stmt->bindString(":VID", searchCriteria.vid);
if(!searchCriteria.logicalLibrary.empty()) stmt->bindString(":LOGICAL_LIBRARY_NAME", searchCriteria.logicalLibrary); if(!searchCriteria.logicalLibrary.empty()) stmt->bindString(":LOGICAL_LIBRARY_NAME", searchCriteria.logicalLibrary);
if(!searchCriteria.tapePool.empty()) stmt->bindString(":TAPE_POOL_NAME", searchCriteria.tapePool); if(!searchCriteria.tapePool.empty()) stmt->bindString(":TAPE_POOL_NAME", searchCriteria.tapePool);
if(!searchCriteria.capacityInBytes.empty()) stmt->bindUint64(":CAPACITY_IN_BYTES", if(!searchCriteria.capacityInBytes.empty()) stmt->bindString(":CAPACITY_IN_BYTES", searchCriteria.capacityInBytes);
utils::toUint64(searchCriteria.capacityInBytes));
if(!searchCriteria.disabled.empty()) stmt->bindUint64(":IS_DISABLED", toUpper(searchCriteria.disabled) == "TRUE"); if(!searchCriteria.disabled.empty()) stmt->bindUint64(":IS_DISABLED", toUpper(searchCriteria.disabled) == "TRUE");
if(!searchCriteria.full.empty()) stmt->bindUint64(":IS_FULL", toUpper(searchCriteria.full) == "TRUE"); if(!searchCriteria.full.empty()) stmt->bindUint64(":IS_FULL", toUpper(searchCriteria.full) == "TRUE");
if(!searchCriteria.lbp.empty()) stmt->bindUint64(":LBP_IS_ON", toUpper(searchCriteria.lbp) == "TRUE"); if(!searchCriteria.lbp.empty()) stmt->bindUint64(":LBP_IS_ON", toUpper(searchCriteria.lbp) == "TRUE");
...@@ -1333,7 +1305,7 @@ std::list<common::dataStructures::Tape> RdbmsCatalogue::getTapes(const TapeSearc ...@@ -1333,7 +1305,7 @@ std::list<common::dataStructures::Tape> RdbmsCatalogue::getTapes(const TapeSearc
tape.logicalLibraryName = rset->columnText("LOGICAL_LIBRARY_NAME"); tape.logicalLibraryName = rset->columnText("LOGICAL_LIBRARY_NAME");
tape.tapePoolName = rset->columnText("TAPE_POOL_NAME"); tape.tapePoolName = rset->columnText("TAPE_POOL_NAME");
tape.encryptionKey = rset->columnText("ENCRYPTION_KEY"); tape.encryptionKey = rset->columnText("ENCRYPTION_KEY");
tape.capacityInBytes = rset->columnUint64("CAPACITY_IN_BYTES"); tape.capacityInBytes = utils::toUint64(rset->columnText("CAPACITY_IN_BYTES"));
tape.dataOnTapeInBytes = rset->columnUint64("DATA_IN_BYTES"); tape.dataOnTapeInBytes = rset->columnUint64("DATA_IN_BYTES");
tape.lastFSeq = rset->columnUint64("LAST_FSEQ"); tape.lastFSeq = rset->columnUint64("LAST_FSEQ");
tape.disabled = rset->columnUint64("IS_DISABLED"); tape.disabled = rset->columnUint64("IS_DISABLED");
...@@ -1665,7 +1637,7 @@ std::list<common::dataStructures::RequesterMountRule> RdbmsCatalogue::getRequest ...@@ -1665,7 +1637,7 @@ std::list<common::dataStructures::RequesterMountRule> RdbmsCatalogue::getRequest
"LAST_UPDATE_HOST_NAME AS LAST_UPDATE_HOST_NAME," "LAST_UPDATE_HOST_NAME AS LAST_UPDATE_HOST_NAME,"
"LAST_UPDATE_TIME AS LAST_UPDATE_TIME " "LAST_UPDATE_TIME AS LAST_UPDATE_TIME "
"FROM " "FROM "
"REQUESTER_MOUNT_RULE;"; "REQUESTER_MOUNT_RULE";
std::unique_ptr<DbStmt> stmt(m_conn->createStmt(sql)); std::unique_ptr<DbStmt> stmt(m_conn->createStmt(sql));
std::unique_ptr<DbRset> rset(stmt->executeQuery()); std::unique_ptr<DbRset> rset(stmt->executeQuery());
while(rset->next()) { while(rset->next()) {
...@@ -1695,7 +1667,7 @@ std::list<common::dataStructures::RequesterMountRule> RdbmsCatalogue::getRequest ...@@ -1695,7 +1667,7 @@ std::list<common::dataStructures::RequesterMountRule> RdbmsCatalogue::getRequest
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void RdbmsCatalogue::deleteRequesterMountRule(const std::string &requesterName) { void RdbmsCatalogue::deleteRequesterMountRule(const std::string &requesterName) {
try { try {
const char *const sql = "DELETE FROM REQUESTER_MOUNT_RULE WHERE REQUESTER_NAME = :REQUESTER_NAME;"; const char *const sql = "DELETE FROM REQUESTER_MOUNT_RULE WHERE REQUESTER_NAME = :REQUESTER_NAME";
std::unique_ptr<DbStmt> stmt(m_conn->createStmt(sql)); std::unique_ptr<DbStmt> stmt(m_conn->createStmt(sql));
stmt->bindString(":REQUESTER_NAME", requesterName); stmt->bindString(":REQUESTER_NAME", requesterName);
stmt->executeNonQuery(); stmt->executeNonQuery();
...@@ -1815,7 +1787,7 @@ common::dataStructures::MountPolicy *RdbmsCatalogue::getRequesterGroupMountPolic ...@@ -1815,7 +1787,7 @@ common::dataStructures::MountPolicy *RdbmsCatalogue::getRequesterGroupMountPolic
"ON " "ON "
"MOUNT_POLICY.MOUNT_POLICY_NAME = REQUESTER_GROUP_MOUNT_RULE.MOUNT_POLICY_NAME " "MOUNT_POLICY.MOUNT_POLICY_NAME = REQUESTER_GROUP_MOUNT_RULE.MOUNT_POLICY_NAME "
"WHERE " "WHERE "
"REQUESTER_GROUP_MOUNT_RULE.REQUESTER_GROUP_NAME = :REQUESTER_GROUP_NAME;"; "REQUESTER_GROUP_MOUNT_RULE.REQUESTER_GROUP_NAME = :REQUESTER_GROUP_NAME";
std::unique_ptr<DbStmt> stmt(m_conn->createStmt(sql)); std::unique_ptr<DbStmt> stmt(m_conn->createStmt(sql));
stmt->bindString(":REQUESTER_GROUP_NAME", requesterGroupName); stmt->bindString(":REQUESTER_GROUP_NAME", requesterGroupName);
std::unique_ptr<DbRset> rset(stmt->executeQuery()); std::unique_ptr<DbRset> rset(stmt->executeQuery());
...@@ -1870,7 +1842,7 @@ std::list<common::dataStructures::RequesterGroupMountRule> RdbmsCatalogue::getRe ...@@ -1870,7 +1842,7 @@ std::list<common::dataStructures::RequesterGroupMountRule> RdbmsCatalogue::getRe
"LAST_UPDATE_HOST_NAME AS LAST_UPDATE_HOST_NAME," "LAST_UPDATE_HOST_NAME AS LAST_UPDATE_HOST_NAME,"
"LAST_UPDATE_TIME AS LAST_UPDATE_TIME " "LAST_UPDATE_TIME AS LAST_UPDATE_TIME "
"FROM " "FROM "
"REQUESTER_GROUP_MOUNT_RULE;"; "REQUESTER_GROUP_MOUNT_RULE";
std::unique_ptr<DbStmt> stmt(m_conn->createStmt(sql)); std::unique_ptr<DbStmt> stmt(m_conn->createStmt(sql));
std::unique_ptr<DbRset> rset(stmt->executeQuery()); std::unique_ptr<DbRset> rset(stmt->executeQuery());
while(rset->next()) { while(rset->next()) {
...@@ -1902,7 +1874,7 @@ std::list<common::dataStructures::RequesterGroupMountRule> RdbmsCatalogue::getRe ...@@ -1902,7 +1874,7 @@ std::list<common::dataStructures::RequesterGroupMountRule> RdbmsCatalogue::getRe
void RdbmsCatalogue::deleteRequesterGroupMountRule(const std::string &requesterGroupName) { void RdbmsCatalogue::deleteRequesterGroupMountRule(const std::string &requesterGroupName) {
try { try {
const char *const sql = const char *const sql =
"DELETE FROM REQUESTER_GROUP_MOUNT_RULE WHERE REQUESTER_GROUP_NAME = :REQUESTER_GROUP_NAME;"; "DELETE FROM REQUESTER_GROUP_MOUNT_RULE WHERE REQUESTER_GROUP_NAME = :REQUESTER_GROUP_NAME";
std::unique_ptr<DbStmt> stmt(m_conn->createStmt(sql)); std::unique_ptr<DbStmt> stmt(m_conn->createStmt(sql));
stmt->bindString(":REQUESTER_GROUP_NAME", requesterGroupName); stmt->bindString(":REQUESTER_GROUP_NAME", requesterGroupName);
stmt->executeNonQuery(); stmt->executeNonQuery();
...@@ -1929,7 +1901,7 @@ bool RdbmsCatalogue::mountPolicyExists(const std::string &mountPolicyName) const ...@@ -1929,7 +1901,7 @@ bool RdbmsCatalogue::mountPolicyExists(const std::string &mountPolicyName) const
"FROM " "FROM "
"MOUNT_POLICY " "MOUNT_POLICY "
"WHERE " "WHERE "
"MOUNT_POLICY_NAME = :MOUNT_POLICY_NAME;"; "MOUNT_POLICY_NAME = :MOUNT_POLICY_NAME";
std::unique_ptr<DbStmt> stmt(m_conn->createStmt(sql)); std::unique_ptr<DbStmt> stmt(m_conn->createStmt(sql));
stmt->bindString(":MOUNT_POLICY_NAME", mountPolicyName); stmt->bindString(":MOUNT_POLICY_NAME", mountPolicyName);
std::unique_ptr<DbRset> rset(stmt->executeQuery()); std::unique_ptr<DbRset> rset(stmt->executeQuery());
...@@ -1950,7 +1922,7 @@ bool RdbmsCatalogue::requesterExists(const std::string &requesterName) const { ...@@ -1950,7 +1922,7 @@ bool RdbmsCatalogue::requesterExists(const std::string &requesterName) const {
"FROM " "FROM "
"REQUESTER_MOUNT_RULE " "REQUESTER_MOUNT_RULE "
"WHERE " "WHERE "
"REQUESTER_NAME = :REQUESTER_NAME;"; "REQUESTER_NAME = :REQUESTER_NAME";
std::unique_ptr<DbStmt> stmt(m_conn->createStmt(sql)); std::unique_ptr<DbStmt> stmt(m_conn->createStmt(sql));
stmt->bindString(":REQUESTER_NAME", requesterName); stmt->bindString(":REQUESTER_NAME", requesterName);
std::unique_ptr<DbRset> rset(stmt->executeQuery()); std::unique_ptr<DbRset> rset(stmt->executeQuery());
...@@ -1993,7 +1965,7 @@ common::dataStructures::MountPolicy *RdbmsCatalogue::getRequesterMountPolicy(con ...@@ -1993,7 +1965,7 @@ common::dataStructures::MountPolicy *RdbmsCatalogue::getRequesterMountPolicy(con
"ON " "ON "
"MOUNT_POLICY.MOUNT_POLICY_NAME = REQUESTER_MOUNT_RULE.MOUNT_POLICY_NAME " "MOUNT_POLICY.MOUNT_POLICY_NAME = REQUESTER_MOUNT_RULE.MOUNT_POLICY_NAME "
"WHERE " "WHERE "
"REQUESTER_MOUNT_RULE.REQUESTER_NAME = :REQUESTER_NAME;"; "REQUESTER_MOUNT_RULE.REQUESTER_NAME = :REQUESTER_NAME";
std::unique_ptr<DbStmt> stmt(m_conn->createStmt(sql)); std::unique_ptr<DbStmt> stmt(m_conn->createStmt(sql));
stmt->bindString(":REQUESTER_NAME", requesterName); stmt->bindString(":REQUESTER_NAME", requesterName);
std::unique_ptr<DbRset> rset(stmt->executeQuery()); std::unique_ptr<DbRset> rset(stmt->executeQuery());
...@@ -2041,7 +2013,7 @@ bool RdbmsCatalogue::requesterGroupExists(const std::string &requesterGroupName) ...@@ -2041,7 +2013,7 @@ bool RdbmsCatalogue::requesterGroupExists(const std::string &requesterGroupName)
"FROM " "FROM "
"REQUESTER_GROUP_MOUNT_RULE " "REQUESTER_GROUP_MOUNT_RULE "
"WHERE " "WHERE "
"REQUESTER_GROUP_NAME = :REQUESTER_GROUP_NAME;"; "REQUESTER_GROUP_NAME = :REQUESTER_GROUP_NAME";
std::unique_ptr<DbStmt> stmt(m_conn->createStmt(sql)); std::unique_ptr<DbStmt> stmt(m_conn->createStmt(sql));
stmt->bindString(":REQUESTER_GROUP_NAME", requesterGroupName); stmt->bindString(":REQUESTER_GROUP_NAME", requesterGroupName);
std::unique_ptr<DbRset> rset(stmt->executeQuery()); std::unique_ptr<DbRset> rset(stmt->executeQuery());
...@@ -2056,7 +2028,7 @@ bool RdbmsCatalogue::requesterGroupExists(const std::string &requesterGroupName) ...@@ -2056,7 +2028,7 @@ bool RdbmsCatalogue::requesterGroupExists(const std::string &requesterGroupName)
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void RdbmsCatalogue::deleteMountPolicy(const std::string &name) { void RdbmsCatalogue::deleteMountPolicy(const std::string &name) {
try { try {
const char *const sql = "DELETE FROM MOUNT_POLICY WHERE MOUNT_POLICY_NAME = :MOUNT_POLICY_NAME;"; const char *const sql = "DELETE FROM MOUNT_POLICY WHERE MOUNT_POLICY_NAME = :MOUNT_POLICY_NAME";
std::unique_ptr<DbStmt> stmt(m_conn->createStmt(sql)); std::unique_ptr<DbStmt> stmt(m_conn->createStmt(sql));
stmt->bindString(":MOUNT_POLICY_NAME", name); stmt->bindString(":MOUNT_POLICY_NAME", name);
stmt->executeNonQuery(); stmt->executeNonQuery();
...@@ -2949,7 +2921,7 @@ RequesterAndGroupMountPolicies RdbmsCatalogue::getMountPolicies(const std::strin ...@@ -2949,7 +2921,7 @@ RequesterAndGroupMountPolicies RdbmsCatalogue::getMountPolicies(const std::strin
"ON " "ON "
"REQUESTER_GROUP_MOUNT_RULE.MOUNT_POLICY_NAME = MOUNT_POLICY.MOUNT_POLICY_NAME " "REQUESTER_GROUP_MOUNT_RULE.MOUNT_POLICY_NAME = MOUNT_POLICY.MOUNT_POLICY_NAME "
"WHERE " "WHERE "
"REQUESTER_GROUP_MOUNT_RULE.REQUESTER_GROUP_NAME = :REQUESTER_GROUP_NAME;"; "REQUESTER_GROUP_MOUNT_RULE.REQUESTER_GROUP_NAME = :REQUESTER_GROUP_NAME";
std::unique_ptr<DbStmt> stmt(m_conn->createStmt(sql)); std::unique_ptr<DbStmt> stmt(m_conn->createStmt(sql));
stmt->bindString(":REQUESTER_NAME", requesterName); stmt->bindString(":REQUESTER_NAME", requesterName);
...@@ -3056,7 +3028,7 @@ std::list<TapeForWriting> RdbmsCatalogue::getTapesForWriting(const std::string & ...@@ -3056,7 +3028,7 @@ std::list<TapeForWriting> RdbmsCatalogue::getTapesForWriting(const std::string &
tape.vid = rset->columnText("VID"); tape.vid = rset->columnText("VID");
tape.tapePool = rset->columnText("TAPE_POOL_NAME"); tape.tapePool = rset->columnText("TAPE_POOL_NAME");
tape.capacityInBytes = rset->columnUint64("CAPACITY_IN_BYTES"); tape.capacityInBytes = utils::toUint64(rset->columnText("CAPACITY_IN_BYTES"));
tape.dataOnTapeInBytes = rset->columnUint64("DATA_IN_BYTES"); tape.dataOnTapeInBytes = rset->columnUint64("DATA_IN_BYTES");
tape.lastFSeq = rset->columnUint64("LAST_FSEQ"); tape.lastFSeq = rset->columnUint64("LAST_FSEQ");
tape.lbp = rset->columnUint64("LBP_IS_ON"); tape.lbp = rset->columnUint64("LBP_IS_ON");
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include "catalogue/SqliteConn.hpp" #include "catalogue/SqliteConn.hpp"
#include "catalogue/UserError.hpp" #include "catalogue/UserError.hpp"
#include "common/exception/Exception.hpp" #include "common/exception/Exception.hpp"
#include "common/utils/utils.hpp"
namespace cta { namespace cta {
namespace catalogue { namespace catalogue {
...@@ -239,7 +240,7 @@ common::dataStructures::Tape SqliteCatalogue::selectTapeForUpdate(const std::str ...@@ -239,7 +240,7 @@ common::dataStructures::Tape SqliteCatalogue::selectTapeForUpdate(const std::str
tape.logicalLibraryName = rset->columnText("LOGICAL_LIBRARY_NAME"); tape.logicalLibraryName = rset->columnText("LOGICAL_LIBRARY_NAME");
tape.tapePoolName = rset->columnText("TAPE_POOL_NAME"); tape.tapePoolName = rset->columnText("TAPE_POOL_NAME");
tape.encryptionKey = rset->columnText("ENCRYPTION_KEY"); tape.encryptionKey = rset->columnText("ENCRYPTION_KEY");
tape.capacityInBytes = rset->columnUint64("CAPACITY_IN_BYTES"); tape.capacityInBytes = utils::toUint64(rset->columnText("CAPACITY_IN_BYTES"));
tape.dataOnTapeInBytes = rset->columnUint64("DATA_IN_BYTES"); tape.dataOnTapeInBytes = rset->columnUint64("DATA_IN_BYTES");
tape.lastFSeq = rset->columnUint64("LAST_FSEQ"); tape.lastFSeq = rset->columnUint64("LAST_FSEQ");
tape.disabled = rset->columnUint64("IS_DISABLED"); tape.disabled = rset->columnUint64("IS_DISABLED");
......
...@@ -84,12 +84,12 @@ CREATE TABLE TAPE( ...@@ -84,12 +84,12 @@ CREATE TABLE TAPE(
IS_DISABLED INTEGER NOT NULL, IS_DISABLED INTEGER NOT NULL,
IS_FULL INTEGER NOT NULL, IS_FULL INTEGER NOT NULL,
LBP_IS_ON INTEGER NOT NULL, LBP_IS_ON INTEGER NOT NULL,
LABEL_DRIVE VARCHAR2(100) NOT NULL, LABEL_DRIVE VARCHAR2(100),
LABEL_TIME INTEGER NOT NULL, LABEL_TIME INTEGER,
LAST_READ_DRIVE VARCHAR2(100) NOT NULL, LAST_READ_DRIVE VARCHAR2(100),
LAST_READ_TIME INTEGER NOT NULL, LAST_READ_TIME INTEGER,
LAST_WRITE_DRIVE VARCHAR2(100) NOT NULL, LAST_WRITE_DRIVE VARCHAR2(100),
LAST_WRITE_TIME INTEGER NOT NULL, LAST_WRITE_TIME INTEGER,
USER_COMMENT VARCHAR2(1000) NOT NULL, USER_COMMENT VARCHAR2(1000) NOT NULL,
CREATION_LOG_USER_NAME VARCHAR2(100) NOT NULL, CREATION_LOG_USER_NAME VARCHAR2(100) NOT NULL,
CREATION_LOG_HOST_NAME VARCHAR2(100) NOT NULL, CREATION_LOG_HOST_NAME VARCHAR2(100) NOT NULL,
......
...@@ -10,3 +10,4 @@ DROP TABLE STORAGE_CLASS; ...@@ -10,3 +10,4 @@ DROP TABLE STORAGE_CLASS;
DROP TABLE TAPE_POOL;