Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
61873c88
提交
61873c88
authored
8 年前
作者:
Thomas Mueller Graf
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
The function IFNULL did not always return the result in the right data type.
上级
cca8464f
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
25 行增加
和
0 行删除
+25
-0
changelog.html
h2/src/docsrc/html/changelog.html
+4
-0
Function.java
h2/src/main/org/h2/expression/Function.java
+5
-0
TestFunctions.java
h2/src/test/org/h2/test/db/TestFunctions.java
+16
-0
没有找到文件。
h2/src/docsrc/html/changelog.html
浏览文件 @
61873c88
...
...
@@ -54,6 +54,8 @@ table with an LOB column.
</li>
<li>
improve performance of queries that use LIKE 'foo%' - 10x in the case of one of my queries
</li>
<li>
The function IFNULL did not always return the result in the right data type.
</li>
<li>
Issue #231: Possible infinite loop when initializing the ObjectDataType class
when concurrently writing into MVStore.
</li>
...
...
@@ -61,6 +63,8 @@ table with an LOB column.
<h2>
Version 1.4.191 Beta (2016-01-21)
</h2>
<ul>
<li>
TO_DATE and TO_TIMESTAMP functions. Thanks a lot to Sam Blume for the patch!
</li>
<li>
Issue #229: DATEDIFF does not work for 'WEEK'.
</li>
<li>
Issue #156: Add support for getGeneratedKeys() when executing commands via PreparedStatement#executeBatch.
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/expression/Function.java
浏览文件 @
61873c88
...
...
@@ -965,6 +965,7 @@ public class Function extends Expression implements FunctionCall {
if
(
v0
==
ValueNull
.
INSTANCE
)
{
result
=
getNullOrValue
(
session
,
args
,
values
,
1
);
}
result
=
convertResult
(
result
);
break
;
}
case
CASEWHEN:
{
...
...
@@ -1129,6 +1130,10 @@ public class Function extends Expression implements FunctionCall {
return
result
;
}
private
Value
convertResult
(
Value
v
)
{
return
v
.
convertTo
(
dataType
);
}
private
static
boolean
cancelStatement
(
Session
session
,
int
targetSessionId
)
{
session
.
getUser
().
checkAdmin
();
Session
[]
sessions
=
session
.
getDatabase
().
getSessions
(
false
);
...
...
This diff is collapsed.
Click to expand it.
h2/src/test/org/h2/test/db/TestFunctions.java
浏览文件 @
61873c88
...
...
@@ -76,6 +76,7 @@ public class TestFunctions extends TestBase implements AggregateFunction {
@Override
public
void
test
()
throws
Exception
{
deleteDb
(
"functions"
);
testIfNull
();
testToDate
();
testToDateException
();
testAddMonths
();
...
...
@@ -1658,6 +1659,21 @@ public class TestFunctions extends TestBase implements AggregateFunction {
conn
.
close
();
}
private
void
testIfNull
()
throws
SQLException
{
Connection
conn
=
getConnection
(
"functions"
);
Statement
stat
=
conn
.
createStatement
(
ResultSet
.
TYPE_SCROLL_INSENSITIVE
,
ResultSet
.
CONCUR_READ_ONLY
);
stat
.
execute
(
"CREATE TABLE T(f1 double)"
);
stat
.
executeUpdate
(
"INSERT INTO T VALUES( 1.2 )"
);
stat
.
executeUpdate
(
"INSERT INTO T VALUES( null )"
);
ResultSet
rs
=
stat
.
executeQuery
(
"SELECT IFNULL(f1, 0.0) FROM T"
);
ResultSetMetaData
metaData
=
rs
.
getMetaData
();
assertEquals
(
"java.lang.Double"
,
metaData
.
getColumnClassName
(
1
));
rs
.
next
();
assertEquals
(
"java.lang.Double"
,
rs
.
getObject
(
1
).
getClass
().
getName
());
rs
.
next
();
assertEquals
(
"java.lang.Double"
,
rs
.
getObject
(
1
).
getClass
().
getName
());
conn
.
close
();
}
private
void
testToCharFromNumber
()
throws
SQLException
{
deleteDb
(
"functions"
);
...
...
This diff is collapsed.
Click to expand it.
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论