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

Formatting.

上级 9c9f746a
...@@ -241,7 +241,8 @@ public class Function extends Expression implements FunctionCall { ...@@ -241,7 +241,8 @@ public class Function extends Expression implements FunctionCall {
addFunction("LENGTH", LENGTH, 1, Value.LONG); addFunction("LENGTH", LENGTH, 1, Value.LONG);
// 2 or 3 arguments // 2 or 3 arguments
addFunction("LOCATE", LOCATE, VAR_ARGS, Value.INT); addFunction("LOCATE", LOCATE, VAR_ARGS, Value.INT);
addFunction("CHARINDEX", LOCATE, VAR_ARGS, Value.INT); // alias for MSSQLServer // alias for MSSQLServer
addFunction("CHARINDEX", LOCATE, VAR_ARGS, Value.INT);
// same as LOCATE with 2 arguments // same as LOCATE with 2 arguments
addFunction("POSITION", LOCATE, 2, Value.INT); addFunction("POSITION", LOCATE, 2, Value.INT);
addFunction("INSTR", INSTR, VAR_ARGS, Value.INT); addFunction("INSTR", INSTR, VAR_ARGS, Value.INT);
...@@ -278,7 +279,8 @@ public class Function extends Expression implements FunctionCall { ...@@ -278,7 +279,8 @@ public class Function extends Expression implements FunctionCall {
// date // date
addFunctionNotDeterministic("CURRENT_DATE", CURRENT_DATE, 0, Value.DATE); addFunctionNotDeterministic("CURRENT_DATE", CURRENT_DATE, 0, Value.DATE);
addFunctionNotDeterministic("CURDATE", CURDATE, 0, Value.DATE); addFunctionNotDeterministic("CURDATE", CURDATE, 0, Value.DATE);
addFunctionNotDeterministic("GETDATE", CURDATE, 0, Value.DATE); // alias for MSSQLServer // alias for MSSQLServer
addFunctionNotDeterministic("GETDATE", CURDATE, 0, Value.DATE);
addFunctionNotDeterministic("CURRENT_TIME", CURRENT_TIME, 0, Value.TIME); addFunctionNotDeterministic("CURRENT_TIME", CURRENT_TIME, 0, Value.TIME);
addFunctionNotDeterministic("CURTIME", CURTIME, 0, Value.TIME); addFunctionNotDeterministic("CURTIME", CURTIME, 0, Value.TIME);
addFunctionNotDeterministic("CURRENT_TIMESTAMP", CURRENT_TIMESTAMP, VAR_ARGS, Value.TIMESTAMP); addFunctionNotDeterministic("CURRENT_TIMESTAMP", CURRENT_TIMESTAMP, VAR_ARGS, Value.TIMESTAMP);
......
...@@ -164,7 +164,7 @@ public class SortOrder implements Comparator<Value[]> { ...@@ -164,7 +164,7 @@ public class SortOrder implements Comparator<Value[]> {
*/ */
public void sort(ArrayList<Value[]> rows, int offset, int limit) { public void sort(ArrayList<Value[]> rows, int offset, int limit) {
int rowsSize = rows.size(); int rowsSize = rows.size();
if (rows.isEmpty() || offset >= rowsSize || limit == 0) { if (rows.isEmpty() || offset >= rowsSize || limit == 0) {
return; return;
} }
if (offset < 0) { if (offset < 0) {
......
...@@ -254,33 +254,6 @@ public class Utils { ...@@ -254,33 +254,6 @@ public class Utils {
} }
return Integer.signum(data1.length - data2.length); return Integer.signum(data1.length - data2.length);
} }
/**
* Compare the contents of two byte arrays. If the content or length of the
* first array is smaller than the second array, -1 is returned. If the
* content or length of the second array is smaller than the first array, 1
* is returned. If the contents and lengths are the same, 0 is returned.
* <p>
* This method interprets bytes as unsigned.
*
* @param data1 the first byte array (must not be null)
* @param data2 the second byte array (must not be null)
* @return the result of the comparison (-1, 1 or 0)
*/
public static int compareNotNull(byte[] data1, byte[] data2) {
if (data1 == data2) {
return 0;
}
int len = Math.min(data1.length, data2.length);
for (int i = 0; i < len; i++) {
int b = data1[i] & 255;
int b2 = data2[i] & 255;
if (b != b2) {
return b > b2 ? 1 : -1;
}
}
return Integer.signum(data1.length - data2.length);
}
/** /**
* Copy the contents of the source array to the target array. If the size if * Copy the contents of the source array to the target array. If the size if
......
...@@ -89,9 +89,8 @@ public class ValueBytes extends Value { ...@@ -89,9 +89,8 @@ public class ValueBytes extends Value {
byte[] v2 = ((ValueBytes) v).value; byte[] v2 = ((ValueBytes) v).value;
if (mode.isBinaryUnsigned()) { if (mode.isBinaryUnsigned()) {
return Utils.compareNotNullUnsigned(value, v2); return Utils.compareNotNullUnsigned(value, v2);
} else {
return Utils.compareNotNullSigned(value, v2);
} }
return Utils.compareNotNullSigned(value, v2);
} }
public String getString() { public String getString() {
......
...@@ -901,19 +901,25 @@ public class TestFunctions extends TestBase implements AggregateFunction { ...@@ -901,19 +901,25 @@ public class TestFunctions extends TestBase implements AggregateFunction {
try { try {
rs = stat.executeQuery("SELECT TRUNCATE('bad', 1) FROM dual"); rs = stat.executeQuery("SELECT TRUNCATE('bad', 1) FROM dual");
fail("expected exception"); fail("expected exception");
} catch (SQLException ex) {} } catch (SQLException ex) {
// expected
}
// check for passing wrong data type // check for passing wrong data type
try { try {
rs = stat.executeQuery("SELECT TRUNCATE('bad') FROM dual"); rs = stat.executeQuery("SELECT TRUNCATE('bad') FROM dual");
fail("expected exception"); fail("expected exception");
} catch (SQLException ex) {} } catch (SQLException ex) {
// expected
}
// check for too many parameters // check for too many parameters
try { try {
rs = stat.executeQuery("SELECT TRUNCATE(1,2,3) FROM dual"); rs = stat.executeQuery("SELECT TRUNCATE(1,2,3) FROM dual");
fail("expected exception"); fail("expected exception");
} catch (SQLException ex) {} } catch (SQLException ex) {
// expected
}
conn.close(); conn.close();
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论