Unverified 提交 9150d35a authored 作者: Noel Grandin's avatar Noel Grandin 提交者: GitHub

Merge pull request #758 from katzyn/misc

Allocate less amount of garbage
...@@ -1154,10 +1154,10 @@ public class Parser { ...@@ -1154,10 +1154,10 @@ public class Parser {
TableFilter sourceTableFilter = readSimpleTableFilterWithAliasExcludes(0, excludeIdentifiers); TableFilter sourceTableFilter = readSimpleTableFilterWithAliasExcludes(0, excludeIdentifiers);
command.setSourceTableFilter(sourceTableFilter); command.setSourceTableFilter(sourceTableFilter);
StringBuilder buff = new StringBuilder( StringBuilder buff = new StringBuilder("SELECT * FROM ")
"SELECT * FROM "+sourceTableFilter.getTable().getName()); .append(sourceTableFilter.getTable().getName());
if (sourceTableFilter.getTableAlias() != null) { if (sourceTableFilter.getTableAlias() != null) {
buff.append(" AS "+sourceTableFilter.getTableAlias()); buff.append(" AS ").append(sourceTableFilter.getTableAlias());
} }
Prepared preparedQuery = prepare(session, buff.toString(), null/*paramValues*/); Prepared preparedQuery = prepare(session, buff.toString(), null/*paramValues*/);
command.setQuery((Select) preparedQuery); command.setQuery((Select) preparedQuery);
...@@ -1208,7 +1208,7 @@ public class Parser { ...@@ -1208,7 +1208,7 @@ public class Parser {
" AS " + command.getTargetTableFilter().getTableAlias()); " AS " + command.getTargetTableFilter().getTableAlias());
} }
targetMatchQuerySQL targetMatchQuerySQL
.append(" WHERE " + command.getOnCondition().getSQL()); .append(" WHERE ").append(command.getOnCondition().getSQL());
command.setTargetMatchQuery( command.setTargetMatchQuery(
(Select) parse(targetMatchQuerySQL.toString())); (Select) parse(targetMatchQuerySQL.toString()));
......
...@@ -423,10 +423,10 @@ public class ScriptCommand extends ScriptBase { ...@@ -423,10 +423,10 @@ public class ScriptCommand extends ScriptBase {
int id; int id;
if (v.getType() == Value.CLOB) { if (v.getType() == Value.CLOB) {
id = writeLobStream(v); id = writeLobStream(v);
buff.append("SYSTEM_COMBINE_CLOB(" + id + ")"); buff.append("SYSTEM_COMBINE_CLOB(").append(id).append(')');
} else if (v.getType() == Value.BLOB) { } else if (v.getType() == Value.BLOB) {
id = writeLobStream(v); id = writeLobStream(v);
buff.append("SYSTEM_COMBINE_BLOB(" + id + ")"); buff.append("SYSTEM_COMBINE_BLOB(").append(id).append(')');
} else { } else {
buff.append(v.getSQL()); buff.append(v.getSQL());
} }
...@@ -471,8 +471,8 @@ public class ScriptCommand extends ScriptBase { ...@@ -471,8 +471,8 @@ public class ScriptCommand extends ScriptBase {
try (InputStream input = v.getInputStream()) { try (InputStream input = v.getInputStream()) {
for (int i = 0;; i++) { for (int i = 0;; i++) {
StringBuilder buff = new StringBuilder(lobBlockSize * 2); StringBuilder buff = new StringBuilder(lobBlockSize * 2);
buff.append("INSERT INTO SYSTEM_LOB_STREAM VALUES(" + id + buff.append("INSERT INTO SYSTEM_LOB_STREAM VALUES(").append(id)
", " + i + ", NULL, '"); .append(", ").append(i).append(", NULL, '");
int len = IOUtils.readFully(input, bytes, lobBlockSize); int len = IOUtils.readFully(input, bytes, lobBlockSize);
if (len <= 0) { if (len <= 0) {
break; break;
...@@ -490,7 +490,8 @@ public class ScriptCommand extends ScriptBase { ...@@ -490,7 +490,8 @@ public class ScriptCommand extends ScriptBase {
try (Reader reader = v.getReader()) { try (Reader reader = v.getReader()) {
for (int i = 0;; i++) { for (int i = 0;; i++) {
StringBuilder buff = new StringBuilder(lobBlockSize * 2); StringBuilder buff = new StringBuilder(lobBlockSize * 2);
buff.append("INSERT INTO SYSTEM_LOB_STREAM VALUES(" + id + ", " + i + ", "); buff.append("INSERT INTO SYSTEM_LOB_STREAM VALUES(").append(id).append(", ").append(i)
.append(", ");
int len = IOUtils.readFully(reader, chars, lobBlockSize); int len = IOUtils.readFully(reader, chars, lobBlockSize);
if (len == 0) { if (len == 0) {
break; break;
......
...@@ -6,7 +6,6 @@ ...@@ -6,7 +6,6 @@
package org.h2.command.dml; package org.h2.command.dml;
import java.util.ArrayList; import java.util.ArrayList;
import org.h2.util.New;
/** /**
* The list of setting for a SET statement. * The list of setting for a SET statement.
...@@ -247,20 +246,22 @@ public class SetTypes { ...@@ -247,20 +246,22 @@ public class SetTypes {
* The type of SET BUILTIN_ALIAS_OVERRIDE statement. * The type of SET BUILTIN_ALIAS_OVERRIDE statement.
*/ */
public static final int BUILTIN_ALIAS_OVERRIDE = 47; public static final int BUILTIN_ALIAS_OVERRIDE = 47;
/** /**
* The type of a SET COLUMN_NAME_RULES statement. * The type of a SET COLUMN_NAME_RULES statement.
*/ */
public static final int COLUMN_NAME_RULES = 48; public static final int COLUMN_NAME_RULES = 48;
private static final int COUNT = COLUMN_NAME_RULES + 1;
private static final ArrayList<String> TYPES = New.arrayList(); private static final ArrayList<String> TYPES;
private SetTypes() { private SetTypes() {
// utility class // utility class
} }
static { static {
ArrayList<String> list = TYPES; ArrayList<String> list = new ArrayList<>(COUNT);
list.add(null); list.add(null);
list.add(IGNORECASE, "IGNORECASE"); list.add(IGNORECASE, "IGNORECASE");
list.add(MAX_LOG_SIZE, "MAX_LOG_SIZE"); list.add(MAX_LOG_SIZE, "MAX_LOG_SIZE");
...@@ -310,7 +311,7 @@ public class SetTypes { ...@@ -310,7 +311,7 @@ public class SetTypes {
list.add(LAZY_QUERY_EXECUTION, "LAZY_QUERY_EXECUTION"); list.add(LAZY_QUERY_EXECUTION, "LAZY_QUERY_EXECUTION");
list.add(BUILTIN_ALIAS_OVERRIDE, "BUILTIN_ALIAS_OVERRIDE"); list.add(BUILTIN_ALIAS_OVERRIDE, "BUILTIN_ALIAS_OVERRIDE");
list.add(COLUMN_NAME_RULES, "COLUMN_NAME_RULES"); list.add(COLUMN_NAME_RULES, "COLUMN_NAME_RULES");
TYPES = list;
} }
/** /**
...@@ -320,12 +321,7 @@ public class SetTypes { ...@@ -320,12 +321,7 @@ public class SetTypes {
* @return the number * @return the number
*/ */
public static int getType(String name) { public static int getType(String name) {
for (int i = 0; i < getTypes().size(); i++) { return TYPES.indexOf(name);
if (name.equals(getTypes().get(i))) {
return i;
}
}
return -1;
} }
public static ArrayList<String> getTypes() { public static ArrayList<String> getTypes() {
...@@ -339,7 +335,7 @@ public class SetTypes { ...@@ -339,7 +335,7 @@ public class SetTypes {
* @return the name * @return the name
*/ */
public static String getTypeName(int type) { public static String getTypeName(int type) {
return getTypes().get(type); return TYPES.get(type);
} }
} }
...@@ -28,7 +28,7 @@ import org.h2.util.Utils; ...@@ -28,7 +28,7 @@ import org.h2.util.Utils;
* Encapsulates the connection settings, including user name and password. * Encapsulates the connection settings, including user name and password.
*/ */
public class ConnectionInfo implements Cloneable { public class ConnectionInfo implements Cloneable {
private static final HashSet<String> KNOWN_SETTINGS = New.hashSet(); private static final HashSet<String> KNOWN_SETTINGS;
private Properties prop = new Properties(); private Properties prop = new Properties();
private String originalURL; private String originalURL;
...@@ -93,19 +93,19 @@ public class ConnectionInfo implements Cloneable { ...@@ -93,19 +93,19 @@ public class ConnectionInfo implements Cloneable {
static { static {
ArrayList<String> list = SetTypes.getTypes(); ArrayList<String> list = SetTypes.getTypes();
HashSet<String> set = KNOWN_SETTINGS;
set.addAll(list);
String[] connectionTime = { "ACCESS_MODE_DATA", "AUTOCOMMIT", "CIPHER", String[] connectionTime = { "ACCESS_MODE_DATA", "AUTOCOMMIT", "CIPHER",
"CREATE", "CACHE_TYPE", "FILE_LOCK", "IGNORE_UNKNOWN_SETTINGS", "CREATE", "CACHE_TYPE", "FILE_LOCK", "IGNORE_UNKNOWN_SETTINGS",
"IFEXISTS", "INIT", "PASSWORD", "RECOVER", "RECOVER_TEST", "IFEXISTS", "INIT", "PASSWORD", "RECOVER", "RECOVER_TEST",
"USER", "AUTO_SERVER", "AUTO_SERVER_PORT", "NO_UPGRADE", "USER", "AUTO_SERVER", "AUTO_SERVER_PORT", "NO_UPGRADE",
"AUTO_RECONNECT", "OPEN_NEW", "PAGE_SIZE", "PASSWORD_HASH", "JMX" }; "AUTO_RECONNECT", "OPEN_NEW", "PAGE_SIZE", "PASSWORD_HASH", "JMX" };
HashSet<String> set = new HashSet<>(list.size() + connectionTime.length);
set.addAll(list);
for (String key : connectionTime) { for (String key : connectionTime) {
if (SysProperties.CHECK && set.contains(key)) { if (!set.add(key) && SysProperties.CHECK) {
DbException.throwInternalError(key); DbException.throwInternalError(key);
} }
set.add(key);
} }
KNOWN_SETTINGS = set;
} }
private static boolean isKnownSetting(String s) { private static boolean isKnownSetting(String s) {
......
...@@ -22,7 +22,6 @@ import org.h2.table.Column; ...@@ -22,7 +22,6 @@ import org.h2.table.Column;
import org.h2.table.ColumnResolver; import org.h2.table.ColumnResolver;
import org.h2.table.Table; import org.h2.table.Table;
import org.h2.table.TableFilter; import org.h2.table.TableFilter;
import org.h2.util.New;
import org.h2.util.StatementBuilder; import org.h2.util.StatementBuilder;
import org.h2.util.StringUtils; import org.h2.util.StringUtils;
import org.h2.value.DataType; import org.h2.value.DataType;
...@@ -125,7 +124,7 @@ public class Aggregate extends Expression { ...@@ -125,7 +124,7 @@ public class Aggregate extends Expression {
*/ */
static final int HISTOGRAM = 16; static final int HISTOGRAM = 16;
private static final HashMap<String, Integer> AGGREGATES = New.hashMap(); private static final HashMap<String, Integer> AGGREGATES = new HashMap<>(24);
private final int type; private final int type;
private final Select select; private final Select select;
...@@ -156,6 +155,9 @@ public class Aggregate extends Expression { ...@@ -156,6 +155,9 @@ public class Aggregate extends Expression {
} }
static { static {
/*
* Update initial size of AGGREGATES after editing the following list.
*/
addAggregate("COUNT", COUNT); addAggregate("COUNT", COUNT);
addAggregate("SUM", SUM); addAggregate("SUM", SUM);
addAggregate("MIN", MIN); addAggregate("MIN", MIN);
......
...@@ -197,9 +197,9 @@ public class FreeSpaceBitSet { ...@@ -197,9 +197,9 @@ public class FreeSpaceBitSet {
on = 0; on = 0;
} }
} }
buff.append("\n"); buff.append('\n')
buff.append(" on " + onCount + " off " + offCount); .append(" on ").append(onCount).append(" off ").append(offCount)
buff.append(" " + 100 * onCount / (onCount+offCount) + "% used "); .append(' ').append(100 * onCount / (onCount+offCount)).append("% used ");
} }
buff.append('['); buff.append('[');
for (int i = 0;;) { for (int i = 0;;) {
......
...@@ -259,18 +259,18 @@ public class Page { ...@@ -259,18 +259,18 @@ public class Page {
public String toString() { public String toString() {
StringBuilder buff = new StringBuilder(); StringBuilder buff = new StringBuilder();
buff.append("id: ").append(System.identityHashCode(this)).append('\n'); buff.append("id: ").append(System.identityHashCode(this)).append('\n');
buff.append("version: ").append(Long.toHexString(version)).append("\n"); buff.append("version: ").append(Long.toHexString(version)).append('\n');
buff.append("pos: ").append(Long.toHexString(pos)).append("\n"); buff.append("pos: ").append(Long.toHexString(pos)).append('\n');
if (pos != 0) { if (pos != 0) {
int chunkId = DataUtils.getPageChunkId(pos); int chunkId = DataUtils.getPageChunkId(pos);
buff.append("chunk: ").append(Long.toHexString(chunkId)).append("\n"); buff.append("chunk: ").append(Long.toHexString(chunkId)).append('\n');
} }
for (int i = 0; i <= keys.length; i++) { for (int i = 0; i <= keys.length; i++) {
if (i > 0) { if (i > 0) {
buff.append(" "); buff.append(" ");
} }
if (children != null) { if (children != null) {
buff.append("[" + Long.toHexString(children[i].pos) + "] "); buff.append('[').append(Long.toHexString(children[i].pos)).append("] ");
} }
if (i < keys.length) { if (i < keys.length) {
buff.append(keys[i]); buff.append(keys[i]);
......
...@@ -19,7 +19,6 @@ import java.util.HashMap; ...@@ -19,7 +19,6 @@ import java.util.HashMap;
import java.util.UUID; import java.util.UUID;
import org.h2.mvstore.DataUtils; import org.h2.mvstore.DataUtils;
import org.h2.mvstore.WriteBuffer; import org.h2.mvstore.WriteBuffer;
import org.h2.util.New;
/** /**
* A data type implementation for the most common data types, including * A data type implementation for the most common data types, including
...@@ -94,8 +93,7 @@ public class ObjectDataType implements DataType { ...@@ -94,8 +93,7 @@ public class ObjectDataType implements DataType {
Float.class, Double.class, BigDecimal.class, String.class, Float.class, Double.class, BigDecimal.class, String.class,
UUID.class, Date.class }; UUID.class, Date.class };
private static final HashMap<Class<?>, Integer> COMMON_CLASSES_MAP = New private static final HashMap<Class<?>, Integer> COMMON_CLASSES_MAP = new HashMap<>(COMMON_CLASSES.length);
.hashMap();
private AutoDetectDataType last = new StringType(this); private AutoDetectDataType last = new StringType(this);
......
...@@ -134,7 +134,7 @@ public class RowImpl implements Row { ...@@ -134,7 +134,7 @@ public class RowImpl implements Row {
StatementBuilder buff = new StatementBuilder("( /* key:"); StatementBuilder buff = new StatementBuilder("( /* key:");
buff.append(getKey()); buff.append(getKey());
if (version != 0) { if (version != 0) {
buff.append(" v:" + version); buff.append(" v:").append(version);
} }
if (isDeleted()) { if (isDeleted()) {
buff.append(" deleted"); buff.append(" deleted");
......
...@@ -64,7 +64,7 @@ public class SimpleRow implements SearchRow { ...@@ -64,7 +64,7 @@ public class SimpleRow implements SearchRow {
StatementBuilder buff = new StatementBuilder("( /* key:"); StatementBuilder buff = new StatementBuilder("( /* key:");
buff.append(getKey()); buff.append(getKey());
if (version != 0) { if (version != 0) {
buff.append(" v:" + version); buff.append(" v:").append(version);
} }
buff.append(" */ "); buff.append(" */ ");
for (Value v : data) { for (Value v : data) {
......
...@@ -490,14 +490,16 @@ public class WebApp { ...@@ -490,14 +490,16 @@ public class WebApp {
columnsBuffer.append(column.getName()); columnsBuffer.append(column.getName());
String col = escapeIdentifier(column.getName()); String col = escapeIdentifier(column.getName());
String level = mainSchema ? ", 1, 1" : ", 2, 2"; String level = mainSchema ? ", 1, 1" : ", 2, 2";
buff.append("setNode(" + treeIndex + level + ", 'column', '" + buff.append("setNode(").append(treeIndex).append(level)
PageParser.escapeJavaScript(column.getName()) + .append(", 'column', '")
"', 'javascript:ins(\\'" + col + "\\')');\n"); .append(PageParser.escapeJavaScript(column.getName()))
.append("', 'javascript:ins(\\'").append(col).append("\\')');\n");
treeIndex++; treeIndex++;
if (mainSchema && showColumnTypes) { if (mainSchema && showColumnTypes) {
buff.append("setNode(" + treeIndex + ", 2, 2, 'type', '" + buff.append("setNode(").append(treeIndex)
PageParser.escapeJavaScript(column.getDataType()) + .append(", 2, 2, 'type', '")
"', null);\n"); .append(PageParser.escapeJavaScript(column.getDataType()))
.append("', null);\n");
treeIndex++; treeIndex++;
} }
} }
...@@ -574,21 +576,22 @@ public class WebApp { ...@@ -574,21 +576,22 @@ public class WebApp {
String level = mainSchema ? ", 1, 1" : ", 2, 1"; String level = mainSchema ? ", 1, 1" : ", 2, 1";
String levelIndex = mainSchema ? ", 2, 1" : ", 3, 1"; String levelIndex = mainSchema ? ", 2, 1" : ", 3, 1";
String levelColumnType = mainSchema ? ", 3, 2" : ", 4, 2"; String levelColumnType = mainSchema ? ", 3, 2" : ", 4, 2";
buff.append("setNode(" + treeIndex + level + buff.append("setNode(").append(treeIndex).append(level)
", 'index_az', '${text.tree.indexes}', null);\n"); .append(", 'index_az', '${text.tree.indexes}', null);\n");
treeIndex++; treeIndex++;
for (IndexInfo info : indexMap.values()) { for (IndexInfo info : indexMap.values()) {
buff.append("setNode(" + treeIndex + levelIndex + buff.append("setNode(").append(treeIndex).append(levelIndex)
", 'index', '" + .append(", 'index', '")
PageParser.escapeJavaScript(info.name) + "', null);\n"); .append(PageParser.escapeJavaScript(info.name))
.append("', null);\n");
treeIndex++; treeIndex++;
buff.append("setNode(" + treeIndex + levelColumnType + buff.append("setNode(").append(treeIndex).append(levelColumnType)
", 'type', '" + info.type + "', null);\n"); .append(", 'type', '").append(info.type).append("', null);\n");
treeIndex++; treeIndex++;
buff.append("setNode(" + treeIndex + levelColumnType + buff.append("setNode(").append(treeIndex).append(levelColumnType)
", 'type', '" + .append(", 'type', '")
PageParser.escapeJavaScript(info.columns) + .append(PageParser.escapeJavaScript(info.columns))
"', null);\n"); .append("', null);\n");
treeIndex++; treeIndex++;
} }
} }
...@@ -622,9 +625,10 @@ public class WebApp { ...@@ -622,9 +625,10 @@ public class WebApp {
tab = schema.quotedName + "." + tab; tab = schema.quotedName + "." + tab;
} }
tab = escapeIdentifier(tab); tab = escapeIdentifier(tab);
buff.append("setNode(" + treeIndex + indentation + " 'table', '" + buff.append("setNode(").append(treeIndex).append(indentation)
PageParser.escapeJavaScript(table.getName()) + .append(" 'table', '")
"', 'javascript:ins(\\'" + tab + "\\',true)');\n"); .append(PageParser.escapeJavaScript(table.getName()))
.append("', 'javascript:ins(\\'").append(tab).append("\\',true)');\n");
treeIndex++; treeIndex++;
if (mainSchema || showColumns) { if (mainSchema || showColumns) {
StringBuilder columnsBuffer = new StringBuilder(); StringBuilder columnsBuffer = new StringBuilder();
...@@ -634,10 +638,10 @@ public class WebApp { ...@@ -634,10 +638,10 @@ public class WebApp {
treeIndex = addIndexes(mainSchema, meta, table.getName(), treeIndex = addIndexes(mainSchema, meta, table.getName(),
schema.name, buff, treeIndex); schema.name, buff, treeIndex);
} }
buff.append("addTable('" + buff.append("addTable('")
PageParser.escapeJavaScript(table.getName()) + "', '" + .append(PageParser.escapeJavaScript(table.getName())).append("', '")
PageParser.escapeJavaScript(columnsBuffer.toString()) + .append(PageParser.escapeJavaScript(columnsBuffer.toString())).append("', ")
"', " + tableId + ");\n"); .append(tableId).append(");\n");
} }
} }
tables = schema.getTables(); tables = schema.getTables();
...@@ -651,9 +655,10 @@ public class WebApp { ...@@ -651,9 +655,10 @@ public class WebApp {
tab = view.getSchema().quotedName + "." + tab; tab = view.getSchema().quotedName + "." + tab;
} }
tab = escapeIdentifier(tab); tab = escapeIdentifier(tab);
buff.append("setNode(" + treeIndex + indentation + " 'view', '" + buff.append("setNode(").append(treeIndex).append(indentation)
PageParser.escapeJavaScript(view.getName()) + .append(" 'view', '")
"', 'javascript:ins(\\'" + tab + "\\',true)');\n"); .append(PageParser.escapeJavaScript(view.getName()))
.append("', 'javascript:ins(\\'").append(tab).append("\\',true)');\n");
treeIndex++; treeIndex++;
if (mainSchema) { if (mainSchema) {
StringBuilder columnsBuffer = new StringBuilder(); StringBuilder columnsBuffer = new StringBuilder();
...@@ -667,19 +672,20 @@ public class WebApp { ...@@ -667,19 +672,20 @@ public class WebApp {
ResultSet rs = prep.executeQuery(); ResultSet rs = prep.executeQuery();
if (rs.next()) { if (rs.next()) {
String sql = rs.getString("SQL"); String sql = rs.getString("SQL");
buff.append("setNode(" + treeIndex + indentNode + buff.append("setNode(").append(treeIndex)
" 'type', '" + .append(indentNode)
PageParser.escapeJavaScript(sql) + .append(" 'type', '")
"', null);\n"); .append(PageParser.escapeJavaScript(sql))
.append("', null);\n");
treeIndex++; treeIndex++;
} }
rs.close(); rs.close();
} }
} }
buff.append("addTable('" + buff.append("addTable('")
PageParser.escapeJavaScript(view.getName()) + "', '" + .append(PageParser.escapeJavaScript(view.getName())).append("', '")
PageParser.escapeJavaScript(columnsBuffer.toString()) + .append(PageParser.escapeJavaScript(columnsBuffer.toString())).append("', ")
"', " + tableId + ");\n"); .append(tableId).append(");\n");
} }
} }
return treeIndex; return treeIndex;
...@@ -695,9 +701,10 @@ public class WebApp { ...@@ -695,9 +701,10 @@ public class WebApp {
session.loadBnf(); session.loadBnf();
isH2 = contents.isH2(); isH2 = contents.isH2();
StringBuilder buff = new StringBuilder(); StringBuilder buff = new StringBuilder()
buff.append("setNode(0, 0, 0, 'database', '" + PageParser.escapeJavaScript(url) .append("setNode(0, 0, 0, 'database', '")
+ "', null);\n"); .append(PageParser.escapeJavaScript(url))
.append("', null);\n");
int treeIndex = 1; int treeIndex = 1;
DbSchema defaultSchema = contents.getDefaultSchema(); DbSchema defaultSchema = contents.getDefaultSchema();
...@@ -707,9 +714,9 @@ public class WebApp { ...@@ -707,9 +714,9 @@ public class WebApp {
if (schema == defaultSchema || schema == null) { if (schema == defaultSchema || schema == null) {
continue; continue;
} }
buff.append("setNode(" + treeIndex + ", 0, 1, 'folder', '" + buff.append("setNode(").append(treeIndex).append(", 0, 1, 'folder', '")
PageParser.escapeJavaScript(schema.name) + .append(PageParser.escapeJavaScript(schema.name))
"', null);\n"); .append("', null);\n");
treeIndex++; treeIndex++;
treeIndex = addTablesAndViews(schema, false, buff, treeIndex); treeIndex = addTablesAndViews(schema, false, buff, treeIndex);
} }
...@@ -719,29 +726,28 @@ public class WebApp { ...@@ -719,29 +726,28 @@ public class WebApp {
"INFORMATION_SCHEMA.SEQUENCES ORDER BY SEQUENCE_NAME"); "INFORMATION_SCHEMA.SEQUENCES ORDER BY SEQUENCE_NAME");
for (int i = 0; rs.next(); i++) { for (int i = 0; rs.next(); i++) {
if (i == 0) { if (i == 0) {
buff.append("setNode(" + treeIndex + buff.append("setNode(").append(treeIndex)
", 0, 1, 'sequences', '${text.tree.sequences}', null);\n"); .append(", 0, 1, 'sequences', '${text.tree.sequences}', null);\n");
treeIndex++; treeIndex++;
} }
String name = rs.getString("SEQUENCE_NAME"); String name = rs.getString("SEQUENCE_NAME");
String current = rs.getString("CURRENT_VALUE"); String current = rs.getString("CURRENT_VALUE");
String increment = rs.getString("INCREMENT"); String increment = rs.getString("INCREMENT");
buff.append("setNode(" + treeIndex + buff.append("setNode(").append(treeIndex)
", 1, 1, 'sequence', '" + .append(", 1, 1, 'sequence', '")
PageParser.escapeJavaScript(name) + .append(PageParser.escapeJavaScript(name))
"', null);\n"); .append("', null);\n");
treeIndex++; treeIndex++;
buff.append("setNode(" + treeIndex + buff.append("setNode(").append(treeIndex)
", 2, 2, 'type', '${text.tree.current}: " + .append(", 2, 2, 'type', '${text.tree.current}: ")
PageParser.escapeJavaScript(current) + .append(PageParser.escapeJavaScript(current))
"', null);\n"); .append("', null);\n");
treeIndex++; treeIndex++;
if (!"1".equals(increment)) { if (!"1".equals(increment)) {
buff.append("setNode(" + buff.append("setNode(").append(treeIndex)
treeIndex + .append(", 2, 2, 'type', '${text.tree.increment}: ")
", 2, 2, 'type', '${text.tree.increment}: " + .append(PageParser.escapeJavaScript(increment))
PageParser.escapeJavaScript(increment) + .append("', null);\n");
"', null);\n");
treeIndex++; treeIndex++;
} }
} }
...@@ -750,20 +756,20 @@ public class WebApp { ...@@ -750,20 +756,20 @@ public class WebApp {
"INFORMATION_SCHEMA.USERS ORDER BY NAME"); "INFORMATION_SCHEMA.USERS ORDER BY NAME");
for (int i = 0; rs.next(); i++) { for (int i = 0; rs.next(); i++) {
if (i == 0) { if (i == 0) {
buff.append("setNode(" + treeIndex + buff.append("setNode(").append(treeIndex)
", 0, 1, 'users', '${text.tree.users}', null);\n"); .append(", 0, 1, 'users', '${text.tree.users}', null);\n");
treeIndex++; treeIndex++;
} }
String name = rs.getString("NAME"); String name = rs.getString("NAME");
String admin = rs.getString("ADMIN"); String admin = rs.getString("ADMIN");
buff.append("setNode(" + treeIndex + buff.append("setNode(").append(treeIndex)
", 1, 1, 'user', '" + .append(", 1, 1, 'user', '")
PageParser.escapeJavaScript(name) + .append(PageParser.escapeJavaScript(name))
"', null);\n"); .append("', null);\n");
treeIndex++; treeIndex++;
if (admin.equalsIgnoreCase("TRUE")) { if (admin.equalsIgnoreCase("TRUE")) {
buff.append("setNode(" + treeIndex + buff.append("setNode(").append(treeIndex)
", 2, 2, 'type', '${text.tree.admin}', null);\n"); .append(", 2, 2, 'type', '${text.tree.admin}', null);\n");
treeIndex++; treeIndex++;
} }
} }
...@@ -773,9 +779,11 @@ public class WebApp { ...@@ -773,9 +779,11 @@ public class WebApp {
DatabaseMetaData meta = session.getMetaData(); DatabaseMetaData meta = session.getMetaData();
String version = meta.getDatabaseProductName() + " " + String version = meta.getDatabaseProductName() + " " +
meta.getDatabaseProductVersion(); meta.getDatabaseProductVersion();
buff.append("setNode(" + treeIndex + ", 0, 0, 'info', '" + buff.append("setNode(").append(treeIndex)
PageParser.escapeJavaScript(version) + "', null);\n"); .append(", 0, 0, 'info', '")
buff.append("refreshQueryTables();"); .append(PageParser.escapeJavaScript(version))
.append("', null);\n")
.append("refreshQueryTables();");
session.put("tree", buff.toString()); session.put("tree", buff.toString());
} catch (Exception e) { } catch (Exception e) {
session.put("tree", ""); session.put("tree", "");
...@@ -1357,21 +1365,22 @@ public class WebApp { ...@@ -1357,21 +1365,22 @@ public class WebApp {
int level = Integer.parseInt(s); int level = Integer.parseInt(s);
conn.setTransactionIsolation(level); conn.setTransactionIsolation(level);
} }
buff.append("Transaction Isolation: " + buff.append("Transaction Isolation: ")
conn.getTransactionIsolation() + "<br />"); .append(conn.getTransactionIsolation())
buff.append(Connection.TRANSACTION_READ_UNCOMMITTED + .append("<br />");
": read_uncommitted<br />"); buff.append(Connection.TRANSACTION_READ_UNCOMMITTED)
buff.append(Connection.TRANSACTION_READ_COMMITTED + .append(": read_uncommitted<br />");
": read_committed<br />"); buff.append(Connection.TRANSACTION_READ_COMMITTED)
buff.append(Connection.TRANSACTION_REPEATABLE_READ + .append(": read_committed<br />");
": repeatable_read<br />"); buff.append(Connection.TRANSACTION_REPEATABLE_READ)
buff.append(Connection.TRANSACTION_SERIALIZABLE + .append(": repeatable_read<br />");
": serializable"); buff.append(Connection.TRANSACTION_SERIALIZABLE)
.append(": serializable");
} }
if (sql.startsWith("@")) { if (sql.startsWith("@")) {
rs = getMetaResultSet(conn, sql); rs = getMetaResultSet(conn, sql);
if (rs == null) { if (rs == null) {
buff.append("?: " + sql); buff.append("?: ").append(sql);
return buff.toString(); return buff.toString();
} }
} else { } else {
...@@ -1385,7 +1394,8 @@ public class WebApp { ...@@ -1385,7 +1394,8 @@ public class WebApp {
rs = stat.getGeneratedKeys(); rs = stat.getGeneratedKeys();
} else { } else {
if (!isResultSet) { if (!isResultSet) {
buff.append("${text.result.updateCount}: " + stat.getUpdateCount()); buff.append("${text.result.updateCount}: ")
.append(stat.getUpdateCount());
time = System.currentTimeMillis() - time; time = System.currentTimeMillis() - time;
buff.append("<br />(").append(time).append(" ms)"); buff.append("<br />(").append(time).append(" ms)");
stat.close(); stat.close();
......
...@@ -387,7 +387,7 @@ public class TableLink extends Table { ...@@ -387,7 +387,7 @@ public class TableLink extends Table {
if (readOnly) { if (readOnly) {
buff.append(" READONLY"); buff.append(" READONLY");
} }
buff.append(" /*" + JdbcSQLException.HIDE_SQL + "*/"); buff.append(" /*").append(JdbcSQLException.HIDE_SQL).append("*/");
return buff.toString(); return buff.toString();
} }
......
...@@ -1477,7 +1477,7 @@ public class Recover extends Tool implements DataHandler { ...@@ -1477,7 +1477,7 @@ public class Recover extends Tool implements DataHandler {
private void writeRow(PrintWriter writer, Data s, Value[] data) { private void writeRow(PrintWriter writer, Data s, Value[] data) {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.append("INSERT INTO " + storageName + " VALUES("); sb.append("INSERT INTO ").append(storageName).append(" VALUES(");
for (valueId = 0; valueId < recordLength; valueId++) { for (valueId = 0; valueId < recordLength; valueId++) {
try { try {
Value v = s.readValue(); Value v = s.readValue();
......
...@@ -184,15 +184,15 @@ public class AbbaLockingDetector implements Runnable { ...@@ -184,15 +184,15 @@ public class AbbaLockingDetector implements Runnable {
* stack frames) * stack frames)
*/ */
private static String getStackTraceForThread(ThreadInfo info) { private static String getStackTraceForThread(ThreadInfo info) {
StringBuilder sb = new StringBuilder("\"" + StringBuilder sb = new StringBuilder().append('"')
info.getThreadName() + "\"" + " Id=" + .append(info.getThreadName()).append("\"" + " Id=")
info.getThreadId() + " " + info.getThreadState()); .append(info.getThreadId()).append(' ').append(info.getThreadState());
if (info.getLockName() != null) { if (info.getLockName() != null) {
sb.append(" on " + info.getLockName()); sb.append(" on ").append(info.getLockName());
} }
if (info.getLockOwnerName() != null) { if (info.getLockOwnerName() != null) {
sb.append(" owned by \"" + info.getLockOwnerName() + sb.append(" owned by \"").append(info.getLockOwnerName())
"\" Id=" + info.getLockOwnerId()); .append("\" Id=").append(info.getLockOwnerId());
} }
if (info.isSuspended()) { if (info.isSuspended()) {
sb.append(" (suspended)"); sb.append(" (suspended)");
...@@ -229,22 +229,25 @@ public class AbbaLockingDetector implements Runnable { ...@@ -229,22 +229,25 @@ public class AbbaLockingDetector implements Runnable {
private static void dumpStackTraceElement(ThreadInfo info, private static void dumpStackTraceElement(ThreadInfo info,
StringBuilder sb, int i, StackTraceElement e) { StringBuilder sb, int i, StackTraceElement e) {
sb.append('\t').append("at ").append(e.toString()); sb.append('\t').append("at ").append(e)
sb.append('\n'); .append('\n');
if (i == 0 && info.getLockInfo() != null) { if (i == 0 && info.getLockInfo() != null) {
Thread.State ts = info.getThreadState(); Thread.State ts = info.getThreadState();
switch (ts) { switch (ts) {
case BLOCKED: case BLOCKED:
sb.append("\t- blocked on " + info.getLockInfo()); sb.append("\t- blocked on ")
sb.append('\n'); .append(info.getLockInfo())
.append('\n');
break; break;
case WAITING: case WAITING:
sb.append("\t- waiting on " + info.getLockInfo()); sb.append("\t- waiting on ")
sb.append('\n'); .append(info.getLockInfo())
.append('\n');
break; break;
case TIMED_WAITING: case TIMED_WAITING:
sb.append("\t- waiting on " + info.getLockInfo()); sb.append("\t- waiting on ")
sb.append('\n'); .append(info.getLockInfo())
.append('\n');
break; break;
default: default:
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论