提交 e2d3afcb authored 作者: Thomas Mueller's avatar Thomas Mueller

--no commit message

--no commit message
上级 a22f28fa
......@@ -24,6 +24,7 @@ import org.h2.util.StringUtils;
import org.h2.value.DataType;
import org.h2.value.Value;
import org.h2.value.ValueInt;
import org.h2.value.ValueLong;
import org.h2.value.ValueNull;
import org.h2.value.ValueString;
import org.h2.value.ValueTime;
......@@ -54,6 +55,7 @@ public class Column {
private int selectivity;
private SingleColumnResolver resolver;
private String comment;
private boolean primaryKey;
// must be equal to ResultSetMetaData columnNoNulls, columnNullable, columnNullableUnknown
public static final int NOT_NULLABLE = 0, NULLABLE = 1, NULLABLE_UNKNOWN = 2;
......@@ -148,6 +150,9 @@ public class Column {
value = ValueNull.INSTANCE;
} else {
value = defaultExpression.getValue(session).convertTo(type);
if(primaryKey) {
session.setLastIdentity(value);
}
}
}
if (value == ValueNull.INSTANCE) {
......@@ -203,7 +208,7 @@ public class Column {
}
if(update) {
sequence.setStartValue(now + increment);
session.setLastIdentity(now);
session.setLastIdentity(ValueLong.get(now));
sequence.flush();
}
}
......@@ -424,5 +429,9 @@ public class Column {
public String getComment() {
return comment;
}
public void setPrimaryKey(boolean primaryKey) {
this.primaryKey = primaryKey;
}
}
......@@ -654,7 +654,7 @@ public class MetaTable extends Table {
add(rows, new String[]{"h2.lobFilesInDirectories", "" + Constants.LOB_FILES_IN_DIRECTORIES});
add(rows, new String[]{"h2.lobFilesPerDirectory", "" + Constants.LOB_FILES_PER_DIRECTORY});
add(rows, new String[]{"h2.multiThreadedKernel", "" + Constants.MULTI_THREADED_KERNEL});
add(rows, new String[]{"h2.runFinalizers", "" + Constants.RUN_FINALIZERS});
add(rows, new String[]{"h2.runFinalize", "" + Constants.RUN_FINALIZE});
add(rows, new String[]{"h2.optimizeMinMax", "" + Constants.OPTIMIZE_MIN_MAX});
add(rows, new String[]{"h2.optimizeIn", "" + Constants.OPTIMIZE_IN});
add(rows, new String[]{"h2.redoBufferSize", "" + Constants.REDO_BUFFER_SIZE});
......@@ -664,7 +664,7 @@ public class MetaTable extends Table {
add(rows, new String[]{"h2.logAllErrors", "" + Constants.LOG_ALL_ERRORS});
add(rows, new String[]{"h2.logAllErrorsFile", "" + Constants.LOG_ALL_ERRORS_FILE});
add(rows, new String[]{"h2.serverCachedObjects", "" + Constants.SERVER_CACHED_OBJECTS});
add(rows, new String[]{"h2.serverSmallResultSetSize", "" + Constants.SERVER_SMALL_RESULTSET_SIZE});
add(rows, new String[]{"h2.serverSmallResultSetSize", "" + Constants.SERVER_SMALL_RESULT_SET_SIZE});
add(rows, new String[]{"h2.emergencySpaceInitial", "" + Constants.EMERGENCY_SPACE_INITIAL});
add(rows, new String[]{"h2.emergencySpaceMin", "" + Constants.EMERGENCY_SPACE_MIN});
add(rows, new String[]{"h2.objectCache", "" + Constants.OBJECT_CACHE});
......
......@@ -25,14 +25,14 @@ public class Plan {
this.filters = new TableFilter[count];
System.arraycopy(filters, 0, this.filters, 0, count);
ObjectArray allCond = new ObjectArray();
ObjectArray allFilt= new ObjectArray();
ObjectArray all = new ObjectArray();
if(condition != null) {
allCond.add(condition);
}
for(int i=0; i<count; i++) {
TableFilter f = filters[i];
do {
allFilt.add(f);
all.add(f);
if(f.getJoinCondition() != null) {
allCond.add(f.getJoinCondition());
}
......@@ -41,8 +41,8 @@ public class Plan {
}
allConditions = new Expression[allCond.size()];
allCond.toArray(allConditions);
allFilters = new TableFilter[allFilt.size()];
allFilt.toArray(allFilters);
allFilters = new TableFilter[all.size()];
all.toArray(allFilters);
}
public PlanItem getItem(TableFilter filter) {
......
......@@ -11,11 +11,26 @@ import org.h2.index.Index;
*/
public class PlanItem {
public double cost;
public Index index;
public PlanItem joinPlan;
private Index index;
private int todoObjectArray;
private PlanItem joinPlan;
public void setIndex(Index index) {
this.index = index;
}
public Index getIndex() {
return index;
}
public PlanItem getJoinPlan() {
return joinPlan;
}
public void setJoinPlan(PlanItem joinPlan) {
this.joinPlan = joinPlan;
}
}
......@@ -225,15 +225,15 @@ public abstract class Table extends SchemaObject {
*/
public PlanItem getBestPlanItem(Session session, int[] masks) throws SQLException {
PlanItem item = new PlanItem();
item.index = getScanIndex(session);
item.cost = item.index.getCost(null);
item.setIndex(getScanIndex(session));
item.cost = item.getIndex().getCost(null);
ObjectArray indexes = getIndexes();
for (int i = 1; indexes != null && masks != null && i < indexes.size(); i++) {
Index index = (Index) indexes.get(i);
int cost = index.getCost(masks);
if (cost < item.cost) {
item.cost = cost;
item.index = index;
item.setIndex(index);
}
}
return item;
......@@ -289,6 +289,12 @@ public abstract class Table extends SchemaObject {
ObjectArray indexes = getIndexes();
if(indexes != null) {
remove(indexes, index);
if(index.indexType.isPrimaryKey()) {
Column[] cols = index.getColumns();
for(int i=0; i<cols.length; i++) {
cols[i].setPrimaryKey(false);
}
}
}
}
......@@ -334,7 +340,7 @@ public abstract class Table extends SchemaObject {
if(list == null) {
list = new ObjectArray();
}
// self contraints are two entries in the list
// self constraints are two entries in the list
// if(Database.CHECK) {
// if(list.indexOf(obj) >= 0) {
// throw Message.internal("object already in list: " + obj.getName());
......
......@@ -96,7 +96,7 @@ public class TableData extends Table implements RecordReader {
}
}
} catch(SQLException e2) {
// this could happend, for example on failure in the storage
// this could happen, for example on failure in the storage
// but if that is not the case it means there is something wrong with the database
// TODO log this problem
throw e2;
......@@ -132,6 +132,7 @@ public class TableData extends Table implements RecordReader {
if(column.getNullable()) {
throw Message.getSQLException(Message.COLUMN_MUST_NOT_BE_NULLABLE_1, column.getName());
}
column.setPrimaryKey(true);
}
}
Index index;
......@@ -175,7 +176,7 @@ public class TableData extends Table implements RecordReader {
try {
index.remove(session);
} catch(SQLException e2) {
// this could happend, for example on failure in the storage
// this could happen, for example on failure in the storage
// but if that is not the case it means there is something wrong with the database
// TODO log this problem
throw e2;
......
......@@ -44,7 +44,11 @@ public class TableFilter implements ColumnResolver {
private Expression joinCondition;
private Row current;
private int state;
private TableFilter join;
private int todo;
private ObjectArray joins;
// private TableFilter join;
private boolean outerJoin;
private boolean foundOne;
private Expression fullCondition;
......@@ -70,17 +74,21 @@ public class TableFilter implements ColumnResolver {
session.getUser().checkRight(table, Right.SELECT);
}
table.lock(session, exclusive);
if (join != null) {
join.lock(session, exclusive);
for(int i=0; joins != null && i<joins.size(); i++) {
getTableFilter(i).lock(session, exclusive);
}
}
private TableFilter getTableFilter(int i) {
return (TableFilter) joins.get(i);
}
public PlanItem getBestPlanItem(Session session) throws SQLException {
PlanItem item;
if (indexConditions.size() == 0) {
item = new PlanItem();
item.index = table.getScanIndex(session);
item.cost = item.index.getCost(null);
item.setIndex(table.getScanIndex(session));
item.cost = item.getIndex().getCost(null);
} else {
int len = table.getColumns().length;
int[] masks = new int[len];
......@@ -98,27 +106,34 @@ public class TableFilter implements ColumnResolver {
}
item = table.getBestPlanItem(session, masks);
}
if(join != null) {
TableFilter j = join;
// this table filter is now evaluatable - in all sub-joins
do {
Expression e = j.getJoinCondition();
if(e != null) {
e.setEvaluatable(this, true);
}
j = j.getJoin();
} while(j != null);
item.joinPlan = join.getBestPlanItem(session);
for(int i=0; joins != null && i<joins.size(); i++) {
TableFilter join = getTableFilter(i);
setEvaluatable(join);
item.setJoinPlan(join.getBestPlanItem(session));
// TODO optimizer: calculate cost of a join: should use separate expected row number and lookup cost
item.cost += item.cost * item.joinPlan.cost;
item.cost += item.cost * item.getJoinPlan().cost;
}
return item;
}
private void setEvaluatable(TableFilter join) {
// this table filter is now evaluatable - in all sub-joins
do {
Expression e = join.getJoinCondition();
if(e != null) {
e.setEvaluatable(this, true);
}
join = join.getJoin();
} while(join != null);
}
public void setPlanItem(PlanItem item) {
this.index = item.index;
if(join != null && item.joinPlan!=null) {
join.setPlanItem(item.joinPlan);
this.index = item.getIndex();
for(int i=0; joins != null && i<joins.size(); i++) {
TableFilter join = getTableFilter(i);
if(item.getJoinPlan()!=null) {
join.setPlanItem(item.getJoinPlan());
}
}
}
......@@ -134,7 +149,8 @@ public class TableFilter implements ColumnResolver {
}
}
}
if(join != null) {
for(int i=0; joins != null && i<joins.size(); i++) {
TableFilter join = getTableFilter(i);
if(Constants.CHECK && join==this) {
throw Message.getInternalError("self join");
}
......@@ -144,13 +160,15 @@ public class TableFilter implements ColumnResolver {
public void startQuery() {
scanCount = 0;
if(join != null) {
for(int i=0; joins != null && i<joins.size(); i++) {
TableFilter join = getTableFilter(i);
join.startQuery();
}
}
public void reset() throws SQLException {
if (join != null) {
for(int i=0; joins != null && i<joins.size(); i++) {
TableFilter join = getTableFilter(i);
join.reset();
}
state = BEFORE_FIRST;
......@@ -190,14 +208,23 @@ public class TableFilter implements ColumnResolver {
}
if(!alwaysFalse) {
cursor = index.find(session, start, end);
if(join != null) {
for(int i=0; joins != null && i<joins.size(); i++) {
TableFilter join = getTableFilter(i);
join.reset();
}
}
} else {
// state == FOUND || LAST_ROW
// the last row was ok - try next row of the join
if(join != null && join.next()) {
boolean found = joins != null;
for(int i=0; joins != null && i<joins.size(); i++) {
TableFilter join = getTableFilter(i);
if(!join.next()) {
found = false;
break;
}
}
if(found) {
return true;
}
}
......@@ -233,12 +260,20 @@ public class TableFilter implements ColumnResolver {
if(state==FOUND && joinConditionOk) {
foundOne = true;
}
if(join != null) {
for(int i=0; joins != null && i<joins.size(); i++) {
TableFilter join = getTableFilter(i);
join.reset();
}
boolean cont = false;
for(int i=0; joins != null && i<joins.size(); i++) {
TableFilter join = getTableFilter(i);
if(!join.next()) {
continue;
cont = true;
}
}
if(cont) {
continue;
}
// check if it's ok
if(state==NULL_ROW || joinConditionOk) {
return true;
......@@ -295,28 +330,36 @@ public class TableFilter implements ColumnResolver {
if(on != null) {
on.mapColumns(this, 0);
}
if(join == null) {
this.join = filter;
if(joins == null) {
this.joins = new ObjectArray();
joins.add(filter);
filter.outerJoin = outer;
if(on != null) {
TableFilter f = filter;
do {
on.mapColumns(f, 0);
f.addFilterCondition(on, true);
on.createIndexConditions(f);
f = f.join;
} while(f != null);
filter.mapAndAddFilter(on);
}
} else {
int todoAddJoinNestedOrSameLevel;
TableFilter join = getTableFilter(0);
join.addJoin(filter, outer, on);
}
if(on != null) {
on.optimize(session);
}
}
private void mapAndAddFilter(Expression on) throws SQLException {
on.mapColumns(this, 0);
addFilterCondition(on, true);
on.createIndexConditions(this);
for(int i=0; joins != null && i<joins.size(); i++) {
TableFilter join = getTableFilter(i);
join.mapAndAddFilter(on);
}
}
public TableFilter getJoin() {
return join;
int todoGetJoin;
return joins == null ? null : getTableFilter(0);
}
public boolean isJoinOuter() {
......@@ -392,7 +435,8 @@ public class TableFilter implements ColumnResolver {
}
public void removeJoin() {
this.join = null;
int todoRemoveJoin;
this.joins = null;
}
public Expression getJoinCondition() {
......@@ -413,7 +457,8 @@ public class TableFilter implements ColumnResolver {
public void setFullCondition(Expression condition) {
this.fullCondition = condition;
if(join != null) {
for(int i=0; joins != null && i<joins.size(); i++) {
TableFilter join = getTableFilter(i);
join.setFullCondition(condition);
}
}
......@@ -421,7 +466,8 @@ public class TableFilter implements ColumnResolver {
public void optimizeFullCondition(boolean fromOuterJoin) {
if(fullCondition != null) {
fullCondition.addFilterConditions(this, fromOuterJoin || outerJoin);
if(join != null) {
for(int i=0; joins != null && i<joins.size(); i++) {
TableFilter join = getTableFilter(i);
join.optimizeFullCondition(fromOuterJoin || outerJoin);
}
}
......@@ -434,7 +480,8 @@ public class TableFilter implements ColumnResolver {
if(joinCondition != null) {
joinCondition.setEvaluatable(filter, b);
}
if(join != null) {
for(int i=0; joins != null && i<joins.size(); i++) {
TableFilter join = getTableFilter(i);
join.setEvaluatable(filter, b);
}
}
......
......@@ -88,7 +88,7 @@ public class TableView extends Table {
public PlanItem getBestPlanItem(Session session, int[] masks) throws SQLException {
PlanItem item = new PlanItem();
item.cost = index.getCost(session, masks);
item.index = index;
item.setIndex(index);
return item;
}
......@@ -187,7 +187,7 @@ public class TableView extends Table {
throw Message.getSQLException(Message.VIEW_IS_INVALID_1, getSQL());
}
PlanItem item = getBestPlanItem(session, null);
return item.index;
return item.getIndex();
}
public ObjectArray getIndexes() {
......
......@@ -19,7 +19,7 @@ import java.util.zip.ZipOutputStream;
import org.h2.compress.CompressDeflate;
import org.h2.compress.CompressLZF;
import org.h2.compress.CompressNo;
import org.h2.compress.Compresser;
import org.h2.compress.Compressor;
import org.h2.compress.LZFInputStream;
import org.h2.compress.LZFOutputStream;
import org.h2.message.Message;
......@@ -69,7 +69,7 @@ public class CompressTool {
if(in.length < 5) {
algorithm = "NO";
}
Compresser compress = getCompresser(algorithm);
Compressor compress = getCompressor(algorithm);
byte[] buff = getBuffer((len < 100 ? len + 100 : len) * 2);
int newLen = compress(in, in.length, compress, buff);
byte[] out = new byte[newLen];
......@@ -80,13 +80,13 @@ public class CompressTool {
/**
* INTERNAL
*/
public synchronized int compress(byte[] in, int len, Compresser compress, byte[] out) {
public synchronized int compress(byte[] in, int len, Compressor compress, byte[] out) {
int newLen = 0;
out[0] = (byte)compress.getAlgorithm();
int start = 1 + writeInt(out, 1, len);
newLen = compress.compress(in, len, out, start);
if(newLen > len + start || newLen <= 0) {
out[0] = Compresser.NO;
out[0] = Compressor.NO;
System.arraycopy(in, 0, out, start, len);
newLen = len + start;
}
......@@ -102,7 +102,7 @@ public class CompressTool {
*/
public byte[] expand(byte[] in) throws SQLException {
int algorithm = in[0];
Compresser compress = getCompresser(algorithm);
Compressor compress = getCompressor(algorithm);
try {
int len = readInt(in, 1);
int start = 1 + getLength(len);
......@@ -119,7 +119,7 @@ public class CompressTool {
*/
public void expand(byte[] in, byte[] out, int outPos) throws SQLException {
int algorithm = in[0];
Compresser compress = getCompresser(algorithm);
Compressor compress = getCompressor(algorithm);
try {
int len = readInt(in, 1);
int start = 1 + getLength(len);
......@@ -198,7 +198,7 @@ public class CompressTool {
}
}
private Compresser getCompresser(String algorithm) throws SQLException {
private Compressor getCompressor(String algorithm) throws SQLException {
if(algorithm == null) {
algorithm = "LZF";
}
......@@ -209,7 +209,7 @@ public class CompressTool {
algorithm = algorithm.substring(0, idx);
}
int a = getCompressAlgorithm(algorithm);
Compresser compress = getCompresser(a);
Compressor compress = getCompressor(a);
compress.setOptions(options);
return compress;
}
......@@ -220,23 +220,23 @@ public class CompressTool {
public int getCompressAlgorithm(String algorithm) throws SQLException {
algorithm = StringUtils.toUpperEnglish(algorithm);
if("NO".equals(algorithm)) {
return Compresser.NO;
return Compressor.NO;
} else if("LZF".equals(algorithm)) {
return Compresser.LZF;
return Compressor.LZF;
} else if("DEFLATE".equals(algorithm)) {
return Compresser.DEFLATE;
return Compressor.DEFLATE;
} else {
throw Message.getSQLException(Message.UNSUPPORTED_COMPRESSION_ALGORITHM_1, algorithm);
}
}
private Compresser getCompresser(int algorithm) throws SQLException {
private Compressor getCompressor(int algorithm) throws SQLException {
switch(algorithm) {
case Compresser.NO:
case Compressor.NO:
return new CompressNo();
case Compresser.LZF:
case Compressor.LZF:
return new CompressLZF();
case Compresser.DEFLATE:
case Compressor.DEFLATE:
return new CompressDeflate();
default:
throw Message.getSQLException(Message.UNSUPPORTED_COMPRESSION_ALGORITHM_1, ""+algorithm);
......
......@@ -193,7 +193,7 @@ public class Csv implements SimpleRowSource {
private void writeHeader() {
for(int i=0; i<columnNames.length; i++) {
if(i>0) {
writer.print(fieldSeparatorRead);
writer.print(fieldSeparatorWrite);
}
writer.print(columnNames[i]);
}
......@@ -475,6 +475,14 @@ public class Csv implements SimpleRowSource {
public void setFieldSeparatorWrite(String fieldSeparatorWrite) {
this.fieldSeparatorWrite = fieldSeparatorWrite;
}
/**
* Override the field separator for reading. The default is ','.
* @param fieldSeparatorRead
*/
public void setFieldSeparatorRead(char fieldSeparatorRead) {
this.fieldSeparatorRead = fieldSeparatorRead;
}
/**
* Override the end-of-row marker for writing. The default is null.
......@@ -489,7 +497,7 @@ public class Csv implements SimpleRowSource {
* This is not supported at this time, and this methods throws a SQLException
*/
public void reset() throws SQLException {
throw new SQLException("Method is notsupported", "CSV");
throw new SQLException("Method is not supported", "CSV");
}
}
......@@ -277,7 +277,7 @@ public class Recover implements DataHandler {
}
private void writeDataError(PrintWriter writer, String error, byte[] data, int dumpBlocks) throws IOException {
writer.println("-- ERROR:" + error + " block:"+block+" blockCount:"+blockCount+" storageId:" + storageId+" recordLength: " + recordLength+" valudId:" + valueId);
writer.println("-- ERROR:" + error + " block:"+block+" blockCount:"+blockCount+" storageId:" + storageId+" recordLength: " + recordLength+" valueId:" + valueId);
StringBuffer sb = new StringBuffer();
for(int i=0; i<dumpBlocks * DiskFile.BLOCK_SIZE; i++) {
int x = (data[i] & 0xff);
......
......@@ -107,7 +107,7 @@ public class RunScript {
showUsage();
return;
}
// long time = System.currentTimeMillis();
long time = System.currentTimeMillis();
// for(int i=0; i<10; i++) {
// int test;
if (options != null) {
......@@ -116,8 +116,8 @@ public class RunScript {
execute(url, user, password, script, null, continueOnError);
}
// }
// time = System.currentTimeMillis() - time;
// System.out.println("Done in " + time + " ms");
time = System.currentTimeMillis() - time;
System.out.println("Done in " + time + " ms");
}
/**
......@@ -136,8 +136,8 @@ public class RunScript {
if (sql == null) {
break;
}
boolean resultset = stat.execute(sql);
if (resultset) {
boolean resultSet = stat.execute(sql);
if (resultSet) {
if (rs != null) {
rs.close();
rs = null;
......
......@@ -318,7 +318,7 @@ public class Server implements Runnable {
/**
* Tries to start the server.
* @return the server if successfull
* @return the server if successful
* @throws SQLException if the server could not be started
*/
public Server start() throws SQLException {
......
......@@ -162,7 +162,7 @@ public class SimpleResultSet implements ResultSet, ResultSetMetaData {
/**
* Moves the cursor to the next row of the result set.
*
* @return true if successfull, false if there are no more rows
* @return true if successful, false if there are no more rows
*/
public boolean next() throws SQLException {
if (source != null) {
......@@ -1228,30 +1228,30 @@ public class SimpleResultSet implements ResultSet, ResultSetMetaData {
return (Column) columns.get(i);
}
//#ifdef JDK16
//#ifdef JDK16
/*
public RowId getRowId(int columnIndex) throws SQLException {
throw getUnsupportedException();
}
*/
//#endif
//#endif
//#ifdef JDK16
//#ifdef JDK16
/*
public RowId getRowId(String columnName) throws SQLException {
throw getUnsupportedException();
}
*/
//#endif
//#endif
/** INTERNAL */
//#ifdef JDK16
//#ifdef JDK16
/*
public void updateRowId(int columnIndex, RowId x) throws SQLException {
throw getUnsupportedException();
}
*/
//#endif
//#endif
/** INTERNAL */
//#ifdef JDK16
......@@ -1293,76 +1293,76 @@ public class SimpleResultSet implements ResultSet, ResultSetMetaData {
}
/** INTERNAL */
//#ifdef JDK16
//#ifdef JDK16
/*
public void updateNClob(int columnIndex, NClob nClob) throws SQLException {
throw getUnsupportedException();
}
*/
//#endif
//#endif
/** INTERNAL */
//#ifdef JDK16
//#ifdef JDK16
/*
public void updateNClob(String columnName, NClob nClob) throws SQLException {
throw getUnsupportedException();
}
*/
//#endif
//#endif
/** INTERNAL */
//#ifdef JDK16
//#ifdef JDK16
/*
public NClob getNClob(int columnIndex) throws SQLException {
throw getUnsupportedException();
}
*/
//#endif
//#endif
/** INTERNAL */
//#ifdef JDK16
//#ifdef JDK16
/*
public NClob getNClob(String columnName) throws SQLException {
throw getUnsupportedException();
}
*/
//#endif
//#endif
/** INTERNAL */
//#ifdef JDK16
//#ifdef JDK16
/*
public SQLXML getSQLXML(int columnIndex) throws SQLException {
throw getUnsupportedException();
}
*/
//#endif
//#endif
/** INTERNAL */
//#ifdef JDK16
//#ifdef JDK16
/*
public SQLXML getSQLXML(String columnName) throws SQLException {
throw getUnsupportedException();
}
*/
//#endif
//#endif
/** INTERNAL */
//#ifdef JDK16
//#ifdef JDK16
/*
public void updateSQLXML(int columnIndex, SQLXML xmlObject) throws SQLException {
throw getUnsupportedException();
}
*/
//#endif
//#endif
/** INTERNAL */
//#ifdef JDK16
//#ifdef JDK16
/*
public void updateSQLXML(String columnName, SQLXML xmlObject) throws SQLException {
throw getUnsupportedException();
}
*/
//#endif
//#endif
/** INTERNAL */
public String getNString(int columnIndex) throws SQLException {
......@@ -1395,22 +1395,22 @@ public class SimpleResultSet implements ResultSet, ResultSetMetaData {
}
/** INTERNAL */
//#ifdef JDK16
//#ifdef JDK16
/*
public <T> T unwrap(Class<T> iface) throws SQLException {
throw getUnsupportedException();
}
*/
//#endif
//#endif
/** INTERNAL */
//#ifdef JDK16
//#ifdef JDK16
/*
public boolean isWrapperFor(Class<?> iface) throws SQLException {
throw getUnsupportedException();
}
*/
//#endif
//#endif
/** INTERNAL */
public void updateAsciiStream(int columnIndex, InputStream x) throws SQLException {
......
......@@ -55,7 +55,7 @@ public class IOUtils {
}
public static long copyAndCloseInput(InputStream in, OutputStream out) throws IOException {
int written = 0;
long written = 0;
try {
byte[] buffer = new byte[4 * 1024];
while(true) {
......@@ -145,23 +145,26 @@ public class IOUtils {
}
public static String readStringAndClose(Reader in, int length) throws IOException {
if(length <= 0) {
length = Integer.MAX_VALUE;
}
int block = Math.min(BUFFER_BLOCK_SIZE, length);
StringWriter out=new StringWriter(length == Integer.MAX_VALUE ? block : length);
char[] buff=new char[block];
while(length > 0) {
int len = Math.min(block, length);
len = in.read(buff, 0, len);
if(len < 0) {
break;
try {
if(length <= 0) {
length = Integer.MAX_VALUE;
}
out.write(buff, 0, len);
length -= len;
int block = Math.min(BUFFER_BLOCK_SIZE, length);
StringWriter out=new StringWriter(length == Integer.MAX_VALUE ? block : length);
char[] buff=new char[block];
while(length > 0) {
int len = Math.min(block, length);
len = in.read(buff, 0, len);
if(len < 0) {
break;
}
out.write(buff, 0, len);
length -= len;
}
return out.toString();
} finally {
in.close();
}
in.close();
return out.toString();
}
public static int readFully(InputStream in, byte[] buffer, int max) throws IOException {
......
......@@ -35,7 +35,7 @@ public class MathUtils {
}
public static BigDecimal setScale(BigDecimal bd, int scale) throws SQLException {
if(scale > Constants.BIGDECIMAL_SCALE_MAX) {
if(scale > Constants.BIG_DECIMAL_SCALE_MAX) {
throw Message.getInvalidValueException(""+scale, "scale");
} else if(scale < 0) {
throw Message.getInvalidValueException(""+scale, "scale");
......
......@@ -24,19 +24,19 @@ import org.h2.message.Message;
public class StringUtils {
// TODO hack for gcj
//#GCJHACK private static final Class[] gcjClasses = {
//#GCJHACK gnu.gcj.convert.Input_ASCII.class,
//#GCJHACK gnu.gcj.convert.Input_UTF8.class,
//#GCJHACK gnu.gcj.convert.Input_8859_1.class,
//#GCJHACK gnu.gcj.convert.Output_ASCII.class,
//#GCJHACK gnu.gcj.convert.Output_UTF8.class,
//#GCJHACK gnu.gcj.convert.UnicodeToBytes.class,
//#GCJHACK gnu.gcj.convert.BytesToUnicode.class,
//#GCJHACK gnu.java.locale.Calendar.class,
//#GCJHACK gnu.java.locale.LocaleInformation.class,
//#GCJHACK gnu.java.locale.LocaleInformation_de.class,
//#GCJHACK java.util.GregorianCalendar.class,
//#GCJHACK };
//#GCJHACK private static final Class[] gcjClasses = {
//#GCJHACK gnu.gcj.convert.Input_ASCII.class,
//#GCJHACK gnu.gcj.convert.Input_UTF8.class,
//#GCJHACK gnu.gcj.convert.Input_8859_1.class,
//#GCJHACK gnu.gcj.convert.Output_ASCII.class,
//#GCJHACK gnu.gcj.convert.Output_UTF8.class,
//#GCJHACK gnu.gcj.convert.UnicodeToBytes.class,
//#GCJHACK gnu.gcj.convert.BytesToUnicode.class,
//#GCJHACK gnu.java.locale.Calendar.class,
//#GCJHACK gnu.java.locale.LocaleInformation.class,
//#GCJHACK gnu.java.locale.LocaleInformation_de.class,
//#GCJHACK java.util.GregorianCalendar.class,
//#GCJHACK };
public static boolean equals(String a, String b) {
if(a==null) {
......@@ -127,7 +127,7 @@ public class StringUtils {
return buff.toString();
}
public static String addAsterix(String s, int index) {
public static String addAsterisk(String s, int index) {
if (s != null && index < s.length()) {
s = s.substring(0, index) + "[*]" + s.substring(index);
}
......@@ -135,7 +135,7 @@ public class StringUtils {
}
private static SQLException getFormatException(String s, int i) {
return Message.getSQLException(Message.STRING_FORMAT_ERROR_1, addAsterix(s, i));
return Message.getSQLException(Message.STRING_FORMAT_ERROR_1, addAsterisk(s, i));
}
public static String javaDecode(String s) throws SQLException {
......@@ -378,8 +378,8 @@ public class StringUtils {
* Formats a date using a format string
*/
public static String formatDateTime(Date date, String format, String locale, String timezone) throws SQLException {
SimpleDateFormat sdf = getDateFormat(format, locale, timezone);
return sdf.format(date);
SimpleDateFormat dateFormat = getDateFormat(format, locale, timezone);
return dateFormat.format(date);
}
/**
......
......@@ -534,7 +534,7 @@ public class DataType {
return ValueNull.INSTANCE;
}
if(type == Value.JAVA_OBJECT) {
// serialize JAVA_OBJECTs, even if the type is known
// serialize JAVA_OBJECT, even if the type is known
if(Constants.SERIALIZE_JAVA_OBJECTS) {
return ValueJavaObject.getNoCopy(ByteUtils.serialize(x));
}
......
......@@ -49,7 +49,7 @@ public class Transfer {
}
protected void finalize() {
if (!Constants.RUN_FINALIZERS) {
if (!Constants.RUN_FINALIZE) {
return;
}
if(socket != null) {
......
......@@ -161,7 +161,7 @@ public class ValueDecimal extends Value {
} else if (DEC_ONE.equals(dec)) {
return ONE;
}
// TODO value optimization: find a way to read size of bigdecimal,
// TODO value optimization: find a way to read size of BigDecimal,
// check max cache size
return (ValueDecimal) Value.cache(new ValueDecimal(dec));
}
......
......@@ -534,7 +534,7 @@ public class ValueLob extends Value {
// }
public int getDisplaySize() {
// TODO displaysize of lob?
// TODO display size of lob?
return 40;
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论