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