提交 7d1b8c51 authored 作者: noelgrandin's avatar noelgrandin

Fix issue #438 JdbcDatabaseMetaData#getSchemas() no longer supported as of 1.3.169

上级 4d176eaa
......@@ -62,6 +62,7 @@ Change Log
queries for in-memory databases using partial sort (by Sergi Vladykin).
</li><li>Experimental off-heap memory storage engine "nioMemFS:" and "nioMemLZF:",
suggestion from Mark Addleman.
</li><li>Fix issue #438:JdbcDatabaseMetaData#getSchemas() no longer supported as of 1.3.169
</li></ul>
<h2>Version 1.3.170 (2012-11-30)</h2>
......
......@@ -2807,12 +2807,44 @@ public class JdbcDatabaseMetaData extends TraceObject implements DatabaseMetaDat
//*/
/**
* [Not supported] Gets the list of schemas.
* Gets the list of schemas in the database.
* The result set is sorted by TABLE_SCHEM.
*
* <ul>
* <li>1 TABLE_SCHEM (String) schema name
* </li><li>2 TABLE_CATALOG (String) catalog name
* </li><li>3 IS_DEFAULT (boolean) if this is the default schema
* </li></ul>
*
* @param catalogPattern null (to get all objects) or the catalog name
* @param schemaPattern null (to get all objects) or a schema name
* (uppercase for unquoted names)
* @return the schema list
* @throws SQLException if the connection is closed
*/
//## Java 1.6 ##
public ResultSet getSchemas(String catalog, String schemaPattern)
public ResultSet getSchemas(String catalogPattern, String schemaPattern)
throws SQLException {
throw unsupported("getSchemas(., .)");
try {
debugCodeCall("getSchemas(String,String)");
checkClosed();
PreparedStatement prep = conn
.prepareAutoCloseStatement("SELECT "
+ "SCHEMA_NAME TABLE_SCHEM, "
+ "CATALOG_NAME TABLE_CATALOG, "
+" IS_DEFAULT "
+ "FROM INFORMATION_SCHEMA.SCHEMATA "
+ "WHERE CATALOG_NAME LIKE ? ESCAPE ? "
+ "AND SCHEMA_NAME LIKE ? ESCAPE ? "
+ "ORDER BY SCHEMA_NAME");
prep.setString(1, getCatalogPattern(catalogPattern));
prep.setString(2, "\\");
prep.setString(3, getSchemaPattern(schemaPattern));
prep.setString(4, "\\");
return prep.executeQuery();
} catch (Exception e) {
throw logAndConvert(e);
}
}
//*/
......
......@@ -75,6 +75,18 @@ public class TestMetaData extends TestBase {
assertEquals("PUBLIC", rs.getString("TABLE_SCHEM"));
assertFalse(rs.next());
rs = meta.getSchemas(null, null);
rs.next();
assertEquals("INFORMATION_SCHEMA", rs.getString("TABLE_SCHEM"));
rs.next();
assertEquals("PUBLIC", rs.getString("TABLE_SCHEM"));
assertFalse(rs.next());
rs = meta.getSchemas(null, "PUBLIC");
rs.next();
assertEquals("PUBLIC", rs.getString("TABLE_SCHEM"));
assertFalse(rs.next());
rs = meta.getTableTypes();
rs.next();
assertEquals("SYSTEM TABLE", rs.getString("TABLE_TYPE"));
......@@ -872,6 +884,15 @@ public class TestMetaData extends TestBase {
assertEquals("PUBLIC", rs.getString(1));
assertFalse(rs.next());
rs = meta.getSchemas(null, null);
assertResultSetMeta(rs, 3, new String[] { "TABLE_SCHEM", "TABLE_CATALOG", "IS_DEFAULT" }, new int[] {
Types.VARCHAR, Types.VARCHAR, Types.BOOLEAN }, null, null);
assertTrue(rs.next());
assertEquals("INFORMATION_SCHEMA", rs.getString(1));
assertTrue(rs.next());
assertEquals("PUBLIC", rs.getString(1));
assertFalse(rs.next());
rs = meta.getCatalogs();
assertResultSetMeta(rs, 1, new String[] { "TABLE_CAT" }, new int[] { Types.VARCHAR }, null, null);
assertResultSetOrdered(rs, new String[][] { { CATALOG } });
......@@ -926,7 +947,7 @@ public class TestMetaData extends TestBase {
meta.getProcedureColumns(null, null, null, null);
meta.getProcedures(null, null, null);
meta.getSchemas();
// meta.getSchemas(null, null);
meta.getSchemas(null, null);
meta.getSuperTables(null, null, null);
// meta.getSuperTypes(null, null, null);
meta.getTablePrivileges(null, null, null);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论