提交 4419055c authored 作者: Thomas Mueller's avatar Thomas Mueller

Enable warning for 'Local variable declaration hides another field or variable'.

上级 0196101c
...@@ -111,10 +111,10 @@ public class FunctionAlias extends DbObjectBase { ...@@ -111,10 +111,10 @@ public class FunctionAlias extends DbObjectBase {
private void loadFromSource() throws SQLException { private void loadFromSource() throws SQLException {
SourceCompiler compiler = database.getCompiler(); SourceCompiler compiler = database.getCompiler();
String className = Constants.USER_PACKAGE + "." + getName(); String fullClassName = Constants.USER_PACKAGE + "." + getName();
compiler.setSource(className, source); compiler.setSource(fullClassName, source);
try { try {
Method m = compiler.getMethod(className); Method m = compiler.getMethod(fullClassName);
JavaMethod method = new JavaMethod(m, 0); JavaMethod method = new JavaMethod(m, 0);
javaMethods = new JavaMethod[] { javaMethods = new JavaMethod[] {
method method
......
...@@ -31,17 +31,20 @@ public class CompareLike extends Condition { ...@@ -31,17 +31,20 @@ public class CompareLike extends Condition {
private static final int MATCH = 0, ONE = 1, ANY = 2; private static final int MATCH = 0, ONE = 1, ANY = 2;
private final CompareMode compareMode; private final CompareMode compareMode;
private final boolean regexp;
private Expression left; private Expression left;
private Expression right; private Expression right;
private Expression escape; private Expression escape;
private boolean isInit; private boolean isInit;
private char[] pattern;
private char[] patternChars;
private String patternString; private String patternString;
private Pattern patternRegexp; private int[] patternTypes;
private int[] types;
private int patternLength; private int patternLength;
private final boolean regexp;
private Pattern patternRegexp;
private boolean ignoreCase; private boolean ignoreCase;
private boolean fastCompare; private boolean fastCompare;
private boolean invalidPattern; private boolean invalidPattern;
...@@ -166,7 +169,7 @@ public class CompareLike extends Condition { ...@@ -166,7 +169,7 @@ public class CompareLike extends Condition {
if (invalidPattern) { if (invalidPattern) {
return; return;
} }
if (patternLength <= 0 || types[0] != MATCH) { if (patternLength <= 0 || patternTypes[0] != MATCH) {
// can't use an index // can't use an index
return; return;
} }
...@@ -177,8 +180,8 @@ public class CompareLike extends Condition { ...@@ -177,8 +180,8 @@ public class CompareLike extends Condition {
} }
int maxMatch = 0; int maxMatch = 0;
StringBuilder buff = new StringBuilder(); StringBuilder buff = new StringBuilder();
while (maxMatch < patternLength && types[maxMatch] == MATCH) { while (maxMatch < patternLength && patternTypes[maxMatch] == MATCH) {
buff.append(pattern[maxMatch++]); buff.append(patternChars[maxMatch++]);
} }
String begin = buff.toString(); String begin = buff.toString();
if (maxMatch == patternLength) { if (maxMatch == patternLength) {
...@@ -232,7 +235,7 @@ public class CompareLike extends Condition { ...@@ -232,7 +235,7 @@ public class CompareLike extends Condition {
// result = patternRegexp.matcher(value).matches(); // result = patternRegexp.matcher(value).matches();
result = patternRegexp.matcher(value).find(); result = patternRegexp.matcher(value).find();
} else { } else {
result = compareAt(value, 0, 0, value.length(), pattern, types); result = compareAt(value, 0, 0, value.length(), patternChars, patternTypes);
} }
return ValueBoolean.get(result); return ValueBoolean.get(result);
} }
...@@ -285,10 +288,10 @@ public class CompareLike extends Condition { ...@@ -285,10 +288,10 @@ public class CompareLike extends Condition {
if (invalidPattern) { if (invalidPattern) {
return false; return false;
} }
return compareAt(value, 0, 0, value.length(), pattern, types); return compareAt(value, 0, 0, value.length(), patternChars, patternTypes);
} }
private void initPattern(String p, Character escape) throws SQLException { private void initPattern(String p, Character escapeChar) throws SQLException {
if (compareMode.getName().equals(CompareMode.OFF) && !ignoreCase) { if (compareMode.getName().equals(CompareMode.OFF) && !ignoreCase) {
fastCompare = true; fastCompare = true;
} }
...@@ -307,18 +310,18 @@ public class CompareLike extends Condition { ...@@ -307,18 +310,18 @@ public class CompareLike extends Condition {
} }
patternLength = 0; patternLength = 0;
if (p == null) { if (p == null) {
types = null; patternTypes = null;
pattern = null; patternChars = null;
return; return;
} }
int len = p.length(); int len = p.length();
pattern = new char[len]; patternChars = new char[len];
types = new int[len]; patternTypes = new int[len];
boolean lastAny = false; boolean lastAny = false;
for (int i = 0; i < len; i++) { for (int i = 0; i < len; i++) {
char c = p.charAt(i); char c = p.charAt(i);
int type; int type;
if (escape != null && escape == c) { if (escapeChar != null && escapeChar == c) {
if (i >= len - 1) { if (i >= len - 1) {
invalidPattern = true; invalidPattern = true;
return; return;
...@@ -338,23 +341,23 @@ public class CompareLike extends Condition { ...@@ -338,23 +341,23 @@ public class CompareLike extends Condition {
type = MATCH; type = MATCH;
lastAny = false; lastAny = false;
} }
types[patternLength] = type; patternTypes[patternLength] = type;
pattern[patternLength++] = c; patternChars[patternLength++] = c;
} }
for (int i = 0; i < patternLength - 1; i++) { for (int i = 0; i < patternLength - 1; i++) {
if ((types[i] == ANY) && (types[i + 1] == ONE)) { if ((patternTypes[i] == ANY) && (patternTypes[i + 1] == ONE)) {
types[i] = ONE; patternTypes[i] = ONE;
types[i + 1] = ANY; patternTypes[i + 1] = ANY;
} }
} }
patternString = new String(pattern, 0, patternLength); patternString = new String(patternChars, 0, patternLength);
} }
private boolean isFullMatch() { private boolean isFullMatch() {
if (types == null) { if (patternTypes == null) {
return false; return false;
} }
for (int type : types) { for (int type : patternTypes) {
if (type != MATCH) { if (type != MATCH) {
return false; return false;
} }
......
...@@ -75,12 +75,12 @@ public class ConditionIn extends Condition { ...@@ -75,12 +75,12 @@ public class ConditionIn extends Condition {
return ValueBoolean.get(result); return ValueBoolean.get(result);
} }
public void mapColumns(ColumnResolver resolver, int queryLevel) throws SQLException { public void mapColumns(ColumnResolver resolver, int level) throws SQLException {
left.mapColumns(resolver, queryLevel); left.mapColumns(resolver, level);
for (Expression e : valueList) { for (Expression e : valueList) {
e.mapColumns(resolver, queryLevel); e.mapColumns(resolver, level);
} }
this.queryLevel = Math.max(queryLevel, this.queryLevel); this.queryLevel = Math.max(level, this.queryLevel);
} }
public Expression optimize(Session session) throws SQLException { public Expression optimize(Session session) throws SQLException {
......
...@@ -83,10 +83,10 @@ public class ConditionInSelect extends Condition { ...@@ -83,10 +83,10 @@ public class ConditionInSelect extends Condition {
return ValueBoolean.get(result); return ValueBoolean.get(result);
} }
public void mapColumns(ColumnResolver resolver, int queryLevel) throws SQLException { public void mapColumns(ColumnResolver resolver, int level) throws SQLException {
left.mapColumns(resolver, queryLevel); left.mapColumns(resolver, level);
query.mapColumns(resolver, queryLevel + 1); query.mapColumns(resolver, level + 1);
this.queryLevel = Math.max(queryLevel, this.queryLevel); this.queryLevel = Math.max(level, this.queryLevel);
} }
public Expression optimize(Session session) throws SQLException { public Expression optimize(Session session) throws SQLException {
......
...@@ -34,7 +34,7 @@ public class ExpressionColumn extends Expression { ...@@ -34,7 +34,7 @@ public class ExpressionColumn extends Expression {
private String schemaName; private String schemaName;
private String tableAlias; private String tableAlias;
private String columnName; private String columnName;
private ColumnResolver resolver; private ColumnResolver columnResolver;
private int queryLevel; private int queryLevel;
private Column column; private Column column;
private boolean evaluatable; private boolean evaluatable;
...@@ -68,7 +68,7 @@ public class ExpressionColumn extends Expression { ...@@ -68,7 +68,7 @@ public class ExpressionColumn extends Expression {
} }
public TableFilter getTableFilter() { public TableFilter getTableFilter() {
return resolver == null ? null : resolver.getTableFilter(); return columnResolver == null ? null : columnResolver.getTableFilter();
} }
public void mapColumns(ColumnResolver resolver, int level) throws SQLException { public void mapColumns(ColumnResolver resolver, int level) throws SQLException {
...@@ -95,11 +95,11 @@ public class ExpressionColumn extends Expression { ...@@ -95,11 +95,11 @@ public class ExpressionColumn extends Expression {
} }
private void mapColumn(ColumnResolver resolver, Column col, int level) throws SQLException { private void mapColumn(ColumnResolver resolver, Column col, int level) throws SQLException {
if (this.resolver == null) { if (this.columnResolver == null) {
queryLevel = level; queryLevel = level;
column = col; column = col;
this.resolver = resolver; this.columnResolver = resolver;
} else if (queryLevel == level && this.resolver != resolver) { } else if (queryLevel == level && this.columnResolver != resolver) {
if (resolver instanceof SelectListColumnResolver) { if (resolver instanceof SelectListColumnResolver) {
// ignore - already mapped, that's ok // ignore - already mapped, that's ok
} else { } else {
...@@ -109,7 +109,7 @@ public class ExpressionColumn extends Expression { ...@@ -109,7 +109,7 @@ public class ExpressionColumn extends Expression {
} }
public Expression optimize(Session session) throws SQLException { public Expression optimize(Session session) throws SQLException {
if (resolver == null) { if (columnResolver == null) {
Schema schema = session.getDatabase().findSchema( Schema schema = session.getDatabase().findSchema(
tableAlias == null ? session.getCurrentSchemaName() : tableAlias); tableAlias == null ? session.getCurrentSchemaName() : tableAlias);
if (schema != null) { if (schema != null) {
...@@ -127,12 +127,12 @@ public class ExpressionColumn extends Expression { ...@@ -127,12 +127,12 @@ public class ExpressionColumn extends Expression {
} }
throw Message.getSQLException(ErrorCode.COLUMN_NOT_FOUND_1, name); throw Message.getSQLException(ErrorCode.COLUMN_NOT_FOUND_1, name);
} }
return resolver.optimize(this, column); return columnResolver.optimize(this, column);
} }
public void updateAggregate(Session session) throws SQLException { public void updateAggregate(Session session) throws SQLException {
Value now = resolver.getValue(column); Value now = columnResolver.getValue(column);
Select select = resolver.getSelect(); Select select = columnResolver.getSelect();
if (select == null) { if (select == null) {
throw Message.getSQLException(ErrorCode.MUST_GROUP_BY_COLUMN_1, getSQL()); throw Message.getSQLException(ErrorCode.MUST_GROUP_BY_COLUMN_1, getSQL());
} }
...@@ -155,7 +155,7 @@ public class ExpressionColumn extends Expression { ...@@ -155,7 +155,7 @@ public class ExpressionColumn extends Expression {
// TODO refactor: simplify check if really part of an aggregated value / // TODO refactor: simplify check if really part of an aggregated value /
// detection of // detection of
// usage of non-grouped by columns without aggregate function // usage of non-grouped by columns without aggregate function
Select select = resolver.getSelect(); Select select = columnResolver.getSelect();
if (select != null) { if (select != null) {
HashMap<Expression, Object> values = select.getCurrentGroup(); HashMap<Expression, Object> values = select.getCurrentGroup();
if (values != null) { if (values != null) {
...@@ -165,7 +165,7 @@ public class ExpressionColumn extends Expression { ...@@ -165,7 +165,7 @@ public class ExpressionColumn extends Expression {
} }
} }
} }
Value value = resolver.getValue(column); Value value = columnResolver.getValue(column);
if (value == null) { if (value == null) {
throw Message.getSQLException(ErrorCode.MUST_GROUP_BY_COLUMN_1, getSQL()); throw Message.getSQLException(ErrorCode.MUST_GROUP_BY_COLUMN_1, getSQL());
} }
...@@ -177,7 +177,7 @@ public class ExpressionColumn extends Expression { ...@@ -177,7 +177,7 @@ public class ExpressionColumn extends Expression {
} }
public void setEvaluatable(TableFilter tableFilter, boolean b) { public void setEvaluatable(TableFilter tableFilter, boolean b) {
if (resolver != null && tableFilter == resolver.getTableFilter()) { if (columnResolver != null && tableFilter == columnResolver.getTableFilter()) {
evaluatable = b; evaluatable = b;
} }
} }
...@@ -250,7 +250,7 @@ public class ExpressionColumn extends Expression { ...@@ -250,7 +250,7 @@ public class ExpressionColumn extends Expression {
visitor.addDataModificationId(column.getTable().getMaxDataModificationId()); visitor.addDataModificationId(column.getTable().getMaxDataModificationId());
return true; return true;
case ExpressionVisitor.NOT_FROM_RESOLVER: case ExpressionVisitor.NOT_FROM_RESOLVER:
return resolver != visitor.getResolver(); return columnResolver != visitor.getResolver();
case ExpressionVisitor.GET_DEPENDENCIES: case ExpressionVisitor.GET_DEPENDENCIES:
visitor.addDependency(column.getTable()); visitor.addDependency(column.getTable());
return true; return true;
......
...@@ -429,7 +429,7 @@ public class Function extends Expression implements FunctionCall { ...@@ -429,7 +429,7 @@ public class Function extends Expression implements FunctionCall {
return null; return null;
} }
private Value getSimpleValue(Session session, Value v0, Expression[] args) throws SQLException { private Value getSimpleValue(Session session, Value v0, Expression[] argList) throws SQLException {
Value result; Value result;
switch (info.type) { switch (info.type) {
case ABS: case ABS:
...@@ -538,7 +538,7 @@ public class Function extends Expression implements FunctionCall { ...@@ -538,7 +538,7 @@ public class Function extends Expression implements FunctionCall {
break; break;
case CONCAT: { case CONCAT: {
result = ValueNull.INSTANCE; result = ValueNull.INSTANCE;
for (Expression e : args) { for (Expression e : argList) {
Value v = e.getValue(session); Value v = e.getValue(session);
if (v == ValueNull.INSTANCE) { if (v == ValueNull.INSTANCE) {
continue; continue;
...@@ -730,15 +730,15 @@ public class Function extends Expression implements FunctionCall { ...@@ -730,15 +730,15 @@ public class Function extends Expression implements FunctionCall {
result = ValueInt.get(session.getId()); result = ValueInt.get(session.getId());
break; break;
case IFNULL: { case IFNULL: {
result = v0 == ValueNull.INSTANCE ? args[1].getValue(session) : v0; result = v0 == ValueNull.INSTANCE ? argList[1].getValue(session) : v0;
break; break;
} }
case CASEWHEN: { case CASEWHEN: {
Expression expr; Expression expr;
if (v0 == ValueNull.INSTANCE || !v0.getBoolean().booleanValue()) { if (v0 == ValueNull.INSTANCE || !v0.getBoolean().booleanValue()) {
expr = args[2]; expr = argList[2];
} else { } else {
expr = args[1]; expr = argList[1];
} }
Value v = expr.getValue(session); Value v = expr.getValue(session);
result = v.convertTo(dataType); result = v.convertTo(dataType);
...@@ -746,8 +746,8 @@ public class Function extends Expression implements FunctionCall { ...@@ -746,8 +746,8 @@ public class Function extends Expression implements FunctionCall {
} }
case COALESCE: { case COALESCE: {
result = v0; result = v0;
for (int i = 0; i < args.length; i++) { for (int i = 0; i < argList.length; i++) {
Value v = i == 0 ? v0 : args[i].getValue(session); Value v = i == 0 ? v0 : argList[i].getValue(session);
if (!(v == ValueNull.INSTANCE)) { if (!(v == ValueNull.INSTANCE)) {
result = v.convertTo(dataType); result = v.convertTo(dataType);
break; break;
...@@ -758,8 +758,8 @@ public class Function extends Expression implements FunctionCall { ...@@ -758,8 +758,8 @@ public class Function extends Expression implements FunctionCall {
case GREATEST: case GREATEST:
case LEAST: { case LEAST: {
result = ValueNull.INSTANCE; result = ValueNull.INSTANCE;
for (int i = 0; i < args.length; i++) { for (int i = 0; i < argList.length; i++) {
Value v = i == 0 ? v0 : args[i].getValue(session); Value v = i == 0 ? v0 : argList[i].getValue(session);
if (!(v == ValueNull.INSTANCE)) { if (!(v == ValueNull.INSTANCE)) {
v = v.convertTo(dataType); v = v.convertTo(dataType);
if (result == ValueNull.INSTANCE) { if (result == ValueNull.INSTANCE) {
...@@ -779,21 +779,21 @@ public class Function extends Expression implements FunctionCall { ...@@ -779,21 +779,21 @@ public class Function extends Expression implements FunctionCall {
case CASE: { case CASE: {
result = null; result = null;
int i = 0; int i = 0;
for (; i < args.length; i++) { for (; i < argList.length; i++) {
Value when = args[i++].getValue(session); Value when = argList[i++].getValue(session);
if (Boolean.TRUE.equals(when)) { if (Boolean.TRUE.equals(when)) {
result = args[i].getValue(session); result = argList[i].getValue(session);
break; break;
} }
} }
if (result == null) { if (result == null) {
result = i < args.length ? args[i].getValue(session) : ValueNull.INSTANCE; result = i < argList.length ? argList[i].getValue(session) : ValueNull.INSTANCE;
} }
break; break;
} }
case ARRAY_GET: { case ARRAY_GET: {
if (v0.getType() == Value.ARRAY) { if (v0.getType() == Value.ARRAY) {
Value v1 = args[1].getValue(session); Value v1 = argList[1].getValue(session);
int element = v1.getInt(); int element = v1.getInt();
Value[] list = ((ValueArray) v0).getList(); Value[] list = ((ValueArray) v0).getList();
if (element < 1 || element > list.length) { if (element < 1 || element > list.length) {
...@@ -845,24 +845,24 @@ public class Function extends Expression implements FunctionCall { ...@@ -845,24 +845,24 @@ public class Function extends Expression implements FunctionCall {
return false; return false;
} }
private Value getValueWithArgs(Session session, Expression[] args) throws SQLException { private Value getValueWithArgs(Session session, Expression[] argList) throws SQLException {
if (info.nullIfParameterIsNull) { if (info.nullIfParameterIsNull) {
for (int i = 0; i < args.length; i++) { for (int i = 0; i < argList.length; i++) {
if (getNullOrValue(session, args, i) == ValueNull.INSTANCE) { if (getNullOrValue(session, argList, i) == ValueNull.INSTANCE) {
return ValueNull.INSTANCE; return ValueNull.INSTANCE;
} }
} }
} }
Value v0 = getNullOrValue(session, args, 0); Value v0 = getNullOrValue(session, argList, 0);
Value resultSimple = getSimpleValue(session, v0, args); Value resultSimple = getSimpleValue(session, v0, argList);
if (resultSimple != null) { if (resultSimple != null) {
return resultSimple; return resultSimple;
} }
Value v1 = getNullOrValue(session, args, 1); Value v1 = getNullOrValue(session, argList, 1);
Value v2 = getNullOrValue(session, args, 2); Value v2 = getNullOrValue(session, argList, 2);
Value v3 = getNullOrValue(session, args, 3); Value v3 = getNullOrValue(session, argList, 3);
Value v4 = getNullOrValue(session, args, 4); Value v4 = getNullOrValue(session, argList, 4);
Value v5 = getNullOrValue(session, args, 5); Value v5 = getNullOrValue(session, argList, 5);
Value result; Value result;
switch (info.type) { switch (info.type) {
case ATAN2: case ATAN2:
...@@ -1055,7 +1055,7 @@ public class Function extends Expression implements FunctionCall { ...@@ -1055,7 +1055,7 @@ public class Function extends Expression implements FunctionCall {
String fieldSeparatorRead = v3 == null ? null : v3.getString(); String fieldSeparatorRead = v3 == null ? null : v3.getString();
String fieldDelimiter = v4 == null ? null : v4.getString(); String fieldDelimiter = v4 == null ? null : v4.getString();
String escapeCharacter = v5 == null ? null : v5.getString(); String escapeCharacter = v5 == null ? null : v5.getString();
Value v6 = getNullOrValue(session, args, 6); Value v6 = getNullOrValue(session, argList, 6);
String nullString = v6 == null ? null : v6.getString(); String nullString = v6 == null ? null : v6.getString();
Csv csv = Csv.getInstance(); Csv csv = Csv.getInstance();
setCsvDelimiterEscape(csv, fieldSeparatorRead, fieldDelimiter, escapeCharacter); setCsvDelimiterEscape(csv, fieldSeparatorRead, fieldDelimiter, escapeCharacter);
...@@ -1081,9 +1081,9 @@ public class Function extends Expression implements FunctionCall { ...@@ -1081,9 +1081,9 @@ public class Function extends Expression implements FunctionCall {
String fieldSeparatorWrite = v3 == null ? null : v3.getString(); String fieldSeparatorWrite = v3 == null ? null : v3.getString();
String fieldDelimiter = v4 == null ? null : v4.getString(); String fieldDelimiter = v4 == null ? null : v4.getString();
String escapeCharacter = v5 == null ? null : v5.getString(); String escapeCharacter = v5 == null ? null : v5.getString();
Value v6 = getNullOrValue(session, args, 6); Value v6 = getNullOrValue(session, argList, 6);
String nullString = v6 == null ? null : v6.getString(); String nullString = v6 == null ? null : v6.getString();
Value v7 = getNullOrValue(session, args, 7); Value v7 = getNullOrValue(session, argList, 7);
String lineSeparator = v7 == null ? null : v7.getString(); String lineSeparator = v7 == null ? null : v7.getString();
Csv csv = Csv.getInstance(); Csv csv = Csv.getInstance();
setCsvDelimiterEscape(csv, fieldSeparatorWrite, fieldDelimiter, escapeCharacter); setCsvDelimiterEscape(csv, fieldSeparatorWrite, fieldDelimiter, escapeCharacter);
...@@ -1096,7 +1096,7 @@ public class Function extends Expression implements FunctionCall { ...@@ -1096,7 +1096,7 @@ public class Function extends Expression implements FunctionCall {
break; break;
} }
case SET: { case SET: {
Variable var = (Variable) args[0]; Variable var = (Variable) argList[0];
session.setVariable(var.getName(), v1); session.setVariable(var.getName(), v1);
result = v1; result = v1;
break; break;
...@@ -1104,7 +1104,7 @@ public class Function extends Expression implements FunctionCall { ...@@ -1104,7 +1104,7 @@ public class Function extends Expression implements FunctionCall {
case FILE_READ: { case FILE_READ: {
session.getUser().checkAdmin(); session.getUser().checkAdmin();
String fileName = v0.getString(); String fileName = v0.getString();
boolean blob = args.length == 1; boolean blob = argList.length == 1;
try { try {
InputStream in = new AutoCloseInputStream(FileUtils.openFileInputStream(fileName)); InputStream in = new AutoCloseInputStream(FileUtils.openFileInputStream(fileName));
if (blob) { if (blob) {
...@@ -1868,18 +1868,18 @@ public class Function extends Expression implements FunctionCall { ...@@ -1868,18 +1868,18 @@ public class Function extends Expression implements FunctionCall {
return args.length; return args.length;
} }
public ValueResultSet getValueForColumnList(Session session, Expression[] args) throws SQLException { public ValueResultSet getValueForColumnList(Session session, Expression[] argList) throws SQLException {
switch (info.type) { switch (info.type) {
case CSVREAD: { case CSVREAD: {
String fileName = args[0].getValue(session).getString(); String fileName = argList[0].getValue(session).getString();
if (fileName == null) { if (fileName == null) {
throw Message.getSQLException(ErrorCode.PARAMETER_NOT_SET_1, "fileName"); throw Message.getSQLException(ErrorCode.PARAMETER_NOT_SET_1, "fileName");
} }
String columnList = args.length < 2 ? null : args[1].getValue(session).getString(); String columnList = argList.length < 2 ? null : argList[1].getValue(session).getString();
String charset = args.length < 3 ? null : args[2].getValue(session).getString(); String charset = argList.length < 3 ? null : argList[2].getValue(session).getString();
String fieldSeparatorRead = args.length < 4 ? null : args[3].getValue(session).getString(); String fieldSeparatorRead = argList.length < 4 ? null : argList[3].getValue(session).getString();
String fieldDelimiter = args.length < 5 ? null : args[4].getValue(session).getString(); String fieldDelimiter = argList.length < 5 ? null : argList[4].getValue(session).getString();
String escapeCharacter = args.length < 6 ? null : args[5].getValue(session).getString(); String escapeCharacter = argList.length < 6 ? null : argList[5].getValue(session).getString();
Csv csv = Csv.getInstance(); Csv csv = Csv.getInstance();
setCsvDelimiterEscape(csv, fieldSeparatorRead, fieldDelimiter, escapeCharacter); setCsvDelimiterEscape(csv, fieldSeparatorRead, fieldDelimiter, escapeCharacter);
char fieldSeparator = csv.getFieldSeparatorRead(); char fieldSeparator = csv.getFieldSeparatorRead();
...@@ -1896,7 +1896,7 @@ public class Function extends Expression implements FunctionCall { ...@@ -1896,7 +1896,7 @@ public class Function extends Expression implements FunctionCall {
default: default:
break; break;
} }
return (ValueResultSet) getValueWithArgs(session, args); return (ValueResultSet) getValueWithArgs(session, argList);
} }
private void setCsvDelimiterEscape(Csv csv, String fieldSeparator, String fieldDelimiter, String escapeCharacter) { private void setCsvDelimiterEscape(Csv csv, String fieldSeparator, String fieldDelimiter, String escapeCharacter) {
......
...@@ -107,8 +107,8 @@ public class JavaFunction extends Expression implements FunctionCall { ...@@ -107,8 +107,8 @@ public class JavaFunction extends Expression implements FunctionCall {
return javaMethod.getParameterCount(); return javaMethod.getParameterCount();
} }
public ValueResultSet getValueForColumnList(Session session, Expression[] args) throws SQLException { public ValueResultSet getValueForColumnList(Session session, Expression[] argList) throws SQLException {
Value v = javaMethod.getValue(session, args, true); Value v = javaMethod.getValue(session, argList, true);
return v == ValueNull.INSTANCE ? null : (ValueResultSet) v; return v == ValueNull.INSTANCE ? null : (ValueResultSet) v;
} }
......
...@@ -74,7 +74,7 @@ public class TableFunction extends Function { ...@@ -74,7 +74,7 @@ public class TableFunction extends Function {
columns.toArray(columnList); columns.toArray(columnList);
} }
private ValueResultSet getTable(Session session, Expression[] args, boolean onlyColumnList, boolean distinct) throws SQLException { private ValueResultSet getTable(Session session, Expression[] argList, boolean onlyColumnList, boolean distinctRows) throws SQLException {
int len = columnList.length; int len = columnList.length;
Expression[] header = new Expression[len]; Expression[] header = new Expression[len];
Database db = session.getDatabase(); Database db = session.getDatabase();
...@@ -84,24 +84,24 @@ public class TableFunction extends Function { ...@@ -84,24 +84,24 @@ public class TableFunction extends Function {
header[i] = col; header[i] = col;
} }
LocalResult result = new LocalResult(session, header, len); LocalResult result = new LocalResult(session, header, len);
if (distinct) { if (distinctRows) {
result.setDistinct(); result.setDistinct();
} }
if (!onlyColumnList) { if (!onlyColumnList) {
Value[][] list = new Value[len][]; Value[][] list = new Value[len][];
int rowCount = 0; int rows = 0;
for (int i = 0; i < len; i++) { for (int i = 0; i < len; i++) {
Value v = args[i].getValue(session); Value v = argList[i].getValue(session);
if (v == ValueNull.INSTANCE) { if (v == ValueNull.INSTANCE) {
list[i] = new Value[0]; list[i] = new Value[0];
} else { } else {
ValueArray array = (ValueArray) v.convertTo(Value.ARRAY); ValueArray array = (ValueArray) v.convertTo(Value.ARRAY);
Value[] l = array.getList(); Value[] l = array.getList();
list[i] = l; list[i] = l;
rowCount = Math.max(rowCount, l.length); rows = Math.max(rows, l.length);
} }
} }
for (int row = 0; row < rowCount; row++) { for (int row = 0; row < rows; row++) {
Value[] r = new Value[len]; Value[] r = new Value[len];
for (int j = 0; j < len; j++) { for (int j = 0; j < len; j++) {
Value[] l = list[j]; Value[] l = list[j];
......
...@@ -871,16 +871,16 @@ public class FullText { ...@@ -871,16 +871,16 @@ public class FullText {
if (newRow != null) { if (newRow != null) {
// update // update
if (hasChanged(oldRow, newRow, index.indexColumns)) { if (hasChanged(oldRow, newRow, index.indexColumns)) {
delete(setting, oldRow); delete(oldRow);
insert(setting, newRow); insert(newRow);
} }
} else { } else {
// delete // delete
delete(setting, oldRow); delete(oldRow);
} }
} else if (newRow != null) { } else if (newRow != null) {
// insert // insert
insert(setting, newRow); insert(newRow);
} }
} }
...@@ -901,10 +901,9 @@ public class FullText { ...@@ -901,10 +901,9 @@ public class FullText {
/** /**
* Add a row to the index. * Add a row to the index.
* *
* @param setting the setting
* @param row the row * @param row the row
*/ */
protected void insert(FullTextSettings setting, Object[] row) throws SQLException { protected void insert(Object[] row) throws SQLException {
String key = getKey(row); String key = getKey(row);
int hash = key.hashCode(); int hash = key.hashCode();
prepInsertRow.setInt(1, hash); prepInsertRow.setInt(1, hash);
...@@ -915,7 +914,7 @@ public class FullText { ...@@ -915,7 +914,7 @@ public class FullText {
rs.next(); rs.next();
int rowId = rs.getInt(1); int rowId = rs.getInt(1);
prepInsertMap.setInt(1, rowId); prepInsertMap.setInt(1, rowId);
int[] wordIds = getWordIds(setting, row); int[] wordIds = getWordIds(row);
for (int id : wordIds) { for (int id : wordIds) {
prepInsertMap.setInt(2, id); prepInsertMap.setInt(2, id);
prepInsertMap.execute(); prepInsertMap.execute();
...@@ -925,10 +924,9 @@ public class FullText { ...@@ -925,10 +924,9 @@ public class FullText {
/** /**
* Delete a row from the index. * Delete a row from the index.
* *
* @param setting the setting
* @param row the row * @param row the row
*/ */
protected void delete(FullTextSettings setting, Object[] row) throws SQLException { protected void delete(Object[] row) throws SQLException {
String key = getKey(row); String key = getKey(row);
int hash = key.hashCode(); int hash = key.hashCode();
prepSelectRow.setInt(1, hash); prepSelectRow.setInt(1, hash);
...@@ -938,7 +936,7 @@ public class FullText { ...@@ -938,7 +936,7 @@ public class FullText {
if (rs.next()) { if (rs.next()) {
int rowId = rs.getInt(1); int rowId = rs.getInt(1);
prepDeleteMap.setInt(1, rowId); prepDeleteMap.setInt(1, rowId);
int[] wordIds = getWordIds(setting, row); int[] wordIds = getWordIds(row);
for (int id : wordIds) { for (int id : wordIds) {
prepDeleteMap.setInt(2, id); prepDeleteMap.setInt(2, id);
prepDeleteMap.executeUpdate(); prepDeleteMap.executeUpdate();
...@@ -950,7 +948,7 @@ public class FullText { ...@@ -950,7 +948,7 @@ public class FullText {
} }
} }
private int[] getWordIds(FullTextSettings setting, Object[] row) throws SQLException { private int[] getWordIds(Object[] row) throws SQLException {
HashSet<String> words = New.hashSet(); HashSet<String> words = New.hashSet();
for (int i = 0; i < index.indexColumns.length; i++) { for (int i = 0; i < index.indexColumns.length; i++) {
int idx = index.indexColumns[i]; int idx = index.indexColumns[i];
......
...@@ -43,23 +43,23 @@ public abstract class BaseIndex extends SchemaObjectBase implements Index { ...@@ -43,23 +43,23 @@ public abstract class BaseIndex extends SchemaObjectBase implements Index {
/** /**
* Initialize the base index. * Initialize the base index.
* *
* @param table the table * @param newTable the table
* @param id the object id * @param id the object id
* @param name the index name * @param name the index name
* @param indexColumns the columns that are indexed or null if this is not * @param newIndexColumns the columns that are indexed or null if this is
* yet known * not yet known
* @param indexType the index type * @param newIndexType the index type
*/ */
void initBaseIndex(Table table, int id, String name, IndexColumn[] indexColumns, IndexType indexType) { void initBaseIndex(Table newTable, int id, String name, IndexColumn[] newIndexColumns, IndexType newIndexType) {
initSchemaObjectBase(table.getSchema(), id, name, Trace.INDEX); initSchemaObjectBase(newTable.getSchema(), id, name, Trace.INDEX);
this.indexType = indexType; this.indexType = newIndexType;
this.table = table; this.table = newTable;
if (indexColumns != null) { if (newIndexColumns != null) {
this.indexColumns = indexColumns; this.indexColumns = newIndexColumns;
columns = new Column[indexColumns.length]; columns = new Column[newIndexColumns.length];
columnIds = new int[columns.length]; columnIds = new int[columns.length];
for (int i = 0; i < columns.length; i++) { for (int i = 0; i < columns.length; i++) {
Column col = indexColumns[i].column; Column col = newIndexColumns[i].column;
columns[i] = col; columns[i] = col;
columnIds[i] = col.getColumnId(); columnIds[i] = col.getColumnId();
} }
......
...@@ -60,11 +60,11 @@ public class IndexCursor implements Cursor { ...@@ -60,11 +60,11 @@ public class IndexCursor implements Cursor {
/** /**
* Re-evaluate the start and end values of the index search for rows. * Re-evaluate the start and end values of the index search for rows.
* *
* @param session the session * @param s the session
* @param indexConditions the index conditions * @param indexConditions the index conditions
*/ */
public void find(Session session, ObjectArray<IndexCondition> indexConditions) throws SQLException { public void find(Session s, ObjectArray<IndexCondition> indexConditions) throws SQLException {
this.session = session; this.session = s;
alwaysFalse = false; alwaysFalse = false;
start = end = null; start = end = null;
inList = null; inList = null;
...@@ -79,16 +79,16 @@ public class IndexCursor implements Cursor { ...@@ -79,16 +79,16 @@ public class IndexCursor implements Cursor {
if (condition.getCompareType() == Comparison.IN_LIST) { if (condition.getCompareType() == Comparison.IN_LIST) {
if (start == null && end == null) { if (start == null && end == null) {
this.inColumn = column; this.inColumn = column;
inList = condition.getCurrentValueList(session); inList = condition.getCurrentValueList(s);
inListIndex = 0; inListIndex = 0;
} }
} else if (condition.getCompareType() == Comparison.IN_QUERY) { } else if (condition.getCompareType() == Comparison.IN_QUERY) {
if (start == null && end == null) { if (start == null && end == null) {
this.inColumn = column; this.inColumn = column;
inResult = condition.getCurrentResult(session); inResult = condition.getCurrentResult(s);
} }
} else { } else {
Value v = column.convert(condition.getCurrentValue(session)); Value v = column.convert(condition.getCurrentValue(s));
boolean isStart = condition.isStart(); boolean isStart = condition.isStart();
boolean isEnd = condition.isEnd(); boolean isEnd = condition.isEnd();
int id = column.getColumnId(); int id = column.getColumnId();
...@@ -125,7 +125,7 @@ public class IndexCursor implements Cursor { ...@@ -125,7 +125,7 @@ public class IndexCursor implements Cursor {
return; return;
} }
if (!alwaysFalse) { if (!alwaysFalse) {
cursor = index.find(session, start, end); cursor = index.find(s, start, end);
} }
} }
......
...@@ -35,10 +35,10 @@ public class ViewIndex extends BaseIndex { ...@@ -35,10 +35,10 @@ public class ViewIndex extends BaseIndex {
private final ObjectArray<Parameter> originalParameters; private final ObjectArray<Parameter> originalParameters;
private final SmallLRUCache<IntArray, CostElement> costCache = SmallLRUCache.newInstance(Constants.VIEW_INDEX_CACHE_SIZE); private final SmallLRUCache<IntArray, CostElement> costCache = SmallLRUCache.newInstance(Constants.VIEW_INDEX_CACHE_SIZE);
private boolean recursive; private boolean recursive;
private int[] masks; private int[] indexMasks;
private String planSQL; private String planSQL;
private Query query; private Query query;
private Session session; private Session createSession;
public ViewIndex(TableView view, String querySQL, ObjectArray<Parameter> originalParameters, boolean recursive) { public ViewIndex(TableView view, String querySQL, ObjectArray<Parameter> originalParameters, boolean recursive) {
initBaseIndex(view, 0, null, null, IndexType.createNonUnique(false)); initBaseIndex(view, 0, null, null, IndexType.createNonUnique(false));
...@@ -55,15 +55,15 @@ public class ViewIndex extends BaseIndex { ...@@ -55,15 +55,15 @@ public class ViewIndex extends BaseIndex {
this.querySQL = index.querySQL; this.querySQL = index.querySQL;
this.originalParameters = index.originalParameters; this.originalParameters = index.originalParameters;
this.recursive = index.recursive; this.recursive = index.recursive;
this.masks = masks; this.indexMasks = masks;
this.session = session; this.createSession = session;
columns = new Column[0]; columns = new Column[0];
query = getQuery(session, masks); query = getQuery(session, masks);
planSQL = query.getPlanSQL(); planSQL = query.getPlanSQL();
} }
public Session getSession() { public Session getSession() {
return session; return createSession;
} }
public String getPlanSQL() { public String getPlanSQL() {
...@@ -107,7 +107,7 @@ public class ViewIndex extends BaseIndex { ...@@ -107,7 +107,7 @@ public class ViewIndex extends BaseIndex {
return cachedCost.cost; return cachedCost.cost;
} }
} }
Query query = (Query) session.prepare(querySQL, true); Query q = (Query) session.prepare(querySQL, true);
if (masks != null) { if (masks != null) {
IntArray paramIndex = new IntArray(); IntArray paramIndex = new IntArray();
for (int i = 0; i < masks.length; i++) { for (int i = 0; i < masks.length; i++) {
...@@ -121,28 +121,28 @@ public class ViewIndex extends BaseIndex { ...@@ -121,28 +121,28 @@ public class ViewIndex extends BaseIndex {
for (int i = 0; i < len; i++) { for (int i = 0; i < len; i++) {
int idx = paramIndex.get(i); int idx = paramIndex.get(i);
int mask = masks[idx]; int mask = masks[idx];
int nextParamIndex = query.getParameters().size() + view.getParameterOffset(); int nextParamIndex = q.getParameters().size() + view.getParameterOffset();
if ((mask & IndexCondition.EQUALITY) != 0) { if ((mask & IndexCondition.EQUALITY) != 0) {
Parameter param = new Parameter(nextParamIndex); Parameter param = new Parameter(nextParamIndex);
query.addGlobalCondition(param, idx, Comparison.EQUAL); q.addGlobalCondition(param, idx, Comparison.EQUAL);
} else { } else {
if ((mask & IndexCondition.START) != 0) { if ((mask & IndexCondition.START) != 0) {
Parameter param = new Parameter(nextParamIndex); Parameter param = new Parameter(nextParamIndex);
query.addGlobalCondition(param, idx, Comparison.BIGGER_EQUAL); q.addGlobalCondition(param, idx, Comparison.BIGGER_EQUAL);
} }
if ((mask & IndexCondition.END) != 0) { if ((mask & IndexCondition.END) != 0) {
Parameter param = new Parameter(nextParamIndex); Parameter param = new Parameter(nextParamIndex);
query.addGlobalCondition(param, idx, Comparison.SMALLER_EQUAL); q.addGlobalCondition(param, idx, Comparison.SMALLER_EQUAL);
} }
} }
} }
if (recursive) { if (recursive) {
return 10; return 10;
} }
String sql = query.getPlanSQL(); String sql = q.getPlanSQL();
query = (Query) session.prepare(sql, true); q = (Query) session.prepare(sql, true);
} }
double cost = query.getCost(); double cost = q.getCost();
cachedCost = new CostElement(); cachedCost = new CostElement();
cachedCost.evaluatedAt = System.currentTimeMillis(); cachedCost.evaluatedAt = System.currentTimeMillis();
cachedCost.cost = cost; cachedCost.cost = cost;
...@@ -181,7 +181,7 @@ public class ViewIndex extends BaseIndex { ...@@ -181,7 +181,7 @@ public class ViewIndex extends BaseIndex {
} }
} }
// for equality, only one parameter is used (first == last) // for equality, only one parameter is used (first == last)
if (last != null && masks[i] != IndexCondition.EQUALITY) { if (last != null && indexMasks[i] != IndexCondition.EQUALITY) {
Value v = last.getValue(i); Value v = last.getValue(i);
if (v != null) { if (v != null) {
Parameter param = paramList.get(idx++); Parameter param = paramList.get(idx++);
...@@ -194,9 +194,9 @@ public class ViewIndex extends BaseIndex { ...@@ -194,9 +194,9 @@ public class ViewIndex extends BaseIndex {
} }
private Query getQuery(Session session, int[] masks) throws SQLException { private Query getQuery(Session session, int[] masks) throws SQLException {
Query query = (Query) session.prepare(querySQL, true); Query q = (Query) session.prepare(querySQL, true);
if (masks == null) { if (masks == null) {
return query; return q;
} }
int firstIndexParam = originalParameters == null ? 0 : originalParameters.size(); int firstIndexParam = originalParameters == null ? 0 : originalParameters.size();
firstIndexParam += view.getParameterOffset(); firstIndexParam += view.getParameterOffset();
...@@ -221,24 +221,24 @@ public class ViewIndex extends BaseIndex { ...@@ -221,24 +221,24 @@ public class ViewIndex extends BaseIndex {
int mask = masks[idx]; int mask = masks[idx];
if ((mask & IndexCondition.EQUALITY) == IndexCondition.EQUALITY) { if ((mask & IndexCondition.EQUALITY) == IndexCondition.EQUALITY) {
Parameter param = new Parameter(firstIndexParam + i); Parameter param = new Parameter(firstIndexParam + i);
query.addGlobalCondition(param, idx, Comparison.EQUAL); q.addGlobalCondition(param, idx, Comparison.EQUAL);
i++; i++;
} else { } else {
if ((mask & IndexCondition.START) == IndexCondition.START) { if ((mask & IndexCondition.START) == IndexCondition.START) {
Parameter param = new Parameter(firstIndexParam + i); Parameter param = new Parameter(firstIndexParam + i);
query.addGlobalCondition(param, idx, Comparison.BIGGER_EQUAL); q.addGlobalCondition(param, idx, Comparison.BIGGER_EQUAL);
i++; i++;
} }
if ((mask & IndexCondition.END) == IndexCondition.END) { if ((mask & IndexCondition.END) == IndexCondition.END) {
Parameter param = new Parameter(firstIndexParam + i); Parameter param = new Parameter(firstIndexParam + i);
query.addGlobalCondition(param, idx, Comparison.SMALLER_EQUAL); q.addGlobalCondition(param, idx, Comparison.SMALLER_EQUAL);
i++; i++;
} }
} }
} }
String sql = query.getPlanSQL(); String sql = q.getPlanSQL();
query = (Query) session.prepare(sql, true); q = (Query) session.prepare(sql, true);
return query; return q;
} }
public void remove(Session session) throws SQLException { public void remove(Session session) throws SQLException {
......
...@@ -35,7 +35,7 @@ public class ResultTempTable implements ResultExternal { ...@@ -35,7 +35,7 @@ public class ResultTempTable implements ResultExternal {
private TableData table; private TableData table;
private SortOrder sort; private SortOrder sort;
private Index index; private Index index;
private Cursor cursor; private Cursor resultCursor;
public ResultTempTable(Session session, SortOrder sort) throws SQLException { public ResultTempTable(Session session, SortOrder sort) throws SQLException {
this.session = session; this.session = session;
...@@ -137,16 +137,16 @@ public class ResultTempTable implements ResultExternal { ...@@ -137,16 +137,16 @@ public class ResultTempTable implements ResultExternal {
} }
public Value[] next() throws SQLException { public Value[] next() throws SQLException {
if (!cursor.next()) { if (!resultCursor.next()) {
return null; return null;
} }
Row row = cursor.get(); Row row = resultCursor.get();
ValueArray data = (ValueArray) row.getValue(0); ValueArray data = (ValueArray) row.getValue(0);
return data.getList(); return data.getList();
} }
public void reset() throws SQLException { public void reset() throws SQLException {
cursor = index.find(session, null, null); resultCursor = index.find(session, null, null);
} }
private Row convertToRow(Value[] values) { private Row convertToRow(Value[] values) {
......
...@@ -577,9 +577,9 @@ public class Recover extends Tool implements DataHandler { ...@@ -577,9 +577,9 @@ public class Recover extends Tool implements DataHandler {
sessionCommit.put(sessionId, pos); sessionCommit.put(sessionId, pos);
} }
} else { } else {
int storageId = s.readInt(); int sId = s.readInt();
int recId = s.readInt(); int recId = s.readInt();
int blockCount = s.readInt(); int bCount = s.readInt();
if (type != 'T') { if (type != 'T') {
s.readDataPageNoSize(); s.readDataPageNoSize();
} }
...@@ -600,9 +600,9 @@ public class Recover extends Tool implements DataHandler { ...@@ -600,9 +600,9 @@ public class Recover extends Tool implements DataHandler {
case 'T': case 'T':
containsUncommitted = true; containsUncommitted = true;
if (!onlySetSessionState) { if (!onlySetSessionState) {
writer.println("// truncate session: "+sessionId+" storage: " + storageId + " pos: " + recId + " blockCount: "+blockCount); writer.println("// truncate session: "+sessionId+" storage: " + sId + " pos: " + recId + " blockCount: "+bCount);
if (sessionCommit.get(sessionId) >= pos) { if (sessionCommit.get(sessionId) >= pos) {
setStorage(storageId); setStorage(sId);
writer.println("TRUNCATE TABLE " + storageName + ";"); writer.println("TRUNCATE TABLE " + storageName + ";");
} }
} }
...@@ -610,10 +610,10 @@ public class Recover extends Tool implements DataHandler { ...@@ -610,10 +610,10 @@ public class Recover extends Tool implements DataHandler {
case 'I': case 'I':
containsUncommitted = true; containsUncommitted = true;
if (!onlySetSessionState) { if (!onlySetSessionState) {
writer.println("// insert session: "+sessionId+" storage: " + storageId + " pos: " + recId + " blockCount: "+blockCount); writer.println("// insert session: "+sessionId+" storage: " + sId + " pos: " + recId + " blockCount: "+bCount);
if (storageId >= 0) { if (sId >= 0) {
if (sessionCommit.get(sessionId) >= pos) { if (sessionCommit.get(sessionId) >= pos) {
setStorage(storageId); setStorage(sId);
writeLogRecord(writer, s, true); writeLogRecord(writer, s, true);
} }
} }
...@@ -622,10 +622,10 @@ public class Recover extends Tool implements DataHandler { ...@@ -622,10 +622,10 @@ public class Recover extends Tool implements DataHandler {
case 'D': case 'D':
containsUncommitted = true; containsUncommitted = true;
if (!onlySetSessionState) { if (!onlySetSessionState) {
writer.println("// delete session: "+sessionId+" storage: " + storageId + " pos: " + recId + " blockCount: "+blockCount); writer.println("// delete session: "+sessionId+" storage: " + sId + " pos: " + recId + " blockCount: "+bCount);
if (storageId >= 0) { if (sId >= 0) {
if (sessionCommit.get(sessionId) >= pos) { if (sessionCommit.get(sessionId) >= pos) {
setStorage(storageId); setStorage(sId);
writeLogRecord(writer, s, false); writeLogRecord(writer, s, false);
} }
} }
...@@ -634,7 +634,7 @@ public class Recover extends Tool implements DataHandler { ...@@ -634,7 +634,7 @@ public class Recover extends Tool implements DataHandler {
default: default:
containsUncommitted = true; containsUncommitted = true;
if (!onlySetSessionState) { if (!onlySetSessionState) {
writer.println("// type?: "+type+" session: "+sessionId+" storage: " + storageId + " pos: " + recId + " blockCount: "+blockCount); writer.println("// type?: "+type+" session: "+sessionId+" storage: " + sId + " pos: " + recId + " blockCount: "+bCount);
} }
break; break;
} }
...@@ -685,9 +685,9 @@ public class Recover extends Tool implements DataHandler { ...@@ -685,9 +685,9 @@ public class Recover extends Tool implements DataHandler {
writer.println("//"); writer.println("//");
int len = in.readInt(); int len = in.readInt();
for (int i = 0; i < len; i++) { for (int i = 0; i < len; i++) {
int storageId = in.readInt(); int sId = in.readInt();
if (storageId != -1) { if (sId != -1) {
writer.println("// pos: " + (i * DiskFile.BLOCKS_PER_PAGE) + " storage: " + storageId); writer.println("// pos: " + (i * DiskFile.BLOCKS_PER_PAGE) + " storage: " + sId);
} }
} }
while (true) { while (true) {
...@@ -705,22 +705,22 @@ public class Recover extends Tool implements DataHandler { ...@@ -705,22 +705,22 @@ public class Recover extends Tool implements DataHandler {
private void dumpIndex(String fileName) { private void dumpIndex(String fileName) {
PrintWriter writer = null; PrintWriter writer = null;
FileStore store = null; FileStore fileStore = null;
try { try {
setDatabaseName(fileName.substring(fileName.length() - Constants.SUFFIX_INDEX_FILE.length())); setDatabaseName(fileName.substring(fileName.length() - Constants.SUFFIX_INDEX_FILE.length()));
writer = getWriter(fileName, ".txt"); writer = getWriter(fileName, ".txt");
store = FileStore.open(null, fileName, "r"); fileStore = FileStore.open(null, fileName, "r");
long length = store.length(); long length = fileStore.length();
int offset = FileStore.HEADER_LENGTH; int offset = FileStore.HEADER_LENGTH;
int blockSize = DiskFile.BLOCK_SIZE; int blockSize = DiskFile.BLOCK_SIZE;
int blocks = (int) (length / blockSize); int blocks = (int) (length / blockSize);
blockCount = 1; blockCount = 1;
int[] pageOwners = new int[blocks / DiskFile.BLOCKS_PER_PAGE]; int[] pageOwners = new int[blocks / DiskFile.BLOCKS_PER_PAGE];
for (block = 0; block < blocks; block += blockCount) { for (block = 0; block < blocks; block += blockCount) {
store.seek(offset + (long) block * blockSize); fileStore.seek(offset + (long) block * blockSize);
byte[] buff = new byte[blockSize]; byte[] buff = new byte[blockSize];
DataPage s = DataPage.create(this, buff); DataPage s = DataPage.create(this, buff);
store.readFully(buff, 0, blockSize); fileStore.readFully(buff, 0, blockSize);
blockCount = s.readInt(); blockCount = s.readInt();
setStorage(-1); setStorage(-1);
recordLength = -1; recordLength = -1;
...@@ -746,7 +746,7 @@ public class Recover extends Tool implements DataHandler { ...@@ -746,7 +746,7 @@ public class Recover extends Tool implements DataHandler {
continue; continue;
} }
if (blockCount > 1) { if (blockCount > 1) {
store.readFully(s.getBytes(), blockSize, blockCount * blockSize - blockSize); fileStore.readFully(s.getBytes(), blockSize, blockCount * blockSize - blockSize);
} }
try { try {
s.check(blockCount * blockSize); s.check(blockCount * blockSize);
...@@ -799,7 +799,7 @@ public class Recover extends Tool implements DataHandler { ...@@ -799,7 +799,7 @@ public class Recover extends Tool implements DataHandler {
e.printStackTrace(); e.printStackTrace();
} finally { } finally {
IOUtils.closeSilently(writer); IOUtils.closeSilently(writer);
closeSilently(store); closeSilently(fileStore);
} }
} }
......
...@@ -541,7 +541,7 @@ public class TestFunctions extends TestBase implements AggregateFunction { ...@@ -541,7 +541,7 @@ public class TestFunctions extends TestBase implements AggregateFunction {
/** /**
* Test method to create a simple result set. * Test method to create a simple result set.
* *
* @param count the number of rows * @param rowCount the number of rows
* @param ip an int * @param ip an int
* @param bp a boolean * @param bp a boolean
* @param fp a float * @param fp a float
...@@ -551,24 +551,24 @@ public class TestFunctions extends TestBase implements AggregateFunction { ...@@ -551,24 +551,24 @@ public class TestFunctions extends TestBase implements AggregateFunction {
* @param sp a short * @param sp a short
* @return a result set * @return a result set
*/ */
public static ResultSet simpleResultSet(Integer count, int ip, boolean bp, float fp, double dp, long lp, public static ResultSet simpleResultSet(Integer rowCount, int ip, boolean bp, float fp, double dp, long lp,
byte byParam, short sp) throws SQLException { byte byParam, short sp) throws SQLException {
SimpleResultSet rs = new SimpleResultSet(); SimpleResultSet rs = new SimpleResultSet();
rs.addColumn("ID", Types.INTEGER, 10, 0); rs.addColumn("ID", Types.INTEGER, 10, 0);
rs.addColumn("NAME", Types.VARCHAR, 255, 0); rs.addColumn("NAME", Types.VARCHAR, 255, 0);
if (count == null) { if (rowCount == null) {
if (ip != 0 || bp || fp != 0.0 || dp != 0.0 || sp != 0 || lp != 0 || byParam != 0) { if (ip != 0 || bp || fp != 0.0 || dp != 0.0 || sp != 0 || lp != 0 || byParam != 0) {
throw new AssertionError("params not 0/false"); throw new AssertionError("params not 0/false");
} }
} }
if (count != null) { if (rowCount != null) {
if (ip != 1 || !bp || fp != 1.0 || dp != 1.0 || sp != 1 || lp != 1 || byParam != 1) { if (ip != 1 || !bp || fp != 1.0 || dp != 1.0 || sp != 1 || lp != 1 || byParam != 1) {
throw new AssertionError("params not 1/true"); throw new AssertionError("params not 1/true");
} }
if (count.intValue() >= 1) { if (rowCount.intValue() >= 1) {
rs.addRow(0, "Hello"); rs.addRow(0, "Hello");
} }
if (count.intValue() >= 2) { if (rowCount.intValue() >= 2) {
rs.addRow(1, "World"); rs.addRow(1, "World");
} }
} }
......
...@@ -61,8 +61,8 @@ public class TestBatchUpdates extends TestBase { ...@@ -61,8 +61,8 @@ public class TestBatchUpdates extends TestBase {
private void testExecuteCall() throws SQLException { private void testExecuteCall() throws SQLException {
deleteDb("batchUpdates"); deleteDb("batchUpdates");
Connection conn = getConnection("batchUpdates"); conn = getConnection("batchUpdates");
Statement stat = conn.createStatement(); stat = conn.createStatement();
stat.execute("CREATE ALIAS updatePrices FOR \"" + getClass().getName() + ".updatePrices\""); stat.execute("CREATE ALIAS updatePrices FOR \"" + getClass().getName() + ".updatePrices\"");
CallableStatement call = conn.prepareCall("{call updatePrices(?, ?)}"); CallableStatement call = conn.prepareCall("{call updatePrices(?, ?)}");
call.setString(1, "Hello"); call.setString(1, "Hello");
...@@ -93,10 +93,10 @@ public class TestBatchUpdates extends TestBase { ...@@ -93,10 +93,10 @@ public class TestBatchUpdates extends TestBase {
private void testException() throws SQLException { private void testException() throws SQLException {
deleteDb("batchUpdates"); deleteDb("batchUpdates");
Connection conn = getConnection("batchUpdates"); conn = getConnection("batchUpdates");
Statement stat = conn.createStatement(); stat = conn.createStatement();
stat.execute("create table test(id int primary key)"); stat.execute("create table test(id int primary key)");
PreparedStatement prep = conn.prepareStatement("insert into test values(?)"); prep = conn.prepareStatement("insert into test values(?)");
for (int i = 0; i < 700; i++) { for (int i = 0; i < 700; i++) {
prep.setString(1, "x"); prep.setString(1, "x");
prep.addBatch(); prep.addBatch();
...@@ -119,7 +119,7 @@ public class TestBatchUpdates extends TestBase { ...@@ -119,7 +119,7 @@ public class TestBatchUpdates extends TestBase {
private void testCoffee() throws SQLException { private void testCoffee() throws SQLException {
deleteDb("batchUpdates"); deleteDb("batchUpdates");
this.conn = getConnection("batchUpdates"); conn = getConnection("batchUpdates");
stat = conn.createStatement(); stat = conn.createStatement();
DatabaseMetaData meta = conn.getMetaData(); DatabaseMetaData meta = conn.getMetaData();
if (!meta.supportsBatchUpdates()) { if (!meta.supportsBatchUpdates()) {
......
...@@ -197,7 +197,7 @@ public class TestMetaData extends TestBase { ...@@ -197,7 +197,7 @@ public class TestMetaData extends TestBase {
trace(name + "=" + value); trace(name + "=" + value);
} }
test(conn); testMore();
// meta.getTablePrivileges() // meta.getTablePrivileges()
...@@ -215,17 +215,17 @@ public class TestMetaData extends TestBase { ...@@ -215,17 +215,17 @@ public class TestMetaData extends TestBase {
} }
private void testColumnLobMeta() throws SQLException { private void testColumnLobMeta() throws SQLException {
Statement stat = conn.createStatement(); stat = conn.createStatement();
stat.executeUpdate("CREATE TABLE t (blob BLOB, clob CLOB)"); stat.executeUpdate("CREATE TABLE t (blob BLOB, clob CLOB)");
stat.execute("INSERT INTO t VALUES('', '')"); stat.execute("INSERT INTO t VALUES('', '')");
ResultSet rs = stat.executeQuery("SELECT blob,clob FROM t"); ResultSet rs = stat.executeQuery("SELECT blob,clob FROM t");
ResultSetMetaData meta = rs.getMetaData(); ResultSetMetaData rsMeta = rs.getMetaData();
if (SysProperties.RETURN_LOB_OBJECTS) { if (SysProperties.RETURN_LOB_OBJECTS) {
assertEquals("java.sql.Blob", meta.getColumnClassName(1)); assertEquals("java.sql.Blob", rsMeta.getColumnClassName(1));
assertEquals("java.sql.Clob", meta.getColumnClassName(2)); assertEquals("java.sql.Clob", rsMeta.getColumnClassName(2));
} else { } else {
assertEquals("java.io.InputStream", meta.getColumnClassName(1)); assertEquals("java.io.InputStream", rsMeta.getColumnClassName(1));
assertEquals("java.io.Reader", meta.getColumnClassName(2)); assertEquals("java.io.Reader", rsMeta.getColumnClassName(2));
} }
rs.next(); rs.next();
if (SysProperties.RETURN_LOB_OBJECTS) { if (SysProperties.RETURN_LOB_OBJECTS) {
...@@ -239,50 +239,50 @@ public class TestMetaData extends TestBase { ...@@ -239,50 +239,50 @@ public class TestMetaData extends TestBase {
} }
private void testColumnMetaData() throws SQLException { private void testColumnMetaData() throws SQLException {
String statement = "select substring('Hello',0,1)"; String sql = "select substring('Hello',0,1)";
ResultSet rs = conn.prepareStatement(statement).executeQuery(); ResultSet rs = conn.prepareStatement(sql).executeQuery();
rs.next(); rs.next();
int type = rs.getMetaData().getColumnType(1); int type = rs.getMetaData().getColumnType(1);
assertEquals(Types.VARCHAR, type); assertEquals(Types.VARCHAR, type);
rs = conn.createStatement().executeQuery("SELECT COUNT(*) C FROM DUAL"); rs = conn.createStatement().executeQuery("SELECT COUNT(*) C FROM DUAL");
assertEquals("C", rs.getMetaData().getColumnName(1)); assertEquals("C", rs.getMetaData().getColumnName(1));
Statement stat = conn.createStatement(); stat = conn.createStatement();
stat.execute("create table a(x array)"); stat.execute("create table a(x array)");
stat.execute("insert into a values((1, 2))"); stat.execute("insert into a values((1, 2))");
rs = stat.executeQuery("SELECT x[1] FROM a"); rs = stat.executeQuery("SELECT x[1] FROM a");
ResultSetMetaData meta = rs.getMetaData(); ResultSetMetaData rsMeta = rs.getMetaData();
assertEquals(Types.VARCHAR, meta.getColumnType(1)); assertEquals(Types.VARCHAR, rsMeta.getColumnType(1));
rs.next(); rs.next();
// assertEquals(String.class.getName(), rs.getObject(1).getClass().getName()); // assertEquals(String.class.getName(), rs.getObject(1).getClass().getName());
stat.execute("drop table a"); stat.execute("drop table a");
} }
private void testColumnPrecision() throws SQLException { private void testColumnPrecision() throws SQLException {
Statement stat = conn.createStatement(); stat = conn.createStatement();
stat.execute("CREATE TABLE ONE(X NUMBER(12,2), Y FLOAT)"); stat.execute("CREATE TABLE ONE(X NUMBER(12,2), Y FLOAT)");
stat.execute("CREATE TABLE TWO AS SELECT * FROM ONE"); stat.execute("CREATE TABLE TWO AS SELECT * FROM ONE");
ResultSet rs; ResultSet rs;
ResultSetMetaData meta; ResultSetMetaData rsMeta;
rs = stat.executeQuery("SELECT * FROM ONE"); rs = stat.executeQuery("SELECT * FROM ONE");
meta = rs.getMetaData(); rsMeta = rs.getMetaData();
assertEquals(12, meta.getPrecision(1)); assertEquals(12, rsMeta.getPrecision(1));
assertEquals(17, meta.getPrecision(2)); assertEquals(17, rsMeta.getPrecision(2));
assertEquals(Types.DECIMAL, meta.getColumnType(1)); assertEquals(Types.DECIMAL, rsMeta.getColumnType(1));
assertEquals(Types.DOUBLE, meta.getColumnType(2)); assertEquals(Types.DOUBLE, rsMeta.getColumnType(2));
rs = stat.executeQuery("SELECT * FROM TWO"); rs = stat.executeQuery("SELECT * FROM TWO");
meta = rs.getMetaData(); rsMeta = rs.getMetaData();
assertEquals(12, meta.getPrecision(1)); assertEquals(12, rsMeta.getPrecision(1));
assertEquals(17, meta.getPrecision(2)); assertEquals(17, rsMeta.getPrecision(2));
assertEquals(Types.DECIMAL, meta.getColumnType(1)); assertEquals(Types.DECIMAL, rsMeta.getColumnType(1));
assertEquals(Types.DOUBLE, meta.getColumnType(2)); assertEquals(Types.DOUBLE, rsMeta.getColumnType(2));
stat.execute("DROP TABLE ONE, TWO"); stat.execute("DROP TABLE ONE, TWO");
} }
private void testColumnDefault() throws SQLException { private void testColumnDefault() throws SQLException {
DatabaseMetaData meta = conn.getMetaData(); meta = conn.getMetaData();
ResultSet rs; ResultSet rs;
Statement stat = conn.createStatement(); stat = conn.createStatement();
stat.execute("CREATE TABLE TEST(A INT, B INT DEFAULT NULL)"); stat.execute("CREATE TABLE TEST(A INT, B INT DEFAULT NULL)");
rs = meta.getColumns(null, null, "TEST", null); rs = meta.getColumns(null, null, "TEST", null);
rs.next(); rs.next();
...@@ -296,9 +296,9 @@ public class TestMetaData extends TestBase { ...@@ -296,9 +296,9 @@ public class TestMetaData extends TestBase {
} }
private void testProcedureColumns() throws SQLException { private void testProcedureColumns() throws SQLException {
DatabaseMetaData meta = conn.getMetaData(); meta = conn.getMetaData();
ResultSet rs; ResultSet rs;
Statement stat = conn.createStatement(); stat = conn.createStatement();
stat.execute("CREATE ALIAS PROP FOR \"java.lang.System.getProperty(java.lang.String)\""); stat.execute("CREATE ALIAS PROP FOR \"java.lang.System.getProperty(java.lang.String)\"");
stat.execute("CREATE ALIAS EXIT FOR \"java.lang.System.exit\""); stat.execute("CREATE ALIAS EXIT FOR \"java.lang.System.exit\"");
rs = meta.getProcedures(null, null, "EX%"); rs = meta.getProcedures(null, null, "EX%");
...@@ -330,12 +330,11 @@ public class TestMetaData extends TestBase { ...@@ -330,12 +330,11 @@ public class TestMetaData extends TestBase {
} }
private void testCrossReferences() throws SQLException { private void testCrossReferences() throws SQLException {
DatabaseMetaData meta = conn.getMetaData(); meta = conn.getMetaData();
ResultSet rs; ResultSet rs;
Statement stat = conn.createStatement(); stat = conn.createStatement();
stat.execute("CREATE TABLE PARENT(A INT, B INT, PRIMARY KEY(A, B))"); stat.execute("CREATE TABLE PARENT(A INT, B INT, PRIMARY KEY(A, B))");
stat stat.execute("CREATE TABLE CHILD(ID INT PRIMARY KEY, PA INT, PB INT, CONSTRAINT AB FOREIGN KEY(PA, PB) REFERENCES PARENT(A, B))");
.execute("CREATE TABLE CHILD(ID INT PRIMARY KEY, PA INT, PB INT, CONSTRAINT AB FOREIGN KEY(PA, PB) REFERENCES PARENT(A, B))");
rs = meta.getCrossReference(null, "PUBLIC", "PARENT", null, "PUBLIC", "CHILD"); rs = meta.getCrossReference(null, "PUBLIC", "PARENT", null, "PUBLIC", "CHILD");
checkCrossRef(rs); checkCrossRef(rs);
rs = meta.getImportedKeys(null, "PUBLIC", "CHILD"); rs = meta.getImportedKeys(null, "PUBLIC", "CHILD");
...@@ -363,8 +362,8 @@ public class TestMetaData extends TestBase { ...@@ -363,8 +362,8 @@ public class TestMetaData extends TestBase {
} }
private void testTempTable() throws SQLException { private void testTempTable() throws SQLException {
Connection conn = getConnection("metaData"); conn = getConnection("metaData");
Statement stat = conn.createStatement(); stat = conn.createStatement();
stat.execute("DROP TABLE IF EXISTS TEST_TEMP"); stat.execute("DROP TABLE IF EXISTS TEST_TEMP");
stat.execute("CREATE TEMP TABLE TEST_TEMP(ID INT PRIMARY KEY, NAME VARCHAR(255))"); stat.execute("CREATE TEMP TABLE TEST_TEMP(ID INT PRIMARY KEY, NAME VARCHAR(255))");
stat.execute("CREATE INDEX IDX_NAME ON TEST_TEMP(NAME)"); stat.execute("CREATE INDEX IDX_NAME ON TEST_TEMP(NAME)");
...@@ -579,9 +578,9 @@ public class TestMetaData extends TestBase { ...@@ -579,9 +578,9 @@ public class TestMetaData extends TestBase {
assertTrue(meta.usesLocalFiles()); assertTrue(meta.usesLocalFiles());
} }
private void test(Connection conn) throws SQLException { private void testMore() throws SQLException {
DatabaseMetaData meta = conn.getMetaData(); meta = conn.getMetaData();
Statement stat = conn.createStatement(); stat = conn.createStatement();
ResultSet rs; ResultSet rs;
conn.setReadOnly(true); conn.setReadOnly(true);
......
...@@ -209,7 +209,7 @@ public class TestNativeSQL extends TestBase { ...@@ -209,7 +209,7 @@ public class TestNativeSQL extends TestBase {
private void testPairs() { private void testPairs() {
for (int i = 0; i < PAIRS.length; i += 2) { for (int i = 0; i < PAIRS.length; i += 2) {
test(conn, PAIRS[i], PAIRS[i + 1]); test(PAIRS[i], PAIRS[i + 1]);
} }
} }
...@@ -241,7 +241,7 @@ public class TestNativeSQL extends TestBase { ...@@ -241,7 +241,7 @@ public class TestNativeSQL extends TestBase {
assertFalse(conn.isClosed()); assertFalse(conn.isClosed());
} }
private void test(Connection conn, String original, String expected) { private void test(String original, String expected) {
trace("original: <" + original + ">"); trace("original: <" + original + ">");
trace("expected: <" + expected + ">"); trace("expected: <" + expected + ">");
try { try {
......
...@@ -166,7 +166,7 @@ public class TestResultSet extends TestBase { ...@@ -166,7 +166,7 @@ public class TestResultSet extends TestBase {
assertFalse(meta.ownDeletesAreVisible(type)); assertFalse(meta.ownDeletesAreVisible(type));
assertFalse(meta.ownInsertsAreVisible(type)); assertFalse(meta.ownInsertsAreVisible(type));
} }
Statement stat = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, stat = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_UPDATABLE); ResultSet.CONCUR_UPDATABLE);
stat.execute("CREATE TABLE TEST(ID INT PRIMARY KEY, NAME VARCHAR(255))"); stat.execute("CREATE TABLE TEST(ID INT PRIMARY KEY, NAME VARCHAR(255))");
stat.execute("INSERT INTO TEST VALUES(1, 'Hello')"); stat.execute("INSERT INTO TEST VALUES(1, 'Hello')");
...@@ -182,7 +182,7 @@ public class TestResultSet extends TestBase { ...@@ -182,7 +182,7 @@ public class TestResultSet extends TestBase {
} }
private void testUpdatePrimaryKey() throws SQLException { private void testUpdatePrimaryKey() throws SQLException {
Statement stat = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, stat = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_UPDATABLE); ResultSet.CONCUR_UPDATABLE);
stat.execute("CREATE TABLE TEST(ID INT PRIMARY KEY, NAME VARCHAR(255))"); stat.execute("CREATE TABLE TEST(ID INT PRIMARY KEY, NAME VARCHAR(255))");
stat.execute("INSERT INTO TEST VALUES(1, 'Hello')"); stat.execute("INSERT INTO TEST VALUES(1, 'Hello')");
...@@ -920,7 +920,7 @@ public class TestResultSet extends TestBase { ...@@ -920,7 +920,7 @@ public class TestResultSet extends TestBase {
trace("Test CLOB"); trace("Test CLOB");
ResultSet rs; ResultSet rs;
String string; String string;
Statement stat = conn.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE); stat = conn.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE);
stat.execute("CREATE TABLE TEST(ID INT PRIMARY KEY,VALUE CLOB)"); stat.execute("CREATE TABLE TEST(ID INT PRIMARY KEY,VALUE CLOB)");
stat.execute("INSERT INTO TEST VALUES(1,'Test')"); stat.execute("INSERT INTO TEST VALUES(1,'Test')");
stat.execute("INSERT INTO TEST VALUES(2,'Hello')"); stat.execute("INSERT INTO TEST VALUES(2,'Hello')");
......
...@@ -66,22 +66,22 @@ public class TestStatement extends TestBase { ...@@ -66,22 +66,22 @@ public class TestStatement extends TestBase {
// ignore // ignore
} }
FileObject trace = FileSystem.getInstance(fileName).openFileObject(fileName, "r"); FileObject trace = FileSystem.getInstance(fileName).openFileObject(fileName, "r");
long start = trace.length(); long lengthBefore = trace.length();
try { try {
stat.execute("ERROR"); stat.execute("ERROR");
} catch (SQLException e) { } catch (SQLException e) {
// ignore // ignore
} }
long error = trace.length(); long error = trace.length();
assertSmaller(start, error); assertSmaller(lengthBefore, error);
start = error; lengthBefore = error;
try { try {
stat.execute("INSERT INTO TEST VALUES(1)"); stat.execute("INSERT INTO TEST VALUES(1)");
} catch (SQLException e) { } catch (SQLException e) {
// ignore // ignore
} }
error = trace.length(); error = trace.length();
assertEquals(start, error); assertEquals(lengthBefore, error);
stat.execute("DROP TABLE TEST IF EXISTS"); stat.execute("DROP TABLE TEST IF EXISTS");
} }
......
...@@ -60,17 +60,17 @@ public class TestConnectionPool extends TestBase { ...@@ -60,17 +60,17 @@ public class TestConnectionPool extends TestBase {
JdbcConnectionPool man = JdbcConnectionPool.create(url, user, password); JdbcConnectionPool man = JdbcConnectionPool.create(url, user, password);
Connection conn = man.getConnection(); Connection conn = man.getConnection();
int len = 1000; int len = 1000;
long start = System.currentTimeMillis(); long time = System.currentTimeMillis();
for (int i = 0; i < len; i++) { for (int i = 0; i < len; i++) {
man.getConnection().close(); man.getConnection().close();
} }
trace((int) (System.currentTimeMillis() - start)); trace((int) (System.currentTimeMillis() - time));
man.dispose(); man.dispose();
start = System.currentTimeMillis(); time = System.currentTimeMillis();
for (int i = 0; i < len; i++) { for (int i = 0; i < len; i++) {
DriverManager.getConnection(url, user, password).close(); DriverManager.getConnection(url, user, password).close();
} }
trace((int) (System.currentTimeMillis() - start)); trace((int) (System.currentTimeMillis() - time));
conn.close(); conn.close();
} }
......
...@@ -182,8 +182,8 @@ public class TestCrashAPI extends TestBase { ...@@ -182,8 +182,8 @@ public class TestCrashAPI extends TestBase {
throw e; throw e;
} }
int len = random.getInt(50); int len = random.getInt(50);
int start = random.getInt(statements.size() - len); int first = random.getInt(statements.size() - len);
int end = start + len; int end = first + len;
Statement stat = conn.createStatement(); Statement stat = conn.createStatement();
stat.execute("SET LOCK_TIMEOUT 10"); stat.execute("SET LOCK_TIMEOUT 10");
stat.execute("SET WRITE_DELAY 0"); stat.execute("SET WRITE_DELAY 0");
...@@ -197,7 +197,7 @@ public class TestCrashAPI extends TestBase { ...@@ -197,7 +197,7 @@ public class TestCrashAPI extends TestBase {
} }
} }
stat.execute("SCRIPT NOPASSWORDS NOSETTINGS"); stat.execute("SCRIPT NOPASSWORDS NOSETTINGS");
for (int i = start; i < end && i < statements.size(); i++) { for (int i = first; i < end && i < statements.size(); i++) {
try { try {
stat.execute("SELECT * FROM TEST WHERE ID=1"); stat.execute("SELECT * FROM TEST WHERE ID=1");
} catch (Throwable t) { } catch (Throwable t) {
......
...@@ -228,14 +228,14 @@ public abstract class TestHalt extends TestBase { ...@@ -228,14 +228,14 @@ public abstract class TestHalt extends TestBase {
// OP_DELETE = 1, OP_UPDATE = 2, OP_SELECT = 4; // OP_DELETE = 1, OP_UPDATE = 2, OP_SELECT = 4;
// int flags = FLAG_NODELAY; // int flags = FLAG_NODELAY;
// FLAG_NO_DELAY = 1, FLAG_AUTO_COMMIT = 2, FLAG_SMALL_CACHE = 4; // FLAG_NO_DELAY = 1, FLAG_AUTO_COMMIT = 2, FLAG_SMALL_CACHE = 4;
int value = random.nextInt(1000); int testValue = random.nextInt(1000);
// for Derby and HSQLDB // for Derby and HSQLDB
// String classPath = "-cp // String classPath = "-cp
// .;D:/data/java/hsqldb.jar;D:/data/java/derby.jar"; // .;D:/data/java/hsqldb.jar;D:/data/java/derby.jar";
String selfDestruct = SelfDestructor.getPropertyString(60); String selfDestruct = SelfDestructor.getPropertyString(60);
String[] procDef = new String[] { "java", selfDestruct, getPageStoreProperty(), String[] procDef = new String[] { "java", selfDestruct, getPageStoreProperty(),
"-cp", getClassPath(), "-cp", getClassPath(),
getClass().getName(), "" + operations, "" + flags, "" + value}; getClass().getName(), "" + operations, "" + flags, "" + testValue};
traceOperation("start: " + StringUtils.arrayCombine(procDef, ' ')); traceOperation("start: " + StringUtils.arrayCombine(procDef, ' '));
Process p = Runtime.getRuntime().exec(procDef); Process p = Runtime.getRuntime().exec(procDef);
InputStream in = p.getInputStream(); InputStream in = p.getInputStream();
......
...@@ -100,14 +100,14 @@ public class TestJoin extends TestBase { ...@@ -100,14 +100,14 @@ public class TestJoin extends TestBase {
execute("INSERT INTO TWO VALUES(3, 3)", null); execute("INSERT INTO TWO VALUES(3, 3)", null);
execute("INSERT INTO TWO VALUES(4, NULL)", null); execute("INSERT INTO TWO VALUES(4, NULL)", null);
random = new Random(); random = new Random();
long start = System.currentTimeMillis(); long startTime = System.currentTimeMillis();
for (int i = 0;; i++) { for (int i = 0;; i++) {
paramCount = 0; paramCount = 0;
buff = new StringBuilder(); buff = new StringBuilder();
long time = System.currentTimeMillis(); long time = System.currentTimeMillis();
if (time - start > 5000) { if (time - startTime > 5000) {
printTime("i:" + i); printTime("i:" + i);
start = time; startTime = time;
} }
buff.append("SELECT "); buff.append("SELECT ");
int tables = 1 + random.nextInt(5); int tables = 1 + random.nextInt(5);
...@@ -279,27 +279,27 @@ public class TestJoin extends TestBase { ...@@ -279,27 +279,27 @@ public class TestJoin extends TestBase {
} }
private String readResult(ResultSet rs) throws SQLException { private String readResult(ResultSet rs) throws SQLException {
StringBuilder buff = new StringBuilder(); StringBuilder b = new StringBuilder();
ResultSetMetaData meta = rs.getMetaData(); ResultSetMetaData meta = rs.getMetaData();
int columnCount = meta.getColumnCount(); int columnCount = meta.getColumnCount();
for (int i = 0; i < columnCount; i++) { for (int i = 0; i < columnCount; i++) {
if (i > 0) { if (i > 0) {
buff.append(","); b.append(",");
} }
buff.append(StringUtils.toUpperEnglish(meta.getColumnLabel(i + 1))); b.append(StringUtils.toUpperEnglish(meta.getColumnLabel(i + 1)));
} }
buff.append(":\n"); b.append(":\n");
String result = buff.toString(); String result = b.toString();
ArrayList<String> list = New.arrayList(); ArrayList<String> list = New.arrayList();
while (rs.next()) { while (rs.next()) {
buff = new StringBuilder(); b = new StringBuilder();
for (int i = 0; i < columnCount; i++) { for (int i = 0; i < columnCount; i++) {
if (i > 0) { if (i > 0) {
buff.append(","); b.append(",");
} }
buff.append(rs.getString(i + 1)); b.append(rs.getString(i + 1));
} }
list.add(buff.toString()); list.add(b.toString());
} }
Collections.sort(list); Collections.sort(list);
for (int i = 0; i < list.size(); i++) { for (int i = 0; i < list.size(); i++) {
......
...@@ -30,7 +30,7 @@ public class TestRandomSQL extends TestBase { ...@@ -30,7 +30,7 @@ public class TestRandomSQL extends TestBase {
private ArrayList<RuleHead> statements; private ArrayList<RuleHead> statements;
private int seed; private int seed;
private boolean exitOnError = true; private boolean exitOnError = true;
private Bnf bnf; private Bnf bnfSyntax;
private int success, total; private int success, total;
/** /**
...@@ -99,9 +99,9 @@ public class TestRandomSQL extends TestBase { ...@@ -99,9 +99,9 @@ public class TestRandomSQL extends TestBase {
public TestBase init(TestAll conf) throws Exception { public TestBase init(TestAll conf) throws Exception {
super.init(conf); super.init(conf);
bnf = Bnf.getInstance(null); bnfSyntax = Bnf.getInstance(null);
bnf.linkStatements(); bnfSyntax.linkStatements();
statements = bnf.getStatements(); statements = bnfSyntax.getStatements();
// go backwards so we can append at the end // go backwards so we can append at the end
for (int i = statements.size() - 1; i >= 0; i--) { for (int i = statements.size() - 1; i >= 0; i--) {
...@@ -131,8 +131,8 @@ public class TestRandomSQL extends TestBase { ...@@ -131,8 +131,8 @@ public class TestRandomSQL extends TestBase {
return this; return this;
} }
private void testWithSeed(Bnf config) throws SQLException { private void testWithSeed(Bnf bnf) throws SQLException {
config.getRandom().setSeed(seed); bnf.getRandom().setSeed(seed);
Connection conn = null; Connection conn = null;
try { try {
conn = connect(); conn = connect();
...@@ -142,9 +142,9 @@ public class TestRandomSQL extends TestBase { ...@@ -142,9 +142,9 @@ public class TestRandomSQL extends TestBase {
} }
Statement stat = conn.createStatement(); Statement stat = conn.createStatement();
for (int i = 0; i < statements.size(); i++) { for (int i = 0; i < statements.size(); i++) {
int sid = config.getRandom().nextInt(statements.size()); int sid = bnf.getRandom().nextInt(statements.size());
RuleHead r = statements.get(sid); RuleHead r = statements.get(sid);
String rand = r.getRule().random(config, 0).trim(); String rand = r.getRule().random(bnf, 0).trim();
if (rand.length() > 0) { if (rand.length() > 0) {
try { try {
Thread.yield(); Thread.yield();
...@@ -184,7 +184,7 @@ public class TestRandomSQL extends TestBase { ...@@ -184,7 +184,7 @@ public class TestRandomSQL extends TestBase {
} catch (SQLException e) { } catch (SQLException e) {
processException("deleteDb", e); processException("deleteDb", e);
} }
testWithSeed(bnf); testWithSeed(bnfSyntax);
} finally { } finally {
SysProperties.setScriptDirectory(old); SysProperties.setScriptDirectory(old);
} }
...@@ -203,8 +203,8 @@ public class TestRandomSQL extends TestBase { ...@@ -203,8 +203,8 @@ public class TestRandomSQL extends TestBase {
exitOnError = false; exitOnError = false;
showSQL = false; showSQL = false;
for (int a = 0; a < len; a++) { for (int a = 0; a < len; a++) {
int seed = RandomUtils.nextInt(Integer.MAX_VALUE); int s = RandomUtils.nextInt(Integer.MAX_VALUE);
testCase(seed); testCase(s);
} }
} }
......
...@@ -67,10 +67,10 @@ public class TestThreads extends TestBase implements Runnable { ...@@ -67,10 +67,10 @@ public class TestThreads extends TestBase implements Runnable {
int threadCount = 4; int threadCount = 4;
Thread[] threads = new Thread[threadCount]; Thread[] threads = new Thread[threadCount];
for (int i = 0; i < threadCount; i++) { for (int i = 0; i < threadCount; i++) {
String table = random.nextBoolean() ? null : getRandomTable(); String t = random.nextBoolean() ? null : getRandomTable();
int op = random.nextInt(OP_TYPES); int op = random.nextInt(OP_TYPES);
op = i % 2 == 0 ? RECONNECT : CHECKPOINT; op = i % 2 == 0 ? RECONNECT : CHECKPOINT;
threads[i] = new Thread(new TestThreads(this, op, table)); threads[i] = new Thread(new TestThreads(this, op, t));
} }
for (int i = 0; i < threadCount; i++) { for (int i = 0; i < threadCount; i++) {
threads[i].start(); threads[i].start();
......
...@@ -47,7 +47,7 @@ public class TestTimer extends TestBase { ...@@ -47,7 +47,7 @@ public class TestTimer extends TestBase {
Random random = new Random(); Random random = new Random();
int max = 0; int max = 0;
int count = 0; int count = 0;
long start = System.currentTimeMillis(); long startTime = System.currentTimeMillis();
while (true) { while (true) {
int action = random.nextInt(10); int action = random.nextInt(10);
int x = max == 0 ? 0 : random.nextInt(max); int x = max == 0 ? 0 : random.nextInt(max);
...@@ -82,9 +82,9 @@ public class TestTimer extends TestBase { ...@@ -82,9 +82,9 @@ public class TestTimer extends TestBase {
int c = rs.getInt(1); int c = rs.getInt(1);
assertEquals(count, c); assertEquals(count, c);
long time = System.currentTimeMillis(); long time = System.currentTimeMillis();
if (time > start + 5000) { if (time > startTime + 5000) {
println("rows: " + count); println("rows: " + count);
start = time; startTime = time;
} }
break; break;
default: default:
......
...@@ -55,13 +55,14 @@ public class TestAutoReconnect extends TestBase implements DatabaseEventListener ...@@ -55,13 +55,14 @@ public class TestAutoReconnect extends TestBase implements DatabaseEventListener
} }
public void test() throws Exception { public void test() throws Exception {
testReconnect(true); autoServer = true;
testReconnect(false); testReconnect();
autoServer = false;
testReconnect();
deleteDb("autoReconnect"); deleteDb("autoReconnect");
} }
private void testReconnect(boolean autoServer) throws Exception { private void testReconnect() throws Exception {
this.autoServer = autoServer;
deleteDb("autoReconnect"); deleteDb("autoReconnect");
if (autoServer) { if (autoServer) {
url = "jdbc:h2:" + baseDir + "/autoReconnect;" + url = "jdbc:h2:" + baseDir + "/autoReconnect;" +
...@@ -197,7 +198,7 @@ public class TestAutoReconnect extends TestBase implements DatabaseEventListener ...@@ -197,7 +198,7 @@ public class TestAutoReconnect extends TestBase implements DatabaseEventListener
// ignore // ignore
} }
public void init(String url) { public void init(String u) {
state = "init"; state = "init";
} }
......
...@@ -47,9 +47,8 @@ public class TestClearReferences extends TestBase { ...@@ -47,9 +47,8 @@ public class TestClearReferences extends TestBase {
} }
public void test() throws Exception { public void test() throws Exception {
String baseDir = "bin/org/h2";
ArrayList<Class < ? >> classes = New.arrayList(); ArrayList<Class < ? >> classes = New.arrayList();
check(classes, new File(baseDir)); check(classes, new File("bin/org/h2"));
for (Class< ? > clazz : classes) { for (Class< ? > clazz : classes) {
clearClass(clazz); clearClass(clazz);
} }
......
...@@ -137,7 +137,7 @@ public class TestCompress extends TestBase { ...@@ -137,7 +137,7 @@ public class TestCompress extends TestBase {
byte[] test = new byte[2 * pageSize]; byte[] test = new byte[2 * pageSize];
compress.compress(buff, pageSize, test, 0); compress.compress(buff, pageSize, test, 0);
for (int j = 0; j < 4; j++) { for (int j = 0; j < 4; j++) {
long start = System.currentTimeMillis(); long time = System.currentTimeMillis();
for (int i = 0; i < 1000; i++) { for (int i = 0; i < 1000; i++) {
InputStream in = FileSystem.getInstance("memFS:").openFileInputStream("memFS:compress.h2.db"); InputStream in = FileSystem.getInstance("memFS:").openFileInputStream("memFS:compress.h2.db");
int total = 0; int total = 0;
...@@ -150,7 +150,7 @@ public class TestCompress extends TestBase { ...@@ -150,7 +150,7 @@ public class TestCompress extends TestBase {
} }
in.close(); in.close();
} }
System.out.println("compress: " + (System.currentTimeMillis() - start) + " ms"); System.out.println("compress: " + (System.currentTimeMillis() - time) + " ms");
} }
for (int j = 0; j < 4; j++) { for (int j = 0; j < 4; j++) {
...@@ -168,14 +168,14 @@ public class TestCompress extends TestBase { ...@@ -168,14 +168,14 @@ public class TestCompress extends TestBase {
} }
in.close(); in.close();
byte[] result = new byte[pageSize]; byte[] result = new byte[pageSize];
long start = System.currentTimeMillis(); long time = System.currentTimeMillis();
for (int i = 0; i < 1000; i++) { for (int i = 0; i < 1000; i++) {
for (int k = 0; k < comp.size(); k++) { for (int k = 0; k < comp.size(); k++) {
byte[] data = comp.get(k); byte[] data = comp.get(k);
compress.expand(data, 0, data.length, result, 0, pageSize); compress.expand(data, 0, data.length, result, 0, pageSize);
} }
} }
System.out.println("expand: " + (System.currentTimeMillis() - start) + " ms"); System.out.println("expand: " + (System.currentTimeMillis() - time) + " ms");
} }
} }
...@@ -214,11 +214,11 @@ public class TestCompress extends TestBase { ...@@ -214,11 +214,11 @@ public class TestCompress extends TestBase {
} }
CompressTool utils = CompressTool.getInstance(); CompressTool utils = CompressTool.getInstance();
for (String a : new String[] { "LZF", "No", "Deflate" }) { for (String a : new String[] { "LZF", "No", "Deflate" }) {
long start = System.currentTimeMillis(); long time = System.currentTimeMillis();
byte[] out = utils.compress(buff, a); byte[] out = utils.compress(buff, a);
byte[] test = utils.expand(out); byte[] test = utils.expand(out);
if (testPerformance) { if (testPerformance) {
System.out.println("p:" + pattern + " len: " + out.length + " time: " + (System.currentTimeMillis() - start) + " " + a); System.out.println("p:" + pattern + " len: " + out.length + " time: " + (System.currentTimeMillis() - time) + " " + a);
} }
assertEquals(buff.length, test.length); assertEquals(buff.length, test.length);
assertEquals(buff, test); assertEquals(buff, test);
......
...@@ -217,8 +217,8 @@ public class TestDataPage extends TestBase implements DataHandler { ...@@ -217,8 +217,8 @@ public class TestDataPage extends TestBase implements DataHandler {
return null; return null;
} }
public int getChecksum(byte[] data, int start, int end) { public int getChecksum(byte[] data, int s, int e) {
return end - start; return e - s;
} }
public void checkPowerOff() { public void checkPowerOff() {
......
...@@ -157,7 +157,7 @@ public class TestFile extends TestBase implements DataHandler { ...@@ -157,7 +157,7 @@ public class TestFile extends TestBase implements DataHandler {
// nothing to do // nothing to do
} }
public int getChecksum(byte[] data, int start, int end) { public int getChecksum(byte[] data, int s, int e) {
return 0; return 0;
} }
......
...@@ -78,13 +78,13 @@ public class TestFileLock extends TestBase implements Runnable { ...@@ -78,13 +78,13 @@ public class TestFileLock extends TestBase implements Runnable {
lock2.unlock(); lock2.unlock();
} }
private void test(boolean allowSockets) throws Exception { private void test(boolean allowSocketsLock) throws Exception {
int threadCount = getSize(3, 5); int threadCount = getSize(3, 5);
wait = getSize(20, 200); wait = getSize(20, 200);
Thread[] threads = new Thread[threadCount]; Thread[] threads = new Thread[threadCount];
new File(FILE).delete(); new File(FILE).delete();
for (int i = 0; i < threadCount; i++) { for (int i = 0; i < threadCount; i++) {
threads[i] = new Thread(new TestFileLock(this, allowSockets)); threads[i] = new Thread(new TestFileLock(this, allowSocketsLock));
threads[i].start(); threads[i].start();
Thread.sleep(wait + (int) (Math.random() * wait)); Thread.sleep(wait + (int) (Math.random() * wait));
} }
......
...@@ -71,9 +71,9 @@ public class TestFileLockSerialized extends TestBase { ...@@ -71,9 +71,9 @@ public class TestFileLockSerialized extends TestBase {
deleteDb("fileLockSerialized"); deleteDb("fileLockSerialized");
final String url = "jdbc:h2:" + baseDir + "/fileLockSerialized;FILE_LOCK=SERIALIZED;OPEN_NEW=TRUE"; final String url = "jdbc:h2:" + baseDir + "/fileLockSerialized;FILE_LOCK=SERIALIZED;OPEN_NEW=TRUE";
Connection c = DriverManager.getConnection(url); Connection conn = DriverManager.getConnection(url);
c.createStatement().execute("create table test(id int) as select 1"); conn.createStatement().execute("create table test(id int) as select 1");
c.close(); conn.close();
final int len = 10; final int len = 10;
final Exception[] ex = new Exception[1]; final Exception[] ex = new Exception[1];
...@@ -147,9 +147,9 @@ public class TestFileLockSerialized extends TestBase { ...@@ -147,9 +147,9 @@ public class TestFileLockSerialized extends TestBase {
while (!stop[0]) { while (!stop[0]) {
try { try {
Thread.sleep(10); Thread.sleep(10);
Connection conn = DriverManager.getConnection(writeUrl, "sa", "sa"); Connection c = DriverManager.getConnection(writeUrl, "sa", "sa");
conn.createStatement().execute("select * from test"); c.createStatement().execute("select * from test");
conn.close(); c.close();
} catch (Exception e) { } catch (Exception e) {
// ignore // ignore
} }
...@@ -294,10 +294,10 @@ public class TestFileLockSerialized extends TestBase { ...@@ -294,10 +294,10 @@ public class TestFileLockSerialized extends TestBase {
final String url = "jdbc:h2:" + baseDir + "/fileLockSerialized;FILE_LOCK=SERIALIZED;OPEN_NEW=TRUE;" + final String url = "jdbc:h2:" + baseDir + "/fileLockSerialized;FILE_LOCK=SERIALIZED;OPEN_NEW=TRUE;" +
"AUTO_RECONNECT=TRUE;MAX_LENGTH_INPLACE_LOB=8192;COMPRESS_LOB=DEFLATE;LOG=2;CACHE_SIZE=65536"; "AUTO_RECONNECT=TRUE;MAX_LENGTH_INPLACE_LOB=8192;COMPRESS_LOB=DEFLATE;LOG=2;CACHE_SIZE=65536";
Connection c = DriverManager.getConnection(url); Connection conn = DriverManager.getConnection(url);
c.createStatement().execute("create table test(id int)"); conn.createStatement().execute("create table test(id int)");
c.createStatement().execute("insert into test values(1)"); conn.createStatement().execute("insert into test values(1)");
c.close(); conn.close();
final long endTime = System.currentTimeMillis() + runTime; final long endTime = System.currentTimeMillis() + runTime;
final Exception[] ex = new Exception[1]; final Exception[] ex = new Exception[1];
......
...@@ -24,7 +24,7 @@ import org.h2.value.ValueString; ...@@ -24,7 +24,7 @@ import org.h2.value.ValueString;
public class TestOverflow extends TestBase { public class TestOverflow extends TestBase {
private ArrayList<Value> values; private ArrayList<Value> values;
private int type; private int dataType;
private BigInteger min, max; private BigInteger min, max;
private boolean successExpected; private boolean successExpected;
...@@ -44,24 +44,24 @@ public class TestOverflow extends TestBase { ...@@ -44,24 +44,24 @@ public class TestOverflow extends TestBase {
test(Value.SHORT, Short.MIN_VALUE, Short.MAX_VALUE); test(Value.SHORT, Short.MIN_VALUE, Short.MAX_VALUE);
} }
private void test(int type, long min, long max) throws SQLException { private void test(int type, long minValue, long maxValue) throws SQLException {
values = New.arrayList(); values = New.arrayList();
this.type = type; this.dataType = type;
this.min = new BigInteger("" + min); this.min = new BigInteger("" + minValue);
this.max = new BigInteger("" + max); this.max = new BigInteger("" + maxValue);
add(0); add(0);
add(min); add(minValue);
add(max); add(maxValue);
add(max - 1); add(maxValue - 1);
add(min + 1); add(minValue + 1);
add(1); add(1);
add(-1); add(-1);
Random random = new Random(1); Random random = new Random(1);
for (int i = 0; i < 40; i++) { for (int i = 0; i < 40; i++) {
if (max > Integer.MAX_VALUE) { if (maxValue > Integer.MAX_VALUE) {
add(random.nextLong()); add(random.nextLong());
} else { } else {
add((random.nextBoolean() ? 1 : -1) * random.nextInt((int) max)); add((random.nextBoolean() ? 1 : -1) * random.nextInt((int) maxValue));
} }
} }
for (Value va : values) { for (Value va : values) {
...@@ -127,7 +127,7 @@ public class TestOverflow extends TestBase { ...@@ -127,7 +127,7 @@ public class TestOverflow extends TestBase {
} }
private void add(long l) throws SQLException { private void add(long l) throws SQLException {
values.add(ValueString.get("" + l).convertTo(type)); values.add(ValueString.get("" + l).convertTo(dataType));
} }
} }
...@@ -325,15 +325,15 @@ public class TestPageStore extends TestBase implements DatabaseEventListener { ...@@ -325,15 +325,15 @@ public class TestPageStore extends TestBase implements DatabaseEventListener {
p = updateMany[random.nextInt(tableCount)]; p = updateMany[random.nextInt(tableCount)];
p.setInt(1, i); p.setInt(1, i);
p.setInt(2, random.nextInt(50)); p.setInt(2, random.nextInt(50));
int start = random.nextInt(1 + i); int first = random.nextInt(1 + i);
p.setInt(3, start); p.setInt(3, first);
p.setInt(4, start + random.nextInt(50)); p.setInt(4, first + random.nextInt(50));
p.executeUpdate(); p.executeUpdate();
} else { } else {
p = deleteMany[random.nextInt(tableCount)]; p = deleteMany[random.nextInt(tableCount)];
int start = random.nextInt(1 + i); int first = random.nextInt(1 + i);
p.setInt(1, start); p.setInt(1, first);
p.setInt(2, start + random.nextInt(100)); p.setInt(2, first + random.nextInt(100));
p.executeUpdate(); p.executeUpdate();
} }
} }
......
...@@ -354,10 +354,10 @@ public class TestTools extends TestBase { ...@@ -354,10 +354,10 @@ public class TestTools extends TestBase {
private void testManagementDb() throws SQLException { private void testManagementDb() throws SQLException {
int count = getSize(2, 10); int count = getSize(2, 10);
for (int i = 0; i < count; i++) { for (int i = 0; i < count; i++) {
Server server = Server.createTcpServer("-tcpPort", "9192").start(); Server tcpServer = Server.createTcpServer("-tcpPort", "9192").start();
server.stop(); tcpServer.stop();
server = Server.createTcpServer("-tcpPassword", "abc", "-tcpPort", "9192").start(); tcpServer = Server.createTcpServer("-tcpPassword", "abc", "-tcpPort", "9192").start();
server.stop(); tcpServer.stop();
} }
} }
...@@ -494,13 +494,13 @@ public class TestTools extends TestBase { ...@@ -494,13 +494,13 @@ public class TestTools extends TestBase {
private void testServer() throws SQLException { private void testServer() throws SQLException {
Connection conn; Connection conn;
deleteDb("test"); deleteDb("test");
Server server = Server.createTcpServer( Server tcpServer = Server.createTcpServer(
"-baseDir", baseDir, "-baseDir", baseDir,
"-tcpPort", "9192", "-tcpPort", "9192",
"-tcpAllowOthers").start(); "-tcpAllowOthers").start();
conn = DriverManager.getConnection("jdbc:h2:tcp://localhost:9192/test", "sa", ""); conn = DriverManager.getConnection("jdbc:h2:tcp://localhost:9192/test", "sa", "");
conn.close(); conn.close();
server.stop(); tcpServer.stop();
Server.createTcpServer( Server.createTcpServer(
"-ifExists", "-ifExists",
"-tcpPassword", "abc", "-tcpPassword", "abc",
......
...@@ -122,7 +122,7 @@ public class TestValueHashMap extends TestBase implements DataHandler { ...@@ -122,7 +122,7 @@ public class TestValueHashMap extends TestBase implements DataHandler {
return null; return null;
} }
public int getChecksum(byte[] data, int start, int end) { public int getChecksum(byte[] data, int s, int e) {
return 0; return 0;
} }
......
...@@ -214,7 +214,7 @@ public class TestValueMemory extends TestBase implements DataHandler { ...@@ -214,7 +214,7 @@ public class TestValueMemory extends TestBase implements DataHandler {
// nothing to do // nothing to do
} }
public int getChecksum(byte[] data, int start, int end) { public int getChecksum(byte[] data, int s, int e) {
return 0; return 0;
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论