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

SQL statements in the exception message are no longer included if they contain '--hide--'.

上级 7167ef8e
......@@ -18,7 +18,8 @@ Change Log
<h1>Change Log</h1>
<h2>Next Version (unreleased)</h2>
<ul><li>Temporary local tables did not always work after reconnect if AUTO_SERVER=TRUE
<ul><li>SQL statements in the exception message are no longer included if they contain '--hide--'.
</li><li>Temporary local tables did not always work after reconnect if AUTO_SERVER=TRUE
</li><li>New system property h2.defaultMaxLengthInplaceLob to change the default maximum size
of an in-place LOB object.
</li><li>New system property h2.nullConcatIsNull to change the default null concatenation behavior.
......
......@@ -132,6 +132,7 @@ public class JdbcSQLException extends SQLException {
/**
* Returns the SQL statement.
* SQL statements that contain '--hide--' are not listed.
*
* @return the SQL statement
*/
......@@ -143,8 +144,10 @@ public class JdbcSQLException extends SQLException {
* INTERNAL
*/
public void setSQL(String sql) {
this.sql = sql;
buildMessage();
if (sql.indexOf("--hide--") < 0) {
this.sql = sql;
buildMessage();
}
}
private void buildMessage() {
......
......@@ -325,6 +325,7 @@ public class TableLink extends Table {
if (readOnly) {
buff.append(" READONLY");
}
buff.append(" /*--hide--*/");
return buff.toString();
}
......
......@@ -15,7 +15,6 @@ import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.Timestamp;
import org.h2.constant.SysProperties;
import org.h2.test.TestBase;
......@@ -34,6 +33,7 @@ public class TestLinkedTable extends TestBase {
}
public void test() throws SQLException {
testHiddenSQL();
// testLinkAutoAdd();
testNestedQueriesToSameTable();
testSharedConnection();
......@@ -50,6 +50,30 @@ public class TestLinkedTable extends TestBase {
deleteDb("linkedTable");
}
private void testHiddenSQL() throws SQLException {
if (config.memory || !SysProperties.SHARE_LINKED_CONNECTIONS) {
return;
}
org.h2.Driver.load();
deleteDb("linkedTable");
Connection conn = getConnection("linkedTable");
try {
conn.createStatement().execute(
"create linked table test(null, 'jdbc:h2:mem:', 'sa', 'pwd', 'DUAL2')");
fail();
} catch (SQLException e) {
assertTrue(e.toString().indexOf("pwd") >= 0);
}
try {
conn.createStatement().execute(
"create linked table test(null, 'jdbc:h2:mem:', 'sa', 'pwd', 'DUAL2') --hide--");
fail();
} catch (SQLException e) {
assertTrue(e.toString().indexOf("pwd") < 0);
}
conn.close();
}
// this is not a bug, it is the documented behavior
// private void testLinkAutoAdd() throws SQLException {
// Class.forName("org.h2.Driver");
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论