HHH-10718 - Fix Underscore in table name can result in SchemaExtractionException: More than one table found

This commit is contained in:
Andrea Boriero 2016-05-11 20:06:51 +01:00
parent 54ffced4dc
commit 55ce254d2d
1 changed files with 31 additions and 25 deletions

View File

@ -361,33 +361,39 @@ public class InformationExtractorJdbcDatabaseMetaDataImpl implements Information
Identifier tableName, Identifier tableName,
ResultSet resultSet) throws SQLException { ResultSet resultSet) throws SQLException {
try { try {
if ( !resultSet.next() ) { boolean found = false;
TableInformation tableInformation = null;
while ( resultSet.next() ) {
if ( tableName.equals( identifierHelper().toIdentifier( resultSet.getString( "TABLE_NAME" ) ) ) ) {
if ( found ) {
log.multipleTablesFound( tableName.render() );
final String catalogName = catalog == null ? "" : catalog.render();
final String schemaName = schema == null ? "" : schema.render();
throw new SchemaExtractionException(
String.format(
Locale.ENGLISH,
"More than one table found in namespace (%s, %s) : %s",
catalogName,
schemaName,
tableName.render()
)
);
}
else {
found = true;
tableInformation = extractTableInformation(
catalog,
schema,
tableName,
resultSet
);
}
}
}
if ( !found ) {
log.tableNotFound( tableName.render() ); log.tableNotFound( tableName.render() );
return null;
} }
final TableInformation tableInformation = extractTableInformation(
catalog,
schema,
tableName,
resultSet
);
if ( resultSet.next() ) {
log.multipleTablesFound( tableName.render() );
final String catalogName = catalog == null ? "" : catalog.render();
final String schemaName = schema == null ? "" : schema.render();
throw new SchemaExtractionException(
String.format(
Locale.ENGLISH,
"More than one table found in namespace (%s, %s) : %s",
catalogName,
schemaName,
tableName.render()
)
);
}
return tableInformation; return tableInformation;
} }
finally { finally {