Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
68f814b3
提交
68f814b3
authored
10月 18, 2013
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Undo cache the last user defined function return value
上级
c16b5581
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
12 行增加
和
26 行删除
+12
-26
FunctionAlias.java
h2/src/main/org/h2/engine/FunctionAlias.java
+8
-25
TestFunctions.java
h2/src/test/org/h2/test/db/TestFunctions.java
+4
-1
没有找到文件。
h2/src/main/org/h2/engine/FunctionAlias.java
浏览文件 @
68f814b3
...
@@ -279,7 +279,7 @@ public class FunctionAlias extends SchemaObjectBase {
...
@@ -279,7 +279,7 @@ public class FunctionAlias extends SchemaObjectBase {
* Each method must have a different number of parameters however.
* Each method must have a different number of parameters however.
* This helper class represents one such method.
* This helper class represents one such method.
*/
*/
public
class
JavaMethod
implements
Comparable
<
JavaMethod
>
{
public
static
class
JavaMethod
implements
Comparable
<
JavaMethod
>
{
private
final
int
id
;
private
final
int
id
;
private
final
Method
method
;
private
final
Method
method
;
private
final
int
dataType
;
private
final
int
dataType
;
...
@@ -287,11 +287,6 @@ public class FunctionAlias extends SchemaObjectBase {
...
@@ -287,11 +287,6 @@ public class FunctionAlias extends SchemaObjectBase {
private
boolean
varArgs
;
private
boolean
varArgs
;
private
Class
<?>
varArgClass
;
private
Class
<?>
varArgClass
;
private
int
paramCount
;
private
int
paramCount
;
/**
* Cache the value of the last call if the function is deterministic.
*/
private
Object
[]
previousParams
;
private
Value
previousReturnValue
;
JavaMethod
(
Method
method
,
int
id
)
{
JavaMethod
(
Method
method
,
int
id
)
{
this
.
method
=
method
;
this
.
method
=
method
;
...
@@ -403,11 +398,6 @@ public class FunctionAlias extends SchemaObjectBase {
...
@@ -403,11 +398,6 @@ public class FunctionAlias extends SchemaObjectBase {
params
[
p
]
=
o
;
params
[
p
]
=
o
;
}
}
}
}
if
(
deterministic
)
{
if
(
previousParams
!=
null
&&
Arrays
.
deepEquals
(
previousParams
,
params
))
{
return
previousReturnValue
;
}
}
boolean
old
=
session
.
getAutoCommit
();
boolean
old
=
session
.
getAutoCommit
();
Value
identity
=
session
.
getLastScopeIdentity
();
Value
identity
=
session
.
getLastScopeIdentity
();
boolean
defaultConnection
=
session
.
getDatabase
().
getSettings
().
defaultConnection
;
boolean
defaultConnection
=
session
.
getDatabase
().
getSettings
().
defaultConnection
;
...
@@ -419,6 +409,9 @@ public class FunctionAlias extends SchemaObjectBase {
...
@@ -419,6 +409,9 @@ public class FunctionAlias extends SchemaObjectBase {
Driver
.
setDefaultConnection
(
session
.
createConnection
(
columnList
));
Driver
.
setDefaultConnection
(
session
.
createConnection
(
columnList
));
}
}
returnValue
=
method
.
invoke
(
null
,
params
);
returnValue
=
method
.
invoke
(
null
,
params
);
if
(
returnValue
==
null
)
{
return
ValueNull
.
INSTANCE
;
}
}
catch
(
InvocationTargetException
e
)
{
}
catch
(
InvocationTargetException
e
)
{
StatementBuilder
buff
=
new
StatementBuilder
(
method
.
getName
());
StatementBuilder
buff
=
new
StatementBuilder
(
method
.
getName
());
buff
.
append
(
'('
);
buff
.
append
(
'('
);
...
@@ -431,21 +424,11 @@ public class FunctionAlias extends SchemaObjectBase {
...
@@ -431,21 +424,11 @@ public class FunctionAlias extends SchemaObjectBase {
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
throw
DbException
.
convert
(
e
);
throw
DbException
.
convert
(
e
);
}
}
Value
ret
;
if
(
returnValue
==
null
)
{
ret
=
ValueNull
.
INSTANCE
;
}
else
{
if
(
Value
.
class
.
isAssignableFrom
(
method
.
getReturnType
()))
{
if
(
Value
.
class
.
isAssignableFrom
(
method
.
getReturnType
()))
{
ret
=
(
Value
)
returnValue
;
return
(
Value
)
returnValue
;
}
else
{
ret
=
DataType
.
convertToValue
(
session
,
returnValue
,
dataType
);
}
}
if
(
deterministic
)
{
previousParams
=
params
;
previousReturnValue
=
ret
;
}
}
return
ret
;
Value
ret
=
DataType
.
convertToValue
(
session
,
returnValue
,
dataType
);
return
ret
.
convertTo
(
dataType
);
}
finally
{
}
finally
{
session
.
setLastScopeIdentity
(
identity
);
session
.
setLastScopeIdentity
(
identity
);
session
.
setAutoCommit
(
old
);
session
.
setAutoCommit
(
old
);
...
...
h2/src/test/org/h2/test/db/TestFunctions.java
浏览文件 @
68f814b3
...
@@ -80,7 +80,10 @@ public class TestFunctions extends TestBase implements AggregateFunction {
...
@@ -80,7 +80,10 @@ public class TestFunctions extends TestBase implements AggregateFunction {
testNvl2
();
testNvl2
();
testConcatWs
();
testConcatWs
();
testTruncate
();
testTruncate
();
testCachingOfDeterministicFunctionAlias
();
// TODO
// testCachingOfDeterministicFunctionAlias();
deleteDb
(
"functions"
);
deleteDb
(
"functions"
);
FileUtils
.
deleteRecursive
(
TEMP_DIR
,
true
);
FileUtils
.
deleteRecursive
(
TEMP_DIR
,
true
);
}
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论