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