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

Formatting.

上级 9c9f746a
......@@ -241,7 +241,8 @@ public class Function extends Expression implements FunctionCall {
addFunction("LENGTH", LENGTH, 1, Value.LONG);
// 2 or 3 arguments
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
addFunction("POSITION", LOCATE, 2, Value.INT);
addFunction("INSTR", INSTR, VAR_ARGS, Value.INT);
......@@ -278,7 +279,8 @@ public class Function extends Expression implements FunctionCall {
// date
addFunctionNotDeterministic("CURRENT_DATE", CURRENT_DATE, 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("CURTIME", CURTIME, 0, Value.TIME);
addFunctionNotDeterministic("CURRENT_TIMESTAMP", CURRENT_TIMESTAMP, VAR_ARGS, Value.TIMESTAMP);
......
......@@ -164,7 +164,7 @@ public class SortOrder implements Comparator<Value[]> {
*/
public void sort(ArrayList<Value[]> rows, int offset, int limit) {
int rowsSize = rows.size();
if (rows.isEmpty() || offset >= rowsSize || limit == 0) {
if (rows.isEmpty() || offset >= rowsSize || limit == 0) {
return;
}
if (offset < 0) {
......
......@@ -254,33 +254,6 @@ public class Utils {
}
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
......
......@@ -89,9 +89,8 @@ public class ValueBytes extends Value {
byte[] v2 = ((ValueBytes) v).value;
if (mode.isBinaryUnsigned()) {
return Utils.compareNotNullUnsigned(value, v2);
} else {
return Utils.compareNotNullSigned(value, v2);
}
return Utils.compareNotNullSigned(value, v2);
}
public String getString() {
......
......@@ -901,19 +901,25 @@ public class TestFunctions extends TestBase implements AggregateFunction {
try {
rs = stat.executeQuery("SELECT TRUNCATE('bad', 1) FROM dual");
fail("expected exception");
} catch (SQLException ex) {}
} catch (SQLException ex) {
// expected
}
// check for passing wrong data type
try {
rs = stat.executeQuery("SELECT TRUNCATE('bad') FROM dual");
fail("expected exception");
} catch (SQLException ex) {}
} catch (SQLException ex) {
// expected
}
// check for too many parameters
try {
rs = stat.executeQuery("SELECT TRUNCATE(1,2,3) FROM dual");
fail("expected exception");
} catch (SQLException ex) {}
} catch (SQLException ex) {
// expected
}
conn.close();
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论