提交 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 ...@@ -18,7 +18,8 @@ Change Log
<h1>Change Log</h1> <h1>Change Log</h1>
<h2>Next Version (unreleased)</h2> <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 </li><li>New system property h2.defaultMaxLengthInplaceLob to change the default maximum size
of an in-place LOB object. of an in-place LOB object.
</li><li>New system property h2.nullConcatIsNull to change the default null concatenation behavior. </li><li>New system property h2.nullConcatIsNull to change the default null concatenation behavior.
......
...@@ -132,6 +132,7 @@ public class JdbcSQLException extends SQLException { ...@@ -132,6 +132,7 @@ public class JdbcSQLException extends SQLException {
/** /**
* Returns the SQL statement. * Returns the SQL statement.
* SQL statements that contain '--hide--' are not listed.
* *
* @return the SQL statement * @return the SQL statement
*/ */
...@@ -143,9 +144,11 @@ public class JdbcSQLException extends SQLException { ...@@ -143,9 +144,11 @@ public class JdbcSQLException extends SQLException {
* INTERNAL * INTERNAL
*/ */
public void setSQL(String sql) { public void setSQL(String sql) {
if (sql.indexOf("--hide--") < 0) {
this.sql = sql; this.sql = sql;
buildMessage(); buildMessage();
} }
}
private void buildMessage() { private void buildMessage() {
StringBuilder buff = new StringBuilder(originalMessage == null ? "- " : originalMessage); StringBuilder buff = new StringBuilder(originalMessage == null ? "- " : originalMessage);
......
...@@ -325,6 +325,7 @@ public class TableLink extends Table { ...@@ -325,6 +325,7 @@ public class TableLink extends Table {
if (readOnly) { if (readOnly) {
buff.append(" READONLY"); buff.append(" READONLY");
} }
buff.append(" /*--hide--*/");
return buff.toString(); return buff.toString();
} }
......
...@@ -15,7 +15,6 @@ import java.sql.ResultSetMetaData; ...@@ -15,7 +15,6 @@ import java.sql.ResultSetMetaData;
import java.sql.SQLException; import java.sql.SQLException;
import java.sql.Statement; import java.sql.Statement;
import java.sql.Timestamp; import java.sql.Timestamp;
import org.h2.constant.SysProperties; import org.h2.constant.SysProperties;
import org.h2.test.TestBase; import org.h2.test.TestBase;
...@@ -34,6 +33,7 @@ public class TestLinkedTable extends TestBase { ...@@ -34,6 +33,7 @@ public class TestLinkedTable extends TestBase {
} }
public void test() throws SQLException { public void test() throws SQLException {
testHiddenSQL();
// testLinkAutoAdd(); // testLinkAutoAdd();
testNestedQueriesToSameTable(); testNestedQueriesToSameTable();
testSharedConnection(); testSharedConnection();
...@@ -50,6 +50,30 @@ public class TestLinkedTable extends TestBase { ...@@ -50,6 +50,30 @@ public class TestLinkedTable extends TestBase {
deleteDb("linkedTable"); 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 // this is not a bug, it is the documented behavior
// private void testLinkAutoAdd() throws SQLException { // private void testLinkAutoAdd() throws SQLException {
// Class.forName("org.h2.Driver"); // Class.forName("org.h2.Driver");
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论