提交 db3c045e authored 作者: Thomas Mueller's avatar Thomas Mueller

Views now store the schema for Java functions if "functions in schemas" is enabled.

上级 cb12305f
......@@ -18,7 +18,9 @@ Change Log
<h1>Change Log</h1>
<h2>Next Version (unreleased)</h2>
<ul><li>Improved error message if the LOB files are already deleted on the client side.
<ul><li>Views now store the schema for Java functions if "functions in schemas" is enabled
(system property h2.functionsInSchema).
</li><li>Improved error message if the LOB files are already deleted on the client side.
</li><li>Closing a Statement or PreparedStatement at the same time as executing a statement
could throw a strange exception. Issue 241.
</li><li>The Recover tool did not work with compressed lob files (set compress_lob lzf).
......
......@@ -108,7 +108,8 @@ public class CreateView extends SchemaCommand {
if (params != null && params.size() > 0) {
throw DbException.get(ErrorCode.FEATURE_NOT_SUPPORTED_1, "parameters in views");
}
querySQL = TraceObject.toString(select.getSQL(), select.getParameters());
// querySQL = TraceObject.toString(select.getSQL(), select.getParameters());
querySQL = TraceObject.toString(select.getPlanSQL(), select.getParameters());
}
Session sysSession = db.getSystemSession();
TableView view;
......
......@@ -30,6 +30,7 @@ public class TestView extends TestBase {
}
public void test() throws SQLException {
testChangeSchemaSearchPath();
testParameterizedView();
testCache();
testCacheFunction(true);
......@@ -40,6 +41,19 @@ public class TestView extends TestBase {
deleteDb("view");
}
private void testChangeSchemaSearchPath() throws SQLException {
deleteDb("view");
Connection conn = getConnection("view;FUNCTIONS_IN_SCHEMA=TRUE");
Statement stat = conn.createStatement();
stat.execute("CREATE ALIAS X AS $$ int x() { return 1; } $$;");
stat.execute("CREATE SCHEMA S");
stat.execute("CREATE VIEW S.TEST AS SELECT X() FROM DUAL");
stat.execute("SET SCHEMA=S");
stat.execute("SET SCHEMA_SEARCH_PATH=S");
stat.execute("SELECT * FROM TEST");
conn.close();
}
private void testParameterizedView() throws SQLException {
deleteDb("view");
Connection conn = getConnection("view");
......@@ -71,12 +85,12 @@ public class TestView extends TestBase {
deleteDb("view");
Connection conn = getConnection("view");
Statement stat = conn.createStatement();
x = 8;
stat.execute("CREATE ALIAS GET_X " +
(deterministic ? "DETERMINISTIC" : "") +
" FOR \"" + getClass().getName() + ".getX\"");
stat.execute("CREATE VIEW V AS SELECT * FROM (SELECT GET_X())");
ResultSet rs;
x = 8;
rs = stat.executeQuery("SELECT * FROM V");
rs.next();
assertEquals(8, rs.getInt(1));
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论