Commit 661bd0d0 authored by Steven Murray's avatar Steven Murray
Browse files

Added LOGICAL_LIBRARY_ID database column

parent e59db155
......@@ -303,6 +303,16 @@ public:
virtual void createLogicalLibrary(const common::dataStructures::SecurityIdentity &admin, const std::string &name, const bool isDisabled, const std::string &comment) = 0;
virtual void deleteLogicalLibrary(const std::string &name) = 0;
virtual std::list<common::dataStructures::LogicalLibrary> getLogicalLibraries() const = 0;
/**
* Modifies the name of the specified logical library.
*
* @param admin The administrator.
* @param currentName The current name of the logical library.
* @param newName The new name of the logical library.
*/
virtual void modifyLogicalLibraryName(const common::dataStructures::SecurityIdentity &admin, const std::string &currentName, const std::string &newName) = 0;
virtual void modifyLogicalLibraryComment(const common::dataStructures::SecurityIdentity &admin, const std::string &name, const std::string &comment) = 0;
virtual void setLogicalLibraryDisabled(const common::dataStructures::SecurityIdentity &admin, const std::string &name, const bool disabledValue) = 0;
......
......@@ -209,6 +209,10 @@ public:
return retryOnLostConnection(m_log, [&]{return m_catalogue->getLogicalLibraries();}, m_maxTriesToConnect);
}
void modifyLogicalLibraryName(const common::dataStructures::SecurityIdentity &admin, const std::string &currentName, const std::string &newName) override {
return retryOnLostConnection(m_log, [&]{return m_catalogue->modifyLogicalLibraryName(admin, currentName, newName);}, m_maxTriesToConnect);
}
void modifyLogicalLibraryComment(const common::dataStructures::SecurityIdentity &admin, const std::string &name, const std::string &comment) override {
return retryOnLostConnection(m_log, [&]{return m_catalogue->modifyLogicalLibraryComment(admin, name, comment);}, m_maxTriesToConnect);
}
......
......@@ -2730,6 +2730,101 @@ TEST_P(cta_catalogue_CatalogueTest, deleteLogicalLibrary_non_empty) {
ASSERT_THROW(m_catalogue->deleteLogicalLibrary(logicalLibraryName), catalogue::UserSpecifiedANonEmptyLogicalLibrary);
}
 
