Commit 33e53666 authored by Michael Davis's avatar Michael Davis
Browse files

[catalogue] Fixes Postgres unit test

parent 91e8b321
......@@ -155,24 +155,28 @@ PostgresCatalogue::~PostgresCatalogue() {
std::string PostgresCatalogue::createAndPopulateTempTableFxid(rdbms::Conn &conn, const TapeFileSearchCriteria &tapeFileSearchCriteria) const {
const std::string tempTableName = "TEMP_DISK_FXIDS";
try {
if(tapeFileSearchCriteria.diskFileIds) {
std::string sql = "CREATE TEMPORARY TABLE " + tempTableName +
"(DISK_FILE_ID VARCHAR(100))";
conn.executeNonQuery(sql);
if(tapeFileSearchCriteria.diskFileIds) {
try {
std::string sql = "CREATE TEMPORARY TABLE " + tempTableName + "(DISK_FILE_ID VARCHAR(100))";
try {
conn.executeNonQuery(sql);
} catch(exception::Exception &ex) {
// Postgres does not drop temporary tables until the end of the session; trying to create another
// temporary table in the same unit test will fail. If this happens, truncate the table and carry on.
sql = "TRUNCATE TABLE " + tempTableName;
conn.executeNonQuery(sql);
}
sql = "INSERT INTO " + tempTableName + " VALUES(:DISK_FILE_ID)";
auto stmt = conn.createStmt(sql);
for(auto &diskFileId : tapeFileSearchCriteria.diskFileIds.value()) {
stmt.bindString(":DISK_FILE_ID", diskFileId);
stmt.executeNonQuery();
}
} catch(exception::Exception &ex) {
ex.getMessage().str(std::string(__FUNCTION__) + ": " + ex.getMessage().str());
throw;
}
return tempTableName;
} catch(exception::Exception &ex) {
ex.getMessage().str(std::string(__FUNCTION__) + ": " + ex.getMessage().str());
throw;
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment