提交 6ab81676 authored 作者: Thomas Mueller's avatar Thomas Mueller

Local variable declaration hides another field or variable.

上级 893cca19
......@@ -825,8 +825,8 @@ public class Parser {
return prepare(session, buff.toString(), paramValues);
}
private Prepared prepare(Session session, String sql, ObjectArray paramValues) throws SQLException {
Prepared prep = session.prepare(sql);
private Prepared prepare(Session s, String sql, ObjectArray paramValues) throws SQLException {
Prepared prep = s.prepare(sql);
ObjectArray params = prep.getParameters();
for (int i = 0; params != null && i < params.size(); i++) {
Parameter p = (Parameter) params.get(i);
......@@ -4177,7 +4177,7 @@ public class Parser {
private RunScriptCommand parseRunScript() throws SQLException {
RunScriptCommand command = new RunScriptCommand(session);
read("FROM");
command.setFile(readExpression());
command.setFileNameExpr(readExpression());
if (readIf("COMPRESSION")) {
command.setCompressionAlgorithm(readUniqueIdentifier());
}
......@@ -4221,7 +4221,7 @@ public class Parser {
command.setDrop(dropTables);
command.setSimple(simple);
if (readIf("TO")) {
command.setFile(readExpression());
command.setFileNameExpr(readExpression());
if (readIf("COMPRESSION")) {
command.setCompressionAlgorithm(readUniqueIdentifier());
}
......
......@@ -299,9 +299,9 @@ public class AlterTableAddConstraint extends SchemaCommand {
private Index getIndex(Table t, IndexColumn[] cols) {
ObjectArray list = t.getIndexes();
for (int i = 0; i < list.size(); i++) {
Index idx = (Index) list.get(i);
if (canUseIndex(idx, t, cols)) {
return idx;
Index existingIndex = (Index) list.get(i);
if (canUseIndex(existingIndex, t, cols)) {
return existingIndex;
}
}
return null;
......@@ -329,12 +329,12 @@ public class AlterTableAddConstraint extends SchemaCommand {
return true;
}
private boolean canUseIndex(Index index, Table table, IndexColumn[] cols) {
if (index.getTable() != table || index.getCreateSQL() == null) {
private boolean canUseIndex(Index existingIndex, Table table, IndexColumn[] cols) {
if (existingIndex.getTable() != table || existingIndex.getCreateSQL() == null) {
// can't use the scan index or index of another table
return false;
}
Column[] indexCols = index.getColumns();
Column[] indexCols = existingIndex.getColumns();
if (indexCols.length < cols.length) {
return false;
}
......@@ -343,7 +343,7 @@ public class AlterTableAddConstraint extends SchemaCommand {
// but not all columns of the index need to be part of the list
// holes are not allowed (index=a,b,c & list=a,b is ok; but list=a,c
// is not)
int idx = index.getColumnIndex(cols[j].column);
int idx = existingIndex.getColumnIndex(cols[j].column);
if (idx < 0 || idx >= cols.length) {
return false;
}
......
......@@ -39,18 +39,18 @@ import org.h2.util.ObjectArray;
*/
public class BackupCommand extends Prepared {
private Expression fileName;
private Expression fileNameExpr;
public BackupCommand(Session session) {
super(session);
}
public void setFileName(Expression fileName) {
this.fileName = fileName;
this.fileNameExpr = fileName;
}
public int update() throws SQLException {
String name = fileName.getValue(session).getString();
String name = fileNameExpr.getValue(session).getString();
session.getUser().checkAdmin();
backupTo(name);
return 0;
......
......@@ -38,12 +38,12 @@ public abstract class Query extends Prepared {
/**
* The limit expression as specified in the LIMIT or TOP clause.
*/
protected Expression limit;
protected Expression limitExpr;
/**
* The offset expression as specified in the LIMIT .. OFFSET clause.
*/
protected Expression offset;
protected Expression offsetExpr;
/**
* The sample size
......@@ -154,10 +154,10 @@ public abstract class Query extends Prepared {
* Get the alias (or column name) of the first column.
* This is used to convert IN(SELECT ...) queries to inner joins.
*
* @param session the session
* @param s the session
* @return the alias or column name
*/
public abstract String getFirstColumnAlias(Session session);
public abstract String getFirstColumnAlias(Session s);
/**
* Check if this expression and all sub-expressions can fulfill a criteria.
......@@ -171,9 +171,9 @@ public abstract class Query extends Prepared {
/**
* Update all aggregate function values.
*
* @param session the session
* @param s the session
*/
public abstract void updateAggregate(Session session) throws SQLException;
public abstract void updateAggregate(Session s) throws SQLException;
public boolean isQuery() {
return true;
......@@ -183,9 +183,9 @@ public abstract class Query extends Prepared {
return true;
}
private boolean sameResultAsLast(Session session, Value[] params, Value[] lastParams, long lastEvaluated)
private boolean sameResultAsLast(Session s, Value[] params, Value[] lastParams, long lastEval)
throws SQLException {
Database db = session.getDatabase();
Database db = s.getDatabase();
for (int i = 0; i < params.length; i++) {
if (!db.areEqual(lastParams[i], params[i])) {
return false;
......@@ -194,7 +194,7 @@ public abstract class Query extends Prepared {
if (!isEverything(ExpressionVisitor.DETERMINISTIC) || !isEverything(ExpressionVisitor.INDEPENDENT)) {
return false;
}
if (db.getModificationDataId() > lastEvaluated && getMaxDataModificationId() > lastEvaluated) {
if (db.getModificationDataId() > lastEval && getMaxDataModificationId() > lastEval) {
return false;
}
return true;
......@@ -376,11 +376,11 @@ public abstract class Query extends Prepared {
}
public void setOffset(Expression offset) {
this.offset = offset;
this.offsetExpr = offset;
}
public void setLimit(Expression limit) {
this.limit = limit;
this.limitExpr = limit;
}
/**
......
......@@ -52,7 +52,7 @@ public abstract class ScriptBase extends Prepared implements DataHandler {
/**
* The file name (if set).
*/
private Expression file;
private Expression fileNameExpr;
private String fileName;
private String cipher;
......@@ -77,13 +77,13 @@ public abstract class ScriptBase extends Prepared implements DataHandler {
key = sha.getKeyPasswordHash("script", password);
}
public void setFile(Expression file) {
this.file = file;
public void setFileNameExpr(Expression file) {
this.fileNameExpr = file;
}
protected String getFileName() throws SQLException {
if (file != null && fileName == null) {
fileName = file.optimize(session).getValue(session).getString();
if (fileNameExpr != null && fileName == null) {
fileName = fileNameExpr.optimize(session).getValue(session).getString();
if (fileName == null || fileName.trim().length() == 0) {
fileName = "script.sql";
}
......@@ -100,17 +100,17 @@ public abstract class ScriptBase extends Prepared implements DataHandler {
* Delete the target file.
*/
void deleteStore() throws SQLException {
String fileName = getFileName();
if (fileName != null) {
FileUtils.delete(fileName);
String file = getFileName();
if (file != null) {
FileUtils.delete(file);
}
}
private void initStore() throws SQLException {
Database db = session.getDatabase();
// script files are always in text format
String fileName = getFileName();
store = FileStore.open(db, fileName, "rw", cipher, key);
String file = getFileName();
store = FileStore.open(db, file, "rw", cipher, key);
store.setCheckedWriting(false);
store.init();
}
......@@ -119,8 +119,8 @@ public abstract class ScriptBase extends Prepared implements DataHandler {
* Open the output stream.
*/
void openOutput() throws SQLException {
String fileName = getFileName();
if (fileName == null) {
String file = getFileName();
if (file == null) {
return;
}
if (isEncrypted()) {
......@@ -129,7 +129,7 @@ public abstract class ScriptBase extends Prepared implements DataHandler {
// always use a big buffer, otherwise end-of-block is written a lot
out = new BufferedOutputStream(out, Constants.IO_BUFFER_SIZE_COMPRESS);
} else {
OutputStream o = FileUtils.openFileOutputStream(fileName, false);
OutputStream o = FileUtils.openFileOutputStream(file, false);
out = new BufferedOutputStream(o, Constants.IO_BUFFER_SIZE);
out = CompressTool.wrapOutputStream(out, compressionAlgorithm, Constants.SCRIPT_SQL);
}
......@@ -139,8 +139,8 @@ public abstract class ScriptBase extends Prepared implements DataHandler {
* Open the input stream.
*/
void openInput() throws SQLException {
String fileName = getFileName();
if (fileName == null) {
String file = getFileName();
if (file == null) {
return;
}
if (isEncrypted()) {
......@@ -149,14 +149,14 @@ public abstract class ScriptBase extends Prepared implements DataHandler {
} else {
InputStream inStream;
try {
inStream = FileUtils.openFileInputStream(fileName);
inStream = FileUtils.openFileInputStream(file);
} catch (IOException e) {
throw Message.convertIOException(e, fileName);
throw Message.convertIOException(e, file);
}
in = new BufferedInputStream(inStream, Constants.IO_BUFFER_SIZE);
in = CompressTool.wrapInputStream(in, compressionAlgorithm, Constants.SCRIPT_SQL);
if (in == null) {
throw Message.getSQLException(ErrorCode.FILE_NOT_FOUND_1, Constants.SCRIPT_SQL + " in " + fileName);
throw Message.getSQLException(ErrorCode.FILE_NOT_FOUND_1, Constants.SCRIPT_SQL + " in " + file);
}
}
}
......
......@@ -102,9 +102,9 @@ public class ScriptCommand extends ScriptBase {
}
public LocalResult queryMeta() throws SQLException {
LocalResult result = createResult();
result.done();
return result;
LocalResult r = createResult();
r.done();
return r;
}
private LocalResult createResult() {
......@@ -125,9 +125,9 @@ public class ScriptCommand extends ScriptBase {
}
Database db = session.getDatabase();
if (settings) {
ObjectArray settings = db.getAllSettings();
for (int i = 0; i < settings.size(); i++) {
Setting setting = (Setting) settings.get(i);
ObjectArray settingList = db.getAllSettings();
for (int i = 0; i < settingList.size(); i++) {
Setting setting = (Setting) settingList.get(i);
if (setting.getName().equals(SetTypes.getTypeName(SetTypes.CREATE_BUILD))) {
// don't add CREATE_BUILD to the script
// (it is only set when creating the database)
......@@ -356,12 +356,12 @@ public class ScriptCommand extends ScriptBase {
switch (v.getType()) {
case Value.BLOB: {
byte[] bytes = new byte[lobBlockSize];
InputStream in = v.getInputStream();
InputStream input = v.getInputStream();
try {
for (int i = 0;; i++) {
StringBuffer buff = new StringBuffer(lobBlockSize * 2);
buff.append("INSERT INTO SYSTEM_LOB_STREAM VALUES(" + id + ", " + i + ", NULL, '");
int len = IOUtils.readFully(in, bytes, 0, lobBlockSize);
int len = IOUtils.readFully(input, bytes, 0, lobBlockSize);
if (len <= 0) {
break;
}
......@@ -371,18 +371,18 @@ public class ScriptCommand extends ScriptBase {
add(sql, true);
}
} finally {
IOUtils.closeSilently(in);
IOUtils.closeSilently(input);
}
break;
}
case Value.CLOB: {
char[] chars = new char[lobBlockSize];
Reader in = v.getReader();
Reader reader = v.getReader();
try {
for (int i = 0;; i++) {
StringBuffer buff = new StringBuffer(lobBlockSize * 2);
buff.append("INSERT INTO SYSTEM_LOB_STREAM VALUES(" + id + ", " + i + ", ");
int len = IOUtils.readFully(in, chars, lobBlockSize);
int len = IOUtils.readFully(reader, chars, lobBlockSize);
if (len < 0) {
break;
}
......@@ -392,7 +392,7 @@ public class ScriptCommand extends ScriptBase {
add(sql, true);
}
} finally {
IOUtils.closeSilently(in);
IOUtils.closeSilently(reader);
}
break;
}
......
......@@ -444,10 +444,10 @@ public class Select extends Query {
}
private void queryDistinct(LocalResult result, long limitRows) throws SQLException {
if (limitRows != 0 && offset != null) {
if (limitRows != 0 && offsetExpr != null) {
// limitRows must be long, otherwise we get an int overflow
// if limitRows is at or near Integer.MAX_VALUE
limitRows += offset.getValue(session).getInt();
limitRows += offsetExpr.getValue(session).getInt();
}
int rowNumber = 0;
setCurrentRowNumber(0);
......@@ -481,10 +481,10 @@ public class Select extends Query {
}
private void queryFlat(int columnCount, LocalResult result, long limitRows) throws SQLException {
if (limitRows != 0 && offset != null) {
if (limitRows != 0 && offsetExpr != null) {
// limitRows must be long, otherwise we get an int overflow
// if limitRows is at or near Integer.MAX_VALUE
limitRows += offset.getValue(session).getInt();
limitRows += offsetExpr.getValue(session).getInt();
}
int rowNumber = 0;
setCurrentRowNumber(0);
......@@ -526,8 +526,8 @@ public class Select extends Query {
protected LocalResult queryWithoutCache(int maxRows) throws SQLException {
int limitRows = maxRows;
if (limit != null) {
int l = limit.getValue(session).getInt();
if (limitExpr != null) {
int l = limitExpr.getValue(session).getInt();
if (limitRows == 0) {
limitRows = l;
} else {
......@@ -558,8 +558,8 @@ public class Select extends Query {
} else {
queryFlat(columnCount, result, limitRows);
}
if (offset != null) {
result.setOffset(offset.getValue(session).getInt());
if (offsetExpr != null) {
result.setOffset(offsetExpr.getValue(session).getInt());
}
if (limitRows != 0) {
result.setLimit(limitRows);
......@@ -810,7 +810,7 @@ public class Select extends Query {
Optimizer optimizer = new Optimizer(topArray, condition, session);
optimizer.optimize();
topTableFilter = optimizer.getTopFilter();
double cost = optimizer.getCost();
double planCost = optimizer.getCost();
TableFilter f = topTableFilter;
while (f != null) {
......@@ -849,7 +849,7 @@ public class Select extends Query {
f = f.getJoin();
}
topTableFilter.prepare();
return cost;
return planCost;
}
public String getPlanSQL() {
......@@ -939,12 +939,12 @@ public class Select extends Query {
buff.append(StringUtils.unEnclose(o.getSQL()));
}
}
if (limit != null) {
if (limitExpr != null) {
buff.append("\nLIMIT ");
buff.append(StringUtils.unEnclose(limit.getSQL()));
if (offset != null) {
buff.append(StringUtils.unEnclose(limitExpr.getSQL()));
if (offsetExpr != null) {
buff.append(" OFFSET ");
buff.append(StringUtils.unEnclose(offset.getSQL()));
buff.append(StringUtils.unEnclose(offsetExpr.getSQL()));
}
}
if (isForUpdate) {
......@@ -1057,16 +1057,16 @@ public class Select extends Query {
}
}
public void updateAggregate(Session session) throws SQLException {
public void updateAggregate(Session s) throws SQLException {
for (int i = 0; i < expressions.size(); i++) {
Expression e = (Expression) expressions.get(i);
e.updateAggregate(session);
e.updateAggregate(s);
}
if (condition != null) {
condition.updateAggregate(session);
condition.updateAggregate(s);
}
if (having != null) {
having.updateAggregate(session);
having.updateAggregate(s);
}
}
......@@ -1120,7 +1120,7 @@ public class Select extends Query {
return isEverything(ExpressionVisitor.READONLY);
}
public String getFirstColumnAlias(Session session) {
public String getFirstColumnAlias(Session s) {
if (SysProperties.CHECK) {
if (visibleColumnCount > 1) {
Message.throwInternalError("" + visibleColumnCount);
......@@ -1130,8 +1130,8 @@ public class Select extends Query {
if (expr instanceof Alias) {
return expr.getAlias();
}
Mode mode = session.getDatabase().getMode();
String name = session.getNextSystemIdentifier(getSQL());
Mode mode = s.getDatabase().getMode();
String name = s.getNextSystemIdentifier(getSQL());
expr = new Alias(expr, name, mode.aliasColumnName);
expressions.set(0, expr);
return expr.getAlias();
......
......@@ -92,19 +92,19 @@ public class SelectUnion extends Query {
}
public LocalResult queryMeta() throws SQLException {
ObjectArray expressions = left.getExpressions();
ObjectArray leftExpressions = left.getExpressions();
int columnCount = left.getColumnCount();
LocalResult result = new LocalResult(session, expressions, columnCount);
LocalResult result = new LocalResult(session, leftExpressions, columnCount);
result.done();
return result;
}
protected LocalResult queryWithoutCache(int maxrows) throws SQLException {
if (maxrows != 0) {
if (limit != null) {
maxrows = Math.min(limit.getValue(session).getInt(), maxrows);
if (limitExpr != null) {
maxrows = Math.min(limitExpr.getValue(session).getInt(), maxrows);
}
limit = ValueExpression.get(ValueInt.get(maxrows));
limitExpr = ValueExpression.get(ValueInt.get(maxrows));
}
int columnCount = left.getColumnCount();
LocalResult result = new LocalResult(session, expressions, columnCount);
......@@ -171,11 +171,11 @@ public class SelectUnion extends Query {
default:
Message.throwInternalError("type=" + unionType);
}
if (offset != null) {
result.setOffset(offset.getValue(session).getInt());
if (offsetExpr != null) {
result.setOffset(offsetExpr.getValue(session).getInt());
}
if (limit != null) {
result.setLimit(limit.getValue(session).getInt());
if (limitExpr != null) {
result.setLimit(limitExpr.getValue(session).getInt());
}
result.done();
return result;
......@@ -323,12 +323,12 @@ public class SelectUnion extends Query {
buff.append(" ORDER BY ");
buff.append(sort.getSQL(exprList, exprList.length));
}
if (limit != null) {
if (limitExpr != null) {
buff.append(" LIMIT ");
buff.append(StringUtils.unEnclose(limit.getSQL()));
if (offset != null) {
buff.append(StringUtils.unEnclose(limitExpr.getSQL()));
if (offsetExpr != null) {
buff.append(" OFFSET ");
buff.append(StringUtils.unEnclose(offset.getSQL()));
buff.append(StringUtils.unEnclose(offsetExpr.getSQL()));
}
}
if (isForUpdate) {
......@@ -350,12 +350,12 @@ public class SelectUnion extends Query {
return left.isReadOnly() && right.isReadOnly();
}
public void updateAggregate(Session session) throws SQLException {
left.updateAggregate(session);
right.updateAggregate(session);
public void updateAggregate(Session s) throws SQLException {
left.updateAggregate(s);
right.updateAggregate(s);
}
public String getFirstColumnAlias(Session session) {
public String getFirstColumnAlias(Session s) {
return null;
}
......
......@@ -45,10 +45,10 @@ public class ConstraintCheck extends Constraint {
this.expr = expr;
}
public String getCreateSQLForCopy(Table table, String quotedName) {
public String getCreateSQLForCopy(Table forTable, String quotedName) {
StringBuffer buff = new StringBuffer();
buff.append("ALTER TABLE ");
buff.append(table.getSQL());
buff.append(forTable.getSQL());
buff.append(" ADD CONSTRAINT ");
buff.append(quotedName);
if (comment != null) {
......
......@@ -93,27 +93,27 @@ public class ConstraintReferential extends Constraint {
/**
* Create the SQL statement of this object so a copy of the table can be made.
*
* @param table the table to create the object for
* @param forTable the table to create the object for
* @param quotedName the name of this object (quoted if necessary)
* @return the SQL statement
*/
public String getCreateSQLForCopy(Table table, String quotedName) {
return getCreateSQLForCopy(table, refTable, quotedName, true);
public String getCreateSQLForCopy(Table forTable, String quotedName) {
return getCreateSQLForCopy(forTable, refTable, quotedName, true);
}
/**
* Create the SQL statement of this object so a copy of the table can be made.
*
* @param table the table to create the object for
* @param refTable the referenced table
* @param forTable the table to create the object for
* @param forRefTable the referenced table
* @param quotedName the name of this object (quoted if necessary)
* @param internalIndex add the index name to the statement
* @return the SQL statement
*/
public String getCreateSQLForCopy(Table table, Table refTable, String quotedName, boolean internalIndex) {
public String getCreateSQLForCopy(Table forTable, Table forRefTable, String quotedName, boolean internalIndex) {
StringBuffer buff = new StringBuffer();
buff.append("ALTER TABLE ");
String mainTable = table.getSQL();
String mainTable = forTable.getSQL();
buff.append(mainTable);
buff.append(" ADD CONSTRAINT ");
buff.append(quotedName);
......@@ -131,7 +131,7 @@ public class ConstraintReferential extends Constraint {
buff.append(cols[i].getSQL());
}
buff.append(")");
if (internalIndex && indexOwner && table == this.table) {
if (internalIndex && indexOwner && forTable == this.table) {
buff.append(" INDEX ");
buff.append(index.getSQL());
}
......@@ -139,9 +139,9 @@ public class ConstraintReferential extends Constraint {
String quotedRefTable;
if (this.table == this.refTable) {
// self-referencing constraints: need to use new table
quotedRefTable = table.getSQL();
quotedRefTable = forTable.getSQL();
} else {
quotedRefTable = refTable.getSQL();
quotedRefTable = forRefTable.getSQL();
}
buff.append(quotedRefTable);
buff.append("(");
......@@ -152,7 +152,7 @@ public class ConstraintReferential extends Constraint {
buff.append(refCols[i].getSQL());
}
buff.append(")");
if (internalIndex && refIndexOwner && table == this.table) {
if (internalIndex && refIndexOwner && forTable == this.table) {
buff.append(" INDEX ");
buff.append(refIndex.getSQL());
}
......@@ -349,16 +349,16 @@ public class ConstraintReferential extends Constraint {
}
}
private boolean found(Session session, Index index, SearchRow check, Row excluding) throws SQLException {
index.getTable().lock(session, false, false);
Cursor cursor = index.find(session, check, check);
private boolean found(Session session, Index searchIndex, SearchRow check, Row excluding) throws SQLException {
searchIndex.getTable().lock(session, false, false);
Cursor cursor = searchIndex.find(session, check, check);
while (cursor.next()) {
SearchRow found;
found = cursor.getSearchRow();
if (excluding != null && found.getPos() == excluding.getPos()) {
continue;
}
Column[] cols = index.getColumns();
Column[] cols = searchIndex.getColumns();
boolean allEqual = true;
for (int i = 0; i < columns.length && i < cols.length; i++) {
int idx = cols[i].getColumnId();
......
......@@ -37,14 +37,14 @@ public class ConstraintUnique extends Constraint {
return primaryKey ? Constraint.PRIMARY_KEY : Constraint.UNIQUE;
}
public String getCreateSQLForCopy(Table table, String quotedName) {
return getCreateSQLForCopy(table, quotedName, true);
public String getCreateSQLForCopy(Table forTable, String quotedName) {
return getCreateSQLForCopy(forTable, quotedName, true);
}
private String getCreateSQLForCopy(Table table, String quotedName, boolean internalIndex) {
private String getCreateSQLForCopy(Table forTable, String quotedName, boolean internalIndex) {
StringBuffer buff = new StringBuffer();
buff.append("ALTER TABLE ");
buff.append(table.getSQL());
buff.append(forTable.getSQL());
buff.append(" ADD CONSTRAINT ");
buff.append(quotedName);
if (comment != null) {
......@@ -61,7 +61,7 @@ public class ConstraintUnique extends Constraint {
buff.append(Parser.quoteIdentifier(columns[i].column.getName()));
}
buff.append(')');
if (internalIndex && indexOwner && table == this.table) {
if (internalIndex && indexOwner && forTable == this.table) {
buff.append(" INDEX ");
buff.append(index.getSQL());
}
......
......@@ -158,11 +158,6 @@ public class Constants {
*/
public static final char DEFAULT_ESCAPE_CHAR = '\\';
/**
* The default port number of the FTP server.
*/
public static final int DEFAULT_FTP_PORT = 8021;
/**
* If the HTTP server should allow connections from other computers by
* default.
......@@ -170,8 +165,8 @@ public class Constants {
public static final boolean DEFAULT_HTTP_ALLOW_OTHERS = false;
/**
* The default port number of the HTTP server (for the H2 Console). This
* value is also in the documentation.
* The default port number of the HTTP server (for the H2 Console).
* This value is also in the documentation and in the Server javadoc.
*/
public static final int DEFAULT_HTTP_PORT = 8082;
......
......@@ -201,9 +201,9 @@ public class Database implements DataHandler {
setEventListenerClass(listener);
}
}
String log = ci.getProperty(SetTypes.LOG, null);
if (log != null) {
this.logIndexChanges = "2".equals(log);
String logSetting = ci.getProperty(SetTypes.LOG, null);
if (logSetting != null) {
this.logIndexChanges = "2".equals(logSetting);
}
String ignoreSummary = ci.getProperty("RECOVER", null);
if (ignoreSummary != null) {
......@@ -437,11 +437,11 @@ public class Database implements DataHandler {
return traceSystem.getTrace(module);
}
public FileStore openFile(String name, String mode, boolean mustExist) throws SQLException {
public FileStore openFile(String name, String openMode, boolean mustExist) throws SQLException {
if (mustExist && !FileUtils.exists(name)) {
throw Message.getSQLException(ErrorCode.FILE_NOT_FOUND_1, name);
}
FileStore store = FileStore.open(this, name, mode, cipher, filePasswordHash);
FileStore store = FileStore.open(this, name, openMode, cipher, filePasswordHash);
try {
store.init();
} catch (SQLException e) {
......@@ -454,15 +454,15 @@ public class Database implements DataHandler {
/**
* Check if the file password hash is correct.
*
* @param cipher the cipher algorithm
* @param hash the hash code
* @param testCipher the cipher algorithm
* @param testHash the hash code
* @return true if the cipher algorithm and the password match
*/
public boolean validateFilePasswordHash(String cipher, byte[] hash) throws SQLException {
if (!StringUtils.equals(cipher, this.cipher)) {
public boolean validateFilePasswordHash(String testCipher, byte[] testHash) throws SQLException {
if (!StringUtils.equals(testCipher, this.cipher)) {
return false;
}
return ByteUtils.compareSecure(hash, filePasswordHash);
return ByteUtils.compareSecure(testHash, filePasswordHash);
}
private void openFileData() throws SQLException {
......
......@@ -42,17 +42,17 @@ public abstract class DbObjectBase implements DbObject {
/**
* Initialize some attributes of this object.
*
* @param database the database
* @param id the object id
* @param db the database
* @param objectId the object id
* @param name the name
* @param traceModule the trace module name
*/
protected void initDbObjectBase(Database database, int id, String name, String traceModule) {
this.database = database;
this.trace = database.getTrace(traceModule);
this.id = id;
protected void initDbObjectBase(Database db, int objectId, String name, String traceModule) {
this.database = db;
this.trace = db.getTrace(traceModule);
this.id = objectId;
this.objectName = name;
this.modificationId = database.getModificationMetaId();
this.modificationId = db.getModificationMetaId();
}
/**
......
......@@ -531,8 +531,8 @@ public class Session extends SessionWithState {
savepoints.keySet().toArray(names);
for (int i = 0; i < names.length; i++) {
String name = names[i];
Integer id = (Integer) savepoints.get(names[i]);
if (id.intValue() > index) {
Integer savepointIndex = (Integer) savepoints.get(names[i]);
if (savepointIndex.intValue() > index) {
savepoints.remove(name);
}
}
......@@ -749,11 +749,11 @@ public class Session extends SessionWithState {
if (savepoints == null) {
throw Message.getSQLException(ErrorCode.SAVEPOINT_IS_INVALID_1, name);
}
Integer id = (Integer) savepoints.get(name);
if (id == null) {
Integer savepointIndex = (Integer) savepoints.get(name);
if (savepointIndex == null) {
throw Message.getSQLException(ErrorCode.SAVEPOINT_IS_INVALID_1, name);
}
int i = id.intValue();
int i = savepointIndex.intValue();
rollbackTo(i, false);
}
......@@ -943,11 +943,11 @@ public class Session extends SessionWithState {
* @return the new identifier
*/
public String getNextSystemIdentifier(String sql) {
String id;
String identifier;
do {
id = SYSTEM_IDENTIFIER_PREFIX + systemIdentifier++;
} while (sql.indexOf(id) >= 0);
return id;
identifier = SYSTEM_IDENTIFIER_PREFIX + systemIdentifier++;
} while (sql.indexOf(identifier) >= 0);
return identifier;
}
/**
......
......@@ -229,12 +229,12 @@ class AggregateData {
return v == null ? ValueNull.INSTANCE : v.convertTo(dataType);
}
private Value divide(Value a, long count) throws SQLException {
if (count == 0) {
private Value divide(Value a, long by) throws SQLException {
if (by == 0) {
return ValueNull.INSTANCE;
}
int type = Value.getHigherOrder(a.getType(), Value.LONG);
Value b = ValueLong.get(count).convertTo(type);
Value b = ValueLong.get(by).convertTo(type);
a = a.convertTo(type).divide(b);
return a;
}
......
......@@ -264,17 +264,17 @@ public class CompareLike extends Condition {
/**
* Test if the value matches the pattern.
*
* @param pattern the pattern
* @param testPattern the pattern
* @param value the value
* @param escape the escape character
* @param escapeChar the escape character
* @return true if the value matches
*/
public boolean test(String pattern, String value, char escape) throws SQLException {
initPattern(pattern, escape);
public boolean test(String testPattern, String value, char escapeChar) throws SQLException {
initPattern(testPattern, escapeChar);
return compareAt(value, 0, 0, value.length());
}
private void initPattern(String p, char escape) throws SQLException {
private void initPattern(String p, char escapeChar) throws SQLException {
if (regexp) {
patternString = p;
try {
......@@ -301,12 +301,12 @@ public class CompareLike extends Condition {
for (int i = 0; i < len; i++) {
char c = p.charAt(i);
int type;
if (escape == c) {
if (escapeChar == c) {
if (i >= len - 1) {
throw Message.getSQLException(ErrorCode.LIKE_ESCAPE_ERROR_1, StringUtils.addAsterisk(p, i));
}
c = p.charAt(++i);
if (c != '_' && c != '%' && c != escape) {
if (c != '_' && c != '%' && c != escapeChar) {
throw Message.getSQLException(ErrorCode.LIKE_ESCAPE_ERROR_1, StringUtils.addAsterisk(p, i));
}
type = MATCH;
......
......@@ -117,14 +117,14 @@ public class Comparison extends Condition {
return "(" + sql + ")";
}
private Expression getCast(Expression expr, int dataType, long precision, int scale, int displaySize, Session session)
private Expression getCast(Expression expr, int targetDataType, long precision, int scale, int displaySize, Session session)
throws SQLException {
if (expr == ValueExpression.getNull()) {
return expr;
}
Function function = Function.getFunction(session.getDatabase(), "CAST");
function.setParameter(0, expr);
function.setDataType(dataType, precision, scale, displaySize);
function.setDataType(targetDataType, precision, scale, displaySize);
function.doneWithParameters();
return function.optimize(session);
}
......@@ -448,12 +448,12 @@ public class Comparison extends Condition {
/**
* Get the left or the right sub-expression of this condition.
*
* @param left true to get the left sub-expression, false to get the right
* @param getLeft true to get the left sub-expression, false to get the right
* sub-expression.
* @return the sub-expression
*/
public Expression getExpression(boolean left) {
return left ? this.left : right;
public Expression getExpression(boolean getLeft) {
return getLeft ? this.left : right;
}
}
......@@ -253,12 +253,12 @@ public class ConditionAndOr extends Condition {
/**
* Get the left or the right sub-expression of this condition.
*
* @param left true to get the left sub-expression, false to get the right
* @param getLeft true to get the left sub-expression, false to get the right
* sub-expression.
* @return the sub-expression
*/
public Expression getExpression(boolean left) {
return left ? this.left : right;
public Expression getExpression(boolean getLeft) {
return getLeft ? this.left : right;
}
}
......@@ -233,7 +233,7 @@ public class FullTextLucene extends FullText {
/**
* Get the index modifier for the given connection.
*
*
* @param conn the connection
* @return the index modifier
*/
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论