TEST_P(cta_catalogue_CatalogueTest, modifyLogicalLibraryName) {
using namespace cta;
ASSERT_TRUE(m_catalogue->getLogicalLibraries().empty());
const std::string libraryName = "logical_library";
const std::string comment = "Create logical library";
const bool libraryIsDisabled= false;
m_catalogue->createLogicalLibrary(m_admin, libraryName, libraryIsDisabled, comment);
{
const auto libraries = m_catalogue->getLogicalLibraries();
ASSERT_EQ(1, libraries.size());
const auto &library = libraries.front();
ASSERT_EQ(libraryName, library.name);
ASSERT_FALSE(library.isDisabled);
ASSERT_EQ(comment, library.comment);
const common::dataStructures::EntryLog creationLog = library.creationLog;
ASSERT_EQ(m_admin.username, creationLog.username);
ASSERT_EQ(m_admin.host, creationLog.host);
const common::dataStructures::EntryLog lastModificationLog = library.lastModificationLog;
ASSERT_EQ(creationLog, lastModificationLog);
}
const std::string newLibraryName = "new_logical_library";
m_catalogue->modifyLogicalLibraryName(m_admin, libraryName, newLibraryName);
{
const auto libraries = m_catalogue->getLogicalLibraries();
ASSERT_EQ(1, libraries.size());
const auto &library = libraries.front();
ASSERT_EQ(newLibraryName, library.name);
ASSERT_FALSE(library.isDisabled);
ASSERT_EQ(comment, library.comment);
const common::dataStructures::EntryLog creationLog = library.creationLog;
ASSERT_EQ(m_admin.username, creationLog.username);
ASSERT_EQ(m_admin.host, creationLog.host);
}
}
TEST_P(cta_catalogue_CatalogueTest, modifyLogicalLibraryName_emptyStringCurrentLogicalLibraryName) {
using namespace cta;
ASSERT_TRUE(m_catalogue->getLogicalLibraries().empty());
const std::string libraryName = "logical_library";
const bool libraryIsDisabled = false;
const std::string comment = "Create logical library";
m_catalogue->createLogicalLibrary(m_admin, libraryName, libraryIsDisabled, comment);
const std::string newLibraryName = "new_logical_library";
ASSERT_THROW(m_catalogue->modifyLogicalLibraryName(m_admin, "", newLibraryName),
catalogue::UserSpecifiedAnEmptyStringLogicalLibraryName);
}
TEST_P(cta_catalogue_CatalogueTest, modifyLogicalLibraryName_emptyStringNewLogicalLibraryName) {
using namespace cta;
ASSERT_TRUE(m_catalogue->getLogicalLibraries().empty());
const std::string libraryName = "logical_library";
const bool libraryIsDisabled = false;
const std::string comment = "Create logical library";
m_catalogue->createLogicalLibrary(m_admin, libraryName, libraryIsDisabled, comment);
{
const auto libraries = m_catalogue->getLogicalLibraries();
ASSERT_EQ(1, libraries.size());
const auto library = libraries.front();
ASSERT_EQ(libraryName, library.name);
ASSERT_FALSE(library.isDisabled);
ASSERT_EQ(comment, library.comment);
const common::dataStructures::EntryLog creationLog = library.creationLog;
ASSERT_EQ(m_admin.username, creationLog.username);
ASSERT_EQ(m_admin.host, creationLog.host);
const common::dataStructures::EntryLog lastModificationLog = library.lastModificationLog;
ASSERT_EQ(creationLog, lastModificationLog);
}
const std::string newLibraryName = "";
ASSERT_THROW(m_catalogue->modifyLogicalLibraryName(m_admin, libraryName, newLibraryName),
catalogue::UserSpecifiedAnEmptyStringLogicalLibraryName);
}
TEST_P(cta_catalogue_CatalogueTest, modifyLogicalLibraryComment) {
using namespace cta;
......
......@@ -147,6 +147,7 @@ void DropSchemaCmd::dropSqliteCatalogueSchema(rdbms::Conn &conn) {
"TAPE_POOL",
"TAPE_POOL_ID",
"LOGICAL_LIBRARY",
"LOGICAL_LIBRARY_ID",
"MOUNT_POLICY",
"ACTIVITIES_WEIGHTS",
"USAGESTATS",
......@@ -160,7 +161,7 @@ void DropSchemaCmd::dropSqliteCatalogueSchema(rdbms::Conn &conn) {
}
//------------------------------------------------------------------------------
// dropSqliteCatalogueSchema
// dropMysqlCatalogueSchema
//------------------------------------------------------------------------------
void DropSchemaCmd::dropMysqlCatalogueSchema(rdbms::Conn &conn) {
try {
......@@ -180,6 +181,7 @@ void DropSchemaCmd::dropMysqlCatalogueSchema(rdbms::Conn &conn) {
"TAPE_POOL",
"TAPE_POOL_ID",
"LOGICAL_LIBRARY",
"LOGICAL_LIBRARY_ID",
"MOUNT_POLICY",
"ACTIVITIES_WEIGHTS",
"USAGESTATS",
......@@ -261,7 +263,12 @@ void DropSchemaCmd::dropOracleCatalogueSchema(rdbms::Conn &conn) {
dropDatabaseTables(conn, tablesToDrop);
std::list<std::string> sequencesToDrop = {"ARCHIVE_FILE_ID_SEQ", "STORAGE_CLASS_ID_SEQ", "TAPE_POOL_ID_SEQ"};
std::list<std::string> sequencesToDrop = {
"ARCHIVE_FILE_ID_SEQ",
"LOGICAL_LIBRARY_ID_SEQ",
"STORAGE_CLASS_ID_SEQ",
"TAPE_POOL_ID_SEQ"
};
dropDatabaseSequences(conn, sequencesToDrop);
} catch(exception::Exception &ex) {
throw exception::Exception(std::string(__FUNCTION__) + " failed: " + ex.getMessage().str());
......@@ -296,7 +303,11 @@ void DropSchemaCmd::dropPostgresCatalogueSchema(rdbms::Conn &conn) {
dropDatabaseTables(conn, tablesToDrop);
std::list<std::string> sequencesToDrop = {"ARCHIVE_FILE_ID_SEQ", "STORAGE_CLASS_ID_SEQ", "TAPE_POOL_ID_SEQ"};
std::list<std::string> sequencesToDrop = {
"ARCHIVE_FILE_ID_SEQ",
"LOGICAL_LIBRARY_ID_SEQ",
"STORAGE_CLASS_ID_SEQ",
"TAPE_POOL_ID_SEQ"};
dropDatabaseSequences(conn, sequencesToDrop);
} catch(exception::Exception &ex) {
throw exception::Exception(std::string(__FUNCTION__) + " failed: " + ex.getMessage().str());
......
......@@ -88,6 +88,7 @@ public:
void modifyAdminUserComment(const common::dataStructures::SecurityIdentity& admin, const std::string& username, const std::string& comment) override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); }
void modifyArchiveRouteComment(const common::dataStructures::SecurityIdentity& admin, const std::string& instanceName, const std::string& storageClassName, const uint32_t copyNb, const std::string& comment) override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); }
void modifyArchiveRouteTapePoolName(const common::dataStructures::SecurityIdentity& admin, const std::string& instanceName, const std::string& storageClassName, const uint32_t copyNb, const std::string& tapePoolName) override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); }
void modifyLogicalLibraryName(const common::dataStructures::SecurityIdentity &admin, const std::string &currentName, const std::string &newName) override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); }
void modifyLogicalLibraryComment(const common::dataStructures::SecurityIdentity& admin, const std::string& name, const std::string& comment) override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); }
void setLogicalLibraryDisabled(const common::dataStructures::SecurityIdentity &admin, const std::string &name, const bool disabledValue) override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); }
void modifyMountPolicyArchiveMinRequestAge(const common::dataStructures::SecurityIdentity& admin, const std::string& name, const uint64_t minArchiveRequestAge) override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); }
......
......@@ -96,6 +96,47 @@ uint64_t MysqlCatalogue::getNextArchiveFileId(rdbms::Conn &conn) {
}
}
//------------------------------------------------------------------------------
// getNextLogicalLibraryId
//------------------------------------------------------------------------------
uint64_t MysqlCatalogue::getNextLogicalLibraryId(rdbms::Conn &conn) {
try {
rdbms::AutoRollback autoRollback(conn);
conn.executeNonQuery("START TRANSACTION");
{
const char *const sql =
"UPDATE LOGICAL_LIBRARY_ID SET ID = LAST_INSERT_ID(ID + 1)";
auto stmt = conn.createStmt(sql);
stmt.executeNonQuery();
}
uint64_t logicalLibraryId = 0;
{
const char *const sql =
"SELECT LAST_INSERT_ID() AS ID ";
auto stmt = conn.createStmt(sql);
auto rset = stmt.executeQuery();
if(!rset.next()) {
throw exception::Exception("LOGICAL_LIBRARY_ID table is empty");
}
logicalLibraryId = rset.columnUint64("ID");
if(rset.next()) {
throw exception::Exception("Found more than one ID counter in the LOGICAL_LIBRARY_ID table");
}
}
conn.commit();
return logicalLibraryId;
} catch(exception::UserError &) {
throw;
} catch(exception::Exception &ex) {
ex.getMessage().str(std::string(__FUNCTION__) + ": " + ex.getMessage().str());
throw;
}
}
//------------------------------------------------------------------------------
// getNextStorageClassId
//------------------------------------------------------------------------------
......
......@@ -71,6 +71,20 @@ protected:
*/
uint64_t getNextArchiveFileId(rdbms::Conn &conn) override;
/**
* Returns a unique logical library ID that can be used by a new logical
* library within the catalogue.
*
* This method must be implemented by the sub-classes of RdbmsCatalogue
* because different database technologies propose different solution to the
* problem of generating ever increasing numeric identifiers.
*
* @param conn The database connection.
* @return a unique logical library ID that can be used by a new logical
* library storage class within the catalogue.
*/
uint64_t getNextLogicalLibraryId(rdbms::Conn &conn) override;
/**
* Returns a unique storage class ID that can be used by a new storage class
* within the catalogue.
......
......@@ -177,6 +177,31 @@ uint64_t OracleCatalogue::getNextArchiveFileId(rdbms::Conn &conn) {
}
}
//------------------------------------------------------------------------------
// getNextLogicalLibraryId
//------------------------------------------------------------------------------
uint64_t OracleCatalogue::getNextLogicalLibraryId(rdbms::Conn &conn) {
try {
const char *const sql =
"SELECT "
"LOGICAL_LIBRARY_ID_SEQ.NEXTVAL AS LOGICAL_LIBRARY_ID "
"FROM "
"DUAL";
auto stmt = conn.createStmt(sql);
auto rset = stmt.executeQuery();
if (!rset.next()) {
throw exception::Exception(std::string("Result set is unexpectedly empty"));
}
return rset.columnUint64("LOGICAL_LIBRARY_ID");
} catch(exception::UserError &) {
throw;
} catch(exception::Exception &ex) {
ex.getMessage().str(std::string(__FUNCTION__) + ": " + ex.getMessage().str());
throw;
}
}
//------------------------------------------------------------------------------
// getNextStorageClassId
//------------------------------------------------------------------------------
......
......@@ -71,6 +71,20 @@ public:
*/
uint64_t getNextArchiveFileId(rdbms::Conn &conn) override;
/**
* Returns a unique logical library ID that can be used by a new logical
* library within the catalogue.
*
* This method must be implemented by the sub-classes of RdbmsCatalogue
* because different database technologies propose different solution to the
* problem of generating ever increasing numeric identifiers.
*
* @param conn The database connection.
* @return a unique logical library ID that can be used by a new logical
* library storage class within the catalogue.
*/
uint64_t getNextLogicalLibraryId(rdbms::Conn &conn) override;
/**
* Returns a unique storage class ID that can be used by a new storage class
* within the catalogue.
......
......@@ -171,6 +171,27 @@ uint64_t PostgresCatalogue::getNextArchiveFileId(rdbms::Conn &conn) {
}
}
//------------------------------------------------------------------------------
// getNextLogicalLibraryId
//------------------------------------------------------------------------------
uint64_t PostgresCatalogue::getNextLogicalLibraryId(rdbms::Conn &conn) {
try {
const char *const sql =
"select NEXTVAL('LOGICAL_LIBRARY_ID_SEQ') AS LOGICAL_LIBRARY_ID";
auto stmt = conn.createStmt(sql);
auto rset = stmt.executeQuery();
if(!rset.next()) {
throw exception::Exception("Result set is unexpectedly empty");
}
return rset.columnUint64("LOGICAL_LIBRARY_ID");
} catch(exception::UserError &) {
throw;
} catch(exception::Exception &ex) {
ex.getMessage().str(std::string(__FUNCTION__) + ": " + ex.getMessage().str());
throw;
}
}
//------------------------------------------------------------------------------
// getNextStorageClassId
//------------------------------------------------------------------------------
......
......@@ -97,6 +97,20 @@ public:
*/
uint64_t getNextArchiveFileId(rdbms::Conn &conn) override;
/**
* Returns a unique logical library ID that can be used by a new logical
* library within the catalogue.
*
* This method must be implemented by the sub-classes of RdbmsCatalogue
* because different database technologies propose different solution to the
* problem of generating ever increasing numeric identifiers.
*
* @param conn The database connection.
* @return a unique logical library ID that can be used by a new logical
* library storage class within the catalogue.
*/
uint64_t getNextLogicalLibraryId(rdbms::Conn &conn) override;
/**
* Returns a unique storage class ID that can be used by a new storage class
* within the catalogue.
......
......@@ -1666,9 +1666,11 @@ void RdbmsCatalogue::createLogicalLibrary(
throw exception::UserError(std::string("Cannot create logical library ") + name +
" because a logical library with the same name already exists");
}
const uint64_t logicalLibraryId = getNextLogicalLibraryId(conn);
const time_t now = time(nullptr);
const char *const sql =
"INSERT INTO LOGICAL_LIBRARY("
"LOGICAL_LIBRARY_ID,"
"LOGICAL_LIBRARY_NAME,"
"IS_DISABLED,"
......@@ -1682,6 +1684,7 @@ void RdbmsCatalogue::createLogicalLibrary(
"LAST_UPDATE_HOST_NAME,"
"LAST_UPDATE_TIME)"
"VALUES("
":LOGICAL_LIBRARY_ID,"
":LOGICAL_LIBRARY_NAME,"
":IS_DISABLED,"
......@@ -1696,6 +1699,7 @@ void RdbmsCatalogue::createLogicalLibrary(
":LAST_UPDATE_TIME)";
auto stmt = conn.createStmt(sql);
stmt.bindUint64(":LOGICAL_LIBRARY_ID", logicalLibraryId);
stmt.bindString(":LOGICAL_LIBRARY_NAME", name);
stmt.bindBool(":IS_DISABLED", isDisabled);
......@@ -1830,6 +1834,51 @@ std::list<common::dataStructures::LogicalLibrary> RdbmsCatalogue::getLogicalLibr
}
}
//------------------------------------------------------------------------------
// modifyLogicalLibraryName
//------------------------------------------------------------------------------
void RdbmsCatalogue::modifyLogicalLibraryName(const common::dataStructures::SecurityIdentity &admin,
const std::string &currentName, const std::string &newName) {
try {
if(currentName.empty()) {
throw UserSpecifiedAnEmptyStringLogicalLibraryName(
"Cannot modify logical library because the logical library name is an empty string");
}
if(newName.empty()) {
throw UserSpecifiedAnEmptyStringLogicalLibraryName(
"Cannot modify logical library because the new name is an empty string");
}
const time_t now = time(nullptr);
const char *const sql =
"UPDATE LOGICAL_LIBRARY SET "
"LOGICAL_LIBRARY_NAME = :NEW_LOGICAL_LIBRARY_NAME,"
"LAST_UPDATE_USER_NAME = :LAST_UPDATE_USER_NAME,"
"LAST_UPDATE_HOST_NAME = :LAST_UPDATE_HOST_NAME,"
"LAST_UPDATE_TIME = :LAST_UPDATE_TIME "
"WHERE "
"LOGICAL_LIBRARY_NAME = :CURRENT_LOGICAL_LIBRARY_NAME";
auto conn = m_connPool.getConn();
auto stmt = conn.createStmt(sql);
stmt.bindString(":NEW_LOGICAL_LIBRARY_NAME", newName);
stmt.bindString(":LAST_UPDATE_USER_NAME", admin.username);
stmt.bindString(":LAST_UPDATE_HOST_NAME", admin.host);
stmt.bindUint64(":LAST_UPDATE_TIME", now);
stmt.bindString(":CURRENT_LOGICAL_LIBRARY_NAME", currentName);
stmt.executeNonQuery();
if(0 == stmt.getNbAffectedRows()) {
throw exception::UserError(std::string("Cannot modify logical library ") + currentName + " because it does not exist");
}
} catch(exception::UserError &) {
throw;
} catch(exception::Exception &ex) {
ex.getMessage().str(std::string(__FUNCTION__) + ": " + ex.getMessage().str());
throw;
}
}
//------------------------------------------------------------------------------
// modifyLogicalLibraryComment
//------------------------------------------------------------------------------
......@@ -1952,72 +2001,72 @@ void RdbmsCatalogue::createTape(
throw exception::UserError(std::string("Cannot create tape ") + vid +
" because a tape with the same volume identifier already exists");
}
if(!logicalLibraryExists(conn, logicalLibraryName)) {
const auto logicalLibraryId = getLogicalLibraryId(conn, logicalLibraryName);
if(!logicalLibraryId) {
throw exception::UserError(std::string("Cannot create tape ") + vid + " because logical library " +
logicalLibraryName + " does not exist");
}
if(!tapePoolExists(conn, tapePoolName)) {
const auto tapePoolId = getTapePoolId(conn, tapePoolName);
if(!tapePoolId) {
throw exception::UserError(std::string("Cannot create tape ") + vid + " because tape pool " +
tapePoolName + " does not exist");
}
const time_t now = time(nullptr);
const char *const sql =
"INSERT INTO TAPE(" "\n"
"VID," "\n"
"MEDIA_TYPE," "\n"
"VENDOR," "\n"
"LOGICAL_LIBRARY_NAME," "\n"
"TAPE_POOL_ID," "\n"
"CAPACITY_IN_BYTES," "\n"
"DATA_IN_BYTES," "\n"
"LAST_FSEQ," "\n"
"IS_DISABLED," "\n"
"IS_FULL," "\n"
"IS_READ_ONLY," "\n"
"IS_FROM_CASTOR," "\n"
"USER_COMMENT," "\n"
"CREATION_LOG_USER_NAME," "\n"
"CREATION_LOG_HOST_NAME," "\n"
"CREATION_LOG_TIME," "\n"
"LAST_UPDATE_USER_NAME," "\n"
"LAST_UPDATE_HOST_NAME," "\n"
"LAST_UPDATE_TIME)" "\n"
"SELECT" "\n"
":VID," "\n"
":MEDIA_TYPE," "\n"
":VENDOR," "\n"
":LOGICAL_LIBRARY_NAME," "\n"
"TAPE_POOL_ID," "\n"
":CAPACITY_IN_BYTES," "\n"
":DATA_IN_BYTES," "\n"
":LAST_FSEQ," "\n"
":IS_DISABLED," "\n"
":IS_FULL," "\n"
":IS_READ_ONLY," "\n"
":IS_FROM_CASTOR," "\n"
":USER_COMMENT," "\n"
":CREATION_LOG_USER_NAME," "\n"
":CREATION_LOG_HOST_NAME," "\n"
":CREATION_LOG_TIME," "\n"
":LAST_UPDATE_USER_NAME," "\n"
":LAST_UPDATE_HOST_NAME," "\n"
":LAST_UPDATE_TIME" "\n"
"FROM "
"TAPE_POOL " "\n"
"WHERE " "\n"
"TAPE_POOL_NAME = :TAPE_POOL_NAME";
"INSERT INTO TAPE(" "\n"
"VID," "\n"
"MEDIA_TYPE," "\n"
"VENDOR," "\n"
"LOGICAL_LIBRARY_ID," "\n"
"TAPE_POOL_ID," "\n"
"CAPACITY_IN_BYTES," "\n"
"DATA_IN_BYTES," "\n"
"LAST_FSEQ," "\n"
"IS_DISABLED," "\n"
"IS_FULL," "\n"
"IS_READ_ONLY," "\n"
"IS_FROM_CASTOR," "\n"
"USER_COMMENT," "\n"
"CREATION_LOG_USER_NAME," "\n"
"CREATION_LOG_HOST_NAME," "\n"
"CREATION_LOG_TIME," "\n"
"LAST_UPDATE_USER_NAME," "\n"
"LAST_UPDATE_HOST_NAME," "\n"
"LAST_UPDATE_TIME)" "\n"
"VALUES(" "\n"
":VID," "\n"
":MEDIA_TYPE," "\n"
":VENDOR," "\n"
":LOGICAL_LIBRARY_ID," "\n"
":TAPE_POOL_ID," "\n"
":CAPACITY_IN_BYTES," "\n"
":DATA_IN_BYTES," "\n"
":LAST_FSEQ," "\n"
":IS_DISABLED," "\n"
":IS_FULL," "\n"
":IS_READ_ONLY," "\n"
":IS_FROM_CASTOR," "\n"
":USER_COMMENT," "\n"
":CREATION_LOG_USER_NAME," "\n"
":CREATION_LOG_HOST_NAME," "\n"
":CREATION_LOG_TIME," "\n"
":LAST_UPDATE_USER_NAME," "\n"
":LAST_UPDATE_HOST_NAME," "\n"
":LAST_UPDATE_TIME" "\n"
")";
auto stmt = conn.createStmt(sql);
stmt.bindString(":VID", vid);
stmt.bindString(":MEDIA_TYPE", mediaType);
stmt.bindString(":VENDOR", vendor);
stmt.bindString(":LOGICAL_LIBRARY_NAME", logicalLibraryName);
stmt.bindUint64(":LOGICAL_LIBRARY_ID", logicalLibraryId.value());
stmt.bindUint64(":TAPE_POOL_ID", tapePoolId.value());
stmt.bindUint64(":CAPACITY_IN_BYTES", capacityInBytes);
stmt.bindUint64(":DATA_IN_BYTES", 0);
stmt.bindUint64(":LAST_FSEQ", 0);
......@@ -2036,8 +2085,6 @@ void RdbmsCatalogue::createTape(
stmt.bindString(":LAST_UPDATE_HOST_NAME", admin.host);
stmt.bindUint64(":LAST_UPDATE_TIME", now);
stmt.bindString(":TAPE_POOL_NAME", tapePoolName);
stmt.executeNonQuery();
log::LogContext lc(m_log);
......@@ -2212,7 +2259,7 @@ std::list<common::dataStructures::Tape> RdbmsCatalogue::getTapes(rdbms::Conn &co
"TAPE.VID AS VID,"
"TAPE.MEDIA_TYPE AS MEDIA_TYPE,"
"TAPE.VENDOR AS VENDOR,"
"TAPE.LOGICAL_LIBRARY_NAME AS LOGICAL_LIBRARY_NAME,"
"LOGICAL_LIBRARY.LOGICAL_LIBRARY_NAME AS LOGICAL_LIBRARY_NAME,"
"TAPE_POOL.TAPE_POOL_NAME AS TAPE_POOL_NAME,"
"TAPE_POOL.VO AS VO,"
"TAPE.ENCRYPTION_KEY_NAME AS ENCRYPTION_KEY_NAME,"
......@@ -2248,7 +2295,9 @@ std::list<common::dataStructures::Tape> RdbmsCatalogue::getTapes(rdbms::Conn &co
"FROM "
"TAPE "
"INNER JOIN TAPE_POOL ON "
"TAPE.TAPE_POOL_ID = TAPE_POOL.TAPE_POOL_ID";
"TAPE.TAPE_POOL_ID = TAPE_POOL.TAPE_POOL_ID "
"INNER JOIN LOGICAL_LIBRARY ON "
"TAPE.LOGICAL_LIBRARY_ID = LOGICAL_LIBRARY.LOGICAL_LIBRARY_ID";
if(searchCriteria.vid ||
searchCriteria.mediaType ||
......@@ -2281,7 +2330,7 @@ std::list<common::dataStructures::Tape> RdbmsCatalogue::getTapes(rdbms::Conn &co
}
if(searchCriteria.logicalLibrary) {
if(addedAWhereConstraint) sql += " AND ";
sql += " TAPE.LOGICAL_LIBRARY_NAME = :LOGICAL_LIBRARY_NAME";
sql += " LOGICAL_LIBRARY.LOGICAL_LIBRARY_NAME = :LOGICAL_LIBRARY_NAME";
addedAWhereConstraint = true;
}
if(searchCriteria.tapePool) {
......@@ -2387,7 +2436,7 @@ common::dataStructures::VidToTapeMap RdbmsCatalogue::getTapesByVid(const std::se