Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
dCache
cta
Commits
3b04912f
Commit
3b04912f
authored
Jun 15, 2020
by
Cedric Caffy
Browse files
[schema-verify] added the stored procedures warnings to the
cta-catalogue-schema-verify tool
parent
b271c7cd
Changes
16
Hide whitespace changes
Inline
Side-by-side
catalogue/DatabaseMetadataGetter.cpp
View file @
3b04912f
...
...
@@ -133,6 +133,10 @@ std::list<std::string> DatabaseMetadataGetter::getParallelTableNames(){
return
m_conn
.
getParallelTableNames
();
}
std
::
list
<
std
::
string
>
DatabaseMetadataGetter
::
getStoredProcedures
()
{
return
m_conn
.
getStoredProcedureNames
();
}
DatabaseMetadataGetter
::~
DatabaseMetadataGetter
()
{}
SQLiteDatabaseMetadataGetter
::
SQLiteDatabaseMetadataGetter
(
cta
::
rdbms
::
Conn
&
conn
)
:
DatabaseMetadataGetter
(
conn
){}
...
...
catalogue/DatabaseMetadataGetter.hpp
View file @
3b04912f
...
...
@@ -62,6 +62,7 @@ class DatabaseMetadataGetter: public MetadataGetter {
virtual
std
::
list
<
std
::
string
>
getConstraintNames
(
const
std
::
string
&
tableName
);
virtual
std
::
list
<
std
::
string
>
getParallelTableNames
();
virtual
cta
::
rdbms
::
Login
::
DbType
getDbType
()
=
0
;
virtual
std
::
list
<
std
::
string
>
getStoredProcedures
();
};
/**
...
...
catalogue/SchemaChecker.cpp
View file @
3b04912f
...
...
@@ -58,7 +58,7 @@ SchemaCheckerResult SchemaChecker::displayingCompareSchema(std::ostream & stdOut
return
totalResult
;
}
SchemaCheckerResult
SchemaChecker
::
checkNo
ParallelTables
(){
SchemaCheckerResult
SchemaChecker
::
warn
ParallelTables
(){
SchemaCheckerResult
res
;
std
::
list
<
std
::
string
>
parallelTables
=
m_databaseMetadataGetter
->
getParallelTableNames
();
for
(
auto
&
table
:
parallelTables
)
{
...
...
@@ -68,7 +68,7 @@ SchemaCheckerResult SchemaChecker::checkNoParallelTables(){
return
res
;
}
SchemaCheckerResult
SchemaChecker
::
check
Schema
Not
Upgrading
(){
SchemaCheckerResult
SchemaChecker
::
warn
SchemaUpgrading
(){
SchemaCheckerResult
res
;
SchemaVersion
catalogueVersion
=
m_databaseMetadataGetter
->
getCatalogueVersion
();
if
(
catalogueVersion
.
getStatus
<
SchemaVersion
::
Status
>
()
==
SchemaVersion
::
Status
::
UPGRADING
){
...
...
@@ -102,6 +102,17 @@ SchemaCheckerResult SchemaChecker::checkTableContainsColumns(const std::string&
return
res
;
}
SchemaCheckerResult
SchemaChecker
::
warnProcedures
()
{
SchemaCheckerResult
res
;
std
::
list
<
std
::
string
>
procedureNames
=
m_databaseMetadataGetter
->
getStoredProcedures
();
for
(
auto
procedure
:
procedureNames
){
std
::
string
warning
=
"PROCEDURE "
+
procedure
+
" exists in the "
+
m_databaseToCheckName
+
" database"
;
res
.
addWarning
(
warning
);
}
return
res
;
}
/////////////////////////////////////////
// SchemaChecker::Builder
/////////////////////////////////////////
...
...
catalogue/SchemaChecker.hpp
View file @
3b04912f
...
...
@@ -55,24 +55,37 @@ public:
/**
* Checks if the catalogue database contains PARALLEL tables
* It will display a warning with the table name if this is the case
* @return a SchemaCheckerResult
* @return a SchemaCheckerResult
containing the warnings
*/
SchemaCheckerResult
checkNo
ParallelTables
();
SchemaCheckerResult
warn
ParallelTables
();
/**
* Checks if the catalogue database schema is upgrading or not
* @return a SchemaCheckerResult containing the warnings
*/
SchemaCheckerResult
check
Schema
Not
Upgrading
();
SchemaCheckerResult
warn
SchemaUpgrading
();
/**
* Compare the schema tables whose names are located in the tableList parameter
* @param tableList the table names we would like to compare
* @return a S
tatus OK or FAILURE
* @return a S
chemaCheckerResult containing the errors
*/
SchemaCheckerResult
compareTablesLocatedInSchema
();
/**
* Checks if the table tableName contains the columns whose names are in the columnNames list
* @param tableName the tableName to check
* @param columnNames the columnName the tableName is supposed to have
* @return a SchemaCheckerResult containing the errors
*/
SchemaCheckerResult
checkTableContainsColumns
(
const
std
::
string
&
tableName
,
const
std
::
list
<
std
::
string
>
columnNames
);
/**
* Checks if there are stored procedures in the schema.
* @return a SchemaCheckerResult containing warnings if there are stored procedures.
*/
SchemaCheckerResult
warnProcedures
();
class
Builder
{
public:
Builder
(
const
std
::
string
databaseToCheckName
,
const
cta
::
rdbms
::
Login
::
DbType
dbType
,
cta
::
rdbms
::
Conn
&
conn
);
...
...
catalogue/VerifySchemaCmd.cpp
View file @
3b04912f
...
...
@@ -81,8 +81,9 @@ int VerifySchemaCmd::exceptionThrowingMain(const int argc, char *const *const ar
.
build
());
SchemaCheckerResult
result
=
schemaChecker
->
displayingCompareSchema
(
std
::
cout
,
std
::
cerr
);
result
+=
schemaChecker
->
checkNoParallelTables
();
result
+=
schemaChecker
->
checkSchemaNotUpgrading
();
result
+=
schemaChecker
->
warnParallelTables
();
result
+=
schemaChecker
->
warnSchemaUpgrading
();
result
+=
schemaChecker
->
warnProcedures
();
result
.
displayWarnings
(
std
::
cout
);
if
(
result
.
getStatus
()
==
SchemaCheckerResult
::
Status
::
FAILED
){
return
1
;
...
...
rdbms/Conn.cpp
View file @
3b04912f
...
...
@@ -252,5 +252,16 @@ std::list<std::string> Conn::getConstraintNames(const std::string &tableName) {
}
}
//------------------------------------------------------------------------------
// getStoredProcedureNames
//------------------------------------------------------------------------------
std
::
list
<
std
::
string
>
Conn
::
getStoredProcedureNames
(){
if
(
nullptr
!=
m_connAndStmts
&&
nullptr
!=
m_connAndStmts
->
conn
)
{
return
m_connAndStmts
->
conn
->
getStoredProcedureNames
();
}
else
{
throw
exception
::
Exception
(
std
::
string
(
__FUNCTION__
)
+
" failed: Conn does not contain a connection"
);
}
}
}
// namespace rdbms
}
// namespace cta
rdbms/Conn.hpp
View file @
3b04912f
...
...
@@ -221,6 +221,16 @@ public:
*/
std
::
list
<
std
::
string
>
getConstraintNames
(
const
std
::
string
&
tableName
);
/**
* Returns the stored procedure names of the database
*
* If the underlying database technologies does not support stored procedures informations
* this method simply returns an empty list.
*
* @return the list of the names of the stored procedures in the database
*/
std
::
list
<
std
::
string
>
getStoredProcedureNames
();
/**
* Get a pointer to the connection wrapper implementation
*
...
...
rdbms/wrapper/ConnWrapper.hpp
View file @
3b04912f
...
...
@@ -166,6 +166,17 @@ public:
* @return the list of the names of the constraints that the given table has.
*/
virtual
std
::
list
<
std
::
string
>
getConstraintNames
(
const
std
::
string
&
tableName
)
=
0
;
/**
*
* Returns the stored procedure names of the database
*
* If the underlying database technologies does not support stored procedures informations
* this method simply returns an empty list.
*
* @return the list of the names of the stored procedures in the database
*/
virtual
std
::
list
<
std
::
string
>
getStoredProcedureNames
()
=
0
;
};
// class ConnWrapper
...
...
rdbms/wrapper/MysqlConn.cpp
View file @
3b04912f
...
...
@@ -352,6 +352,13 @@ std::list<std::string> MysqlConn::getConstraintNames(const std::string& tableNam
return
std
::
list
<
std
::
string
>
();
}
//------------------------------------------------------------------------------
// getStoredProcedureNames
//------------------------------------------------------------------------------
std
::
list
<
std
::
string
>
MysqlConn
::
getStoredProcedureNames
()
{
return
std
::
list
<
std
::
string
>
();
}
}
// namespace wrapper
}
// namespace rdbms
}
// namespace cta
rdbms/wrapper/MysqlConn.hpp
View file @
3b04912f
...
...
@@ -185,11 +185,26 @@ public:
/**
* Returns the Constraint names of a given table in the database schema
*
* If the underlying database technologies does not support constraint
* then this method simply returns an empty list.
*
* @param tableName the table name to get the constraint names from
* @return the list of the names of the constraints that the given table has.
*/
std
::
list
<
std
::
string
>
getConstraintNames
(
const
std
::
string
&
tableName
)
override
;
/**
*
* Returns the stored procedure names of the database
*
* If the underlying database technologies does not support stored procedures informations
* this method simply returns an empty list.
*
* @return the list of the names of the stored procedures in the database
*/
std
::
list
<
std
::
string
>
getStoredProcedureNames
()
override
;
private:
/**
...
...
rdbms/wrapper/OcciConn.cpp
View file @
3b04912f
...
...
@@ -338,6 +338,30 @@ std::list<std::string> OcciConn::getConstraintNames(const std::string& tableName
}
}
//------------------------------------------------------------------------------
// getStoredProcedureNames
//------------------------------------------------------------------------------
std
::
list
<
std
::
string
>
OcciConn
::
getStoredProcedureNames
()
{
try
{
std
::
list
<
std
::
string
>
names
;
const
char
*
const
sql
=
"SELECT "
"OBJECT_NAME "
"FROM "
"USER_PROCEDURES"
;
auto
stmt
=
createStmt
(
sql
);
auto
rset
=
stmt
->
executeQuery
();
while
(
rset
->
next
())
{
auto
name
=
rset
->
columnOptionalString
(
"OBJECT_NAME"
);
names
.
push_back
(
name
.
value
());
}
return
names
;
}
catch
(
exception
::
Exception
&
ex
)
{
throw
exception
::
Exception
(
std
::
string
(
__FUNCTION__
)
+
" failed: "
+
ex
.
getMessage
().
str
());
}
}
//------------------------------------------------------------------------------
// isOpen
//------------------------------------------------------------------------------
...
...
rdbms/wrapper/OcciConn.hpp
View file @
3b04912f
...
...
@@ -176,6 +176,18 @@ public:
* @return the list of the names of the constraints that the given table has.
*/
std
::
list
<
std
::
string
>
getConstraintNames
(
const
std
::
string
&
tableName
)
override
;
/**
*
* Returns the stored procedure names of the database
*
* If the underlying database technologies does not support stored procedures informations
* this method simply returns an empty list.
*
* @return the list of the names of the stored procedures in the database
*/
std
::
list
<
std
::
string
>
getStoredProcedureNames
()
override
;
private:
friend
OcciStmt
;
...
...
rdbms/wrapper/PostgresConn.cpp
View file @
3b04912f
...
...
@@ -362,6 +362,14 @@ std::list<std::string> PostgresConn::getConstraintNames(const std::string& table
}
}
//------------------------------------------------------------------------------
// getStoredProcedureNames
//------------------------------------------------------------------------------
std
::
list
<
std
::
string
>
PostgresConn
::
getStoredProcedureNames
()
{
return
std
::
list
<
std
::
string
>
();
}
//------------------------------------------------------------------------------
// isOpen
//------------------------------------------------------------------------------
...
...
rdbms/wrapper/PostgresConn.hpp
View file @
3b04912f
...
...
@@ -130,6 +130,17 @@ public:
*/
std
::
list
<
std
::
string
>
getConstraintNames
(
const
std
::
string
&
tableName
)
override
;
/**
*
* Returns the stored procedure names of the database
*
* If the underlying database technologies does not support stored procedures informations
* this method simply returns an empty list.
*
* @return the list of the names of the stored procedures in the database
*/
std
::
list
<
std
::
string
>
getStoredProcedureNames
()
override
;
/**
* Returns the names of all the column and their type as a map for the given
* table in the database schema.
...
...
rdbms/wrapper/SqliteConn.cpp
View file @
3b04912f
...
...
@@ -431,8 +431,17 @@ std::list<std::string> SqliteConn::getConstraintNames(const std::string &tableNa
}
catch
(
exception
::
Exception
&
ex
)
{
throw
exception
::
Exception
(
std
::
string
(
__FUNCTION__
)
+
" failed: "
+
ex
.
getMessage
().
str
());
}
}
//------------------------------------------------------------------------------
// getStoredProcedureNames
//------------------------------------------------------------------------------
std
::
list
<
std
::
string
>
SqliteConn
::
getStoredProcedureNames
()
{
return
std
::
list
<
std
::
string
>
();
}
}
// namespace wrapper
}
// namespace rdbms
}
// namespace cta
rdbms/wrapper/SqliteConn.hpp
View file @
3b04912f
...
...
@@ -179,6 +179,18 @@ public:
*/
std
::
list
<
std
::
string
>
getConstraintNames
(
const
std
::
string
&
tableName
)
override
;
/**
*
* Returns the stored procedure names of the database
*
* If the underlying database technologies does not support stored procedures informations
* this method simply returns an empty list.
*
* @return the list of the names of the stored procedures in the database
*/
std
::
list
<
std
::
string
>
getStoredProcedureNames
()
override
;
/**
* This is an SqliteConn specific method that prints the database schema to
* the specified output stream.
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment