Fix the bug in getIndexInfo for mysql (#14750)

This commit is contained in:
Pranav 2023-08-03 21:45:01 -07:00 committed by GitHub
parent 3335040b22
commit d31c04c4c6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 37 additions and 7 deletions

View File

@ -864,13 +864,7 @@ public abstract class SQLMetadataConnector implements MetadataStorageConnector
{
DatabaseMetaData databaseMetaData = handle.getConnection().getMetaData();
// Fetch the index for given table
ResultSet resultSet = databaseMetaData.getIndexInfo(
null,
null,
StringUtils.toUpperCase(tableName),
false,
false
);
ResultSet resultSet = getIndexInfo(databaseMetaData, tableName);
while (resultSet.next()) {
String indexName = resultSet.getString("INDEX_NAME");
if (org.apache.commons.lang.StringUtils.isNotBlank(indexName)) {
@ -887,6 +881,24 @@ public abstract class SQLMetadataConnector implements MetadataStorageConnector
return ImmutableSet.copyOf(res);
}
/**
* Get the ResultSet for indexInfo for given table
*
* @param databaseMetaData DatabaseMetaData
* @param tableName Name of table
* @return ResultSet with index info
*/
public ResultSet getIndexInfo(DatabaseMetaData databaseMetaData, String tableName) throws SQLException
{
return databaseMetaData.getIndexInfo(
null,
null,
tableName, // tableName is case-sensitive in mysql default setting
false,
false
);
}
/**
* create index on the table with retry if not already exist, to be called after createTable
*

View File

@ -168,6 +168,24 @@ public class DerbyConnector extends SQLMetadataConnector
);
}
/**
* Get the ResultSet for indexInfo for given table
*
* @param databaseMetaData DatabaseMetaData
* @param tableName Name of table
* @return ResultSet with index info
*/
@Override
public ResultSet getIndexInfo(DatabaseMetaData databaseMetaData, String tableName) throws SQLException
{
return databaseMetaData.getIndexInfo(
null,
null,
StringUtils.toUpperCase(tableName), // tableName needs to be uppercase in derby default setting
false,
false
);
}
@LifecycleStart
public void start()
{