Unverified 提交 c5652260 authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov 提交者: GitHub

Merge pull request #1597 from katzyn/check

Remove SysProperties.CHECK preconditions around simple assertions
...@@ -16,7 +16,6 @@ import org.h2.command.Parser; ...@@ -16,7 +16,6 @@ import org.h2.command.Parser;
import org.h2.engine.Constants; import org.h2.engine.Constants;
import org.h2.engine.Database; import org.h2.engine.Database;
import org.h2.engine.Session; import org.h2.engine.Session;
import org.h2.engine.SysProperties;
import org.h2.expression.Alias; import org.h2.expression.Alias;
import org.h2.expression.Expression; import org.h2.expression.Expression;
import org.h2.expression.ExpressionColumn; import org.h2.expression.ExpressionColumn;
...@@ -963,7 +962,7 @@ public class Select extends Query { ...@@ -963,7 +962,7 @@ public class Select extends Query {
@Override @Override
public void init() { public void init() {
if (SysProperties.CHECK && checkInit) { if (checkInit) {
DbException.throwInternalError(); DbException.throwInternalError();
} }
expandColumnList(); expandColumnList();
...@@ -1079,7 +1078,7 @@ public class Select extends Query { ...@@ -1079,7 +1078,7 @@ public class Select extends Query {
// sometimes a subquery is prepared twice (CREATE TABLE AS SELECT) // sometimes a subquery is prepared twice (CREATE TABLE AS SELECT)
return; return;
} }
if (SysProperties.CHECK && !checkInit) { if (!checkInit) {
DbException.throwInternalError("not initialized"); DbException.throwInternalError("not initialized");
} }
if (orderList != null) { if (orderList != null) {
......
...@@ -12,7 +12,6 @@ import org.h2.api.ErrorCode; ...@@ -12,7 +12,6 @@ import org.h2.api.ErrorCode;
import org.h2.engine.Database; import org.h2.engine.Database;
import org.h2.engine.Mode; import org.h2.engine.Mode;
import org.h2.engine.Session; import org.h2.engine.Session;
import org.h2.engine.SysProperties;
import org.h2.expression.Expression; import org.h2.expression.Expression;
import org.h2.expression.ExpressionColumn; import org.h2.expression.ExpressionColumn;
import org.h2.expression.ExpressionVisitor; import org.h2.expression.ExpressionVisitor;
...@@ -283,7 +282,7 @@ public class SelectUnion extends Query { ...@@ -283,7 +282,7 @@ public class SelectUnion extends Query {
@Override @Override
public void init() { public void init() {
if (SysProperties.CHECK && checkInit) { if (checkInit) {
DbException.throwInternalError(); DbException.throwInternalError();
} }
checkInit = true; checkInit = true;
...@@ -312,7 +311,7 @@ public class SelectUnion extends Query { ...@@ -312,7 +311,7 @@ public class SelectUnion extends Query {
// sometimes a subquery is prepared twice (CREATE TABLE AS SELECT) // sometimes a subquery is prepared twice (CREATE TABLE AS SELECT)
return; return;
} }
if (SysProperties.CHECK && !checkInit) { if (!checkInit) {
DbException.throwInternalError("not initialized"); DbException.throwInternalError("not initialized");
} }
isPrepared = true; isPrepared = true;
......
...@@ -99,7 +99,7 @@ public class ConnectionInfo implements Cloneable { ...@@ -99,7 +99,7 @@ public class ConnectionInfo implements Cloneable {
HashSet<String> set = new HashSet<>(128); HashSet<String> set = new HashSet<>(128);
set.addAll(SetTypes.getTypes()); set.addAll(SetTypes.getTypes());
for (String key : connectionTime) { for (String key : connectionTime) {
if (!set.add(key) && SysProperties.CHECK) { if (!set.add(key)) {
DbException.throwInternalError(key); DbException.throwInternalError(key);
} }
} }
......
...@@ -1076,10 +1076,8 @@ public class Database implements DataHandler { ...@@ -1076,10 +1076,8 @@ public class Database implements DataHandler {
try { try {
Cursor cursor = metaIdIndex.find(session, r, r); Cursor cursor = metaIdIndex.find(session, r, r);
if (cursor.next()) { if (cursor.next()) {
if (SysProperties.CHECK) { if (lockMode != Constants.LOCK_MODE_OFF && !wasLocked) {
if (lockMode != Constants.LOCK_MODE_OFF && !wasLocked) { throw DbException.throwInternalError();
throw DbException.throwInternalError();
}
} }
Row found = cursor.get(); Row found = cursor.get();
meta.removeRow(session, found); meta.removeRow(session, found);
...@@ -2780,7 +2778,7 @@ public class Database implements DataHandler { ...@@ -2780,7 +2778,7 @@ public class Database implements DataHandler {
} }
long now = System.nanoTime(); long now = System.nanoTime();
if (now > reconnectCheckNext + reconnectCheckDelayNs) { if (now > reconnectCheckNext + reconnectCheckDelayNs) {
if (SysProperties.CHECK && checkpointAllowed < 0) { if (checkpointAllowed < 0) {
DbException.throwInternalError(Integer.toString(checkpointAllowed)); DbException.throwInternalError(Integer.toString(checkpointAllowed));
} }
synchronized (reconnectSync) { synchronized (reconnectSync) {
...@@ -2849,8 +2847,7 @@ public class Database implements DataHandler { ...@@ -2849,8 +2847,7 @@ public class Database implements DataHandler {
} }
synchronized (reconnectSync) { synchronized (reconnectSync) {
if (reconnectModified(true)) { if (reconnectModified(true)) {
checkpointAllowed++; if (++checkpointAllowed > 20) {
if (SysProperties.CHECK && checkpointAllowed > 20) {
throw DbException.throwInternalError(Integer.toString(checkpointAllowed)); throw DbException.throwInternalError(Integer.toString(checkpointAllowed));
} }
return true; return true;
...@@ -2872,7 +2869,7 @@ public class Database implements DataHandler { ...@@ -2872,7 +2869,7 @@ public class Database implements DataHandler {
synchronized (reconnectSync) { synchronized (reconnectSync) {
checkpointAllowed--; checkpointAllowed--;
} }
if (SysProperties.CHECK && checkpointAllowed < 0) { if (checkpointAllowed < 0) {
throw DbException.throwInternalError(Integer.toString(checkpointAllowed)); throw DbException.throwInternalError(Integer.toString(checkpointAllowed));
} }
} }
......
...@@ -129,7 +129,7 @@ public abstract class DbObjectBase implements DbObject { ...@@ -129,7 +129,7 @@ public abstract class DbObjectBase implements DbObject {
* used. * used.
*/ */
protected void invalidate() { protected void invalidate() {
if (SysProperties.CHECK && id == -1) { if (id == -1) {
throw DbException.throwInternalError(); throw DbException.throwInternalError();
} }
setModified(); setModified();
......
...@@ -968,10 +968,8 @@ public class Session extends SessionWithState implements TransactionStore.Rollba ...@@ -968,10 +968,8 @@ public class Session extends SessionWithState implements TransactionStore.Rollba
} }
private void unlockAll() { private void unlockAll() {
if (SysProperties.CHECK) { if (undoLog != null && undoLog.size() > 0) {
if (undoLog != null && undoLog.size() > 0) { DbException.throwInternalError();
DbException.throwInternalError();
}
} }
if (!locks.isEmpty()) { if (!locks.isEmpty()) {
for (Table t : locks) { for (Table t : locks) {
...@@ -1349,7 +1347,7 @@ public class Session extends SessionWithState implements TransactionStore.Rollba ...@@ -1349,7 +1347,7 @@ public class Session extends SessionWithState implements TransactionStore.Rollba
*/ */
public void removeAtCommit(Value v) { public void removeAtCommit(Value v) {
final String key = v.toString(); final String key = v.toString();
if (SysProperties.CHECK && !v.isLinkedToTable()) { if (!v.isLinkedToTable()) {
DbException.throwInternalError(key); DbException.throwInternalError(key);
} }
if (removeLobMap == null) { if (removeLobMap == null) {
......
...@@ -196,10 +196,8 @@ public class UndoLogRecord { ...@@ -196,10 +196,8 @@ public class UndoLogRecord {
} }
int oldOp = operation; int oldOp = operation;
load(buff, log); load(buff, log);
if (SysProperties.CHECK) { if (operation != oldOp) {
if (operation != oldOp) { DbException.throwInternalError("operation=" + operation + " op=" + oldOp);
DbException.throwInternalError("operation=" + operation + " op=" + oldOp);
}
} }
} }
......
...@@ -9,7 +9,6 @@ import java.util.ArrayList; ...@@ -9,7 +9,6 @@ import java.util.ArrayList;
import org.h2.api.ErrorCode; import org.h2.api.ErrorCode;
import org.h2.engine.Database; import org.h2.engine.Database;
import org.h2.engine.Session; import org.h2.engine.Session;
import org.h2.engine.SysProperties;
import org.h2.expression.Expression; import org.h2.expression.Expression;
import org.h2.expression.ExpressionColumn; import org.h2.expression.ExpressionColumn;
import org.h2.expression.ExpressionVisitor; import org.h2.expression.ExpressionVisitor;
...@@ -229,7 +228,7 @@ public class Comparison extends Condition { ...@@ -229,7 +228,7 @@ public class Comparison extends Condition {
return ValueExpression.get(getValue(session)); return ValueExpression.get(getValue(session));
} }
} else { } else {
if (SysProperties.CHECK && (left == null || right == null)) { if (left == null || right == null) {
DbException.throwInternalError(left + " " + right); DbException.throwInternalError(left + " " + right);
} }
if (left == ValueExpression.getNull() || if (left == ValueExpression.getNull() ||
......
...@@ -6,7 +6,6 @@ ...@@ -6,7 +6,6 @@
package org.h2.expression.condition; package org.h2.expression.condition;
import org.h2.engine.Session; import org.h2.engine.Session;
import org.h2.engine.SysProperties;
import org.h2.expression.Expression; import org.h2.expression.Expression;
import org.h2.expression.ExpressionVisitor; import org.h2.expression.ExpressionVisitor;
import org.h2.expression.ValueExpression; import org.h2.expression.ValueExpression;
...@@ -39,7 +38,7 @@ public class ConditionAndOr extends Condition { ...@@ -39,7 +38,7 @@ public class ConditionAndOr extends Condition {
this.andOrType = andOrType; this.andOrType = andOrType;
this.left = left; this.left = left;
this.right = right; this.right = right;
if (SysProperties.CHECK && (left == null || right == null)) { if (left == null || right == null) {
DbException.throwInternalError(left + " " + right); DbException.throwInternalError(left + " " + right);
} }
} }
......
...@@ -176,7 +176,7 @@ public class PageBtreeIndex extends PageIndex { ...@@ -176,7 +176,7 @@ public class PageBtreeIndex extends PageIndex {
private Cursor find(Session session, SearchRow first, boolean bigger, private Cursor find(Session session, SearchRow first, boolean bigger,
SearchRow last) { SearchRow last) {
if (SysProperties.CHECK && store == null) { if (store == null) {
throw DbException.get(ErrorCode.OBJECT_CLOSED); throw DbException.get(ErrorCode.OBJECT_CLOSED);
} }
PageBtree root = getPage(rootPageId); PageBtree root = getPage(rootPageId);
......
...@@ -9,7 +9,6 @@ import java.util.Arrays; ...@@ -9,7 +9,6 @@ import java.util.Arrays;
import org.h2.api.ErrorCode; import org.h2.api.ErrorCode;
import org.h2.engine.Constants; import org.h2.engine.Constants;
import org.h2.engine.Session; import org.h2.engine.Session;
import org.h2.engine.SysProperties;
import org.h2.message.DbException; import org.h2.message.DbException;
import org.h2.result.SearchRow; import org.h2.result.SearchRow;
import org.h2.store.Data; import org.h2.store.Data;
...@@ -132,7 +131,7 @@ public class PageBtreeLeaf extends PageBtree { ...@@ -132,7 +131,7 @@ public class PageBtreeLeaf extends PageBtree {
} }
last = entryCount == 0 ? pageSize : offsets[entryCount - 1]; last = entryCount == 0 ? pageSize : offsets[entryCount - 1];
rowLength = index.getRowSize(data, row, true); rowLength = index.getRowSize(data, row, true);
if (SysProperties.CHECK && last - rowLength < start + OFFSET_LENGTH) { if (last - rowLength < start + OFFSET_LENGTH) {
throw DbException.throwInternalError(); throw DbException.throwInternalError();
} }
} }
......
...@@ -171,8 +171,7 @@ public class PageBtreeNode extends PageBtree { ...@@ -171,8 +171,7 @@ public class PageBtreeNode extends PageBtree {
} }
last = entryCount == 0 ? pageSize : offsets[entryCount - 1]; last = entryCount == 0 ? pageSize : offsets[entryCount - 1];
rowLength = index.getRowSize(data, row, true); rowLength = index.getRowSize(data, row, true);
if (SysProperties.CHECK && last - rowLength < if (last - rowLength < start + CHILD_OFFSET_PAIR_LENGTH) {
start + CHILD_OFFSET_PAIR_LENGTH) {
throw DbException.throwInternalError(); throw DbException.throwInternalError();
} }
} }
......
...@@ -10,7 +10,6 @@ import java.util.Arrays; ...@@ -10,7 +10,6 @@ import java.util.Arrays;
import org.h2.api.ErrorCode; import org.h2.api.ErrorCode;
import org.h2.engine.Constants; import org.h2.engine.Constants;
import org.h2.engine.Session; import org.h2.engine.Session;
import org.h2.engine.SysProperties;
import org.h2.message.DbException; import org.h2.message.DbException;
import org.h2.result.Row; import org.h2.result.Row;
import org.h2.store.Data; import org.h2.store.Data;
...@@ -578,7 +577,7 @@ public class PageDataLeaf extends PageData { ...@@ -578,7 +577,7 @@ public class PageDataLeaf extends PageData {
* @param overflow the new overflow page id * @param overflow the new overflow page id
*/ */
void setOverflow(int old, int overflow) { void setOverflow(int old, int overflow) {
if (SysProperties.CHECK && old != firstOverflowPageId) { if (old != firstOverflowPageId) {
DbException.throwInternalError("move " + this + " " + firstOverflowPageId); DbException.throwInternalError("move " + this + " " + firstOverflowPageId);
} }
index.getPageStore().logUndo(this, data); index.getPageStore().logUndo(this, data);
......
...@@ -8,7 +8,6 @@ package org.h2.index; ...@@ -8,7 +8,6 @@ package org.h2.index;
import org.h2.api.ErrorCode; import org.h2.api.ErrorCode;
import org.h2.engine.Constants; import org.h2.engine.Constants;
import org.h2.engine.Session; import org.h2.engine.Session;
import org.h2.engine.SysProperties;
import org.h2.message.DbException; import org.h2.message.DbException;
import org.h2.store.Data; import org.h2.store.Data;
import org.h2.store.Page; import org.h2.store.Page;
...@@ -245,7 +244,7 @@ public class PageDataOverflow extends Page { ...@@ -245,7 +244,7 @@ public class PageDataOverflow extends Page {
} }
private void setNext(int old, int nextPage) { private void setNext(int old, int nextPage) {
if (SysProperties.CHECK && old != this.nextPage) { if (old != this.nextPage) {
DbException.throwInternalError("move " + this + " " + nextPage); DbException.throwInternalError("move " + this + " " + nextPage);
} }
store.logUndo(this, data); store.logUndo(this, data);
......
...@@ -7,7 +7,6 @@ package org.h2.index; ...@@ -7,7 +7,6 @@ package org.h2.index;
import org.h2.command.dml.AllColumnsForPlan; import org.h2.command.dml.AllColumnsForPlan;
import org.h2.engine.Session; import org.h2.engine.Session;
import org.h2.engine.SysProperties;
import org.h2.message.DbException; import org.h2.message.DbException;
import org.h2.result.Row; import org.h2.result.Row;
import org.h2.result.SearchRow; import org.h2.result.SearchRow;
...@@ -205,7 +204,7 @@ public class TreeIndex extends BaseIndex { ...@@ -205,7 +204,7 @@ public class TreeIndex extends BaseIndex {
x.left = d.left; x.left = d.left;
} }
if (SysProperties.CHECK && x.right == null) { if (x.right == null) {
DbException.throwInternalError("tree corrupted"); DbException.throwInternalError("tree corrupted");
} }
x.right.parent = x; x.right.parent = x;
......
...@@ -609,7 +609,7 @@ public class MVTable extends TableBase { ...@@ -609,7 +609,7 @@ public class MVTable extends TableBase {
} else { } else {
addRowsToIndex(session, buffer, index); addRowsToIndex(session, buffer, index);
} }
if (SysProperties.CHECK && remaining != 0) { if (remaining != 0) {
DbException.throwInternalError("rowcount remaining=" + remaining + DbException.throwInternalError("rowcount remaining=" + remaining +
" " + getName()); " " + getName());
} }
...@@ -636,7 +636,7 @@ public class MVTable extends TableBase { ...@@ -636,7 +636,7 @@ public class MVTable extends TableBase {
remaining--; remaining--;
} }
addRowsToIndex(session, buffer, index); addRowsToIndex(session, buffer, index);
if (SysProperties.CHECK && remaining != 0) { if (remaining != 0) {
DbException.throwInternalError("rowcount remaining=" + remaining + DbException.throwInternalError("rowcount remaining=" + remaining +
" " + getName()); " " + getName());
} }
......
...@@ -270,7 +270,7 @@ public class Schema extends DbObjectBase { ...@@ -270,7 +270,7 @@ public class Schema extends DbObjectBase {
* @param obj the object to add * @param obj the object to add
*/ */
public void add(SchemaObject obj) { public void add(SchemaObject obj) {
if (SysProperties.CHECK && obj.getSchema() != this) { if (obj.getSchema() != this) {
DbException.throwInternalError("wrong schema"); DbException.throwInternalError("wrong schema");
} }
String name = obj.getName(); String name = obj.getName();
......
...@@ -5,7 +5,6 @@ ...@@ -5,7 +5,6 @@
*/ */
package org.h2.security; package org.h2.security;
import org.h2.engine.SysProperties;
import org.h2.message.DbException; import org.h2.message.DbException;
import org.h2.util.Bits; import org.h2.util.Bits;
...@@ -47,10 +46,8 @@ public class XTEA implements BlockCipher { ...@@ -47,10 +46,8 @@ public class XTEA implements BlockCipher {
@Override @Override
public void encrypt(byte[] bytes, int off, int len) { public void encrypt(byte[] bytes, int off, int len) {
if (SysProperties.CHECK) { if (len % ALIGN != 0) {
if (len % ALIGN != 0) { DbException.throwInternalError("unaligned len " + len);
DbException.throwInternalError("unaligned len " + len);
}
} }
for (int i = off; i < off + len; i += 8) { for (int i = off; i < off + len; i += 8) {
encryptBlock(bytes, bytes, i); encryptBlock(bytes, bytes, i);
...@@ -59,10 +56,8 @@ public class XTEA implements BlockCipher { ...@@ -59,10 +56,8 @@ public class XTEA implements BlockCipher {
@Override @Override
public void decrypt(byte[] bytes, int off, int len) { public void decrypt(byte[] bytes, int off, int len) {
if (SysProperties.CHECK) { if (len % ALIGN != 0) {
if (len % ALIGN != 0) { DbException.throwInternalError("unaligned len " + len);
DbException.throwInternalError("unaligned len " + len);
}
} }
for (int i = off; i < off + len; i += 8) { for (int i = off; i < off + len; i += 8) {
decryptBlock(bytes, bytes, i); decryptBlock(bytes, bytes, i);
......
...@@ -273,8 +273,7 @@ public class FileStore { ...@@ -273,8 +273,7 @@ public class FileStore {
* @param len the number of bytes to read * @param len the number of bytes to read
*/ */
public void readFully(byte[] b, int off, int len) { public void readFully(byte[] b, int off, int len) {
if (SysProperties.CHECK && if (len < 0 || len % Constants.FILE_BLOCK_SIZE != 0) {
(len < 0 || len % Constants.FILE_BLOCK_SIZE != 0)) {
DbException.throwInternalError( DbException.throwInternalError(
"unaligned read " + name + " len " + len); "unaligned read " + name + " len " + len);
} }
...@@ -293,8 +292,7 @@ public class FileStore { ...@@ -293,8 +292,7 @@ public class FileStore {
* @param pos the location * @param pos the location
*/ */
public void seek(long pos) { public void seek(long pos) {
if (SysProperties.CHECK && if (pos % Constants.FILE_BLOCK_SIZE != 0) {
pos % Constants.FILE_BLOCK_SIZE != 0) {
DbException.throwInternalError( DbException.throwInternalError(
"unaligned seek " + name + " pos " + pos); "unaligned seek " + name + " pos " + pos);
} }
...@@ -327,8 +325,7 @@ public class FileStore { ...@@ -327,8 +325,7 @@ public class FileStore {
* @param len the number of bytes to write * @param len the number of bytes to write
*/ */
public void write(byte[] b, int off, int len) { public void write(byte[] b, int off, int len) {
if (SysProperties.CHECK && (len < 0 || if (len < 0 || len % Constants.FILE_BLOCK_SIZE != 0) {
len % Constants.FILE_BLOCK_SIZE != 0)) {
DbException.throwInternalError( DbException.throwInternalError(
"unaligned write " + name + " len " + len); "unaligned write " + name + " len " + len);
} }
...@@ -350,7 +347,7 @@ public class FileStore { ...@@ -350,7 +347,7 @@ public class FileStore {
* @param newLength the new file size * @param newLength the new file size
*/ */
public void setLength(long newLength) { public void setLength(long newLength) {
if (SysProperties.CHECK && newLength % Constants.FILE_BLOCK_SIZE != 0) { if (newLength % Constants.FILE_BLOCK_SIZE != 0) {
DbException.throwInternalError( DbException.throwInternalError(
"unaligned setLength " + name + " pos " + newLength); "unaligned setLength " + name + " pos " + newLength);
} }
......
...@@ -14,7 +14,6 @@ import java.util.HashMap; ...@@ -14,7 +14,6 @@ import java.util.HashMap;
import org.h2.api.ErrorCode; import org.h2.api.ErrorCode;
import org.h2.compress.CompressLZF; import org.h2.compress.CompressLZF;
import org.h2.engine.Session; import org.h2.engine.Session;
import org.h2.engine.SysProperties;
import org.h2.message.DbException; import org.h2.message.DbException;
import org.h2.message.Trace; import org.h2.message.Trace;
import org.h2.result.Row; import org.h2.result.Row;
...@@ -498,10 +497,8 @@ public class PageLog { ...@@ -498,10 +497,8 @@ public class PageLog {
if (trace.isDebugEnabled()) { if (trace.isDebugEnabled()) {
trace.debug("log undo " + pageId); trace.debug("log undo " + pageId);
} }
if (SysProperties.CHECK) { if (page == null) {
if (page == null) { DbException.throwInternalError("Undo entry not written");
DbException.throwInternalError("Undo entry not written");
}
} }
undo.set(pageId); undo.set(pageId);
undoAll.set(pageId); undoAll.set(pageId);
......
...@@ -717,8 +717,7 @@ public class PageStore implements CacheWriter { ...@@ -717,8 +717,7 @@ public class PageStore implements CacheWriter {
try { try {
p.moveTo(pageStoreSession, free); p.moveTo(pageStoreSession, free);
} finally { } finally {
changeCount++; if (++changeCount < 0) {
if (SysProperties.CHECK && changeCount < 0) {
throw DbException.throwInternalError( throw DbException.throwInternalError(
"changeCount has wrapped"); "changeCount has wrapped");
} }
...@@ -1670,10 +1669,8 @@ public class PageStore implements CacheWriter { ...@@ -1670,10 +1669,8 @@ public class PageStore implements CacheWriter {
metaRootPageId.put(id, rootPageId); metaRootPageId.put(id, rootPageId);
if (type == META_TYPE_DATA_INDEX) { if (type == META_TYPE_DATA_INDEX) {
CreateTableData data = new CreateTableData(); CreateTableData data = new CreateTableData();
if (SysProperties.CHECK) { if (columns == null) {
if (columns == null) { throw DbException.throwInternalError(row.toString());
throw DbException.throwInternalError(row.toString());
}
} }
for (int i = 0, len = columns.length; i < len; i++) { for (int i = 0, len = columns.length; i < len; i++) {
Column col = new Column("C" + i, Value.INT); Column col = new Column("C" + i, Value.INT);
...@@ -1980,8 +1977,7 @@ public class PageStore implements CacheWriter { ...@@ -1980,8 +1977,7 @@ public class PageStore implements CacheWriter {
* Increment the change count. To be done after the operation has finished. * Increment the change count. To be done after the operation has finished.
*/ */
public void incrementChangeCount() { public void incrementChangeCount() {
changeCount++; if (++changeCount < 0) {
if (SysProperties.CHECK && changeCount < 0) {
throw DbException.throwInternalError("changeCount has wrapped"); throw DbException.throwInternalError("changeCount has wrapped");
} }
} }
......
...@@ -257,7 +257,7 @@ public class RegularTable extends TableBase { ...@@ -257,7 +257,7 @@ public class RegularTable extends TableBase {
remaining--; remaining--;
} }
addRowsToIndex(session, buffer, index); addRowsToIndex(session, buffer, index);
if (SysProperties.CHECK && remaining != 0) { if (remaining != 0) {
DbException.throwInternalError("rowcount remaining=" + DbException.throwInternalError("rowcount remaining=" +
remaining + " " + getName()); remaining + " " + getName());
} }
......
...@@ -14,7 +14,6 @@ import org.h2.command.dml.AllColumnsForPlan; ...@@ -14,7 +14,6 @@ import org.h2.command.dml.AllColumnsForPlan;
import org.h2.command.dml.Select; import org.h2.command.dml.Select;
import org.h2.engine.Right; import org.h2.engine.Right;
import org.h2.engine.Session; import org.h2.engine.Session;
import org.h2.engine.SysProperties;
import org.h2.expression.Expression; import org.h2.expression.Expression;
import org.h2.expression.ExpressionColumn; import org.h2.expression.ExpressionColumn;
import org.h2.expression.condition.Comparison; import org.h2.expression.condition.Comparison;
...@@ -321,13 +320,13 @@ public class TableFilter implements ColumnResolver { ...@@ -321,13 +320,13 @@ public class TableFilter implements ColumnResolver {
} }
} }
if (nestedJoin != null) { if (nestedJoin != null) {
if (SysProperties.CHECK && nestedJoin == this) { if (nestedJoin == this) {
DbException.throwInternalError("self join"); DbException.throwInternalError("self join");
} }
nestedJoin.prepare(); nestedJoin.prepare();
} }
if (join != null) { if (join != null) {
if (SysProperties.CHECK && join == this) { if (join == this) {
DbException.throwInternalError("self join"); DbException.throwInternalError("self join");
} }
join.prepare(); join.prepare();
......
...@@ -131,11 +131,8 @@ public class CacheLRU implements Cache { ...@@ -131,11 +131,8 @@ public class CacheLRU implements Cache {
if (old == null) { if (old == null) {
put(rec); put(rec);
} else { } else {
if (SysProperties.CHECK) { if (old != rec) {
if (old != rec) { DbException.throwInternalError("old!=record pos:" + pos + " old:" + old + " new:" + rec);
DbException.throwInternalError("old!=record pos:" + pos +
" old:" + old + " new:" + rec);
}
} }
if (!fifo) { if (!fifo) {
removeFromLinkedList(rec); removeFromLinkedList(rec);
...@@ -190,7 +187,7 @@ public class CacheLRU implements Cache { ...@@ -190,7 +187,7 @@ public class CacheLRU implements Cache {
break; break;
} }
} }
if (SysProperties.CHECK && check == head) { if (check == head) {
DbException.throwInternalError("try to remove head"); DbException.throwInternalError("try to remove head");
} }
// we are not allowed to remove it if the log is not yet written // we are not allowed to remove it if the log is not yet written
...@@ -230,17 +227,15 @@ public class CacheLRU implements Cache { ...@@ -230,17 +227,15 @@ public class CacheLRU implements Cache {
for (i = 0; i < size; i++) { for (i = 0; i < size; i++) {
CacheObject rec = changed.get(i); CacheObject rec = changed.get(i);
remove(rec.getPos()); remove(rec.getPos());
if (SysProperties.CHECK) { if (rec.cacheNext != null) {
if (rec.cacheNext != null) { throw DbException.throwInternalError();
throw DbException.throwInternalError();
}
} }
} }
} }
} }
private void addToFront(CacheObject rec) { private void addToFront(CacheObject rec) {
if (SysProperties.CHECK && rec == head) { if (rec == head) {
DbException.throwInternalError("try to move head"); DbException.throwInternalError("try to move head");
} }
rec.cacheNext = head; rec.cacheNext = head;
...@@ -250,7 +245,7 @@ public class CacheLRU implements Cache { ...@@ -250,7 +245,7 @@ public class CacheLRU implements Cache {
} }
private void removeFromLinkedList(CacheObject rec) { private void removeFromLinkedList(CacheObject rec) {
if (SysProperties.CHECK && rec == head) { if (rec == head) {
DbException.throwInternalError("try to remove head"); DbException.throwInternalError("try to remove head");
} }
rec.cachePrevious.cacheNext = rec.cacheNext; rec.cachePrevious.cacheNext = rec.cacheNext;
......
...@@ -5,7 +5,6 @@ ...@@ -5,7 +5,6 @@
*/ */
package org.h2.util; package org.h2.util;
import org.h2.engine.SysProperties;
import org.h2.message.DbException; import org.h2.message.DbException;
/** /**
...@@ -49,10 +48,8 @@ public abstract class CacheObject implements Comparable<CacheObject> { ...@@ -49,10 +48,8 @@ public abstract class CacheObject implements Comparable<CacheObject> {
public abstract int getMemory(); public abstract int getMemory();
public void setPos(int pos) { public void setPos(int pos) {
if (SysProperties.CHECK) { if (cachePrevious != null || cacheNext != null || cacheChained != null) {
if (cachePrevious != null || cacheNext != null || cacheChained != null) { DbException.throwInternalError("setPos too late");
DbException.throwInternalError("setPos too late");
}
} }
this.pos = pos; this.pos = pos;
} }
......
...@@ -7,8 +7,6 @@ package org.h2.util; ...@@ -7,8 +7,6 @@ package org.h2.util;
import java.util.Arrays; import java.util.Arrays;
import org.h2.engine.SysProperties;
/** /**
* An array with integer element. * An array with integer element.
*/ */
...@@ -63,10 +61,8 @@ public class IntArray { ...@@ -63,10 +61,8 @@ public class IntArray {
* @return the value * @return the value
*/ */
public int get(int index) { public int get(int index) {
if (SysProperties.CHECK) { if (index >= size) {
if (index >= size) { throw new ArrayIndexOutOfBoundsException("i=" + index + " size=" + size);
throw new ArrayIndexOutOfBoundsException("i=" + index + " size=" + size);
}
} }
return data[index]; return data[index];
} }
...@@ -77,10 +73,8 @@ public class IntArray { ...@@ -77,10 +73,8 @@ public class IntArray {
* @param index the index * @param index the index
*/ */
public void remove(int index) { public void remove(int index) {
if (SysProperties.CHECK) { if (index >= size) {
if (index >= size) { throw new ArrayIndexOutOfBoundsException("i=" + index + " size=" + size);
throw new ArrayIndexOutOfBoundsException("i=" + index + " size=" + size);
}
} }
System.arraycopy(data, index + 1, data, index, size - index - 1); System.arraycopy(data, index + 1, data, index, size - index - 1);
size--; size--;
...@@ -164,11 +158,8 @@ public class IntArray { ...@@ -164,11 +158,8 @@ public class IntArray {
* @param toIndex upper bound (exclusive) * @param toIndex upper bound (exclusive)
*/ */
public void removeRange(int fromIndex, int toIndex) { public void removeRange(int fromIndex, int toIndex) {
if (SysProperties.CHECK) { if (fromIndex > toIndex || toIndex > size) {
if (fromIndex > toIndex || toIndex > size) { throw new ArrayIndexOutOfBoundsException("from=" + fromIndex + " to=" + toIndex + " size=" + size);
throw new ArrayIndexOutOfBoundsException("from=" + fromIndex +
" to=" + toIndex + " size=" + size);
}
} }
System.arraycopy(data, toIndex, data, fromIndex, size - toIndex); System.arraycopy(data, toIndex, data, fromIndex, size - toIndex);
size -= toIndex - fromIndex; size -= toIndex - fromIndex;
......
...@@ -433,14 +433,10 @@ public class StringUtils { ...@@ -433,14 +433,10 @@ public class StringUtils {
} else if (ch == '%') { } else if (ch == '%') {
buff[j++] = (byte) Integer.parseInt(encoded.substring(i + 1, i + 3), 16); buff[j++] = (byte) Integer.parseInt(encoded.substring(i + 1, i + 3), 16);
i += 2; i += 2;
} else { } else if (ch <= 127 && ch >= ' ') {
if (SysProperties.CHECK) {
if (ch > 127 || ch < ' ') {
throw new IllegalArgumentException(
"Unexpected char " + (int) ch + " decoding " + encoded);
}
}
buff[j++] = (byte) ch; buff[j++] = (byte) ch;
} else {
throw new IllegalArgumentException("Unexpected char " + (int) ch + " decoding " + encoded);
} }
} }
return new String(buff, 0, j, StandardCharsets.UTF_8); return new String(buff, 0, j, StandardCharsets.UTF_8);
......
...@@ -208,7 +208,7 @@ public class ValueLob extends Value { ...@@ -208,7 +208,7 @@ public class ValueLob extends Value {
private static String getFileName(DataHandler handler, int tableId, private static String getFileName(DataHandler handler, int tableId,
int objectId) { int objectId) {
if (SysProperties.CHECK && tableId == 0 && objectId == 0) { if (tableId == 0 && objectId == 0) {
DbException.throwInternalError("0 LOB"); DbException.throwInternalError("0 LOB");
} }
String table = tableId < 0 ? ".temp" : ".t" + tableId; String table = tableId < 0 ? ".temp" : ".t" + tableId;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论