提交 dc3d3fd7 authored 作者: Jacek Ławrynowicz's avatar Jacek Ławrynowicz

if inlining improvements, other review changes

上级 4f750584
...@@ -140,7 +140,10 @@ public class TimestampWithTimeZone implements Serializable, Cloneable { ...@@ -140,7 +140,10 @@ public class TimestampWithTimeZone implements Serializable, Cloneable {
if (timeNanos != other.timeNanos) { if (timeNanos != other.timeNanos) {
return false; return false;
} }
return timeZoneOffsetMins == other.timeZoneOffsetMins; if (timeZoneOffsetMins != other.timeZoneOffsetMins) {
return false;
}
return true;
} }
} }
...@@ -71,8 +71,10 @@ public class DbSchema { ...@@ -71,8 +71,10 @@ public class DbSchema {
} else if (contents.isPostgreSQL() && } else if (contents.isPostgreSQL() &&
StringUtils.toUpperEnglish(name).startsWith("PG_")) { StringUtils.toUpperEnglish(name).startsWith("PG_")) {
isSystem = true; isSystem = true;
} else if (contents.isDerby() && name.startsWith("SYS")) {
isSystem = true;
} else { } else {
isSystem = contents.isDerby() && name.startsWith("SYS"); isSystem = false;
} }
} }
......
...@@ -285,11 +285,6 @@ public class Parser { ...@@ -285,11 +285,6 @@ public class Parser {
if (hasMore) { if (hasMore) {
String remaining = originalSQL.substring(parseIndex); String remaining = originalSQL.substring(parseIndex);
if (remaining.trim().length() != 0) { if (remaining.trim().length() != 0) {
// list.addCommand(c);
// do {
// c = parseCommand();
// list.addCommand(c);
// } while (currentToken.equals(";"));
c = new CommandList(this, sql, c, remaining); c = new CommandList(this, sql, c, remaining);
} }
} }
...@@ -3567,21 +3562,15 @@ public class Parser { ...@@ -3567,21 +3562,15 @@ public class Parser {
private boolean equalsToken(String a, String b) { private boolean equalsToken(String a, String b) {
if (a == null) { if (a == null) {
return b == null; return b == null;
} else if (a.equals(b)) { } else
return true; return a.equals(b) || !identifiersToUpper && a.equalsIgnoreCase(b);
} else {
return !identifiersToUpper && a.equalsIgnoreCase(b);
}
} }
private static boolean equalsTokenIgnoreCase(String a, String b) { private static boolean equalsTokenIgnoreCase(String a, String b) {
if (a == null) { if (a == null) {
return b == null; return b == null;
} else if (a.equals(b)) { } else
return true; return a.equals(b) || a.equalsIgnoreCase(b);
} else {
return a.equalsIgnoreCase(b);
}
} }
private boolean isTokenInList(Collection<String> upperCaseTokenList) { private boolean isTokenInList(Collection<String> upperCaseTokenList) {
......
...@@ -307,7 +307,11 @@ public abstract class Query extends Prepared { ...@@ -307,7 +307,11 @@ public abstract class Query extends Prepared {
!isEverything(ExpressionVisitor.INDEPENDENT_VISITOR)) { !isEverything(ExpressionVisitor.INDEPENDENT_VISITOR)) {
return false; return false;
} }
return db.getModificationDataId() <= lastEval || getMaxDataModificationId() <= lastEval; if (db.getModificationDataId() > lastEval &&
getMaxDataModificationId() > lastEval) {
return false;
}
return true;
} }
public final Value[] getParameterValues() { public final Value[] getParameterValues() {
......
...@@ -232,10 +232,7 @@ public class Select extends Query { ...@@ -232,10 +232,7 @@ public class Select extends Query {
} }
private boolean isHavingNullOrFalse(Value[] row) { private boolean isHavingNullOrFalse(Value[] row) {
if (havingIndex >= 0) { return havingIndex >= 0 && !row[havingIndex].getBoolean();
return !row[havingIndex].getBoolean();
}
return false;
} }
private Index getGroupSortedIndex() { private Index getGroupSortedIndex() {
......
...@@ -219,7 +219,7 @@ public class Update extends Prepared { ...@@ -219,7 +219,7 @@ public class Update extends Prepared {
for (Column c : columns) { for (Column c : columns) {
Expression e = expressionMap.get(c); Expression e = expressionMap.get(c);
e.mapColumns(targetTableFilter, 0); e.mapColumns(targetTableFilter, 0);
if (sourceTableFilter != null) { if (sourceTableFilter!=null){
e.mapColumns(sourceTableFilter, 0); e.mapColumns(sourceTableFilter, 0);
} }
expressionMap.put(c, e.optimize(session)); expressionMap.put(c, e.optimize(session));
......
...@@ -2870,10 +2870,7 @@ public class Database implements DataHandler { ...@@ -2870,10 +2870,7 @@ public class Database implements DataHandler {
* @return true if they match * @return true if they match
*/ */
public boolean equalsIdentifiers(String a, String b) { public boolean equalsIdentifiers(String a, String b) {
if (a.equals(b)) { return a.equals(b) || (!dbSettings.databaseToUpper && a.equalsIgnoreCase(b));
return true;
}
return !dbSettings.databaseToUpper && a.equalsIgnoreCase(b);
} }
@Override @Override
......
...@@ -103,7 +103,8 @@ public class SessionRemote extends SessionWithState implements DataHandler { ...@@ -103,7 +103,8 @@ public class SessionRemote extends SessionWithState implements DataHandler {
ArrayList<String> serverList = new ArrayList<>(); ArrayList<String> serverList = new ArrayList<>();
for (Transfer transfer : transferList) { for (Transfer transfer : transferList) {
serverList.add(transfer.getSocket().getInetAddress(). serverList.add(transfer.getSocket().getInetAddress().
getHostAddress() + ":" + transfer.getSocket().getPort()); getHostAddress() + ":" +
transfer.getSocket().getPort());
} }
return serverList; return serverList;
} }
......
...@@ -471,7 +471,8 @@ public class FullText { ...@@ -471,7 +471,8 @@ public class FullText {
addColumnData(columns, data, expr); addColumnData(columns, data, expr);
Object[] col = columns.toArray(); Object[] col = columns.toArray();
Object[] dat = data.toArray(); Object[] dat = data.toArray();
return new Object[][]{col, dat}; Object[][] columnData = { col, dat };
return columnData;
} }
/** /**
......
...@@ -138,6 +138,7 @@ public class JdbcClob extends TraceObject implements NClob ...@@ -138,6 +138,7 @@ public class JdbcClob extends TraceObject implements NClob
if (value.getPrecision() != 0) { if (value.getPrecision() != 0) {
throw DbException.getInvalidValueException("length", value.getPrecision()); throw DbException.getInvalidValueException("length", value.getPrecision());
} }
final JdbcConnection c = conn; // required to avoid synthetic method creation
// PipedReader / PipedWriter are a lot slower // PipedReader / PipedWriter are a lot slower
// than PipedInputStream / PipedOutputStream // than PipedInputStream / PipedOutputStream
// (Sun/Oracle Java 1.6.0_20) // (Sun/Oracle Java 1.6.0_20)
...@@ -145,7 +146,7 @@ public class JdbcClob extends TraceObject implements NClob ...@@ -145,7 +146,7 @@ public class JdbcClob extends TraceObject implements NClob
final Task task = new Task() { final Task task = new Task() {
@Override @Override
public void call() { public void call() {
value = conn.createClob(IOUtils.getReader(in), -1); value = c.createClob(IOUtils.getReader(in), -1);
} }
}; };
PipedOutputStream out = new PipedOutputStream(in) { PipedOutputStream out = new PipedOutputStream(in) {
......
...@@ -146,7 +146,7 @@ public class JdbcDatabaseMetaData extends TraceObject implements ...@@ -146,7 +146,7 @@ public class JdbcDatabaseMetaData extends TraceObject implements
String tableType; String tableType;
if (types != null && types.length > 0) { if (types != null && types.length > 0) {
StatementBuilder buff = new StatementBuilder("TABLE_TYPE IN("); StatementBuilder buff = new StatementBuilder("TABLE_TYPE IN(");
for (String type : types) { for (String ignored : types) {
buff.appendExceptFirst(", "); buff.appendExceptFirst(", ");
buff.append('?'); buff.append('?');
} }
......
...@@ -1408,7 +1408,10 @@ public final class MVStore { ...@@ -1408,7 +1408,10 @@ public final class MVStore {
} }
} }
Chunk r = retainChunk; Chunk r = retainChunk;
return r == null || c.version <= r.version; if (r != null && c.version > r.version) {
return false;
}
return true;
} }
private long getTimeSinceCreation() { private long getTimeSinceCreation() {
...@@ -2482,7 +2485,11 @@ public final class MVStore { ...@@ -2482,7 +2485,11 @@ public final class MVStore {
// the last time // the last time
boolean fileOps; boolean fileOps;
long fileOpCount = fileStore.getWriteCount() + fileStore.getReadCount(); long fileOpCount = fileStore.getWriteCount() + fileStore.getReadCount();
fileOps = autoCompactLastFileOpCount != fileOpCount; if (autoCompactLastFileOpCount != fileOpCount) {
fileOps = true;
} else {
fileOps = false;
}
// use a lower fill rate if there were any file operations // use a lower fill rate if there were any file operations
int targetFillRate = fileOps ? autoCompactFillRate / 3 : autoCompactFillRate; int targetFillRate = fileOps ? autoCompactFillRate / 3 : autoCompactFillRate;
compact(targetFillRate, autoCommitMemory); compact(targetFillRate, autoCommitMemory);
......
...@@ -736,10 +736,13 @@ public class MVTable extends TableBase { ...@@ -736,10 +736,13 @@ public class MVTable extends TableBase {
DbException de = DbException.convert(e); DbException de = DbException.convert(e);
if (de.getErrorCode() == ErrorCode.DUPLICATE_KEY_1) { if (de.getErrorCode() == ErrorCode.DUPLICATE_KEY_1) {
for (Index index : indexes) { for (Index index : indexes) {
if (index.getIndexType().isUnique() && index instanceof MultiVersionIndex) { if (index.getIndexType().isUnique() &&
index instanceof MultiVersionIndex) {
MultiVersionIndex mv = (MultiVersionIndex) index; MultiVersionIndex mv = (MultiVersionIndex) index;
if (mv.isUncommittedFromOtherSession(session, row)) { if (mv.isUncommittedFromOtherSession(session, row)) {
throw DbException.get(ErrorCode.CONCURRENT_UPDATE_1, index.getName()); throw DbException.get(
ErrorCode.CONCURRENT_UPDATE_1,
index.getName());
} }
} }
} }
......
...@@ -777,7 +777,10 @@ public class Column { ...@@ -777,7 +777,10 @@ public class Column {
if (defaultExpression != null && !defaultExpression.isEverything(visitor)) { if (defaultExpression != null && !defaultExpression.isEverything(visitor)) {
return false; return false;
} }
return checkConstraint == null || checkConstraint.isEverything(visitor); if (checkConstraint != null && !checkConstraint.isEverything(visitor)) {
return false;
}
return true;
} }
public boolean isPrimaryKey() { public boolean isPrimaryKey() {
...@@ -830,7 +833,10 @@ public class Column { ...@@ -830,7 +833,10 @@ public class Column {
if (isComputed || newColumn.isComputed) { if (isComputed || newColumn.isComputed) {
return false; return false;
} }
return onUpdateExpression == null && newColumn.onUpdateExpression == null; if (onUpdateExpression != null || newColumn.onUpdateExpression != null) {
return false;
}
return true;
} }
/** /**
......
...@@ -1118,8 +1118,8 @@ public final class JoinBatch { ...@@ -1118,8 +1118,8 @@ public final class JoinBatch {
if (joinBatches == null) { if (joinBatches == null) {
return; return;
} }
for (JoinBatch joinBatche : joinBatches) { for (JoinBatch joinBatch : joinBatches) {
joinBatche.viewTopFutureCursor = null; joinBatch.viewTopFutureCursor = null;
} }
} }
} }
......
...@@ -714,7 +714,10 @@ public class MetaTable extends Table { ...@@ -714,7 +714,10 @@ public class MetaTable extends Table {
if (indexFrom != null && db.compare(v, indexFrom) < 0) { if (indexFrom != null && db.compare(v, indexFrom) < 0) {
return false; return false;
} }
return indexTo == null || db.compare(v, indexTo) <= 0; if (indexTo != null && db.compare(v, indexTo) > 0) {
return false;
}
return true;
} }
private static String replaceNullWithEmpty(String s) { private static String replaceNullWithEmpty(String s) {
......
...@@ -143,7 +143,8 @@ public class RegularTable extends TableBase { ...@@ -143,7 +143,8 @@ public class RegularTable extends TableBase {
if (index.getIndexType().isUnique() && index instanceof MultiVersionIndex) { if (index.getIndexType().isUnique() && index instanceof MultiVersionIndex) {
MultiVersionIndex mv = (MultiVersionIndex) index; MultiVersionIndex mv = (MultiVersionIndex) index;
if (mv.isUncommittedFromOtherSession(session, row)) { if (mv.isUncommittedFromOtherSession(session, row)) {
throw DbException.get(ErrorCode.CONCURRENT_UPDATE_1, index.getName()); throw DbException.get(
ErrorCode.CONCURRENT_UPDATE_1, index.getName());
} }
} }
} }
......
...@@ -583,7 +583,8 @@ public abstract class Table extends SchemaObjectBase { ...@@ -583,7 +583,8 @@ public abstract class Table extends SchemaObjectBase {
if (columns.size() == 1) { if (columns.size() == 1) {
constraintsToDrop.add(constraint); constraintsToDrop.add(constraint);
} else { } else {
throw DbException.get(ErrorCode.COLUMN_IS_REFERENCED_1, constraint.getSQL()); throw DbException.get(
ErrorCode.COLUMN_IS_REFERENCED_1, constraint.getSQL());
} }
} }
} }
...@@ -602,7 +603,8 @@ public abstract class Table extends SchemaObjectBase { ...@@ -602,7 +603,8 @@ public abstract class Table extends SchemaObjectBase {
if (index.getColumns().length == 1) { if (index.getColumns().length == 1) {
indexesToDrop.add(index); indexesToDrop.add(index);
} else { } else {
throw DbException.get(ErrorCode.COLUMN_IS_REFERENCED_1, index.getSQL()); throw DbException.get(
ErrorCode.COLUMN_IS_REFERENCED_1, index.getSQL());
} }
} }
} }
......
...@@ -286,7 +286,11 @@ public class TableView extends Table { ...@@ -286,7 +286,11 @@ public class TableView extends Table {
return false; return false;
} }
} }
return topQuery == null || topQuery.isEverything(ExpressionVisitor.QUERY_COMPARABLE_VISITOR); if (topQuery != null &&
!topQuery.isEverything(ExpressionVisitor.QUERY_COMPARABLE_VISITOR)) {
return false;
}
return true;
} }
public Query getTopQuery() { public Query getTopQuery() {
......
...@@ -613,7 +613,8 @@ public class SimpleResultSet implements ResultSet, ResultSetMetaData, ...@@ -613,7 +613,8 @@ public class SimpleResultSet implements ResultSet, ResultSetMetaData,
*/ */
@Override @Override
public Clob getClob(int columnIndex) throws SQLException { public Clob getClob(int columnIndex) throws SQLException {
return (Clob) get(columnIndex); Clob c = (Clob) get(columnIndex);
return c == null ? null : c;
} }
/** /**
......
...@@ -275,7 +275,10 @@ public class CompareMode { ...@@ -275,7 +275,10 @@ public class CompareMode {
if (strength != o.strength) { if (strength != o.strength) {
return false; return false;
} }
return binaryUnsigned == o.binaryUnsigned; if (binaryUnsigned != o.binaryUnsigned) {
return false;
}
return true;
} }
@Override @Override
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论