Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
dd5190c9
提交
dd5190c9
authored
4月 05, 2013
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Formatting.
上级
9c9f746a
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
15 行增加
和
35 行删除
+15
-35
Function.java
h2/src/main/org/h2/expression/Function.java
+4
-2
SortOrder.java
h2/src/main/org/h2/result/SortOrder.java
+1
-1
Utils.java
h2/src/main/org/h2/util/Utils.java
+0
-27
ValueBytes.java
h2/src/main/org/h2/value/ValueBytes.java
+1
-2
TestFunctions.java
h2/src/test/org/h2/test/db/TestFunctions.java
+9
-3
没有找到文件。
h2/src/main/org/h2/expression/Function.java
浏览文件 @
dd5190c9
...
...
@@ -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
);
...
...
h2/src/main/org/h2/result/SortOrder.java
浏览文件 @
dd5190c9
...
...
@@ -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
)
{
...
...
h2/src/main/org/h2/util/Utils.java
浏览文件 @
dd5190c9
...
...
@@ -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
...
...
h2/src/main/org/h2/value/ValueBytes.java
浏览文件 @
dd5190c9
...
...
@@ -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
()
{
...
...
h2/src/test/org/h2/test/db/TestFunctions.java
浏览文件 @
dd5190c9
...
...
@@ -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
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论