Commit 4b4b6b4e authored by Cedric Caffy's avatar Cedric Caffy
Browse files

[schema-verify] cta-catalogue-schema-verify displays warning if ERROR logging

tables (ERR$_TABLE_NAME) are found
parent c8a39cf6
......@@ -145,6 +145,13 @@ std::list<std::string> DatabaseMetadataGetter::getTypes() {
return m_conn.getTypeNames();
}
std::list<std::string> DatabaseMetadataGetter::getErrorLoggingTables() {
std::list<std::string> tableNames = DatabaseMetadataGetter::getTableNames();
cta::utils::Regex regex("(^ERR\\$_)");
removeObjectNameNotMatches(tableNames,regex);
return tableNames;
}
DatabaseMetadataGetter::~DatabaseMetadataGetter() {}
SQLiteDatabaseMetadataGetter::SQLiteDatabaseMetadataGetter(cta::rdbms::Conn & conn):DatabaseMetadataGetter(conn){}
......@@ -177,8 +184,8 @@ cta::rdbms::Login::DbType OracleDatabaseMetadataGetter::getDbType(){
std::list<std::string> OracleDatabaseMetadataGetter::getTableNames(){
std::list<std::string> tableNames = DatabaseMetadataGetter::getTableNames();
//Ignore migration-related tables
removeObjectNameContaining(tableNames,{"ERR$_TAPE_FILE","TEMP_REMOVE_CASTOR_METADATA"});
//Ignore error logging tables
removeObjectNameMatches(tableNames,cta::utils::Regex("(^ERR\\$_)"));
return tableNames;
}
......
......@@ -65,6 +65,12 @@ class DatabaseMetadataGetter: public MetadataGetter {
virtual std::list<std::string> getStoredProcedures();
virtual std::list<std::string> getSynonyms();
virtual std::list<std::string> getTypes();
/**
* Returns ERROR logging tables.
* (Oracle only : ERR$_TABLE_NAME)
* @return the ERROR logging tables (Oracle only)
*/
virtual std::list<std::string> getErrorLoggingTables();
};
/**
......
......@@ -132,6 +132,15 @@ SchemaCheckerResult SchemaChecker::warnTypes() {
return res;
}
SchemaCheckerResult SchemaChecker::warnErrorLoggingTables() {
SchemaCheckerResult res;
std::list<std::string> errorTables = m_databaseMetadataGetter->getErrorLoggingTables();
for(auto & errorTable: errorTables) {
std::string warning = "Error logging table " + errorTable + " exists in the " + m_databaseToCheckName + " database";
res.addWarning(warning);
}
return res;
}
/////////////////////////////////////////
// SchemaChecker::Builder
......
......@@ -98,6 +98,12 @@ public:
*/
SchemaCheckerResult warnTypes();
/**
* Checks if there are error logging tables in the database
* @return a SchemaCheckerResult containing warnings if there are error logging tables in the database
*/
SchemaCheckerResult warnErrorLoggingTables();
class Builder {
public:
Builder(const std::string databaseToCheckName, const cta::rdbms::Login::DbType dbType, cta::rdbms::Conn &conn);
......
......@@ -86,6 +86,7 @@ int VerifySchemaCmd::exceptionThrowingMain(const int argc, char *const *const ar
result += schemaChecker->warnProcedures();
result += schemaChecker->warnSynonyms();
result += schemaChecker->warnTypes();
result += schemaChecker->warnErrorLoggingTables();
result.displayWarnings(std::cout);
if(result.getStatus() == SchemaCheckerResult::Status::FAILED){
return 1;
......
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