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

The H2 Console now abbreviates large texts in results.

上级 c3fc6e3e
......@@ -18,7 +18,8 @@ Change Log
<h1>Change Log</h1>
<h2>Next Version (unreleased)</h2>
<ul><li>Multiple UNION queries could not be used in derived tables.
<ul><li>The H2 Console now abbreviates large texts in results.
</li><li>Multiple UNION queries could not be used in derived tables.
</li><li>Linked tables can now be read-only.
</li><li>Temporary linked tables are now supported.
</li><li>The optimization for IN(...) is now enabled by default. Use -Dh2.optimizeInJoin=false to disable it.
......
......@@ -210,6 +210,12 @@ public class SysProperties {
*/
public static final int EMERGENCY_SPACE_MIN = getIntSetting("h2.emergencySpaceMin", 64 * 1024);
/**
* System property <code>h2.largeResultBufferSize</code> (default: 4096).<br />
* Buffer size for large result sets. Set this value to 0 to disable the buffer.
*/
public static final int LARGE_RESULT_BUFFER_SIZE = getIntSetting("h2.largeResultBufferSize", 4 * 1024);
/**
* System property <code>h2.lobCloseBetweenReads</code> (default: false).<br />
* Close LOB files between read operations.
......@@ -463,10 +469,10 @@ public class SysProperties {
public static final boolean TRACE_IO = getBooleanSetting("h2.traceIO", false);
/**
* System property <code>h2.largeResultBufferSize</code> (default: 4096).<br />
* Buffer size for large result sets. Set this value to 0 to disable the buffer.
* System property <code>h2.webMaxValueLength</code> (default: 10000).<br />
* The H2 Console will abbreviate result values larger than this size.
*/
public static final int LARGE_RESULT_BUFFER_SIZE = getIntSetting("h2.largeResultBufferSize", 4 * 1024);
public static final int WEB_MAX_VALUE_LENGTH = getIntSetting("h2.webMaxValueLength", 10000);
/**
* System property <code>h2.collatorCacheSize</code> (default: 10000).<br />
......
......@@ -48,6 +48,7 @@ import java.util.Map.Entry;
import org.h2.api.DatabaseEventListener;
import org.h2.bnf.Bnf;
import org.h2.constant.ErrorCode;
import org.h2.constant.SysProperties;
import org.h2.engine.Constants;
import org.h2.jdbc.JdbcSQLException;
import org.h2.message.Message;
......@@ -1373,7 +1374,7 @@ class WebThread extends Thread implements DatabaseEventListener {
}
for (int i = 0; i < rs.getMetaData().getColumnCount(); i++) {
String x = attributes.getProperty("r" + row + "c" + (i + 1));
rs.updateString(i + 1, unescapeData(x));
unescapeData(x, rs, i + 1);
}
if (insert) {
rs.insertRow();
......@@ -1950,7 +1951,7 @@ class WebThread extends Thread implements DatabaseEventListener {
buff.append(PageParser.escapeHtml(meta.getColumnLabel(i + 1)));
buff.append("</td>");
buff.append("<td>");
buff.append(escapeData(rs.getString(i + 1)));
buff.append(escapeData(rs, i + 1));
buff.append("</td></tr>");
}
}
......@@ -1986,7 +1987,7 @@ class WebThread extends Thread implements DatabaseEventListener {
}
for (int i = 0; i < columns; i++) {
buff.append("<td>");
buff.append(escapeData(rs.getString(i + 1)));
buff.append(escapeData(rs, i + 1));
buff.append("</td>");
}
buff.append("</tr>");
......@@ -2059,24 +2060,30 @@ class WebThread extends Thread implements DatabaseEventListener {
return "index.do";
}
private String escapeData(String d) {
private String escapeData(ResultSet rs, int columnIndex) throws SQLException {
String d = rs.getString(columnIndex);
if (d == null) {
return "<i>null</i>";
} else if (d.startsWith("null")) {
return "<div style='display: none'>=</div>" + PageParser.escapeHtml(d);
} else if (d.length() > SysProperties.WEB_MAX_VALUE_LENGTH) {
return "<div style='display: none'>=+</div>" +
PageParser.escapeHtml(d.substring(0, 100) + "... (" + d.length() + ")");
} else if (d.equals("null") || d.startsWith("= ") || d.startsWith("=+")) {
return "<div style='display: none'>= </div>" + PageParser.escapeHtml(d);
}
return PageParser.escapeHtml(d);
}
private String unescapeData(String d) {
if (d.endsWith("null")) {
if (d.equals("null")) {
return null;
} else if (d.startsWith("=")) {
return d.substring(1);
}
private void unescapeData(String d, ResultSet rs, int columnIndex) throws SQLException {
if (d.equals("null")) {
rs.updateNull(columnIndex);
} else if (d.startsWith("=+")) {
// don't update
} else if (d.startsWith("= ")) {
d = d.substring(2);
rs.updateString(columnIndex, d);
} else {
rs.updateString(columnIndex, d);
}
return d;
}
private String settingRemove() {
......
......@@ -275,9 +275,7 @@ java org.h2.test.TestAll timer
main methods for the tests and make that work
H2 Console: don't display very large blobs; instead show first view bytes and length
MVCC:
TestMVCC:
Concurrent update in table test: another transaction has updated or
deleted the same row when exactly does it occur in other databases
(PostgreSQL, Oracle)?
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论