提交 2c153446 authored 作者: Noel Grandin's avatar Noel Grandin

add some info when we throw internal error

no reason to be parsimonious here, can only help
上级 e539889c
......@@ -7,7 +7,6 @@ package org.h2.constraint;
import java.util.HashSet;
import java.util.Iterator;
import org.h2.api.ErrorCode;
import org.h2.engine.Session;
import org.h2.expression.Expression;
......@@ -115,7 +114,7 @@ public class ConstraintCheck extends Constraint {
@Override
public void setIndexOwner(Index index) {
DbException.throwInternalError();
DbException.throwInternalError(toString());
}
@Override
......
......@@ -7,7 +7,6 @@ package org.h2.constraint;
import java.util.ArrayList;
import java.util.HashSet;
import org.h2.api.ErrorCode;
import org.h2.command.Parser;
import org.h2.command.Prepared;
......@@ -626,7 +625,7 @@ public class ConstraintReferential extends Constraint {
} else if (this.refIndex == index) {
refIndexOwner = true;
} else {
DbException.throwInternalError();
DbException.throwInternalError(index + " " + toString());
}
}
......
......@@ -27,7 +27,7 @@ public class Comment extends DbObjectBase {
@Override
public String getCreateSQLForCopy(Table table, String quotedName) {
throw DbException.throwInternalError();
throw DbException.throwInternalError(toString());
}
private static String getTypeName(int type) {
......
......@@ -1664,7 +1664,7 @@ public class Database implements DataHandler {
ArrayList<DbObject> list = obj.getChildren();
Comment comment = findComment(obj);
if (comment != null) {
DbException.throwInternalError();
DbException.throwInternalError(comment.toString());
}
updateMeta(session, obj);
// remember that this scans only one level deep!
......@@ -2575,7 +2575,7 @@ public class Database implements DataHandler {
long now = System.currentTimeMillis();
if (now > reconnectCheckNext + reconnectCheckDelay) {
if (SysProperties.CHECK && checkpointAllowed < 0) {
DbException.throwInternalError();
DbException.throwInternalError("" + checkpointAllowed);
}
synchronized (reconnectSync) {
if (checkpointAllowed > 0) {
......@@ -2645,7 +2645,7 @@ public class Database implements DataHandler {
if (reconnectModified(true)) {
checkpointAllowed++;
if (SysProperties.CHECK && checkpointAllowed > 20) {
throw DbException.throwInternalError();
throw DbException.throwInternalError("" + checkpointAllowed);
}
return true;
}
......@@ -2667,7 +2667,7 @@ public class Database implements DataHandler {
checkpointAllowed--;
}
if (SysProperties.CHECK && checkpointAllowed < 0) {
throw DbException.throwInternalError();
throw DbException.throwInternalError("" + checkpointAllowed);
}
}
......
......@@ -12,7 +12,6 @@ import java.lang.reflect.Modifier;
import java.sql.Connection;
import java.util.ArrayList;
import java.util.Arrays;
import org.h2.Driver;
import org.h2.api.ErrorCode;
import org.h2.command.Parser;
......@@ -196,7 +195,7 @@ public class FunctionAlias extends SchemaObjectBase {
@Override
public String getCreateSQLForCopy(Table table, String quotedName) {
throw DbException.throwInternalError();
throw DbException.throwInternalError(toString());
}
@Override
......
......@@ -23,7 +23,7 @@ public class Role extends RightOwner {
@Override
public String getCreateSQLForCopy(Table table, String quotedName) {
throw DbException.throwInternalError();
throw DbException.throwInternalError(toString());
}
@Override
......
......@@ -840,7 +840,7 @@ public class Session extends SessionWithState {
public void addLock(Table table) {
if (SysProperties.CHECK) {
if (locks.contains(table)) {
DbException.throwInternalError();
DbException.throwInternalError(table.toString());
}
}
locks.add(table);
......@@ -869,7 +869,7 @@ public class Session extends SessionWithState {
if (locks.indexOf(log.getTable()) < 0
&& TableType.TABLE_LINK != tableType
&& TableType.EXTERNAL_TABLE_ENGINE != tableType) {
DbException.throwInternalError();
DbException.throwInternalError("" + tableType);
}
}
}
......@@ -1271,7 +1271,7 @@ public class Session extends SessionWithState {
*/
public void removeAtCommit(Value v) {
if (SysProperties.CHECK && !v.isLinkedToTable()) {
DbException.throwInternalError();
DbException.throwInternalError(v.toString());
}
if (removeLobMap == null) {
removeLobMap = New.hashMap();
......
......@@ -39,7 +39,7 @@ public class Setting extends DbObjectBase {
@Override
public String getCreateSQLForCopy(Table table, String quotedName) {
throw DbException.throwInternalError();
throw DbException.throwInternalError(toString());
}
@Override
......
......@@ -76,7 +76,7 @@ public class User extends RightOwner {
@Override
public String getCreateSQLForCopy(Table table, String quotedName) {
throw DbException.throwInternalError();
throw DbException.throwInternalError(toString());
}
@Override
......
......@@ -7,7 +7,6 @@ package org.h2.engine;
import java.sql.Connection;
import java.sql.SQLException;
import org.h2.api.Aggregate;
import org.h2.api.AggregateFunction;
import org.h2.command.Parser;
......@@ -55,7 +54,7 @@ public class UserAggregate extends DbObjectBase {
@Override
public String getCreateSQLForCopy(Table table, String quotedName) {
throw DbException.throwInternalError();
throw DbException.throwInternalError(toString());
}
@Override
......
......@@ -23,7 +23,7 @@ public class UserDataType extends DbObjectBase {
@Override
public String getCreateSQLForCopy(Table table, String quotedName) {
throw DbException.throwInternalError();
throw DbException.throwInternalError(toString());
}
@Override
......
......@@ -329,7 +329,7 @@ public class CompareLike extends Condition {
}
return false;
default:
DbException.throwInternalError();
DbException.throwInternalError("" + types[pi]);
}
}
return si == sLen;
......
......@@ -206,7 +206,7 @@ public class Comparison extends Condition {
}
} else {
if (SysProperties.CHECK && (left == null || right == null)) {
DbException.throwInternalError();
DbException.throwInternalError(left + " " + right);
}
if (left == ValueExpression.getNull() ||
right == ValueExpression.getNull()) {
......
......@@ -37,7 +37,7 @@ public class ConditionAndOr extends Condition {
this.left = left;
this.right = right;
if (SysProperties.CHECK && (left == null || right == null)) {
DbException.throwInternalError();
DbException.throwInternalError(left + " " + right);
}
}
......
......@@ -34,12 +34,12 @@ public class Wildcard extends Expression {
@Override
public Value getValue(Session session) {
throw DbException.throwInternalError();
throw DbException.throwInternalError(toString());
}
@Override
public int getType() {
throw DbException.throwInternalError();
throw DbException.throwInternalError(toString());
}
@Override
......@@ -54,22 +54,22 @@ public class Wildcard extends Expression {
@Override
public void setEvaluatable(TableFilter tableFilter, boolean b) {
DbException.throwInternalError();
DbException.throwInternalError(toString());
}
@Override
public int getScale() {
throw DbException.throwInternalError();
throw DbException.throwInternalError(toString());
}
@Override
public long getPrecision() {
throw DbException.throwInternalError();
throw DbException.throwInternalError(toString());
}
@Override
public int getDisplaySize() {
throw DbException.throwInternalError();
throw DbException.throwInternalError(toString());
}
@Override
......@@ -92,7 +92,7 @@ public class Wildcard extends Expression {
@Override
public void updateAggregate(Session session) {
DbException.throwInternalError();
DbException.throwInternalError(toString());
}
@Override
......@@ -100,12 +100,12 @@ public class Wildcard extends Expression {
if (visitor.getType() == ExpressionVisitor.QUERY_COMPARABLE) {
return true;
}
throw DbException.throwInternalError();
throw DbException.throwInternalError("" + visitor.getType());
}
@Override
public int getCost() {
throw DbException.throwInternalError();
throw DbException.throwInternalError(toString());
}
}
......@@ -141,7 +141,7 @@ public abstract class BaseIndex extends SchemaObjectBase implements Index {
*/
@Override
public Cursor findNext(Session session, SearchRow higherThan, SearchRow last) {
throw DbException.throwInternalError();
throw DbException.throwInternalError(toString());
}
/**
......
......@@ -56,7 +56,7 @@ public class FunctionCursor implements Cursor {
@Override
public boolean previous() {
throw DbException.throwInternalError();
throw DbException.throwInternalError(toString());
}
}
......@@ -74,7 +74,7 @@ public class FunctionCursorResultSet implements Cursor {
@Override
public boolean previous() {
throw DbException.throwInternalError();
throw DbException.throwInternalError(toString());
}
}
\ No newline at end of file
......@@ -68,7 +68,7 @@ public class HashIndex extends BaseIndex {
public Cursor find(Session session, SearchRow first, SearchRow last) {
if (first == null || last == null) {
// TODO hash index: should additionally check if values are the same
throw DbException.throwInternalError();
throw DbException.throwInternalError(first + " " + last);
}
Value v = first.getValue(indexColumn);
/*
......
......@@ -347,7 +347,7 @@ public class IndexCursor implements Cursor {
@Override
public boolean previous() {
throw DbException.throwInternalError();
throw DbException.throwInternalError(toString());
}
}
......@@ -8,7 +8,6 @@ package org.h2.index;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import org.h2.engine.Session;
import org.h2.message.DbException;
import org.h2.result.Row;
......@@ -73,7 +72,7 @@ public class LinkedCursor implements Cursor {
@Override
public boolean previous() {
throw DbException.throwInternalError();
throw DbException.throwInternalError(toString());
}
}
......@@ -42,7 +42,7 @@ public class MetaCursor implements Cursor {
@Override
public boolean previous() {
throw DbException.throwInternalError();
throw DbException.throwInternalError(toString());
}
}
......@@ -93,7 +93,7 @@ public class MultiVersionIndex implements Index {
@Override
public Cursor findNext(Session session, SearchRow first, SearchRow last) {
throw DbException.throwInternalError();
throw DbException.throwInternalError(toString());
}
@Override
......
......@@ -86,7 +86,7 @@ public class NonUniqueHashIndex extends BaseIndex {
@Override
public Cursor find(Session session, SearchRow first, SearchRow last) {
if (first == null || last == null) {
throw DbException.throwInternalError();
throw DbException.throwInternalError(first + " " + last);
}
if (first != last) {
if (compareKeys(first, last) != 0) {
......
......@@ -6,7 +6,6 @@
package org.h2.index;
import java.util.Arrays;
import org.h2.api.ErrorCode;
import org.h2.engine.Constants;
import org.h2.engine.Session;
......@@ -178,7 +177,7 @@ public class PageBtreeLeaf extends PageBtree {
written = false;
changeCount = index.getPageStore().getChangeCount();
if (entryCount <= 0) {
DbException.throwInternalError();
DbException.throwInternalError("" + entryCount);
}
int startNext = at > 0 ? offsets[at - 1] : index.getPageStore().getPageSize();
int rowLength = startNext - offsets[at];
......
......@@ -474,7 +474,7 @@ public class PageBtreeNode extends PageBtree {
written = false;
changeCount = index.getPageStore().getChangeCount();
if (entryCount < 0) {
DbException.throwInternalError();
DbException.throwInternalError("" + entryCount);
}
if (entryCount > i) {
int startNext = i > 0 ? offsets[i - 1] : index.getPageStore().getPageSize();
......@@ -604,7 +604,7 @@ public class PageBtreeNode extends PageBtree {
return;
}
}
throw DbException.throwInternalError();
throw DbException.throwInternalError(oldPos + " " + newPos);
}
}
\ No newline at end of file
......@@ -104,7 +104,7 @@ class PageDataCursor implements Cursor {
@Override
public boolean previous() {
throw DbException.throwInternalError();
throw DbException.throwInternalError(toString());
}
}
......@@ -300,7 +300,7 @@ public class PageDataIndex extends PageIndex {
@Override
public Cursor findFirstOrLast(Session session, boolean first) {
throw DbException.throwInternalError();
throw DbException.throwInternalError(toString());
}
long getLastKey() {
......
......@@ -7,7 +7,6 @@ package org.h2.index;
import java.lang.ref.SoftReference;
import java.util.Arrays;
import org.h2.api.ErrorCode;
import org.h2.engine.Constants;
import org.h2.engine.Session;
......@@ -221,7 +220,7 @@ public class PageDataLeaf extends PageData {
if (offset < start) {
writtenData = false;
if (entryCount > 1) {
DbException.throwInternalError();
DbException.throwInternalError("" + entryCount);
}
// need to write the overflow page id
start += 4;
......@@ -284,7 +283,7 @@ public class PageDataLeaf extends PageData {
}
entryCount--;
if (entryCount < 0) {
DbException.throwInternalError();
DbException.throwInternalError("" + entryCount);
}
if (firstOverflowPageId != 0) {
start -= 4;
......
......@@ -388,7 +388,7 @@ public class PageDataNode extends PageData {
entryCount--;
length -= 4 + Data.getVarLongLen(keys[removedKeyIndex]);
if (entryCount < 0) {
DbException.throwInternalError();
DbException.throwInternalError("" + entryCount);
}
keys = remove(keys, entryCount + 1, removedKeyIndex);
childPageIds = remove(childPageIds, entryCount + 2, i);
......@@ -453,7 +453,7 @@ public class PageDataNode extends PageData {
return;
}
}
throw DbException.throwInternalError();
throw DbException.throwInternalError(oldPos + " " + newPos);
}
}
......@@ -85,7 +85,7 @@ public class PageDelegateIndex extends PageIndex {
@Override
public Cursor findNext(Session session, SearchRow higherThan, SearchRow last) {
throw DbException.throwInternalError();
throw DbException.throwInternalError(toString());
}
@Override
......
......@@ -59,7 +59,7 @@ class RangeCursor implements Cursor {
@Override
public boolean previous() {
throw DbException.throwInternalError();
throw DbException.throwInternalError(toString());
}
}
......@@ -72,7 +72,7 @@ public class ScanCursor implements Cursor {
@Override
public boolean previous() {
throw DbException.throwInternalError();
throw DbException.throwInternalError(toString());
}
}
......@@ -47,7 +47,7 @@ public class SingleRowCursor implements Cursor {
@Override
public boolean previous() {
throw DbException.throwInternalError();
throw DbException.throwInternalError(toString());
}
}
......@@ -237,7 +237,7 @@ public class SpatialTreeIndex extends BaseIndex implements SpatialIndex {
@Override
public Cursor findFirstOrLast(Session session, boolean first) {
if (closed) {
throw DbException.throwInternalError();
throw DbException.throwInternalError(toString());
}
if (!first) {
throw DbException.throwInternalError(
......
......@@ -355,7 +355,7 @@ public class TreeIndex extends BaseIndex {
@Override
public Cursor findFirstOrLast(Session session, boolean first) {
if (closed) {
throw DbException.throwInternalError();
throw DbException.throwInternalError(toString());
}
if (first) {
// TODO optimization: this loops through NULL
......
......@@ -81,7 +81,7 @@ public class ViewCursor implements Cursor {
@Override
public boolean previous() {
throw DbException.throwInternalError();
throw DbException.throwInternalError(toString());
}
}
......@@ -28,7 +28,7 @@ public class Constant extends SchemaObjectBase {
@Override
public String getCreateSQLForCopy(Table table, String quotedName) {
throw DbException.throwInternalError();
throw DbException.throwInternalError(toString());
}
@Override
......
......@@ -88,7 +88,7 @@ public class Schema extends DbObjectBase {
@Override
public String getCreateSQLForCopy(Table table, String quotedName) {
throw DbException.throwInternalError();
throw DbException.throwInternalError(toString());
}
@Override
......
......@@ -6,7 +6,6 @@
package org.h2.schema;
import java.math.BigInteger;
import org.h2.api.ErrorCode;
import org.h2.engine.DbObject;
import org.h2.engine.Session;
......@@ -208,7 +207,7 @@ public class Sequence extends SchemaObjectBase {
@Override
public String getCreateSQLForCopy(Table table, String quotedName) {
throw DbException.throwInternalError();
throw DbException.throwInternalError(toString());
}
@Override
......
......@@ -10,7 +10,6 @@ import java.lang.ref.Reference;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;
import java.util.Arrays;
import org.h2.api.ErrorCode;
import org.h2.engine.Constants;
import org.h2.engine.SysProperties;
......@@ -400,7 +399,7 @@ public class FileStore {
if (SysProperties.CHECK2) {
try {
if (file.position() != filePos) {
DbException.throwInternalError();
DbException.throwInternalError(file.position() + " " + filePos);
}
} catch (IOException e) {
throw DbException.convertIOException(e, name);
......
......@@ -15,7 +15,6 @@ import java.sql.Statement;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import org.h2.api.ErrorCode;
import org.h2.engine.Database;
import org.h2.engine.SysProperties;
......@@ -614,7 +613,7 @@ public class LobStorageBackend implements LobStorageInterface {
private static void assertNotHolds(Object lock) {
if (Thread.holdsLock(lock)) {
throw DbException.throwInternalError();
throw DbException.throwInternalError(lock.toString());
}
}
......@@ -625,7 +624,7 @@ public class LobStorageBackend implements LobStorageInterface {
*/
static void assertHoldsLock(Object lock) {
if (!Thread.holdsLock(lock)) {
throw DbException.throwInternalError();
throw DbException.throwInternalError(lock.toString());
}
}
......
......@@ -125,7 +125,7 @@ public class FunctionTable extends Table {
@Override
public boolean canDrop() {
throw DbException.throwInternalError();
throw DbException.throwInternalError(toString());
}
@Override
......
......@@ -2000,7 +2000,7 @@ public class MetaTable extends Table {
@Override
public long getRowCount(Session session) {
throw DbException.throwInternalError();
throw DbException.throwInternalError(toString());
}
@Override
......
......@@ -144,7 +144,7 @@ public class RangeTable extends Table {
@Override
public TableType getTableType() {
throw DbException.throwInternalError();
throw DbException.throwInternalError(toString());
}
@Override
......
......@@ -318,7 +318,7 @@ public abstract class Table extends SchemaObjectBase {
@Override
public String getCreateSQLForCopy(Table table, String quotedName) {
throw DbException.throwInternalError();
throw DbException.throwInternalError(toString());
}
/**
......
......@@ -7,7 +7,6 @@ package org.h2.table;
import java.util.ArrayList;
import java.util.HashSet;
import org.h2.api.ErrorCode;
import org.h2.command.Parser;
import org.h2.command.dml.Select;
......@@ -835,7 +834,7 @@ public class TableFilter implements ColumnResolver {
IndexLookupBatch lookupBatch = joinBatch.getLookupBatch(joinFilterId);
if (lookupBatch == null) {
if (joinFilterId != 0) {
throw DbException.throwInternalError();
throw DbException.throwInternalError("" + joinFilterId);
}
} else {
planBuff.append("batched:");
......
......@@ -389,7 +389,7 @@ public class TableView extends Table {
@Override
public long getRowCount(Session session) {
throw DbException.throwInternalError();
throw DbException.throwInternalError(toString());
}
@Override
......
......@@ -84,7 +84,7 @@ public abstract class LazyFuture<T> implements Future<T> {
case S_CANCELED:
throw new CancellationException();
default:
throw DbException.throwInternalError();
throw DbException.throwInternalError("" + state);
}
}
......
......@@ -723,7 +723,7 @@ public class ValueLob extends Value {
}
Value v2 = copy(h, tabId);
if (SysProperties.CHECK && v2 != this) {
DbException.throwInternalError();
DbException.throwInternalError(v2.toString());
}
}
} catch (IOException e) {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论