提交 42715ee9 authored 作者: Thomas Mueller's avatar Thomas Mueller

--no commit message

--no commit message
上级 9cf66529
...@@ -66,6 +66,7 @@ public class AggregateData { ...@@ -66,6 +66,7 @@ public class AggregateData {
if(value == null) { if(value == null) {
value = v; value = v;
} else { } else {
v = v.convertTo(value.getType());
value = value.add(v); value = value.add(v);
} }
break; break;
......
...@@ -78,6 +78,7 @@ public class Comparison extends Condition { ...@@ -78,6 +78,7 @@ public class Comparison extends Condition {
Function function = Function.getFunction(session.getDatabase(), "CAST"); Function function = Function.getFunction(session.getDatabase(), "CAST");
function.setParameter(0, expr); function.setParameter(0, expr);
function.setDataType(dataType, precision, scale); function.setDataType(dataType, precision, scale);
function.doneWithParameters();
return function.optimize(session); return function.optimize(session);
} }
......
...@@ -97,7 +97,7 @@ public class ConditionAndOr extends Condition { ...@@ -97,7 +97,7 @@ public class ConditionAndOr extends Condition {
} }
public Expression optimize(Session session) throws SQLException { public Expression optimize(Session session) throws SQLException {
// TODO NULL values: see http://www-cs-students.stanford.edu/~wlam/compsci/sqlnulls // TODO NULL: see http://www-cs-students.stanford.edu/~wlam/compsci/sqlnulls
// TODO test if all optimizations are switched off against all on (including performance) // TODO test if all optimizations are switched off against all on (including performance)
// TODO document NULL exactly for every case // TODO document NULL exactly for every case
left = left.optimize(session); left = left.optimize(session);
......
...@@ -91,13 +91,13 @@ public class Function extends Expression implements FunctionCall { ...@@ -91,13 +91,13 @@ public class Function extends Expression implements FunctionCall {
ARRAY_GET = 209, CSVREAD = 210, CSVWRITE = 211, MEMORY_FREE = 212, ARRAY_GET = 209, CSVREAD = 210, CSVWRITE = 211, MEMORY_FREE = 212,
MEMORY_USED = 213, LOCK_MODE = 214, SCHEMA = 215, SESSION_ID = 216, ARRAY_LENGTH = 217; MEMORY_USED = 213, LOCK_MODE = 214, SCHEMA = 215, SESSION_ID = 216, ARRAY_LENGTH = 217;
private static final int VARARGS = -1; private static final int VAR_ARGS = -1;
private static HashMap functions; private static HashMap functions;
private FunctionInfo info; private FunctionInfo info;
private Expression[] args; private Expression[] args;
private ObjectArray varargs; private ObjectArray varArgs;
private int dataType, scale; private int dataType, scale;
private long precision; private long precision;
private Database database; private Database database;
...@@ -163,7 +163,7 @@ public class Function extends Expression implements FunctionCall { ...@@ -163,7 +163,7 @@ public class Function extends Expression implements FunctionCall {
addFunction("PI", PI, 0, Value.DOUBLE); addFunction("PI", PI, 0, Value.DOUBLE);
addFunction("POWER", POWER, 2, Value.DOUBLE); addFunction("POWER", POWER, 2, Value.DOUBLE);
addFunction("RADIANS", RADIANS, 1, Value.DOUBLE); addFunction("RADIANS", RADIANS, 1, Value.DOUBLE);
addFunctionNotConst("RAND", RAND, VARARGS, Value.DOUBLE); // no args: regular rand; with one arg: seed random generator addFunctionNotConst("RAND", RAND, VAR_ARGS, Value.DOUBLE); // no args: regular rand; with one arg: seed random generator
addFunction("ROUND", ROUND, 2, Value.DOUBLE); addFunction("ROUND", ROUND, 2, Value.DOUBLE);
addFunction("ROUNDMAGIC", ROUNDMAGIC, 1, Value.DOUBLE); addFunction("ROUNDMAGIC", ROUNDMAGIC, 1, Value.DOUBLE);
addFunction("SIGN", SIGN, 1, Value.INT); addFunction("SIGN", SIGN, 1, Value.INT);
...@@ -175,7 +175,7 @@ public class Function extends Expression implements FunctionCall { ...@@ -175,7 +175,7 @@ public class Function extends Expression implements FunctionCall {
addFunction("ENCRYPT", ENCRYPT, 3, Value.BYTES); addFunction("ENCRYPT", ENCRYPT, 3, Value.BYTES);
addFunction("DECRYPT", DECRYPT, 3, Value.BYTES); addFunction("DECRYPT", DECRYPT, 3, Value.BYTES);
addFunctionNotConst("SECURE_RAND", SECURE_RAND, 1, Value.BYTES); addFunctionNotConst("SECURE_RAND", SECURE_RAND, 1, Value.BYTES);
addFunction("COMPRESS", COMPRESS, VARARGS, Value.BYTES); addFunction("COMPRESS", COMPRESS, VAR_ARGS, Value.BYTES);
addFunction("EXPAND", EXPAND, 1, Value.BYTES); addFunction("EXPAND", EXPAND, 1, Value.BYTES);
addFunction("ZERO", ZERO, 0, Value.INT); addFunction("ZERO", ZERO, 0, Value.INT);
addFunctionNotConst("RANDOM_UUID", RANDOM_UUID, 0, Value.UUID); addFunctionNotConst("RANDOM_UUID", RANDOM_UUID, 0, Value.UUID);
...@@ -186,38 +186,38 @@ public class Function extends Expression implements FunctionCall { ...@@ -186,38 +186,38 @@ public class Function extends Expression implements FunctionCall {
addFunction("CHAR", CHAR, 1, Value.STRING); addFunction("CHAR", CHAR, 1, Value.STRING);
addFunction("CHAR_LENGTH", CHAR_LENGTH, 1, Value.INT); addFunction("CHAR_LENGTH", CHAR_LENGTH, 1, Value.INT);
addFunction("CHARACTER_LENGTH", CHAR_LENGTH, 1, Value.INT); // same as CHAR_LENGTH addFunction("CHARACTER_LENGTH", CHAR_LENGTH, 1, Value.INT); // same as CHAR_LENGTH
addFunctionWithNull("CONCAT", CONCAT, VARARGS, Value.STRING); addFunctionWithNull("CONCAT", CONCAT, VAR_ARGS, Value.STRING);
addFunction("DIFFERENCE", DIFFERENCE, 2, Value.INT); addFunction("DIFFERENCE", DIFFERENCE, 2, Value.INT);
addFunction("HEXTORAW", HEXTORAW, 1, Value.STRING); addFunction("HEXTORAW", HEXTORAW, 1, Value.STRING);
addFunctionWithNull("INSERT", INSERT, 4, Value.STRING); addFunctionWithNull("INSERT", INSERT, 4, Value.STRING);
addFunction("LCASE", LCASE, 1, Value.STRING); addFunction("LCASE", LCASE, 1, Value.STRING);
addFunction("LEFT", LEFT, 2, Value.STRING); addFunction("LEFT", LEFT, 2, Value.STRING);
addFunction("LENGTH", LENGTH, 1, Value.INT); addFunction("LENGTH", LENGTH, 1, Value.INT);
addFunction("LOCATE", LOCATE, VARARGS, Value.INT); // 2 or 3 arguments addFunction("LOCATE", LOCATE, VAR_ARGS, Value.INT); // 2 or 3 arguments
addFunction("POSITION", LOCATE, 2, Value.INT); // same as LOCATE with 2 arguments addFunction("POSITION", LOCATE, 2, Value.INT); // same as LOCATE with 2 arguments
addFunction("INSTR", INSTR, VARARGS, Value.INT); addFunction("INSTR", INSTR, VAR_ARGS, Value.INT);
addFunction("LTRIM", LTRIM, VARARGS, Value.STRING); addFunction("LTRIM", LTRIM, VAR_ARGS, Value.STRING);
addFunction("OCTET_LENGTH", OCTET_LENGTH, 1, Value.INT); addFunction("OCTET_LENGTH", OCTET_LENGTH, 1, Value.INT);
addFunction("RAWTOHEX", RAWTOHEX, 1, Value.STRING); addFunction("RAWTOHEX", RAWTOHEX, 1, Value.STRING);
addFunction("REPEAT", REPEAT, 2, Value.STRING); addFunction("REPEAT", REPEAT, 2, Value.STRING);
addFunctionWithNull("REPLACE", REPLACE, VARARGS, Value.STRING); addFunctionWithNull("REPLACE", REPLACE, VAR_ARGS, Value.STRING);
addFunction("RIGHT", RIGHT, 2, Value.STRING); addFunction("RIGHT", RIGHT, 2, Value.STRING);
addFunction("RTRIM", RTRIM, VARARGS, Value.STRING); addFunction("RTRIM", RTRIM, VAR_ARGS, Value.STRING);
addFunction("SOUNDEX", SOUNDEX, 1, Value.STRING); addFunction("SOUNDEX", SOUNDEX, 1, Value.STRING);
addFunction("SPACE", SPACE, 1, Value.STRING); addFunction("SPACE", SPACE, 1, Value.STRING);
addFunction("SUBSTR", SUBSTR, VARARGS, Value.STRING); addFunction("SUBSTR", SUBSTR, VAR_ARGS, Value.STRING);
addFunction("SUBSTRING", SUBSTRING, VARARGS, Value.STRING); addFunction("SUBSTRING", SUBSTRING, VAR_ARGS, Value.STRING);
addFunction("UCASE", UCASE, 1, Value.STRING); addFunction("UCASE", UCASE, 1, Value.STRING);
addFunction("LOWER", LOWER, 1, Value.STRING); addFunction("LOWER", LOWER, 1, Value.STRING);
addFunction("UPPER", UPPER, 1, Value.STRING); addFunction("UPPER", UPPER, 1, Value.STRING);
addFunction("POSITION", POSITION, 2, Value.INT); addFunction("POSITION", POSITION, 2, Value.INT);
addFunction("TRIM", TRIM, VARARGS, Value.STRING); addFunction("TRIM", TRIM, VAR_ARGS, Value.STRING);
addFunction("STRINGENCODE", STRINGENCODE, 1, Value.STRING); addFunction("STRINGENCODE", STRINGENCODE, 1, Value.STRING);
addFunction("STRINGDECODE", STRINGDECODE, 1, Value.STRING); addFunction("STRINGDECODE", STRINGDECODE, 1, Value.STRING);
addFunction("STRINGTOUTF8", STRINGTOUTF8, 1, Value.BYTES); addFunction("STRINGTOUTF8", STRINGTOUTF8, 1, Value.BYTES);
addFunction("UTF8TOSTRING", UTF8TOSTRING, 1, Value.STRING); addFunction("UTF8TOSTRING", UTF8TOSTRING, 1, Value.STRING);
addFunction("XMLATTR", XMLATTR, 2, Value.STRING); addFunction("XMLATTR", XMLATTR, 2, Value.STRING);
addFunctionWithNull("XMLNODE", XMLNODE, VARARGS, Value.STRING); addFunctionWithNull("XMLNODE", XMLNODE, VAR_ARGS, Value.STRING);
addFunction("XMLCOMMENT", XMLCOMMENT, 1, Value.STRING); addFunction("XMLCOMMENT", XMLCOMMENT, 1, Value.STRING);
addFunction("XMLCDATA", XMLCDATA, 1, Value.STRING); addFunction("XMLCDATA", XMLCDATA, 1, Value.STRING);
addFunction("XMLSTARTDOC", XMLSTARTDOC, 0, Value.STRING); addFunction("XMLSTARTDOC", XMLSTARTDOC, 0, Value.STRING);
...@@ -228,8 +228,8 @@ public class Function extends Expression implements FunctionCall { ...@@ -228,8 +228,8 @@ public class Function extends Expression implements FunctionCall {
addFunctionNotConst("CURDATE", CURDATE, 0, Value.DATE); addFunctionNotConst("CURDATE", CURDATE, 0, Value.DATE);
addFunctionNotConst("CURRENT_TIME", CURRENT_TIME, 0, Value.TIME); addFunctionNotConst("CURRENT_TIME", CURRENT_TIME, 0, Value.TIME);
addFunctionNotConst("CURTIME", CURTIME, 0, Value.TIME); addFunctionNotConst("CURTIME", CURTIME, 0, Value.TIME);
addFunctionNotConst("CURRENT_TIMESTAMP", CURRENT_TIMESTAMP, VARARGS, Value.TIMESTAMP); addFunctionNotConst("CURRENT_TIMESTAMP", CURRENT_TIMESTAMP, VAR_ARGS, Value.TIMESTAMP);
addFunctionNotConst("NOW", NOW, VARARGS, Value.TIMESTAMP); addFunctionNotConst("NOW", NOW, VAR_ARGS, Value.TIMESTAMP);
addFunction("DATEADD", DATEADD, 3, Value.TIMESTAMP); addFunction("DATEADD", DATEADD, 3, Value.TIMESTAMP);
addFunction("DATEDIFF", DATEDIFF, 3, Value.LONG); addFunction("DATEDIFF", DATEDIFF, 3, Value.LONG);
addFunction("DAYNAME", DAYNAME, 1, Value.STRING); addFunction("DAYNAME", DAYNAME, 1, Value.STRING);
...@@ -246,8 +246,8 @@ public class Function extends Expression implements FunctionCall { ...@@ -246,8 +246,8 @@ public class Function extends Expression implements FunctionCall {
addFunction("WEEK", WEEK, 1, Value.INT); addFunction("WEEK", WEEK, 1, Value.INT);
addFunction("YEAR", YEAR, 1, Value.INT); addFunction("YEAR", YEAR, 1, Value.INT);
addFunction("EXTRACT", EXTRACT, 2, Value.INT); addFunction("EXTRACT", EXTRACT, 2, Value.INT);
addFunctionWithNull("FORMATDATETIME", FORMATDATETIME, VARARGS, Value.STRING); addFunctionWithNull("FORMATDATETIME", FORMATDATETIME, VAR_ARGS, Value.STRING);
addFunctionWithNull("PARSEDATETIME", PARSEDATETIME, VARARGS, Value.TIMESTAMP); addFunctionWithNull("PARSEDATETIME", PARSEDATETIME, VAR_ARGS, Value.TIMESTAMP);
// system // system
addFunctionNotConst("DATABASE", DATABASE, 0, Value.STRING); addFunctionNotConst("DATABASE", DATABASE, 0, Value.STRING);
addFunctionNotConst("USER", USER, 0, Value.STRING); addFunctionNotConst("USER", USER, 0, Value.STRING);
...@@ -263,15 +263,15 @@ public class Function extends Expression implements FunctionCall { ...@@ -263,15 +263,15 @@ public class Function extends Expression implements FunctionCall {
addFunctionWithNull("CASEWHEN", CASEWHEN, 3, Value.NULL); addFunctionWithNull("CASEWHEN", CASEWHEN, 3, Value.NULL);
addFunctionWithNull("CONVERT", CONVERT, 1, Value.NULL); addFunctionWithNull("CONVERT", CONVERT, 1, Value.NULL);
addFunctionWithNull("CAST", CAST, 1, Value.NULL); addFunctionWithNull("CAST", CAST, 1, Value.NULL);
addFunctionWithNull("COALESCE", COALESCE, VARARGS, Value.NULL); addFunctionWithNull("COALESCE", COALESCE, VAR_ARGS, Value.NULL);
addFunctionWithNull("NVL", COALESCE, VARARGS, Value.NULL); addFunctionWithNull("NVL", COALESCE, VAR_ARGS, Value.NULL);
addFunctionWithNull("NULLIF", NULLIF, 2, Value.NULL); addFunctionWithNull("NULLIF", NULLIF, 2, Value.NULL);
addFunctionWithNull("CASE", CASE, VARARGS, Value.NULL); addFunctionWithNull("CASE", CASE, VAR_ARGS, Value.NULL);
addFunctionNotConst("NEXTVAL", NEXTVAL, VARARGS, Value.LONG); addFunctionNotConst("NEXTVAL", NEXTVAL, VAR_ARGS, Value.LONG);
addFunctionNotConst("CURRVAL", CURRVAL, VARARGS, Value.LONG); addFunctionNotConst("CURRVAL", CURRVAL, VAR_ARGS, Value.LONG);
addFunction("ARRAY_GET", ARRAY_GET, 2, Value.NULL); addFunction("ARRAY_GET", ARRAY_GET, 2, Value.NULL);
addFunction("CSVREAD", CSVREAD, VARARGS, Value.RESULT_SET, false, false); addFunction("CSVREAD", CSVREAD, VAR_ARGS, Value.RESULT_SET, false, false);
addFunction("CSVWRITE", CSVWRITE, VARARGS, Value.NULL, false, false); addFunction("CSVWRITE", CSVWRITE, VAR_ARGS, Value.NULL, false, false);
addFunctionNotConst("MEMORY_FREE", MEMORY_FREE, 0, Value.INT); addFunctionNotConst("MEMORY_FREE", MEMORY_FREE, 0, Value.INT);
addFunctionNotConst("MEMORY_USED", MEMORY_USED, 0, Value.INT); addFunctionNotConst("MEMORY_USED", MEMORY_USED, 0, Value.INT);
addFunctionNotConst("LOCK_MODE", LOCK_MODE, 0, Value.INT); addFunctionNotConst("LOCK_MODE", LOCK_MODE, 0, Value.INT);
...@@ -318,16 +318,16 @@ public class Function extends Expression implements FunctionCall { ...@@ -318,16 +318,16 @@ public class Function extends Expression implements FunctionCall {
private Function(Database database, FunctionInfo info) { private Function(Database database, FunctionInfo info) {
this.database = database; this.database = database;
this.info = info; this.info = info;
if(info.parameterCount == VARARGS) { if(info.parameterCount == VAR_ARGS) {
varargs = new ObjectArray(); varArgs = new ObjectArray();
} else { } else {
args = new Expression[info.parameterCount]; args = new Expression[info.parameterCount];
} }
} }
public void setParameter(int index, Expression param) throws SQLException { public void setParameter(int index, Expression param) throws SQLException {
if(varargs != null) { if(varArgs != null) {
varargs.add(param); varArgs.add(param);
} else { } else {
if(index >= args.length) { if(index >= args.length) {
throw Message.getSQLException(Message.INVALID_PARAMETER_COUNT_1, ""+args.length); throw Message.getSQLException(Message.INVALID_PARAMETER_COUNT_1, ""+args.length);
...@@ -914,7 +914,7 @@ public class Function extends Expression implements FunctionCall { ...@@ -914,7 +914,7 @@ public class Function extends Expression implements FunctionCall {
int field = getDatePart(part); int field = getDatePart(part);
Calendar calendar = Calendar.getInstance(); Calendar calendar = Calendar.getInstance();
long t1 = d1.getTime(), t2 = d2.getTime(); long t1 = d1.getTime(), t2 = d2.getTime();
// need to convert to UTC, otherwise we get inconsistent results with certain timezones (those that are 30 minites off) // need to convert to UTC, otherwise we get inconsistent results with certain timezones (those that are 30 minutes off)
TimeZone zone = calendar.getTimeZone(); TimeZone zone = calendar.getTimeZone();
calendar.setTime(d1); calendar.setTime(d1);
t1 += zone.getOffset(calendar.get(Calendar.ERA), calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), t1 += zone.getOffset(calendar.get(Calendar.ERA), calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH),
...@@ -987,12 +987,12 @@ public class Function extends Expression implements FunctionCall { ...@@ -987,12 +987,12 @@ public class Function extends Expression implements FunctionCall {
s = (i == 0) ? s : s.substring(i); s = (i == 0) ? s : s.substring(i);
} }
if(trailing) { if(trailing) {
int endindex = s.length() - 1; int endIndex = s.length() - 1;
int i = endindex; int i = endIndex;
while (i >= 0 && s.charAt(i) == space) { while (i >= 0 && s.charAt(i) == space) {
i--; i--;
} }
s = i == endindex ? s : s.substring(0, i + 1); s = i == endIndex ? s : s.substring(0, i + 1);
} }
return s; return s;
} }
...@@ -1149,21 +1149,21 @@ public class Function extends Expression implements FunctionCall { ...@@ -1149,21 +1149,21 @@ public class Function extends Expression implements FunctionCall {
private static String getSoundex(String s) { private static String getSoundex(String s) {
int len = s.length(); int len = s.length();
char[] chars = new char[] { '0', '0', '0', '0' }; char[] chars = new char[] { '0', '0', '0', '0' };
char lastdigit = '0'; char lastDigit = '0';
for (int i = 0, j = 0; i < len && j < 4; i++) { for (int i = 0, j = 0; i < len && j < 4; i++) {
char c = s.charAt(i); char c = s.charAt(i);
char newdigit = c > SOUNDEX_INDEX.length ? 0 : SOUNDEX_INDEX[c]; char newDigit = c > SOUNDEX_INDEX.length ? 0 : SOUNDEX_INDEX[c];
if(newdigit != 0) { if(newDigit != 0) {
if (j == 0) { if (j == 0) {
chars[j++] = c; chars[j++] = c;
lastdigit = newdigit; lastDigit = newDigit;
} else if (newdigit <= '6') { } else if (newDigit <= '6') {
if (newdigit != lastdigit) { if (newDigit != lastDigit) {
chars[j++] = newdigit; chars[j++] = newDigit;
lastdigit = newdigit; lastDigit = newDigit;
} }
} else if (newdigit == '7') { } else if (newDigit == '7') {
lastdigit = newdigit; lastDigit = newDigit;
} }
} }
} }
...@@ -1181,8 +1181,8 @@ public class Function extends Expression implements FunctionCall { ...@@ -1181,8 +1181,8 @@ public class Function extends Expression implements FunctionCall {
} }
public void doneWithParameters() throws SQLException { public void doneWithParameters() throws SQLException {
if(info.parameterCount == VARARGS) { if(info.parameterCount == VAR_ARGS) {
int len = varargs.size(); int len = varArgs.size();
int min=0, max=Integer.MAX_VALUE; int min=0, max=Integer.MAX_VALUE;
switch (info.type) { switch (info.type) {
case COALESCE: case COALESCE:
...@@ -1239,8 +1239,8 @@ public class Function extends Expression implements FunctionCall { ...@@ -1239,8 +1239,8 @@ public class Function extends Expression implements FunctionCall {
throw Message.getSQLException(Message.INVALID_PARAMETER_COUNT_1, min + ".." + max); throw Message.getSQLException(Message.INVALID_PARAMETER_COUNT_1, min + ".." + max);
} }
args = new Expression[len]; args = new Expression[len];
varargs.toArray(args); varArgs.toArray(args);
varargs = null; varArgs = null;
} else { } else {
int len = args.length; int len = args.length;
if(len>0 && args[len-1] == null) { if(len>0 && args[len-1] == null) {
......
...@@ -358,12 +358,12 @@ public class BtreeNode extends BtreePage { ...@@ -358,12 +358,12 @@ public class BtreeNode extends BtreePage {
String first = null; String first = null;
String last = null; String last = null;
for(int i=0; i<pageChildren.size(); i++) { for(int i=0; i<pageChildren.size(); i++) {
String firstnow = index.getPage(pageChildren.get(i)).print(indent + " "); String firstNow = index.getPage(pageChildren.get(i)).print(indent + " ");
if(first == null) { if(first == null) {
first = firstnow; first = firstNow;
} }
if(last != null && !last.equals(firstnow)) { if(last != null && !last.equals(firstNow)) {
System.out.println("STOP!!! " + last + " firstnow:" + firstnow); System.out.println("STOP!!! " + last + " firstNow:" + firstNow);
} }
if(i<pageData.size()) { if(i<pageData.size()) {
String now = getData(i).getValue(1).getString().substring(4150); String now = getData(i).getValue(1).getString().substring(4150);
......
...@@ -104,19 +104,19 @@ public class LinearHashBucket extends Record { ...@@ -104,19 +104,19 @@ public class LinearHashBucket extends Record {
public int getRealByteCount(DataPage dummy) throws SQLException { public int getRealByteCount(DataPage dummy) throws SQLException {
int size = 2 + dummy.getIntLen() + dummy.getIntLen(); int size = 2 + dummy.getIntLen() + dummy.getIntLen();
int datasize = 0; int dataSize = 0;
for(int i=0; i<records.size(); i++) { for(int i=0; i<records.size(); i++) {
LinearHashEntry record = (LinearHashEntry) records.get(i); LinearHashEntry record = (LinearHashEntry) records.get(i);
// TODO index: just add the hash if the key is too large // TODO index: just add the hash if the key is too large
datasize += dummy.getValueLen(record.key); dataSize += dummy.getValueLen(record.key);
size += 2 * dummy.getIntLen(); size += 2 * dummy.getIntLen();
} }
if(size + datasize >= index.getBucketSize()) { if(size + dataSize >= index.getBucketSize()) {
writePos = true; writePos = true;
return size; return size;
} else { } else {
writePos = false; writePos = false;
return size + datasize; return size + dataSize;
} }
} }
......
...@@ -262,7 +262,7 @@ public class LinearHashIndex extends Index implements RecordReader { ...@@ -262,7 +262,7 @@ public class LinearHashIndex extends Index implements RecordReader {
// (and it would be an error to set next to -1) // (and it would be an error to set next to -1)
moveOut(session, foreign, storeIn); moveOut(session, foreign, storeIn);
if(Constants.CHECK && getBucket(foreign).getNextBucket() != -1) { if(Constants.CHECK && getBucket(foreign).getNextBucket() != -1) {
throw Message.getInternalError("moveout "+foreign); throw Message.getInternalError("moveOut "+foreign);
} }
return; return;
} }
......
...@@ -34,7 +34,7 @@ public class TreeIndex extends Index { ...@@ -34,7 +34,7 @@ public class TreeIndex extends Index {
public void add(Session session, Row row) throws SQLException { public void add(Session session, Row row) throws SQLException {
TreeNode i = new TreeNode(row); TreeNode i = new TreeNode(row);
TreeNode n = root, x = n; TreeNode n = root, x = n;
boolean isleft = true; boolean isLeft = true;
while (true) { while (true) {
if (n == null) { if (n == null) {
if (x == null) { if (x == null) {
...@@ -42,7 +42,7 @@ public class TreeIndex extends Index { ...@@ -42,7 +42,7 @@ public class TreeIndex extends Index {
rowCount++; rowCount++;
return; return;
} }
set(x, isleft, i); set(x, isLeft, i);
break; break;
} }
Row r = n.row; Row r = n.row;
...@@ -55,17 +55,17 @@ public class TreeIndex extends Index { ...@@ -55,17 +55,17 @@ public class TreeIndex extends Index {
} }
compare = compareKeys(row, r); compare = compareKeys(row, r);
} }
isleft = compare < 0; isLeft = compare < 0;
x = n; x = n;
n = child(x, isleft); n = child(x, isLeft);
} }
balance(x, isleft); balance(x, isLeft);
rowCount++; rowCount++;
} }
private void balance(TreeNode x, boolean isleft) { private void balance(TreeNode x, boolean isLeft) {
while (true) { while (true) {
int sign = isleft ? 1 : -1; int sign = isLeft ? 1 : -1;
switch (x.balance * sign) { switch (x.balance * sign) {
case 1 : case 1 :
x.balance = 0; x.balance = 0;
...@@ -74,20 +74,20 @@ public class TreeIndex extends Index { ...@@ -74,20 +74,20 @@ public class TreeIndex extends Index {
x.balance = -sign; x.balance = -sign;
break; break;
case -1 : case -1 :
TreeNode l = child(x, isleft); TreeNode l = child(x, isLeft);
if (l.balance == -sign) { if (l.balance == -sign) {
replace(x, l); replace(x, l);
set(x, isleft, child(l, !isleft)); set(x, isLeft, child(l, !isLeft));
set(l, !isleft, x); set(l, !isLeft, x);
x.balance = 0; x.balance = 0;
l.balance = 0; l.balance = 0;
} else { } else {
TreeNode r = child(l, !isleft); TreeNode r = child(l, !isLeft);
replace(x, r); replace(x, r);
set(l, !isleft, child(r, isleft)); set(l, !isLeft, child(r, isLeft));
set(r, isleft, l); set(r, isLeft, l);
set(x, isleft, child(r, !isleft)); set(x, isLeft, child(r, !isLeft));
set(r, !isleft, x); set(r, !isLeft, x);
int rb = r.balance; int rb = r.balance;
x.balance = (rb == -sign) ? sign : 0; x.balance = (rb == -sign) ? sign : 0;
l.balance = (rb == sign) ? -sign : 0; l.balance = (rb == sign) ? -sign : 0;
...@@ -98,13 +98,13 @@ public class TreeIndex extends Index { ...@@ -98,13 +98,13 @@ public class TreeIndex extends Index {
if (x == root) { if (x == root) {
return; return;
} }
isleft = x.isFromLeft(); isLeft = x.isFromLeft();
x = x.parent; x = x.parent;
} }
} }
private TreeNode child(TreeNode x, boolean isleft) { private TreeNode child(TreeNode x, boolean isLeft) {
return isleft ? x.left : x.right; return isLeft ? x.left : x.right;
} }
private void replace(TreeNode x, TreeNode n) { private void replace(TreeNode x, TreeNode n) {
...@@ -198,12 +198,12 @@ public class TreeIndex extends Index { ...@@ -198,12 +198,12 @@ public class TreeIndex extends Index {
} }
rowCount--; rowCount--;
boolean isleft = x.isFromLeft(); boolean isLeft = x.isFromLeft();
replace(x, n); replace(x, n);
n = x.parent; n = x.parent;
while (n != null) { while (n != null) {
x = n; x = n;
int sign = isleft ? 1 : -1; int sign = isLeft ? 1 : -1;
switch (x.balance * sign) { switch (x.balance * sign) {
case -1 : case -1 :
x.balance = 0; x.balance = 0;
...@@ -212,12 +212,12 @@ public class TreeIndex extends Index { ...@@ -212,12 +212,12 @@ public class TreeIndex extends Index {
x.balance = sign; x.balance = sign;
return; return;
case 1 : case 1 :
TreeNode r = child(x, !isleft); TreeNode r = child(x, !isLeft);
int b = r.balance; int b = r.balance;
if (b * sign >= 0) { if (b * sign >= 0) {
replace(x, r); replace(x, r);
set(x, !isleft, child(r, isleft)); set(x, !isLeft, child(r, isLeft));
set(r, isleft, x); set(r, isLeft, x);
if (b == 0) { if (b == 0) {
x.balance = sign; x.balance = sign;
r.balance = -sign; r.balance = -sign;
...@@ -227,20 +227,20 @@ public class TreeIndex extends Index { ...@@ -227,20 +227,20 @@ public class TreeIndex extends Index {
r.balance = 0; r.balance = 0;
x = r; x = r;
} else { } else {
TreeNode l = child(r, isleft); TreeNode l = child(r, isLeft);
replace(x, l); replace(x, l);
b = l.balance; b = l.balance;
set(r, isleft, child(l, !isleft)); set(r, isLeft, child(l, !isLeft));
set(l, !isleft, r); set(l, !isLeft, r);
set(x, !isleft, child(l, isleft)); set(x, !isLeft, child(l, isLeft));
set(l, isleft, x); set(l, isLeft, x);
x.balance = (b == sign) ? -sign : 0; x.balance = (b == sign) ? -sign : 0;
r.balance = (b == -sign) ? sign : 0; r.balance = (b == -sign) ? sign : 0;
l.balance = 0; l.balance = 0;
x = l; x = l;
} }
} }
isleft = x.isFromLeft(); isLeft = x.isFromLeft();
n = x.parent; n = x.parent;
} }
} }
......
...@@ -149,8 +149,10 @@ public class ViewIndex extends Index { ...@@ -149,8 +149,10 @@ public class ViewIndex extends Index {
if(lastResult != null && canReuse) { if(lastResult != null && canReuse) {
if(query.sameResultAsLast(session, params, lastParameters, lastEvaluated)) { if(query.sameResultAsLast(session, params, lastParameters, lastEvaluated)) {
lastResult = lastResult.createShallowCopy(session); lastResult = lastResult.createShallowCopy(session);
lastResult.reset(); if(lastResult != null) {
return new ViewCursor(table, lastResult); lastResult.reset();
return new ViewCursor(table, lastResult);
}
} }
} }
} }
......
...@@ -54,7 +54,7 @@ import java.sql.SQLClientInfoException; ...@@ -54,7 +54,7 @@ import java.sql.SQLClientInfoException;
* Represents a connection (session) to a database. * Represents a connection (session) to a database.
*/ */
public class JdbcConnection extends TraceObject implements Connection { public class JdbcConnection extends TraceObject implements Connection {
// TODO test: check if enough sychronization on jdbc objects // TODO test: check if enough synchronization on jdbc objects
// TODO feature auto-reconnect on lost connection! // TODO feature auto-reconnect on lost connection!
private String url; private String url;
...@@ -272,11 +272,11 @@ public class JdbcConnection extends TraceObject implements Connection { ...@@ -272,11 +272,11 @@ public class JdbcConnection extends TraceObject implements Connection {
} }
/** /**
* Switches autocommit on or off. Calling this function does not commit the * Switches auto commit on or off. Calling this function does not commit the
* current transaction. * current transaction.
* *
* @param autoCommit * @param autoCommit
* true for autocommit on, false for off * true for auto commit on, false for off
* @throws SQLException * @throws SQLException
* if the connection is closed * if the connection is closed
*/ */
...@@ -299,7 +299,7 @@ public class JdbcConnection extends TraceObject implements Connection { ...@@ -299,7 +299,7 @@ public class JdbcConnection extends TraceObject implements Connection {
} }
/** /**
* Gets the current setting for autocommit. * Gets the current setting for auto commit.
* *
* @return true for on, false for off * @return true for on, false for off
* @throws SQLException * @throws SQLException
...@@ -319,14 +319,14 @@ public class JdbcConnection extends TraceObject implements Connection { ...@@ -319,14 +319,14 @@ public class JdbcConnection extends TraceObject implements Connection {
getAutoCommit = prepareCommand("CALL AUTOCOMMIT()", getAutoCommit); getAutoCommit = prepareCommand("CALL AUTOCOMMIT()", getAutoCommit);
ResultInterface result = getAutoCommit.executeQuery(0, false); ResultInterface result = getAutoCommit.executeQuery(0, false);
result.next(); result.next();
boolean autocommit = result.currentRow()[0].getBoolean().booleanValue(); boolean autoCommit = result.currentRow()[0].getBoolean().booleanValue();
result.close(); result.close();
return autocommit; return autoCommit;
} }
/** /**
* Commits the current transaction. This call has only an effect if * Commits the current transaction. This call has only an effect if
* autocommit is switched off. * auto commit is switched off.
* *
* @throws SQLException * @throws SQLException
* if the connection is closed * if the connection is closed
...@@ -344,7 +344,7 @@ public class JdbcConnection extends TraceObject implements Connection { ...@@ -344,7 +344,7 @@ public class JdbcConnection extends TraceObject implements Connection {
/** /**
* Rolls back the current transaction. This call has only an effect if * Rolls back the current transaction. This call has only an effect if
* autocommit is switched off. * auto commit is switched off.
* *
* @throws SQLException * @throws SQLException
* if the connection is closed * if the connection is closed
...@@ -1117,25 +1117,25 @@ public class JdbcConnection extends TraceObject implements Connection { ...@@ -1117,25 +1117,25 @@ public class JdbcConnection extends TraceObject implements Connection {
i++; i++;
checkRunOver(i, len, sql); checkRunOver(i, len, sql);
} }
int repl = 0; int remove = 0;
if (found(sql, start, "fn")) { if (found(sql, start, "fn")) {
repl = 2; remove = 2;
} else if (found(sql, start, "escape")) { } else if (found(sql, start, "escape")) {
break; break;
} else if (found(sql, start, "call")) { } else if (found(sql, start, "call")) {
break; break;
} else if (found(sql, start, "oj")) { } else if (found(sql, start, "oj")) {
repl = 2; remove = 2;
} else if (found(sql, start, "ts")) { } else if (found(sql, start, "ts")) {
repl = 2; remove = 2;
} else if (found(sql, start, "t")) { } else if (found(sql, start, "t")) {
repl = 1; remove = 1;
} else if (found(sql, start, "d")) { } else if (found(sql, start, "d")) {
repl = 1; remove = 1;
} else if (found(sql, start, "params")) { } else if (found(sql, start, "params")) {
repl = 1; remove = "params".length();
} }
for (i = start; repl > 0; i++, repl--) { for (i = start; remove > 0; i++, remove--) {
chars[i] = ' '; chars[i] = ' ';
} }
break; break;
......
...@@ -1572,7 +1572,7 @@ public class JdbcDatabaseMetaData extends TraceObject implements DatabaseMetaDat ...@@ -1572,7 +1572,7 @@ public class JdbcDatabaseMetaData extends TraceObject implements DatabaseMetaDat
} }
/** /**
* Returns whether refererential integrity is supported. * Returns whether referential integrity is supported.
* *
* @return true * @return true
*/ */
...@@ -1872,7 +1872,7 @@ public class JdbcDatabaseMetaData extends TraceObject implements DatabaseMetaDat ...@@ -1872,7 +1872,7 @@ public class JdbcDatabaseMetaData extends TraceObject implements DatabaseMetaDat
} }
/** /**
* Returns whether open result sets accross commits are supported. * Returns whether open result sets across commits are supported.
* *
* @return false * @return false
*/ */
...@@ -1882,7 +1882,7 @@ public class JdbcDatabaseMetaData extends TraceObject implements DatabaseMetaDat ...@@ -1882,7 +1882,7 @@ public class JdbcDatabaseMetaData extends TraceObject implements DatabaseMetaDat
} }
/** /**
* Returns whether open result sets accross rollback are supported. * Returns whether open result sets across rollback are supported.
* *
* @return false * @return false
*/ */
...@@ -1892,7 +1892,7 @@ public class JdbcDatabaseMetaData extends TraceObject implements DatabaseMetaDat ...@@ -1892,7 +1892,7 @@ public class JdbcDatabaseMetaData extends TraceObject implements DatabaseMetaDat
} }
/** /**
* Returns whether open statements accross commit are supported. * Returns whether open statements across commit are supported.
* *
* @return true * @return true
*/ */
...@@ -1902,7 +1902,7 @@ public class JdbcDatabaseMetaData extends TraceObject implements DatabaseMetaDat ...@@ -1902,7 +1902,7 @@ public class JdbcDatabaseMetaData extends TraceObject implements DatabaseMetaDat
} }
/** /**
* Returns whether open statements accross rollback are supported. * Returns whether open statements across rollback are supported.
* *
* @return true * @return true
*/ */
...@@ -1974,7 +1974,7 @@ public class JdbcDatabaseMetaData extends TraceObject implements DatabaseMetaDat ...@@ -1974,7 +1974,7 @@ public class JdbcDatabaseMetaData extends TraceObject implements DatabaseMetaDat
/** /**
* Returns whether a specific result set type is supported. * Returns whether a specific result set type is supported.
* ResultSet.TYPE_SCROLL_SENSITIVE is notsupported. * ResultSet.TYPE_SCROLL_SENSITIVE is not supported.
* *
* @return true for all types except ResultSet.TYPE_FORWARD_ONLY * @return true for all types except ResultSet.TYPE_FORWARD_ONLY
*/ */
...@@ -1985,7 +1985,7 @@ public class JdbcDatabaseMetaData extends TraceObject implements DatabaseMetaDat ...@@ -1985,7 +1985,7 @@ public class JdbcDatabaseMetaData extends TraceObject implements DatabaseMetaDat
/** /**
* Returns whether a specific result set concurrency is supported. * Returns whether a specific result set concurrency is supported.
* ResultSet.TYPE_SCROLL_SENSITIVE is notsupported. * ResultSet.TYPE_SCROLL_SENSITIVE is not supported.
* *
* @return true if the type is not ResultSet.TYPE_SCROLL_SENSITIVE * @return true if the type is not ResultSet.TYPE_SCROLL_SENSITIVE
*/ */
...@@ -2053,7 +2053,7 @@ public class JdbcDatabaseMetaData extends TraceObject implements DatabaseMetaDat ...@@ -2053,7 +2053,7 @@ public class JdbcDatabaseMetaData extends TraceObject implements DatabaseMetaDat
} }
/** /**
* Returns whether updates are dectected. * Returns whether updates are detected.
* @return false * @return false
*/ */
public boolean updatesAreDetected(int type) { public boolean updatesAreDetected(int type) {
...@@ -2620,7 +2620,7 @@ public class JdbcDatabaseMetaData extends TraceObject implements DatabaseMetaDat ...@@ -2620,7 +2620,7 @@ public class JdbcDatabaseMetaData extends TraceObject implements DatabaseMetaDat
} }
/** /**
* Returns whether an exception while autocommit is on closes all result sets. * Returns whether an exception while auto commit is on closes all result sets.
* @return false * @return false
*/ */
public boolean autoCommitFailureClosesAllResultSets() throws SQLException { public boolean autoCommitFailureClosesAllResultSets() throws SQLException {
......
...@@ -103,7 +103,7 @@ public class JdbcPreparedStatement extends JdbcStatement implements PreparedStat ...@@ -103,7 +103,7 @@ public class JdbcPreparedStatement extends JdbcStatement implements PreparedStat
* another result set exists for this statement, this will be closed (even if this statement fails). * another result set exists for this statement, this will be closed (even if this statement fails).
* *
* If the statement is a create or drop and does not throw an exception, the current transaction (if any) is * If the statement is a create or drop and does not throw an exception, the current transaction (if any) is
* committed after executing the statement. If autocommit is on, this statement will be committed. * committed after executing the statement. If auto commit is on, this statement will be committed.
* *
* @return the update count (number of row affected by an insert, update or delete, or 0 if no rows or the statement * @return the update count (number of row affected by an insert, update or delete, or 0 if no rows or the statement
* was a create, drop, commit or rollback) * was a create, drop, commit or rollback)
...@@ -134,7 +134,7 @@ public class JdbcPreparedStatement extends JdbcStatement implements PreparedStat ...@@ -134,7 +134,7 @@ public class JdbcPreparedStatement extends JdbcStatement implements PreparedStat
/** /**
* Executes an arbitrary statement. If another result set exists for this statement, this will be closed (even if * Executes an arbitrary statement. If another result set exists for this statement, this will be closed (even if
* this statement fails). If autocommit is on, and the statement is not a select, this statement will be committed. * this statement fails). If auto commit is on, and the statement is not a select, this statement will be committed.
* *
* @return true if a result set is available, false if not * @return true if a result set is available, false if not
* @throws SQLException if this object is closed or invalid * @throws SQLException if this object is closed or invalid
...@@ -251,7 +251,7 @@ public class JdbcPreparedStatement extends JdbcStatement implements PreparedStat ...@@ -251,7 +251,7 @@ public class JdbcPreparedStatement extends JdbcStatement implements PreparedStat
* Sets a parameter to null. * Sets a parameter to null.
* *
* @param parameterIndex the parameter index (1, 2, ...) * @param parameterIndex the parameter index (1, 2, ...)
* @param sqlType the data type (Types.xxx) * @param sqlType the data type (Types.x)
* @throws SQLException if this object is closed * @throws SQLException if this object is closed
*/ */
public void setNull(int parameterIndex, int sqlType) throws SQLException { public void setNull(int parameterIndex, int sqlType) throws SQLException {
...@@ -658,7 +658,7 @@ public class JdbcPreparedStatement extends JdbcStatement implements PreparedStat ...@@ -658,7 +658,7 @@ public class JdbcPreparedStatement extends JdbcStatement implements PreparedStat
* Sets a parameter to null. * Sets a parameter to null.
* *
* @param parameterIndex the parameter index (1, 2, ...) * @param parameterIndex the parameter index (1, 2, ...)
* @param sqlType the data type (Types.xxx) * @param sqlType the data type (Types.x)
* @param typeName this parameter is ignored * @param typeName this parameter is ignored
* @throws SQLException if this object is closed * @throws SQLException if this object is closed
*/ */
...@@ -998,7 +998,7 @@ public class JdbcPreparedStatement extends JdbcStatement implements PreparedStat ...@@ -998,7 +998,7 @@ public class JdbcPreparedStatement extends JdbcStatement implements PreparedStat
/** /**
* Executes the batch. * Executes the batch.
* *
* @return the array of updatecounts * @return the array of update counts
*/ */
public int[] executeBatch() throws SQLException { public int[] executeBatch() throws SQLException {
try { try {
...@@ -1037,9 +1037,9 @@ public class JdbcPreparedStatement extends JdbcStatement implements PreparedStat ...@@ -1037,9 +1037,9 @@ public class JdbcPreparedStatement extends JdbcStatement implements PreparedStat
} }
batchParameters = null; batchParameters = null;
if (error) { if (error) {
JdbcBatchUpdateException bue = new JdbcBatchUpdateException(next, result); JdbcBatchUpdateException e = new JdbcBatchUpdateException(next, result);
bue.setNextException(next); e.setNextException(next);
throw bue; throw e;
} }
return result; return result;
} catch(Throwable e) { } catch(Throwable e) {
......
...@@ -59,7 +59,7 @@ public class JdbcResultSet extends TraceObject implements ResultSet { ...@@ -59,7 +59,7 @@ public class JdbcResultSet extends TraceObject implements ResultSet {
/** /**
* Moves the cursor to the next row of the result set. * 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 { public boolean next() throws SQLException {
try { try {
...@@ -393,7 +393,7 @@ public class JdbcResultSet extends TraceObject implements ResultSet { ...@@ -393,7 +393,7 @@ public class JdbcResultSet extends TraceObject implements ResultSet {
} }
/** /**
* Returns a column value as a Java object. For BINARY data, the data is deserialized into a Java Object. * Returns a column value as a Java object. For BINARY data, the data is de-serialized into a Java Object.
* *
* @param columnIndex (1,2,...) * @param columnIndex (1,2,...)
* @return the value or null * @return the value or null
...@@ -415,7 +415,7 @@ public class JdbcResultSet extends TraceObject implements ResultSet { ...@@ -415,7 +415,7 @@ public class JdbcResultSet extends TraceObject implements ResultSet {
} }
/** /**
* Returns a column value as a Java object. For BINARY data, the data is deserialized into a Java Object. * Returns a column value as a Java object. For BINARY data, the data is de-serialized into a Java Object.
* *
* @param columnName the name of the column label * @param columnName the name of the column label
* @return the value or null * @return the value or null
...@@ -2253,7 +2253,7 @@ public class JdbcResultSet extends TraceObject implements ResultSet { ...@@ -2253,7 +2253,7 @@ public class JdbcResultSet extends TraceObject implements ResultSet {
/** /**
* [Not supported] Gets the cursor name if it was defined. This feature is superseded by * [Not supported] Gets the cursor name if it was defined. This feature is superseded by
* updateXXX methods. This method throws a SQLException because cursor names are not supported. * updateX methods. This method throws a SQLException because cursor names are not supported.
*/ */
public String getCursorName() throws SQLException { public String getCursorName() throws SQLException {
try { try {
...@@ -2294,8 +2294,8 @@ public class JdbcResultSet extends TraceObject implements ResultSet { ...@@ -2294,8 +2294,8 @@ public class JdbcResultSet extends TraceObject implements ResultSet {
try { try {
debugCodeCall("getConcurrency"); debugCodeCall("getConcurrency");
checkClosed(); checkClosed();
UpdatableRow upd = new UpdatableRow(conn, result, session); UpdatableRow row = new UpdatableRow(conn, result, session);
return upd.isUpdatable() ? ResultSet.CONCUR_UPDATABLE : ResultSet.CONCUR_READ_ONLY; return row.isUpdatable() ? ResultSet.CONCUR_UPDATABLE : ResultSet.CONCUR_READ_ONLY;
} catch(Throwable e) { } catch(Throwable e) {
throw logAndConvert(e); throw logAndConvert(e);
} }
...@@ -2783,11 +2783,11 @@ public class JdbcResultSet extends TraceObject implements ResultSet { ...@@ -2783,11 +2783,11 @@ public class JdbcResultSet extends TraceObject implements ResultSet {
} }
private UpdatableRow getUpdatableRow() throws SQLException { private UpdatableRow getUpdatableRow() throws SQLException {
UpdatableRow upd = new UpdatableRow(conn, result, session); UpdatableRow row = new UpdatableRow(conn, result, session);
if(!upd.isUpdatable()) { if(!row.isUpdatable()) {
throw Message.getSQLException(Message.NOT_ON_UPDATABLE_ROW); throw Message.getSQLException(Message.NOT_ON_UPDATABLE_ROW);
} }
return upd; return row;
} }
int getColumnIndex(String columnName) throws SQLException { int getColumnIndex(String columnName) throws SQLException {
......
...@@ -85,7 +85,7 @@ public class JdbcStatement extends TraceObject implements Statement { ...@@ -85,7 +85,7 @@ public class JdbcStatement extends TraceObject implements Statement {
* *
* If the statement is a create or drop and does not throw an exception, * If the statement is a create or drop and does not throw an exception,
* the current transaction (if any) is committed after executing the statement. * the current transaction (if any) is committed after executing the statement.
* If autocommit is on, this statement will be committed. * If auto commit is on, this statement will be committed.
* *
* @param sql the SQL statement * @param sql the SQL statement
* @return the update count (number of row affected by an insert, * @return the update count (number of row affected by an insert,
...@@ -125,7 +125,7 @@ public class JdbcStatement extends TraceObject implements Statement { ...@@ -125,7 +125,7 @@ public class JdbcStatement extends TraceObject implements Statement {
* *
* If the statement is a create or drop and does not throw an exception, * If the statement is a create or drop and does not throw an exception,
* the current transaction (if any) is committed after executing the statement. * the current transaction (if any) is committed after executing the statement.
* If autocommit is on, and the statement is not a select, this statement will be committed. * If auto commit is on, and the statement is not a select, this statement will be committed.
* *
* @return true if a result set is available, false if not * @return true if a result set is available, false if not
*/ */
...@@ -585,7 +585,7 @@ public class JdbcStatement extends TraceObject implements Statement { ...@@ -585,7 +585,7 @@ public class JdbcStatement extends TraceObject implements Statement {
/** /**
* Executes the batch. * Executes the batch.
* *
* @return the array of updatecounts * @return the array of update counts
*/ */
public int[] executeBatch() throws SQLException { public int[] executeBatch() throws SQLException {
try { try {
......
...@@ -70,14 +70,17 @@ implements XAConnection, XAResource, JdbcConnectionListener ...@@ -70,14 +70,17 @@ implements XAConnection, XAResource, JdbcConnectionListener
Properties info = new Properties(); Properties info = new Properties();
info.setProperty("user", user); info.setProperty("user", user);
info.setProperty("password", password); info.setProperty("password", password);
conn = new JdbcConnection(url, info); conn = new JdbcConnection(url, info);
conn.setJdbcConnectionListener(this);
return conn; return conn;
} }
public void addConnectionEventListener(ConnectionEventListener listener) { public void addConnectionEventListener(ConnectionEventListener listener) {
debugCode("addConnectionEventListener(listener)"); debugCode("addConnectionEventListener(listener)");
listeners.add(listener); listeners.add(listener);
conn.setJdbcConnectionListener(this); if(conn != null) {
conn.setJdbcConnectionListener(this);
}
} }
public void removeConnectionEventListener(ConnectionEventListener listener) { public void removeConnectionEventListener(ConnectionEventListener listener) {
...@@ -238,7 +241,7 @@ implements XAConnection, XAResource, JdbcConnectionListener ...@@ -238,7 +241,7 @@ implements XAConnection, XAResource, JdbcConnectionListener
buff.append(xid.getFormatId()); buff.append(xid.getFormatId());
buff.append(",bq:"); buff.append(",bq:");
buff.append(ByteUtils.convertBytesToString(xid.getBranchQualifier())); buff.append(ByteUtils.convertBytesToString(xid.getBranchQualifier()));
buff.append(",gxid:"); buff.append(",gx:");
buff.append(ByteUtils.convertBytesToString(xid.getGlobalTransactionId())); buff.append(ByteUtils.convertBytesToString(xid.getGlobalTransactionId()));
buff.append(",c:"); buff.append(",c:");
buff.append(xid.getClass().getName()); buff.append(xid.getClass().getName());
......
...@@ -23,7 +23,7 @@ public class Message { ...@@ -23,7 +23,7 @@ public class Message {
private static final Properties MESSAGES = new Properties(); private static final Properties MESSAGES = new Properties();
static { static {
// TODO multilanguage messages // TODO multi language messages
// String language = Locale.getDefault().getLanguage(); // String language = Locale.getDefault().getLanguage();
try { try {
byte[] messages = Resources.get("/org/h2/res/messages.properties"); byte[] messages = Resources.get("/org/h2/res/messages.properties");
...@@ -37,16 +37,14 @@ public class Message { ...@@ -37,16 +37,14 @@ public class Message {
/** /**
* Gets the SQL Exception object for a specific SQLState. Supported * Gets the SQL Exception object for a specific SQLState. Supported
* sqlstates are: * SQL states are:
* *
* @param sqlstate - * @param sqlState - the SQL State
* the SQL State * @param param - the parameter of the message
* @param param -
* the parameter of the message
* @return the SQLException object * @return the SQLException object
*/ */
public static JdbcSQLException getSQLException(int sqlstate, String p1) { public static JdbcSQLException getSQLException(int sqlState, String p1) {
return getSQLException(sqlstate, new String[] { p1 }, null); return getSQLException(sqlState, new String[] { p1 }, null);
} }
public static String translate(String key, String[] param) { public static String translate(String key, String[] param) {
...@@ -360,8 +358,8 @@ public class Message { ...@@ -360,8 +358,8 @@ public class Message {
if(e instanceof SQLException) { if(e instanceof SQLException) {
return (SQLException)e; return (SQLException)e;
} else if(e instanceof InvocationTargetException) { } else if(e instanceof InvocationTargetException) {
InvocationTargetException ite = (InvocationTargetException)e; InvocationTargetException te = (InvocationTargetException)e;
Throwable t = ite.getTargetException(); Throwable t = te.getTargetException();
if(t instanceof SQLException) { if(t instanceof SQLException) {
return (SQLException)t; return (SQLException)t;
} }
......
...@@ -67,8 +67,8 @@ MERGE INTO tableName [(columnName [,...])] [KEY(columnName [,...])] ...@@ -67,8 +67,8 @@ MERGE INTO tableName [(columnName [,...])] [KEY(columnName [,...])]
"," ","
Updates the row if it exists, and if the row does not exist, inserts a new row. Updates the row if it exists, and if the row does not exist, inserts a new row.
If the key columns are not specified, the primary key columns are used to find the row. If the key columns are not specified, the primary key columns are used to find the row.
This command is sometimes called 'UPSERT' as it UPdates a row if it exists, This command is sometimes called 'UPSERT' as it updates a row if it exists,
or inSERTS the row if it does not yet exist. or inserts the row if it does not yet exist.
If more than one row per new row is affected, an exception is thrown. If more than one row per new row is affected, an exception is thrown.
"," ","
MERGE INTO TEST KEY(ID) VALUES(2, 'World') MERGE INTO TEST KEY(ID) VALUES(2, 'World')
...@@ -122,7 +122,7 @@ ALTER SEQUENCE sequenceName ...@@ -122,7 +122,7 @@ ALTER SEQUENCE sequenceName
"," ","
Changes the next value and / or the increment of a sequence. Changes the next value and / or the increment of a sequence.
"," ","
ALTER SEQUENCE SEQID RESTART WITH 1000 ALTER SEQUENCE SEQ_ID RESTART WITH 1000
" "
"Commands (DDL)","ALTER TABLE ADD"," "Commands (DDL)","ALTER TABLE ADD","
...@@ -197,8 +197,8 @@ ALTER TABLE TEST ALTER COLUMN NAME SET DEFAULT '' ...@@ -197,8 +197,8 @@ ALTER TABLE TEST ALTER COLUMN NAME SET DEFAULT ''
ALTER TABLE tableName ALTER COLUMN columnName ALTER TABLE tableName ALTER COLUMN columnName
SET NOT NULL SET NOT NULL
"," ","
Sets a column to not allow NULL values. Sets a column to not allow NULL.
This is not possible if there are any null values in the table. This is not possible if there are any rows with NULL in this column.
"," ","
ALTER TABLE TEST ALTER COLUMN NAME SET NOT NULL ALTER TABLE TEST ALTER COLUMN NAME SET NOT NULL
" "
...@@ -207,7 +207,7 @@ ALTER TABLE TEST ALTER COLUMN NAME SET NOT NULL ...@@ -207,7 +207,7 @@ ALTER TABLE TEST ALTER COLUMN NAME SET NOT NULL
ALTER TABLE tableName ALTER COLUMN columnName ALTER TABLE tableName ALTER COLUMN columnName
SET NULL SET NULL
"," ","
Sets a column to allow NULL values. Sets a column to allow NULL.
This is not possible if the column is part of a primary key or multi-column hash index. This is not possible if the column is part of a primary key or multi-column hash index.
If there are single column indexes on this column, they are dropped. If there are single column indexes on this column, they are dropped.
"," ","
...@@ -235,7 +235,7 @@ ALTER TABLE tableName RENAME TO newName ...@@ -235,7 +235,7 @@ ALTER TABLE tableName RENAME TO newName
"," ","
Renames a table. Renames a table.
"," ","
ALTER TABLE TEST RENAME TO MYDATA ALTER TABLE TEST RENAME TO MY_DATA
" "
"Commands (DDL)","ALTER USER ADMIN"," "Commands (DDL)","ALTER USER ADMIN","
...@@ -331,7 +331,7 @@ CREATE DOMAIN [IF NOT EXISTS] newDomainName AS dataType ...@@ -331,7 +331,7 @@ CREATE DOMAIN [IF NOT EXISTS] newDomainName AS dataType
[CHECK condition] [CHECK condition]
"," ","
Creates a new data type (domain). Creates a new data type (domain).
The check condition must evaluate to true or to NULL (to prevent NULL values, use NOT NULL). The check condition must evaluate to true or to NULL (to prevent NULL, use NOT NULL).
In the condition, the term VALUE refers to the value being tested. In the condition, the term VALUE refers to the value being tested.
"," ","
CREATE DOMAIN EMAIL AS VARCHAR(255) CHECK (POSITION('@', VALUE) > 1) CREATE DOMAIN EMAIL AS VARCHAR(255) CHECK (POSITION('@', VALUE) > 1)
...@@ -383,7 +383,7 @@ CREATE SEQUENCE [IF NOT EXISTS] newSequenceName ...@@ -383,7 +383,7 @@ CREATE SEQUENCE [IF NOT EXISTS] newSequenceName
"," ","
Creates a new sequence. The data type of a sequence is BIGINT. Creates a new sequence. The data type of a sequence is BIGINT.
"," ","
CREATE SEQUENCE SEQID CREATE SEQUENCE SEQ_ID
" "
"Commands (DDL)","CREATE TABLE"," "Commands (DDL)","CREATE TABLE","
...@@ -486,7 +486,7 @@ DROP SEQUENCE [IF EXISTS] sequenceName ...@@ -486,7 +486,7 @@ DROP SEQUENCE [IF EXISTS] sequenceName
"," ","
Drops a sequence. Drops a sequence.
"," ","
DROP SEQUENCE SEQID DROP SEQUENCE SEQ_ID
" "
"Commands (DDL)","DROP SCHEMA"," "Commands (DDL)","DROP SCHEMA","
DROP SCHEMA [IF EXISTS] schemaName DROP SCHEMA [IF EXISTS] schemaName
...@@ -679,7 +679,7 @@ SET ASSERT 0 ...@@ -679,7 +679,7 @@ SET ASSERT 0
"Commands (Other)","SET AUTOCOMMIT"," "Commands (Other)","SET AUTOCOMMIT","
SET AUTOCOMMIT {TRUE | ON | FALSE | OFF} SET AUTOCOMMIT {TRUE | ON | FALSE | OFF}
"," ","
Switches autocommit on or off. Switches auto commit on or off.
"," ","
SET AUTOCOMMIT OFF SET AUTOCOMMIT OFF
" "
...@@ -726,7 +726,7 @@ SET COLLATION ENGLISH ...@@ -726,7 +726,7 @@ SET COLLATION ENGLISH
"Commands (Other)","SET COMPRESS_LOB"," "Commands (Other)","SET COMPRESS_LOB","
SET COMPRESS_LOB {NO|LZF|DEFLATE} SET COMPRESS_LOB {NO|LZF|DEFLATE}
"," ","
Sets the compression algorithm for BLOBs and CLOBs. Sets the compression algorithm for BLOB and CLOB data.
Compression is usually slower, but needs less memory. Compression is usually slower, but needs less memory.
This setting is persistent. This setting is persistent.
Admin rights are required to execute this command. Admin rights are required to execute this command.
...@@ -930,7 +930,7 @@ SET PASSWORD string ...@@ -930,7 +930,7 @@ SET PASSWORD string
Changes the password of the current user. Changes the password of the current user.
The password must be in single quotes. It is case sensitive and can contain spaces. The password must be in single quotes. It is case sensitive and can contain spaces.
"," ","
SET PASSWORD 'stzri!.5' SET PASSWORD 'abcstzri!.5'
" "
"Commands (Other)","SET SALT HASH"," "Commands (Other)","SET SALT HASH","
...@@ -1041,7 +1041,7 @@ CHECK expression ...@@ -1041,7 +1041,7 @@ CHECK expression
| referentialConstraint} | referentialConstraint}
"," ","
Defines a constraint. Defines a constraint.
The check condition must evaluate to true or to NULL (to prevent NULL values, use NOT NULL). The check condition must evaluate to true or to NULL (to prevent NULL, use NOT NULL).
"," ","
PRIMARY KEY(ID, NAME) PRIMARY KEY(ID, NAME)
" "
...@@ -2325,7 +2325,7 @@ YEAR(CREATED) ...@@ -2325,7 +2325,7 @@ YEAR(CREATED)
"Functions (System)","AUTOCOMMIT"," "Functions (System)","AUTOCOMMIT","
AUTOCOMMIT(): boolean AUTOCOMMIT(): boolean
"," ","
Returns true if autocommit is switched on for this session. Returns true if auto commit is switched on for this session.
"," ","
AUTOCOMMIT() AUTOCOMMIT()
" "
...@@ -2368,7 +2368,7 @@ Returns the current (last) value of the sequence. ...@@ -2368,7 +2368,7 @@ Returns the current (last) value of the sequence.
If the schema name is not set, the current schema is used. If the schema name is not set, the current schema is used.
If the schema name is not set, the sequence name is converted to uppercase (for compatibility). If the schema name is not set, the sequence name is converted to uppercase (for compatibility).
"," ","
CURRVAL('TESTSEQ') CURRVAL('TEST_SEQ')
" "
"Functions (System)","CSVREAD"," "Functions (System)","CSVREAD","
...@@ -2471,7 +2471,7 @@ Returns the next value of the sequence. ...@@ -2471,7 +2471,7 @@ Returns the next value of the sequence.
If the schema name is not set, the current schema is used. If the schema name is not set, the current schema is used.
If the schema name is not set, the sequence name is converted to uppercase (for compatibility). If the schema name is not set, the sequence name is converted to uppercase (for compatibility).
"," ","
NEXTVAL('TESTSEQ') NEXTVAL('TEST_SEQ')
" "
"Functions (System)","NULLIF"," "Functions (System)","NULLIF","
......
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
90003=Hexadecimal string with odd number of characters: {0} 90003=Hexadecimal string with odd number of characters: {0}
90004=Hexadecimal string contains non hex character: {0} 90004=Hexadecimal string contains non hex character: {0}
90005=Value too long for column {0} 90005=Value too long for column {0}
90006=Null value not allowed for column {0} 90006=Null not allowed for column {0}
90007=The object is already closed 90007=The object is already closed
90008=Invalid value {0} for parameter {1} 90008=Invalid value {0} for parameter {1}
90009=Cannot parse date constant {0} 90009=Cannot parse date constant {0}
...@@ -116,7 +116,7 @@ ...@@ -116,7 +116,7 @@
90093=Clustering error - database currently runs in standalone mode 90093=Clustering error - database currently runs in standalone mode
90094=Clustering error - database currently runs in cluster mode, server list: {0} 90094=Clustering error - database currently runs in cluster mode, server list: {0}
90095=String format error: {0} 90095=String format error: {0}
90096=Not enought rights for object {0} 90096=Not enough rights for object {0}
90097=The database is read only 90097=The database is read only
90098=The database has been closed 90098=The database has been closed
90099=Error setting database event listener {0} 90099=Error setting database event listener {0}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论