Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
fe9b5e70
提交
fe9b5e70
authored
14 年前
作者:
noelgrandin@gmail.com
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Support for COSH, SINH, and TANH functions.
上级
70ef2e60
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
61 行增加
和
3 行删除
+61
-3
help.csv
h2/src/docsrc/help/help.csv
+30
-0
changelog.html
h2/src/docsrc/html/changelog.html
+2
-1
roadmap.html
h2/src/docsrc/html/roadmap.html
+0
-1
Function.java
h2/src/main/org/h2/expression/Function.java
+13
-1
TestFunctions.java
h2/src/test/org/h2/test/db/TestFunctions.java
+16
-0
没有找到文件。
h2/src/docsrc/help/help.csv
浏览文件 @
fe9b5e70
...
...
@@ -2406,6 +2406,16 @@ This method returns a double.
COS(ANGLE)
"
"Functions (Numeric)","COSH","
COSH(double)
","
Calculate the hyperbolic cosine.
See also Java ""Math.cosh"".
This method returns a double.
","
COSH(X)
"
"Functions (Numeric)","COT","
COT(double)
","
...
...
@@ -2426,6 +2436,16 @@ This method returns a double.
SIN(ANGLE)
"
"Functions (Numeric)","SINH","
SINH(double)
","
Calculate the hyperbolic sine.
See also Java ""Math.sinh"".
This method returns a double.
","
SINH(ANGLE)
"
"Functions (Numeric)","TAN","
TAN(double)
","
...
...
@@ -2436,6 +2456,16 @@ This method returns a double.
TAN(ANGLE)
"
"Functions (Numeric)","TANH","
TANH(double)
","
Calculate the hyperbolic tangent.
See also Java ""Math.tanh"".
This method returns a double.
","
TANH(X)
"
"Functions (Numeric)","ATAN2","
ATAN2(double, double)
","
...
...
This diff is collapsed.
Click to expand it.
h2/src/docsrc/html/changelog.html
浏览文件 @
fe9b5e70
...
...
@@ -19,7 +19,8 @@ Change Log
<h2>
Next Version (unreleased)
</h2>
<ul>
<li>
Support for the % operator (modulo) thanks to Noel Grandin.
<li>
Support for COSH, SINH, and TANH functions.
</li><li>
Support for the % operator (modulo) thanks to Noel Grandin.
</li><li>
Issue 288: Some right outer join queries failed to produce the correct result or
threw exceptions such as "column x must be in the group by list".
</li><li>
Some right outer joins with invalid column referenced (typos) threw a NullPointerException instead of
...
...
This diff is collapsed.
Click to expand it.
h2/src/docsrc/html/roadmap.html
浏览文件 @
fe9b5e70
...
...
@@ -231,7 +231,6 @@ See also <a href="build.html#providing_patches">Providing Patches</a>.
</li><li>
Integrate spatial functions from http://geosysin.iict.ch/irstv-trac/wiki/H2spatial/Download
</li><li>
Cluster: hot deploy (adding a node at runtime).
</li><li>
Support DatabaseMetaData.insertsAreDetected: updatable result sets should detect inserts.
</li><li>
Support COSH, SINH, and TANH functions
</li><li>
Oracle: support DECODE method (convert to CASE WHEN).
</li><li>
Native search: support "phrase search", wildcard search (* and ?), case-insensitive search, boolean operators, and grouping
</li><li>
Improve documentation of access rights.
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/expression/Function.java
浏览文件 @
fe9b5e70
...
...
@@ -73,7 +73,7 @@ public class Function extends Expression implements FunctionCall {
CEILING
=
8
,
COS
=
9
,
COT
=
10
,
DEGREES
=
11
,
EXP
=
12
,
FLOOR
=
13
,
LOG
=
14
,
LOG10
=
15
,
MOD
=
16
,
PI
=
17
,
POWER
=
18
,
RADIANS
=
19
,
RAND
=
20
,
ROUND
=
21
,
ROUNDMAGIC
=
22
,
SIGN
=
23
,
SIN
=
24
,
SQRT
=
25
,
TAN
=
26
,
TRUNCATE
=
27
,
SECURE_RAND
=
28
,
HASH
=
29
,
ENCRYPT
=
30
,
DECRYPT
=
31
,
COMPRESS
=
32
,
EXPAND
=
33
,
ZERO
=
34
,
RANDOM_UUID
=
35
;
EXPAND
=
33
,
ZERO
=
34
,
RANDOM_UUID
=
35
,
COSH
=
36
,
SINH
=
37
,
TANH
=
38
;
public
static
final
int
ASCII
=
50
,
BIT_LENGTH
=
51
,
CHAR
=
52
,
CHAR_LENGTH
=
53
,
CONCAT
=
54
,
DIFFERENCE
=
55
,
HEXTORAW
=
56
,
INSERT
=
57
,
INSTR
=
58
,
LCASE
=
59
,
LEFT
=
60
,
LENGTH
=
61
,
LOCATE
=
62
,
LTRIM
=
63
,
...
...
@@ -165,6 +165,7 @@ public class Function extends Expression implements FunctionCall {
addFunction
(
"BITXOR"
,
BITXOR
,
2
,
Value
.
LONG
);
addFunction
(
"CEILING"
,
CEILING
,
1
,
Value
.
DOUBLE
);
addFunction
(
"COS"
,
COS
,
1
,
Value
.
DOUBLE
);
addFunction
(
"COSH"
,
COSH
,
1
,
Value
.
DOUBLE
);
addFunction
(
"COT"
,
COT
,
1
,
Value
.
DOUBLE
);
addFunction
(
"DEGREES"
,
DEGREES
,
1
,
Value
.
DOUBLE
);
addFunction
(
"EXP"
,
EXP
,
1
,
Value
.
DOUBLE
);
...
...
@@ -182,8 +183,10 @@ public class Function extends Expression implements FunctionCall {
addFunction
(
"ROUNDMAGIC"
,
ROUNDMAGIC
,
1
,
Value
.
DOUBLE
);
addFunction
(
"SIGN"
,
SIGN
,
1
,
Value
.
INT
);
addFunction
(
"SIN"
,
SIN
,
1
,
Value
.
DOUBLE
);
addFunction
(
"SINH"
,
SINH
,
1
,
Value
.
DOUBLE
);
addFunction
(
"SQRT"
,
SQRT
,
1
,
Value
.
DOUBLE
);
addFunction
(
"TAN"
,
TAN
,
1
,
Value
.
DOUBLE
);
addFunction
(
"TANH"
,
TANH
,
1
,
Value
.
DOUBLE
);
addFunction
(
"TRUNCATE"
,
TRUNCATE
,
2
,
Value
.
DOUBLE
);
addFunction
(
"HASH"
,
HASH
,
3
,
Value
.
BYTES
);
addFunction
(
"ENCRYPT"
,
ENCRYPT
,
3
,
Value
.
BYTES
);
...
...
@@ -447,6 +450,9 @@ public class Function extends Expression implements FunctionCall {
case
COS:
result
=
ValueDouble
.
get
(
Math
.
cos
(
v0
.
getDouble
()));
break
;
case
COSH:
result
=
ValueDouble
.
get
(
Math
.
cosh
(
v0
.
getDouble
()));
break
;
case
COT:
{
double
d
=
Math
.
tan
(
v0
.
getDouble
());
if
(
d
==
0.0
)
{
...
...
@@ -492,12 +498,18 @@ public class Function extends Expression implements FunctionCall {
case
SIN:
result
=
ValueDouble
.
get
(
Math
.
sin
(
v0
.
getDouble
()));
break
;
case
SINH:
result
=
ValueDouble
.
get
(
Math
.
sinh
(
v0
.
getDouble
()));
break
;
case
SQRT:
result
=
ValueDouble
.
get
(
Math
.
sqrt
(
v0
.
getDouble
()));
break
;
case
TAN:
result
=
ValueDouble
.
get
(
Math
.
tan
(
v0
.
getDouble
()));
break
;
case
TANH:
result
=
ValueDouble
.
get
(
Math
.
tanh
(
v0
.
getDouble
()));
break
;
case
SECURE_RAND:
result
=
ValueBytes
.
getNoCopy
(
MathUtils
.
secureRandomBytes
(
v0
.
getInt
()));
break
;
...
...
This diff is collapsed.
Click to expand it.
h2/src/test/org/h2/test/db/TestFunctions.java
浏览文件 @
fe9b5e70
...
...
@@ -60,6 +60,7 @@ public class TestFunctions extends TestBase implements AggregateFunction {
testDeterministic
();
testTransactionId
();
testPrecision
();
testMathFunctions
();
testVarArgs
();
testAggregate
();
testFunctions
();
...
...
@@ -274,6 +275,21 @@ public class TestFunctions extends TestBase implements AggregateFunction {
conn
.
close
();
}
private
void
testMathFunctions
()
throws
SQLException
{
Connection
conn
=
getConnection
(
"functions"
);
Statement
stat
=
conn
.
createStatement
();
ResultSet
rs
=
stat
.
executeQuery
(
"CALL SINH(50)"
);
assertTrue
(
rs
.
next
());
assertEquals
(
Math
.
sinh
(
50
),
rs
.
getDouble
(
1
));
rs
=
stat
.
executeQuery
(
"CALL COSH(50)"
);
assertTrue
(
rs
.
next
());
assertEquals
(
Math
.
cosh
(
50
),
rs
.
getDouble
(
1
));
rs
=
stat
.
executeQuery
(
"CALL TANH(50)"
);
assertTrue
(
rs
.
next
());
assertEquals
(
Math
.
tanh
(
50
),
rs
.
getDouble
(
1
));
conn
.
close
();
}
private
void
testVarArgs
()
throws
SQLException
{
//## Java 1.5 begin ##
Connection
conn
=
getConnection
(
"functions"
);
...
...
This diff is collapsed.
Click to expand it.
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论