Skip to content

Commit 23027fb

Browse files
author
Paultagoras
committed
Return a blank ResultSet instead of null
1 parent f007504 commit 23027fb

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

jdbc-v2/src/main/java/com/clickhouse/jdbc/metadata/DatabaseMetaDataImpl.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1065,7 +1065,14 @@ private static String getDataTypeInfoSql() {
10651065

10661066
@Override
10671067
public ResultSet getIndexInfo(String catalog, String schema, String table, boolean unique, boolean approximate) throws SQLException {
1068-
return null;
1068+
try {
1069+
String sql = "SELECT null AS TABLE_CAT, null AS TABLE_SCHEM, null AS TABLE_NAME, null AS NON_UNIQUE," +
1070+
" null AS INDEX_QUALIFIER, null AS INDEX_NAME, null AS TYPE, null AS ORDINAL_POSITION, null AS COLUMN_NAME, null AS ASC_OR_DESC," +
1071+
" null AS CARDINALITY, null AS PAGES, null AS FILTER_CONDITION LIMIT 0";
1072+
return connection.createStatement().executeQuery(sql);
1073+
} catch (Exception e) {
1074+
throw ExceptionUtils.toSqlState(e);
1075+
}
10691076
}
10701077

10711078
@Override

jdbc-v2/src/test/java/com/clickhouse/jdbc/metadata/DatabaseMetaDataTest.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,4 +316,14 @@ public void testGetDriverVersion() throws Exception {
316316
assertNotEquals(version, "unknown");
317317
}
318318
}
319+
320+
321+
@Test(groups = { "integration" })
322+
public void testGetIndexInfo() throws Exception {
323+
try (Connection conn = getJdbcConnection()) {
324+
DatabaseMetaData dbmd = conn.getMetaData();
325+
ResultSet rs = dbmd.getIndexInfo(null, null, "numbers", false, false);
326+
assertFalse(rs.next());
327+
}
328+
}
319329
}

0 commit comments

Comments
 (0)