Commit 8517f255 authored by Eric Cano's avatar Eric Cano
Browse files

Added recording of which tape file supersedes old ones in Oracle catalogue.

parent b87d7a7c
......@@ -227,6 +227,7 @@ void DropSchemaCmd::dropOracleCatalogueSchema(rdbms::Conn &conn) {
"ARCHIVE_FILE",
"TAPE",
"TEMP_TAPE_FILE_BATCH",
"TEMP_TAPE_FILE_INSERTION_BATCH",
"REQUESTER_MOUNT_RULE",
"REQUESTER_GROUP_MOUNT_RULE",
"ADMIN_USER",
......
......@@ -440,22 +440,39 @@ void OracleCatalogue::filesWrittenToTape(const std::set<TapeItemWrittenPointer>
}
const char *const sql =
"INSERT INTO TAPE_FILE("
"VID,"
"FSEQ,"
"BLOCK_ID,"
"COMPRESSED_SIZE_IN_BYTES,"
"COPY_NB,"
"CREATION_TIME,"
"ARCHIVE_FILE_ID)"
"VALUES("
":VID,"
":FSEQ,"
":BLOCK_ID,"
":COMPRESSED_SIZE_IN_BYTES,"
":COPY_NB,"
":CREATION_TIME,"
":ARCHIVE_FILE_ID)";
"BEGIN" "\n"
"INSERT INTO TEMP_TAPE_FILE_INSERTION_BATCH(" "\n"
"VID," "\n"
"FSEQ," "\n"
"BLOCK_ID," "\n"
"COMPRESSED_SIZE_IN_BYTES," "\n"
"COPY_NB," "\n"
"CREATION_TIME," "\n"
"ARCHIVE_FILE_ID)" "\n"
"VALUES(" "\n"
":VID," "\n"
":FSEQ," "\n"
":BLOCK_ID," "\n"
":COMPRESSED_SIZE_IN_BYTES," "\n"
":COPY_NB," "\n"
":CREATION_TIME," "\n"
":ARCHIVE_FILE_ID);" "\n"
"INSERT INTO TAPE_FILE (VID, FSEQ, BLOCK_ID, COMPRESSED_SIZE_IN_BYTES," "\n"
"COPY_NB, CREATION_TIME, ARCHIVE_FILE_ID)" "\n"
"SELECT VID, FSEQ, BLOCK_ID, COMPRESSED_SIZE_IN_BYTES," "\n"
"COPY_NB, CREATION_TIME, ARCHIVE_FILE_ID FROM TEMP_TAPE_FILE_INSERTION_BATCH;" "\n"
"FOR TF IN (SELECT * FROM TEMP_TAPE_FILE_INSERTION_BATCH)" "\n"
"LOOP" "\n"
"UPDATE TAPE_FILE SET" "\n"
"SUPERSEDED_BY_VID=TF.VID," /*VID of the new file*/ "\n"
"SUPERSEDED_BY_FSEQ=TF.FSEQ" /*FSEQ of the new file*/ "\n"
"WHERE" "\n"
"TAPE_FILE.ARCHIVE_FILE_ID= TF.ARCHIVE_FILE_ID AND" "\n"
"TAPE_FILE.COPY_NB= TF.COPY_NB AND" "\n"
"(TAPE_FILE.VID <> TF.VID OR TAPE_FILE.FSEQ <> TF.FSEQ);" "\n"
"END LOOP;" "\n"
"COMMIT;" "\n"
"END;";
auto stmt = conn.createStmt(sql);
rdbms::wrapper::OcciStmt &occiStmt = dynamic_cast<rdbms::wrapper::OcciStmt &>(stmt.getStmt());
occiStmt.setColumn(tapeFileBatch.vid);
......@@ -493,8 +510,6 @@ void OracleCatalogue::filesWrittenToTape(const std::set<TapeItemWrittenPointer>
throw exception::Exception(msg.str());
}
conn.commit();
} catch(exception::UserError &) {
throw;
} catch(exception::Exception &ex) {
......
......@@ -19,3 +19,14 @@ CREATE GLOBAL TEMPORARY TABLE TEMP_TAPE_FILE_BATCH(
)
ON COMMIT DELETE ROWS;
CREATE INDEX TEMP_T_F_B_ARCHIVE_FILE_ID_I ON TEMP_TAPE_FILE_BATCH(ARCHIVE_FILE_ID);
CREATE GLOBAL TEMPORARY TABLE TEMP_TAPE_FILE_INSERTION_BATCH(
VID VARCHAR(100),
FSEQ NUMERIC(20, 0),
BLOCK_ID NUMERIC(20, 0),
COMPRESSED_SIZE_IN_BYTES NUMERIC(20, 0),
COPY_NB NUMERIC(20, 0),
CREATION_TIME NUMERIC(20, 0),
ARCHIVE_FILE_ID NUMERIC(20, 0)
)
ON COMMIT DELETE ROWS;
CREATE INDEX TEMP_T_F_I_B_ARCHIVE_FILE_ID_I ON TEMP_TAPE_FILE_INSERTION_BATCH(ARCHIVE_FILE_ID);
......@@ -41,9 +41,12 @@ ParamNameToIdx::ParamNameToIdx(const std::string &sql) {
}
if(':' == *ptr) {
// We need to overlook ':=' in PL/SQL code (at least)
if (isValidParamNameChar(*(ptr+1))) {
waitingForAParam = false;
paramName << ":";
}
}
} else { // Currently processing a parameter name
......
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