SQL: Change schema calls to empty set (#41034)

As empty string has a certain meaning, the JDBC driver returns an empty
set instead for better client compatibility.

Fix #41028

(cherry picked from commit 4cbafa585b7a514eb6c156606dd516324cd3980a)
This commit is contained in:
Costin Leau 2019-04-10 13:14:18 +03:00 committed by Costin Leau
parent 4263a28039
commit 38f471ae1c
2 changed files with 9 additions and 12 deletions

View File

@ -754,22 +754,14 @@ class JdbcDatabaseMetaData implements DatabaseMetaData, JdbcWrapper {
@Override
public ResultSet getSchemas() throws SQLException {
Object[][] data = { { EMPTY, defaultCatalog() } };
return memorySet(con.cfg, columnInfo("SCHEMATA",
"TABLE_SCHEM",
"TABLE_CATALOG"), data);
return emptySet(con.cfg, "SCHEMATA",
"TABLE_SCHEM",
"TABLE_CATALOG");
}
@Override
public ResultSet getSchemas(String catalog, String schemaPattern) throws SQLException {
List<JdbcColumnInfo> info = columnInfo("SCHEMATA",
"TABLE_SCHEM",
"TABLE_CATALOG");
if (!isDefaultCatalog(catalog) || !isDefaultSchema(schemaPattern)) {
return emptySet(con.cfg, info);
}
Object[][] data = { { EMPTY, defaultCatalog() } };
return memorySet(con.cfg, info, data);
return getSchemas();
}
@Override

View File

@ -104,6 +104,11 @@ public class JdbcDatabaseMetaDataTests extends ESTestCase {
testEmptySet(() -> md.getPseudoColumns(null, null, null, null));
}
public void testGetSchemas() throws Exception {
testEmptySet(() -> md.getSchemas());
testEmptySet(() -> md.getSchemas(null, null));
}
private static void testEmptySet(CheckedSupplier<ResultSet, SQLException> supplier) throws SQLException {
try (ResultSet result = supplier.get()) {
assertNotNull(result);