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
c8a39cf6
Commit
c8a39cf6
authored
Jun 16, 2020
by
Cedric Caffy
Browse files
[schema-verify] Added warnings for TYPES and SYNONYMS
parent
3b04912f
Changes
16
Hide whitespace changes
Inline
Side-by-side
catalogue/DatabaseMetadataGetter.cpp
View file @
c8a39cf6
...
...
@@ -137,6 +137,14 @@ std::list<std::string> DatabaseMetadataGetter::getStoredProcedures() {
return
m_conn
.
getStoredProcedureNames
();
}
std
::
list
<
std
::
string
>
DatabaseMetadataGetter
::
getSynonyms
(){
return
m_conn
.
getSynonymNames
();
}
std
::
list
<
std
::
string
>
DatabaseMetadataGetter
::
getTypes
()
{
return
m_conn
.
getTypeNames
();
}
DatabaseMetadataGetter
::~
DatabaseMetadataGetter
()
{}
SQLiteDatabaseMetadataGetter
::
SQLiteDatabaseMetadataGetter
(
cta
::
rdbms
::
Conn
&
conn
)
:
DatabaseMetadataGetter
(
conn
){}
...
...
catalogue/DatabaseMetadataGetter.hpp
View file @
c8a39cf6
...
...
@@ -63,6 +63,8 @@ class DatabaseMetadataGetter: public MetadataGetter {
virtual
std
::
list
<
std
::
string
>
getParallelTableNames
();
virtual
cta
::
rdbms
::
Login
::
DbType
getDbType
()
=
0
;
virtual
std
::
list
<
std
::
string
>
getStoredProcedures
();
virtual
std
::
list
<
std
::
string
>
getSynonyms
();
virtual
std
::
list
<
std
::
string
>
getTypes
();
};
/**
...
...
catalogue/SchemaChecker.cpp
View file @
c8a39cf6
...
...
@@ -105,13 +105,33 @@ SchemaCheckerResult SchemaChecker::checkTableContainsColumns(const std::string&
SchemaCheckerResult
SchemaChecker
::
warnProcedures
()
{
SchemaCheckerResult
res
;
std
::
list
<
std
::
string
>
procedureNames
=
m_databaseMetadataGetter
->
getStoredProcedures
();
for
(
auto
procedure
:
procedureNames
){
for
(
auto
&
procedure
:
procedureNames
){
std
::
string
warning
=
"PROCEDURE "
+
procedure
+
" exists in the "
+
m_databaseToCheckName
+
" database"
;
res
.
addWarning
(
warning
);
}
return
res
;
}
SchemaCheckerResult
SchemaChecker
::
warnSynonyms
()
{
SchemaCheckerResult
res
;
std
::
list
<
std
::
string
>
synonymsNames
=
m_databaseMetadataGetter
->
getSynonyms
();
for
(
auto
&
synonym
:
synonymsNames
){
std
::
string
warning
=
"SYNONYM "
+
synonym
+
" exists in the "
+
m_databaseToCheckName
+
" database"
;
res
.
addWarning
(
warning
);
}
return
res
;
}
SchemaCheckerResult
SchemaChecker
::
warnTypes
()
{
SchemaCheckerResult
res
;
std
::
list
<
std
::
string
>
typeNames
=
m_databaseMetadataGetter
->
getTypes
();
for
(
auto
&
type
:
typeNames
)
{
std
::
string
warning
=
"TYPE "
+
type
+
" exists in the "
+
m_databaseToCheckName
+
" database"
;
res
.
addWarning
(
warning
);
}
return
res
;
}
/////////////////////////////////////////
// SchemaChecker::Builder
...
...
catalogue/SchemaChecker.hpp
View file @
c8a39cf6
...
...
@@ -81,11 +81,23 @@ public:
SchemaCheckerResult
checkTableContainsColumns
(
const
std
::
string
&
tableName
,
const
std
::
list
<
std
::
string
>
columnNames
);
/**
* Checks if there are stored procedures in the
schema
.
* Checks if there are stored procedures in the
database
.
* @return a SchemaCheckerResult containing warnings if there are stored procedures.
*/
SchemaCheckerResult
warnProcedures
();
/**
* Checks if there are synonyms in the database.
* @return a SchemaCheckerResult containing warnings if there are synonyms
*/
SchemaCheckerResult
warnSynonyms
();
/**
* Checks if there are types in the database
* @return a SchemaCheckerResult containing warnings if there are types in the database
*/
SchemaCheckerResult
warnTypes
();
class
Builder
{
public:
Builder
(
const
std
::
string
databaseToCheckName
,
const
cta
::
rdbms
::
Login
::
DbType
dbType
,
cta
::
rdbms
::
Conn
&
conn
);
...
...
catalogue/VerifySchemaCmd.cpp
View file @
c8a39cf6
...
...
@@ -84,6 +84,8 @@ int VerifySchemaCmd::exceptionThrowingMain(const int argc, char *const *const ar
result
+=
schemaChecker
->
warnParallelTables
();
result
+=
schemaChecker
->
warnSchemaUpgrading
();
result
+=
schemaChecker
->
warnProcedures
();
result
+=
schemaChecker
->
warnSynonyms
();
result
+=
schemaChecker
->
warnTypes
();
result
.
displayWarnings
(
std
::
cout
);
if
(
result
.
getStatus
()
==
SchemaCheckerResult
::
Status
::
FAILED
){
return
1
;
...
...
rdbms/Conn.cpp
View file @
c8a39cf6
...
...
@@ -263,5 +263,27 @@ std::list<std::string> Conn::getStoredProcedureNames(){
}
}
//------------------------------------------------------------------------------
// getSynonymNames
//------------------------------------------------------------------------------
std
::
list
<
std
::
string
>
Conn
::
getSynonymNames
(){
if
(
nullptr
!=
m_connAndStmts
&&
nullptr
!=
m_connAndStmts
->
conn
)
{
return
m_connAndStmts
->
conn
->
getSynonymNames
();
}
else
{
throw
exception
::
Exception
(
std
::
string
(
__FUNCTION__
)
+
" failed: Conn does not contain a connection"
);
}
}
//------------------------------------------------------------------------------
// getTypeNames
//------------------------------------------------------------------------------
std
::
list
<
std
::
string
>
Conn
::
getTypeNames
()
{
if
(
nullptr
!=
m_connAndStmts
&&
nullptr
!=
m_connAndStmts
->
conn
)
{
return
m_connAndStmts
->
conn
->
getTypeNames
();
}
else
{
throw
exception
::
Exception
(
std
::
string
(
__FUNCTION__
)
+
" failed: Conn does not contain a connection"
);
}
}
}
// namespace rdbms
}
// namespace cta
rdbms/Conn.hpp
View file @
c8a39cf6
...
...
@@ -231,6 +231,26 @@ public:
*/
std
::
list
<
std
::
string
>
getStoredProcedureNames
();
/**
* Returns the synonym names of the database
*
* If the underlying database technologies does not support synonym informations
* this method simply returns an empty list.
*
* @return the list of the names of the synonyms in the database
*/
std
::
list
<
std
::
string
>
getSynonymNames
();
/**
* Returns the type names of the database
*
* If the underlying database technologies does not support type informations
* this method simply returns an empty list.
*
* @return the list of the names of the types in the database
*/
std
::
list
<
std
::
string
>
getTypeNames
();
/**
* Get a pointer to the connection wrapper implementation
*
...
...
rdbms/wrapper/ConnWrapper.hpp
View file @
c8a39cf6
...
...
@@ -177,7 +177,27 @@ public:
* @return the list of the names of the stored procedures in the database
*/
virtual
std
::
list
<
std
::
string
>
getStoredProcedureNames
()
=
0
;
/**
* Returns the synonym names of the database
*
* If the underlying database technologies does not support synonym informations
* this method simply returns an empty list.
*
* @return the list of the names of the synonyms in the database
*/
virtual
std
::
list
<
std
::
string
>
getSynonymNames
()
=
0
;
/**
* Returns the type names of the database
*
* If the underlying database technologies does not support type informations
* this method simply returns an empty list.
*
* @return the list of the names of the types in the database
*/
virtual
std
::
list
<
std
::
string
>
getTypeNames
()
=
0
;
};
// class ConnWrapper
}
// namespace wrapper
...
...
rdbms/wrapper/MysqlConn.cpp
View file @
c8a39cf6
...
...
@@ -359,6 +359,22 @@ std::list<std::string> MysqlConn::getStoredProcedureNames() {
return
std
::
list
<
std
::
string
>
();
}
//------------------------------------------------------------------------------
// getSynonymNames
//------------------------------------------------------------------------------
std
::
list
<
std
::
string
>
MysqlConn
::
getSynonymNames
()
{
return
std
::
list
<
std
::
string
>
();
}
//------------------------------------------------------------------------------
// getTypeNames
//------------------------------------------------------------------------------
std
::
list
<
std
::
string
>
MysqlConn
::
getTypeNames
()
{
return
std
::
list
<
std
::
string
>
();
}
}
// namespace wrapper
}
// namespace rdbms
}
// namespace cta
rdbms/wrapper/MysqlConn.hpp
View file @
c8a39cf6
...
...
@@ -204,6 +204,27 @@ public:
* @return the list of the names of the stored procedures in the database
*/
std
::
list
<
std
::
string
>
getStoredProcedureNames
()
override
;
/**
* Returns the synonym names of the database
*
* If the underlying database technologies does not support synonym informations
* this method simply returns an empty list.
*
* @return the list of the names of the synonyms in the database
*/
std
::
list
<
std
::
string
>
getSynonymNames
()
override
;
/**
* Returns the type names of the database
*
* If the underlying database technologies does not support type informations
* this method simply returns an empty list.
*
* @return the list of the names of the types in the database
*/
std
::
list
<
std
::
string
>
getTypeNames
()
override
;
private:
...
...
rdbms/wrapper/OcciConn.cpp
View file @
c8a39cf6
...
...
@@ -342,7 +342,7 @@ std::list<std::string> OcciConn::getConstraintNames(const std::string& tableName
// getStoredProcedureNames
//------------------------------------------------------------------------------
std
::
list
<
std
::
string
>
OcciConn
::
getStoredProcedureNames
()
{
try
{
try
{
std
::
list
<
std
::
string
>
names
;
const
char
*
const
sql
=
"SELECT "
...
...
@@ -361,6 +361,51 @@ std::list<std::string> OcciConn::getStoredProcedureNames() {
}
}
//------------------------------------------------------------------------------
// getSynonymNames
//------------------------------------------------------------------------------
std
::
list
<
std
::
string
>
OcciConn
::
getSynonymNames
()
{
try
{
std
::
list
<
std
::
string
>
names
;
const
char
*
const
sql
=
"SELECT "
"SYNONYM_NAME "
"FROM "
"USER_SYNONYMS"
;
auto
stmt
=
createStmt
(
sql
);
auto
rset
=
stmt
->
executeQuery
();
while
(
rset
->
next
())
{
auto
name
=
rset
->
columnOptionalString
(
"SYNONYM_NAME"
);
names
.
push_back
(
name
.
value
());
}
return
names
;
}
catch
(
exception
::
Exception
&
ex
)
{
throw
exception
::
Exception
(
std
::
string
(
__FUNCTION__
)
+
" failed: "
+
ex
.
getMessage
().
str
());
}
}
//------------------------------------------------------------------------------
// getTypeNames
//------------------------------------------------------------------------------
std
::
list
<
std
::
string
>
OcciConn
::
getTypeNames
()
{
try
{
std
::
list
<
std
::
string
>
names
;
const
char
*
const
sql
=
"SELECT "
"TYPE_NAME "
"FROM "
"USER_TYPES"
;
auto
stmt
=
createStmt
(
sql
);
auto
rset
=
stmt
->
executeQuery
();
while
(
rset
->
next
())
{
auto
name
=
rset
->
columnOptionalString
(
"TYPE_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 @
c8a39cf6
...
...
@@ -187,6 +187,26 @@ public:
* @return the list of the names of the stored procedures in the database
*/
std
::
list
<
std
::
string
>
getStoredProcedureNames
()
override
;
/**
* Returns the synonym names of the database
*
* If the underlying database technologies does not support synonym informations
* this method simply returns an empty list.
*
* @return the list of the names of the synonyms in the database
*/
std
::
list
<
std
::
string
>
getSynonymNames
()
override
;
/**
* Returns the type names of the database
*
* If the underlying database technologies does not support type informations
* this method simply returns an empty list.
*
* @return the list of the names of the types in the database
*/
std
::
list
<
std
::
string
>
getTypeNames
()
override
;
private:
...
...
rdbms/wrapper/PostgresConn.cpp
View file @
c8a39cf6
...
...
@@ -370,6 +370,20 @@ std::list<std::string> PostgresConn::getStoredProcedureNames() {
}
//------------------------------------------------------------------------------
// getSynonymNames
//------------------------------------------------------------------------------
std
::
list
<
std
::
string
>
PostgresConn
::
getSynonymNames
()
{
return
std
::
list
<
std
::
string
>
();
}
//------------------------------------------------------------------------------
// getTypeNames
//------------------------------------------------------------------------------
std
::
list
<
std
::
string
>
PostgresConn
::
getTypeNames
()
{
return
std
::
list
<
std
::
string
>
();
}
//------------------------------------------------------------------------------
// isOpen
//------------------------------------------------------------------------------
...
...
rdbms/wrapper/PostgresConn.hpp
View file @
c8a39cf6
...
...
@@ -140,7 +140,27 @@ public:
* @return the list of the names of the stored procedures in the database
*/
std
::
list
<
std
::
string
>
getStoredProcedureNames
()
override
;
/**
* Returns the synonym names of the database
*
* If the underlying database technologies does not support synonym informations
* this method simply returns an empty list.
*
* @return the list of the names of the synonyms in the database
*/
std
::
list
<
std
::
string
>
getSynonymNames
()
override
;
/**
* Returns the type names of the database
*
* If the underlying database technologies does not support type informations
* this method simply returns an empty list.
*
* @return the list of the names of the types in the database
*/
std
::
list
<
std
::
string
>
getTypeNames
()
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 @
c8a39cf6
...
...
@@ -441,6 +441,20 @@ std::list<std::string> SqliteConn::getStoredProcedureNames() {
return
std
::
list
<
std
::
string
>
();
}
//------------------------------------------------------------------------------
// getSynonymNames
//------------------------------------------------------------------------------
std
::
list
<
std
::
string
>
SqliteConn
::
getSynonymNames
()
{
return
std
::
list
<
std
::
string
>
();
}
//------------------------------------------------------------------------------
// getTypeNames
//------------------------------------------------------------------------------
std
::
list
<
std
::
string
>
SqliteConn
::
getTypeNames
()
{
return
std
::
list
<
std
::
string
>
();
}
}
// namespace wrapper
}
// namespace rdbms
...
...
rdbms/wrapper/SqliteConn.hpp
View file @
c8a39cf6
...
...
@@ -190,6 +190,25 @@ public:
*/
std
::
list
<
std
::
string
>
getStoredProcedureNames
()
override
;
/**
* Returns the synonym names of the database
*
* If the underlying database technologies does not support synonym informations
* this method simply returns an empty list.
*
* @return the list of the names of the synonyms in the database
*/
std
::
list
<
std
::
string
>
getSynonymNames
()
override
;
/**
* Returns the type names of the database
*
* If the underlying database technologies does not support type informations
* this method simply returns an empty list.
*
* @return the list of the names of the types in the database
*/
std
::
list
<
std
::
string
>
getTypeNames
()
override
;
/**
* This is an SqliteConn specific method that prints the database schema to
...
...
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