Skip to content
Snippets Groups Projects
Commit f2386580 authored by Victor Kotlyar's avatar Victor Kotlyar
Browse files

Fix regexp for parsing the catalogue schema columns

parent 48d7d61d
No related branches found
No related tags found
No related merge requests found
......@@ -58,7 +58,7 @@ std::map<std::string, std::string> CatalogueSchema::getSchemaColumns(const std::
searchPos = findResult + 1;
if(0 < sqlStmt.size()) { // Ignore empty statements
const std::string createTableSQL = "CREATE TABLE " + tableName + "\\(([a-zA-Z0-9_, '\\)\\(]+)\\)";
const std::string createTableSQL = "CREATE TABLE " + tableName + "[ ]*\\(([a-zA-Z0-9_, '\\)\\(]+)\\)";
cta::utils::Regex tableSqlRegex(createTableSQL.c_str());
auto tableSql = tableSqlRegex.exec(sqlStmt);
if (2 == tableSql.size()) {
......@@ -71,7 +71,7 @@ std::map<std::string, std::string> CatalogueSchema::getSchemaColumns(const std::
const std::string sqlStmtComma = utils::trimString(tableSql[1].substr(searchPosComma, stmtLenComma));
searchPosComma = findResultComma + 1;
if(0 < sqlStmtComma.size()) { // Ignore empty statements
const std::string columnSQL = "([a-zA-Z_]+) +(" + columnTypes + ")";
const std::string columnSQL = "([a-zA-Z_0-9]+) +(" + columnTypes + ")";
cta::utils::Regex columnSqlRegex(columnSQL.c_str());
auto columnSql = columnSqlRegex.exec(sqlStmtComma);
if (3 == columnSql.size()) {
......@@ -103,7 +103,7 @@ std::list<std::string> CatalogueSchema::getSchemaTableNames() const {
searchPos = findResult + 1;
if(0 < sqlStmt.size()) { // Ignore empty statements
cta::utils::Regex tableNamesRegex("CREATE TABLE ([a-zA-Z_]+)");
cta::utils::Regex tableNamesRegex("CREATE TABLE ([a-zA-Z_0-9]+)");
auto tableName = tableNamesRegex.exec(sqlStmt);
if (2 == tableName.size()) {
schemaTables.push_back(tableName[1].c_str());
......
......@@ -214,7 +214,8 @@ VerifySchemaCmd::VerifyStatus VerifySchemaCmd::verifyColumns(const std::list<std
for (const auto &dbColumn : dbColumns) {
if (!schemaColumns.count(dbColumn.first)) {
std::cerr << " ERROR: the DB column " << dbColumn.first
<<" not found in the catalogue schema" << std::endl;
<< " for table " << tableName
<< " not found in the catalogue schema" << std::endl;
status = VerifyStatus::ERROR;
}
}
......@@ -225,18 +226,20 @@ VerifySchemaCmd::VerifyStatus VerifySchemaCmd::verifyColumns(const std::list<std
std::cerr << " ERROR: type mismatch for the column: DB["
<< schemaColumn.first << "] = " << dbColumns.at(schemaColumn.first)
<< ", SCHEMA[" << schemaColumn.first << "] = "
<< schemaColumn.second << std::endl;
<< schemaColumn.second
<< " for table " << tableName << std::endl;
status = VerifyStatus::ERROR;
}
} else {
std::cerr << " ERROR: the schema column " << schemaColumn.first
<<" not found in the DB" << std::endl;
<< " not found in the DB"
<< " for table " << tableName << std::endl;
status = VerifyStatus::ERROR;
}
}
} else {
std::cerr << " ERROR: the schema table " << tableName
<<" not found in the DB" << std::endl;
<< " not found in the DB" << std::endl;
status = VerifyStatus::ERROR;
}
}
......
......@@ -262,7 +262,7 @@ std::map<std::string, std::string> SqliteConn::getColumns(const std::string &tab
const std::string sqlStmtComma = utils::trimString(tableSql.substr(searchPosComma, stmtLenComma));
searchPosComma = findResultComma + 1;
if(0 < sqlStmtComma.size()) { // Ignore empty statements
const std::string columnSQL = "([a-zA-Z_]+) +(" + columnTypes + ")";
const std::string columnSQL = "([a-zA-Z_0-9]+) +(" + columnTypes + ")";
cta::utils::Regex columnSqlRegex(columnSQL.c_str());
auto columnSql = columnSqlRegex.exec(sqlStmtComma);
if (3 == columnSql.size()) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment