提交 4461f5e6 authored 作者: Thomas Mueller's avatar Thomas Mueller

--no commit message

--no commit message
上级 9a0e05a6
#Thu Jan 17 08:51:17 CET 2008
#Fri Jan 18 08:04:40 CET 2008
javac=javac
benchmark.drivers.dir=C\:/data/java
path.servlet.jar=C\:/data/classpath/servlet-api.jar
......
......@@ -1997,7 +1997,10 @@ public class Parser {
read();
if (indexed && currentTokenType == VALUE && currentValue.getType() == Value.INT) {
if (indexedParameterList == null) {
if (parameters.size() > 0) {
if (parameters == null) {
// this can occur when parsing expressions only (for example check constraints)
throw getSyntaxError();
} else if (parameters.size() > 0) {
throw Message.getSQLException(ErrorCode.CANNOT_MIX_INDEXED_AND_UNINDEXED_PARAMS);
}
indexedParameterList = new ObjectArray();
......
......@@ -66,7 +66,7 @@ public class JdbcBlob extends TraceObject implements Blob {
}
return size;
} catch (Throwable e) {
throw Message.convert(e);
throw logAndConvert(e);
}
}
......@@ -108,7 +108,7 @@ public class JdbcBlob extends TraceObject implements Blob {
}
return out.toByteArray();
} catch (Throwable e) {
throw Message.convert(e);
throw logAndConvert(e);
}
}
......@@ -134,8 +134,13 @@ public class JdbcBlob extends TraceObject implements Blob {
* @return the input stream
*/
public InputStream getBinaryStream() throws SQLException {
debugCodeCall("getBinaryStream");
return value.getInputStream();
try {
debugCodeCall("getBinaryStream");
checkClosed();
return value.getInputStream();
} catch (Throwable e) {
throw logAndConvert(e);
}
}
/**
......@@ -148,15 +153,15 @@ public class JdbcBlob extends TraceObject implements Blob {
/**
* [Not supported] Searches a pattern and return the position.
*
* @param pattern the pattern to search
* @param start the index, the first byte is at position 1
* @return the position (first byte is at position 1), or -1 for not found
*/
public long position(byte[] pattern, long start) throws SQLException {
debugCode("position(pattern, "+start+");");
throw Message.getUnsupportedException();
// TODO test
// *
// * @param pattern the pattern to search
// * @param start the index, the first byte is at position 1
// * @return the position (first byte is at position 1), or -1 for not found
// try {
// debugCode("position(pattern, "+start+");");
// if(pattern == null) {
......@@ -193,21 +198,21 @@ public class JdbcBlob extends TraceObject implements Blob {
// }
// return -1;
// } catch(Throwable e) {
// throw Message.convert(e);
// throw logAndConvert(e);
// }
}
/**
* [Not supported] Searches a pattern and return the position.
*
* @param pattern the pattern to search
* @param start the index, the first byte is at position 1
* @return the position (first byte is at position 1), or -1 for not found
*/
public long position(Blob blobPattern, long start) throws SQLException {
debugCode("position(blobPattern, "+start+");");
throw Message.getUnsupportedException();
// *
// * @param pattern the pattern to search
// * @param start the index, the first byte is at position 1
// * @return the position (first byte is at position 1), or -1 for not found
// try {
// debugCode("position(blobPattern, "+start+");");
// if(blobPattern == null) {
......@@ -224,7 +229,7 @@ public class JdbcBlob extends TraceObject implements Blob {
// }
// return position(out.toByteArray(), start);
// } catch(Throwable e) {
// throw Message.convert(e);
// throw logAndConvert(e);
// }
}
......
......@@ -79,7 +79,7 @@ public class JdbcClob extends TraceObject implements Clob
in.close();
}
} catch (Throwable e) {
throw Message.convert(e);
throw logAndConvert(e);
}
}
......@@ -155,7 +155,7 @@ public class JdbcClob extends TraceObject implements Clob
if (length < 0) {
throw Message.getInvalidValueException("length", "" + length);
}
StringBuffer buff = new StringBuffer(length);
StringBuffer buff = new StringBuffer(Math.min(4096, length));
Reader reader = value.getReader();
try {
IOUtils.skipFully(reader, pos - 1);
......@@ -229,7 +229,7 @@ public class JdbcClob extends TraceObject implements Clob
throw Message.getSQLException(ErrorCode.OBJECT_CLOSED);
}
}
/**
* INTERNAL
*/
......
......@@ -2065,6 +2065,7 @@ public class JdbcResultSet extends TraceObject implements ResultSet {
if (debug()) {
debugCode("updateBlob("+columnIndex+", x, " + length + "L);");
}
checkClosed();
Value v = conn.createBlob(x, length);
update(columnIndex, v);
} catch (Throwable e) {
......@@ -2084,6 +2085,7 @@ public class JdbcResultSet extends TraceObject implements ResultSet {
if (debug()) {
debugCode("updateBlob("+columnIndex+", x);");
}
checkClosed();
Value v;
if (x == null) {
v = ValueNull.INSTANCE;
......@@ -2108,6 +2110,7 @@ public class JdbcResultSet extends TraceObject implements ResultSet {
if (debug()) {
debugCode("updateBlob("+quote(columnName)+", x);");
}
checkClosed();
Value v;
if (x == null) {
v = ValueNull.INSTANCE;
......@@ -2144,6 +2147,7 @@ public class JdbcResultSet extends TraceObject implements ResultSet {
if (debug()) {
debugCode("updateBlob("+quote(columnName)+", x, " + length + "L);");
}
checkClosed();
Value v = conn.createBlob(x, -1);
update(columnName, v);
} catch (Throwable e) {
......@@ -3014,6 +3018,7 @@ public class JdbcResultSet extends TraceObject implements ResultSet {
public int getHoldability() throws SQLException {
try {
debugCodeCall("getHoldability");
checkClosed();
return conn.getHoldability();
} catch (Throwable e) {
throw logAndConvert(e);
......@@ -3367,6 +3372,7 @@ public class JdbcResultSet extends TraceObject implements ResultSet {
if (debug()) {
debugCode("updateNCharacterStream("+columnIndex+", x, "+length+"L);");
}
checkClosed();
Value v = conn.createClob(x, length);
update(columnIndex, v);
} catch (Throwable e) {
......@@ -3410,6 +3416,7 @@ public class JdbcResultSet extends TraceObject implements ResultSet {
if (debug()) {
debugCode("updateNCharacterStream("+quote(columnName)+", x, "+length+"L);");
}
checkClosed();
Value v = conn.createClob(x, length);
update(columnName, v);
} catch (Throwable e) {
......
......@@ -150,7 +150,13 @@ public class FileSystemDisk extends FileSystem {
}
File f = File.createTempFile(prefix, suffix, dir);
if (deleteOnExit) {
f.deleteOnExit();
try {
f.deleteOnExit();
} catch (Throwable e) {
// sometimes this throws a NullPointerException
// at java.io.DeleteOnExitHook.add(DeleteOnExitHook.java:33)
// we can ignore it
}
}
return f.getCanonicalPath();
}
......
......@@ -7,6 +7,7 @@ package org.h2.util;
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.EOFException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
......@@ -42,13 +43,21 @@ public class IOUtils {
public static void skipFully(InputStream in, long skip) throws IOException {
while (skip > 0) {
skip -= in.skip(skip);
long skipped = in.skip(skip);
if (skipped <= 0) {
throw new EOFException();
}
skip -= skipped;
}
}
public static void skipFully(Reader reader, long skip) throws IOException {
while (skip > 0) {
skip -= reader.skip(skip);
long skipped = reader.skip(skip);
if (skipped <= 0) {
throw new EOFException();
}
skip -= skipped;
}
}
......
......@@ -67,6 +67,11 @@ public class TestCases extends TestBase {
deleteDb("cases");
Connection conn = getConnection("cases");
Statement stat = conn.createStatement();
try {
stat.execute("create table address(id identity, name varchar check? instr(value, '@') > 1)");
} catch (SQLException e) {
checkNotGeneralException(e);
}
stat.execute("SET AUTOCOMMIT OFF; \n//create sequence if not exists object_id;\n");
stat.execute("SET AUTOCOMMIT OFF;\n//create sequence if not exists object_id;\n");
stat.execute("SET AUTOCOMMIT OFF; //create sequence if not exists object_id;");
......
......@@ -252,6 +252,8 @@ public class TestCrashAPI extends TestBase {
private void printIfBad(int seed, int id, int objectId, Throwable t) {
if (t instanceof BatchUpdateException) {
// do nothing
} else if (t.getClass().getName().indexOf("SQLClientInfoException") >= 0) {
// do nothing
} else if (t instanceof SQLException) {
SQLException s = (SQLException) t;
String state = s.getSQLState();
......
......@@ -168,15 +168,35 @@ public class RandomGen {
StringBuffer buff = new StringBuffer();
buff.append(getInt(10) + 2000);
buff.append('-');
buff.append(getInt(12) + 1);
int month = getInt(12) + 1;
if (month < 10) {
buff.append('0');
}
buff.append(month);
buff.append('-');
buff.append(getInt(28) + 1);
int day = getInt(28) + 1;
if (day < 10) {
buff.append('0');
}
buff.append(day);
buff.append(' ');
buff.append(getInt(24));
int hour = getInt(24);
if (hour < 10) {
buff.append('0');
}
buff.append(hour);
buff.append(':');
buff.append(getInt(60));
int minute = getInt(60);
if (minute < 10) {
buff.append('0');
}
buff.append(minute);
buff.append(':');
buff.append(getInt(60));
int second = getInt(60);
if (second < 10) {
buff.append('0');
}
buff.append(second);
// TODO test timestamp nanos
return Timestamp.valueOf(buff.toString());
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论