HHH-10718 - Fix Underscore in table name can result in SchemaExtractionException: More than one table found
This commit is contained in:
parent
bc8fc81efa
commit
251a19ef24
|
@ -359,33 +359,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 {
|
||||||
|
|
Loading…
Reference in New Issue