Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
7914d55a
提交
7914d55a
authored
12月 04, 2013
作者:
noelgrandin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Issue 534: CREATE ALIAS NOCACHE, Patch by Nicolas Fortin
上级
397d3126
显示空白字符变更
内嵌
并排
正在显示
12 个修改的文件
包含
61 行增加
和
34 行删除
+61
-34
help.csv
h2/src/docsrc/help/help.csv
+7
-3
changelog.html
h2/src/docsrc/html/changelog.html
+1
-0
Parser.java
h2/src/main/org/h2/command/Parser.java
+1
-0
CreateFunctionAlias.java
h2/src/main/org/h2/command/ddl/CreateFunctionAlias.java
+10
-2
FunctionAlias.java
h2/src/main/org/h2/engine/FunctionAlias.java
+14
-2
Function.java
h2/src/main/org/h2/expression/Function.java
+13
-13
FunctionCall.java
h2/src/main/org/h2/expression/FunctionCall.java
+3
-3
FunctionInfo.java
h2/src/main/org/h2/expression/FunctionInfo.java
+2
-2
JavaFunction.java
h2/src/main/org/h2/expression/JavaFunction.java
+2
-2
FunctionIndex.java
h2/src/main/org/h2/index/FunctionIndex.java
+4
-3
help.csv
h2/src/main/org/h2/res/help.csv
+1
-1
FunctionTable.java
h2/src/main/org/h2/table/FunctionTable.java
+3
-3
没有找到文件。
h2/src/docsrc/help/help.csv
浏览文件 @
7914d55a
...
...
@@ -420,11 +420,15 @@ CREATE AGGREGATE MEDIAN FOR ""com.acme.db.Median""
"
"Commands (DDL)","CREATE ALIAS","
CREATE ALIAS [ IF NOT EXISTS ] newFunctionAliasName [ DETERMINISTIC ]
CREATE ALIAS [ IF NOT EXISTS ] newFunctionAliasName [ DETERMINISTIC ]
[ NOBUFFER ]
{ FOR classAndMethodName | AS sourceCodeString }
","
Creates a new function alias. Deterministic functions must always return the
same value for the same parameters. The result of such functions is cached if possible.
Creates a new function alias. If this is a ResultSet returning function,
by default the return value is cached in a local temporary file.
NOBUFFER - disables caching of ResultSet return value to temporary file.
DETERMINISTIC - Deterministic functions must always return the same value for the same parameters.
The method name must be the full qualified class and method name,
and may optionally include the parameter classes as in
...
...
h2/src/docsrc/html/changelog.html
浏览文件 @
7914d55a
...
...
@@ -45,6 +45,7 @@ Change Log
</li><li>
Extend support of "GRANT ALTER ANY SCHEMA TO
<
user
>
" to allow grantee ability to manipulate tables
</li><li>
Issue 532: Javadoc for ErrorCode.ROLES_AND_RIGHT_CANNOT_BE_MIXED looks wrong
</li><li>
Issue 528: Add Oracle-compatible TO_CHAR function, patch by Daniel Gredler.
</li><li>
Issue 534: CREATE ALIAS NOCACHE, Patch by Nicolas Fortin
</li></ul>
<h2>
Version 1.3.174 (2013-10-19)
</h2>
...
...
h2/src/main/org/h2/command/Parser.java
浏览文件 @
7914d55a
...
...
@@ -4433,6 +4433,7 @@ public class Parser {
command
.
setAliasName
(
aliasName
);
command
.
setIfNotExists
(
ifNotExists
);
command
.
setDeterministic
(
readIf
(
"DETERMINISTIC"
));
command
.
setBufferResultSetToLocalTemp
(!
readIf
(
"NOBUFFER"
));
if
(
readIf
(
"AS"
))
{
command
.
setSource
(
readString
());
}
else
{
...
...
h2/src/main/org/h2/command/ddl/CreateFunctionAlias.java
浏览文件 @
7914d55a
...
...
@@ -27,6 +27,7 @@ public class CreateFunctionAlias extends SchemaCommand {
private
boolean
ifNotExists
;
private
boolean
force
;
private
String
source
;
private
boolean
bufferResultSetToLocalTemp
=
true
;
public
CreateFunctionAlias
(
Session
session
,
Schema
schema
)
{
super
(
session
,
schema
);
...
...
@@ -45,9 +46,9 @@ public class CreateFunctionAlias extends SchemaCommand {
int
id
=
getObjectId
();
FunctionAlias
functionAlias
;
if
(
javaClassMethod
!=
null
)
{
functionAlias
=
FunctionAlias
.
newInstance
(
getSchema
(),
id
,
aliasName
,
javaClassMethod
,
force
);
functionAlias
=
FunctionAlias
.
newInstance
(
getSchema
(),
id
,
aliasName
,
javaClassMethod
,
force
,
bufferResultSetToLocalTemp
);
}
else
{
functionAlias
=
FunctionAlias
.
newInstanceFromSource
(
getSchema
(),
id
,
aliasName
,
source
,
force
);
functionAlias
=
FunctionAlias
.
newInstanceFromSource
(
getSchema
(),
id
,
aliasName
,
source
,
force
,
bufferResultSetToLocalTemp
);
}
functionAlias
.
setDeterministic
(
deterministic
);
db
.
addSchemaObject
(
session
,
functionAlias
);
...
...
@@ -80,6 +81,13 @@ public class CreateFunctionAlias extends SchemaCommand {
this
.
deterministic
=
deterministic
;
}
/**
* Should the return value ResultSet be buffered in a local temporary file?
*/
public
void
setBufferResultSetToLocalTemp
(
boolean
b
)
{
this
.
bufferResultSetToLocalTemp
=
b
;
}
public
void
setSource
(
String
source
)
{
this
.
source
=
source
;
}
...
...
h2/src/main/org/h2/engine/FunctionAlias.java
浏览文件 @
7914d55a
...
...
@@ -46,6 +46,7 @@ public class FunctionAlias extends SchemaObjectBase {
private
String
source
;
private
JavaMethod
[]
javaMethods
;
private
boolean
deterministic
;
private
boolean
bufferResultSetToLocalTemp
=
true
;
private
FunctionAlias
(
Schema
schema
,
int
id
,
String
name
)
{
initSchemaObjectBase
(
schema
,
id
,
name
,
Trace
.
FUNCTION
);
...
...
@@ -61,7 +62,7 @@ public class FunctionAlias extends SchemaObjectBase {
* @param force create the object even if the class or method does not exist
* @return the database object
*/
public
static
FunctionAlias
newInstance
(
Schema
schema
,
int
id
,
String
name
,
String
javaClassMethod
,
boolean
force
)
{
public
static
FunctionAlias
newInstance
(
Schema
schema
,
int
id
,
String
name
,
String
javaClassMethod
,
boolean
force
,
boolean
bufferResultSetToLocalTemp
)
{
FunctionAlias
alias
=
new
FunctionAlias
(
schema
,
id
,
name
);
int
paren
=
javaClassMethod
.
indexOf
(
'('
);
int
lastDot
=
javaClassMethod
.
lastIndexOf
(
'.'
,
paren
<
0
?
javaClassMethod
.
length
()
:
paren
);
...
...
@@ -70,6 +71,7 @@ public class FunctionAlias extends SchemaObjectBase {
}
alias
.
className
=
javaClassMethod
.
substring
(
0
,
lastDot
);
alias
.
methodName
=
javaClassMethod
.
substring
(
lastDot
+
1
);
alias
.
bufferResultSetToLocalTemp
=
bufferResultSetToLocalTemp
;
alias
.
init
(
force
);
return
alias
;
}
...
...
@@ -84,9 +86,10 @@ public class FunctionAlias extends SchemaObjectBase {
* @param force create the object even if the class or method does not exist
* @return the database object
*/
public
static
FunctionAlias
newInstanceFromSource
(
Schema
schema
,
int
id
,
String
name
,
String
source
,
boolean
force
)
{
public
static
FunctionAlias
newInstanceFromSource
(
Schema
schema
,
int
id
,
String
name
,
String
source
,
boolean
force
,
boolean
bufferResultSetToLocalTemp
)
{
FunctionAlias
alias
=
new
FunctionAlias
(
schema
,
id
,
name
);
alias
.
source
=
source
;
alias
.
bufferResultSetToLocalTemp
=
bufferResultSetToLocalTemp
;
alias
.
init
(
force
);
return
alias
;
}
...
...
@@ -209,6 +212,9 @@ public class FunctionAlias extends SchemaObjectBase {
if
(
deterministic
)
{
buff
.
append
(
" DETERMINISTIC"
);
}
if
(!
bufferResultSetToLocalTemp
)
{
buff
.
append
(
" NOBUFFER"
);
}
if
(
source
!=
null
)
{
buff
.
append
(
" AS "
).
append
(
StringUtils
.
quoteStringSQL
(
source
));
}
else
{
...
...
@@ -505,4 +511,10 @@ public class FunctionAlias extends SchemaObjectBase {
}
}
/**
* Should the return value ResultSet be buffered in a local temporary file?
*/
public
boolean
isBufferResultSetToLocalTemp
()
{
return
bufferResultSetToLocalTemp
;
}
}
h2/src/main/org/h2/expression/Function.java
浏览文件 @
7914d55a
...
...
@@ -346,9 +346,9 @@ public class Function extends Expression implements FunctionCall {
addFunctionNotDeterministic
(
"NEXTVAL"
,
NEXTVAL
,
VAR_ARGS
,
Value
.
LONG
);
addFunctionNotDeterministic
(
"CURRVAL"
,
CURRVAL
,
VAR_ARGS
,
Value
.
LONG
);
addFunction
(
"ARRAY_GET"
,
ARRAY_GET
,
2
,
Value
.
STRING
);
addFunction
(
"ARRAY_CONTAINS"
,
ARRAY_CONTAINS
,
2
,
Value
.
BOOLEAN
,
false
,
true
,
fals
e
);
addFunction
(
"CSVREAD"
,
CSVREAD
,
VAR_ARGS
,
Value
.
RESULT_SET
,
false
,
false
,
tru
e
);
addFunction
(
"CSVWRITE"
,
CSVWRITE
,
VAR_ARGS
,
Value
.
INT
,
false
,
false
,
fals
e
);
addFunction
(
"ARRAY_CONTAINS"
,
ARRAY_CONTAINS
,
2
,
Value
.
BOOLEAN
,
false
,
true
,
tru
e
);
addFunction
(
"CSVREAD"
,
CSVREAD
,
VAR_ARGS
,
Value
.
RESULT_SET
,
false
,
false
,
fals
e
);
addFunction
(
"CSVWRITE"
,
CSVWRITE
,
VAR_ARGS
,
Value
.
INT
,
false
,
false
,
tru
e
);
addFunctionNotDeterministic
(
"MEMORY_FREE"
,
MEMORY_FREE
,
0
,
Value
.
INT
);
addFunctionNotDeterministic
(
"MEMORY_USED"
,
MEMORY_USED
,
0
,
Value
.
INT
);
addFunctionNotDeterministic
(
"LOCK_MODE"
,
LOCK_MODE
,
0
,
Value
.
INT
);
...
...
@@ -359,8 +359,8 @@ public class Function extends Expression implements FunctionCall {
addFunctionWithNull
(
"LEAST"
,
LEAST
,
VAR_ARGS
,
Value
.
NULL
);
addFunctionWithNull
(
"GREATEST"
,
GREATEST
,
VAR_ARGS
,
Value
.
NULL
);
addFunctionNotDeterministic
(
"CANCEL_SESSION"
,
CANCEL_SESSION
,
1
,
Value
.
BOOLEAN
);
addFunction
(
"SET"
,
SET
,
2
,
Value
.
NULL
,
false
,
false
,
fals
e
);
addFunction
(
"FILE_READ"
,
FILE_READ
,
VAR_ARGS
,
Value
.
NULL
,
false
,
false
,
fals
e
);
addFunction
(
"SET"
,
SET
,
2
,
Value
.
NULL
,
false
,
false
,
tru
e
);
addFunction
(
"FILE_READ"
,
FILE_READ
,
VAR_ARGS
,
Value
.
NULL
,
false
,
false
,
tru
e
);
addFunctionNotDeterministic
(
"TRANSACTION_ID"
,
TRANSACTION_ID
,
0
,
Value
.
STRING
);
addFunctionWithNull
(
"DECODE"
,
DECODE
,
VAR_ARGS
,
Value
.
NULL
);
addFunctionNotDeterministic
(
"DISK_SPACE_USED"
,
DISK_SPACE_USED
,
1
,
Value
.
LONG
);
...
...
@@ -374,7 +374,7 @@ public class Function extends Expression implements FunctionCall {
addFunctionWithNull
(
"ROW_NUMBER"
,
ROW_NUMBER
,
0
,
Value
.
LONG
);
// ON DUPLICATE KEY VALUES function
addFunction
(
"VALUES"
,
VALUES
,
1
,
Value
.
NULL
,
false
,
true
,
tru
e
);
addFunction
(
"VALUES"
,
VALUES
,
1
,
Value
.
NULL
,
false
,
true
,
fals
e
);
}
protected
Function
(
Database
database
,
FunctionInfo
info
)
{
...
...
@@ -388,7 +388,7 @@ public class Function extends Expression implements FunctionCall {
}
private
static
void
addFunction
(
String
name
,
int
type
,
int
parameterCount
,
int
dataType
,
boolean
nullIfParameterIsNull
,
boolean
deterministic
,
boolean
fast
)
{
boolean
nullIfParameterIsNull
,
boolean
deterministic
,
boolean
bufferResultSetToLocalTemp
)
{
FunctionInfo
info
=
new
FunctionInfo
();
info
.
name
=
name
;
info
.
type
=
type
;
...
...
@@ -396,20 +396,20 @@ public class Function extends Expression implements FunctionCall {
info
.
dataType
=
dataType
;
info
.
nullIfParameterIsNull
=
nullIfParameterIsNull
;
info
.
deterministic
=
deterministic
;
info
.
fast
=
fast
;
info
.
bufferResultSetToLocalTemp
=
bufferResultSetToLocalTemp
;
FUNCTIONS
.
put
(
name
,
info
);
}
private
static
void
addFunctionNotDeterministic
(
String
name
,
int
type
,
int
parameterCount
,
int
dataType
)
{
addFunction
(
name
,
type
,
parameterCount
,
dataType
,
true
,
false
,
fals
e
);
addFunction
(
name
,
type
,
parameterCount
,
dataType
,
true
,
false
,
tru
e
);
}
private
static
void
addFunction
(
String
name
,
int
type
,
int
parameterCount
,
int
dataType
)
{
addFunction
(
name
,
type
,
parameterCount
,
dataType
,
true
,
true
,
fals
e
);
addFunction
(
name
,
type
,
parameterCount
,
dataType
,
true
,
true
,
tru
e
);
}
private
static
void
addFunctionWithNull
(
String
name
,
int
type
,
int
parameterCount
,
int
dataType
)
{
addFunction
(
name
,
type
,
parameterCount
,
dataType
,
false
,
true
,
fals
e
);
addFunction
(
name
,
type
,
parameterCount
,
dataType
,
false
,
true
,
tru
e
);
}
/**
...
...
@@ -2354,8 +2354,8 @@ public class Function extends Expression implements FunctionCall {
}
@Override
public
boolean
is
Fast
()
{
return
info
.
fast
;
public
boolean
is
BufferResultSetToLocalTemp
()
{
return
info
.
bufferResultSetToLocalTemp
;
}
}
h2/src/main/org/h2/expression/FunctionCall.java
浏览文件 @
7914d55a
...
...
@@ -75,10 +75,10 @@ public interface FunctionCall {
boolean
isDeterministic
();
/**
*
Whether the function is fast, meaning the result shouldn't be cached.
*
Should the return value ResultSet be buffered in a local temporary file?
*
* @return true if it
is
* @return true if it
should be.
*/
boolean
is
Fast
();
boolean
is
BufferResultSetToLocalTemp
();
}
h2/src/main/org/h2/expression/FunctionInfo.java
浏览文件 @
7914d55a
...
...
@@ -42,8 +42,8 @@ class FunctionInfo {
boolean
deterministic
;
/**
*
Whether the function is fast, meaning the result shouldn't be cached.
*
Should the return value ResultSet be buffered in a local temporary file?
*/
boolean
fast
;
boolean
bufferResultSetToLocalTemp
=
true
;
}
h2/src/main/org/h2/expression/JavaFunction.java
浏览文件 @
7914d55a
...
...
@@ -184,8 +184,8 @@ public class JavaFunction extends Expression implements FunctionCall {
}
@Override
public
boolean
is
Fast
()
{
return
f
alse
;
public
boolean
is
BufferResultSetToLocalTemp
()
{
return
f
unctionAlias
.
isBufferResultSetToLocalTemp
()
;
}
}
h2/src/main/org/h2/index/FunctionIndex.java
浏览文件 @
7914d55a
...
...
@@ -45,10 +45,11 @@ public class FunctionIndex extends BaseIndex {
@Override
public
Cursor
find
(
Session
session
,
SearchRow
first
,
SearchRow
last
)
{
if
(
functionTable
.
isFast
())
{
if
(
functionTable
.
isBufferResultSetToLocalTemp
())
{
return
new
FunctionCursor
(
functionTable
.
getResult
(
session
));
}
else
{
return
new
FunctionCursorResultSet
(
session
,
functionTable
.
getResultSet
(
session
));
}
return
new
FunctionCursor
(
functionTable
.
getResult
(
session
));
}
@Override
...
...
h2/src/main/org/h2/res/help.csv
浏览文件 @
7914d55a
...
...
@@ -155,7 +155,7 @@ CREATE AGGREGATE [ IF NOT EXISTS ] newAggregateName FOR className
","
Creates a new user-defined aggregate function."
"Commands (DDL)","CREATE ALIAS","
CREATE ALIAS [ IF NOT EXISTS ] newFunctionAliasName [ DETERMINISTIC ]
CREATE ALIAS [ IF NOT EXISTS ] newFunctionAliasName [ DETERMINISTIC ]
[ NOBUFFER ]
{ FOR classAndMethodName | AS sourceCodeString }
","
Creates a new function alias."
...
...
h2/src/main/org/h2/table/FunctionTable.java
浏览文件 @
7914d55a
...
...
@@ -171,7 +171,7 @@ public class FunctionTable extends Table {
}
/**
* Read the result from the function. This method
caches the result
.
* Read the result from the function. This method
buffers the result in a temporary file
.
*
* @param session the session
* @return the result
...
...
@@ -213,8 +213,8 @@ public class FunctionTable extends Table {
return
(
ValueResultSet
)
v
;
}
public
boolean
is
Fast
()
{
return
function
.
is
Fast
();
public
boolean
is
BufferResultSetToLocalTemp
()
{
return
function
.
is
BufferResultSetToLocalTemp
();
}
@Override
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论