mirror of https://github.com/apache/druid.git
Fix the bug in getIndexInfo for mysql (#14750)
This commit is contained in:
parent
3335040b22
commit
d31c04c4c6
|
@ -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
|
||||
*
|
||||
|
|
|
@ -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()
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue