Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
da3b22de
提交
da3b22de
authored
16 年前
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
New system function TRANSACTION_ID().
上级
aa89ddc7
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
31 行增加
和
1 行删除
+31
-1
Function.java
h2/src/main/org/h2/expression/Function.java
+6
-1
TestFunctions.java
h2/src/test/org/h2/test/db/TestFunctions.java
+25
-0
没有找到文件。
h2/src/main/org/h2/expression/Function.java
浏览文件 @
da3b22de
...
@@ -100,7 +100,7 @@ public class Function extends Expression implements FunctionCall {
...
@@ -100,7 +100,7 @@ public class Function extends Expression implements FunctionCall {
CASE
=
206
,
NEXTVAL
=
207
,
CURRVAL
=
208
,
ARRAY_GET
=
209
,
CSVREAD
=
210
,
CSVWRITE
=
211
,
CASE
=
206
,
NEXTVAL
=
207
,
CURRVAL
=
208
,
ARRAY_GET
=
209
,
CSVREAD
=
210
,
CSVWRITE
=
211
,
MEMORY_FREE
=
212
,
MEMORY_USED
=
213
,
LOCK_MODE
=
214
,
SCHEMA
=
215
,
SESSION_ID
=
216
,
ARRAY_LENGTH
=
217
,
MEMORY_FREE
=
212
,
MEMORY_USED
=
213
,
LOCK_MODE
=
214
,
SCHEMA
=
215
,
SESSION_ID
=
216
,
ARRAY_LENGTH
=
217
,
LINK_SCHEMA
=
218
,
GREATEST
=
219
,
LEAST
=
220
,
CANCEL_SESSION
=
221
,
SET
=
222
,
TABLE
=
223
,
TABLE_DISTINCT
=
224
,
LINK_SCHEMA
=
218
,
GREATEST
=
219
,
LEAST
=
220
,
CANCEL_SESSION
=
221
,
SET
=
222
,
TABLE
=
223
,
TABLE_DISTINCT
=
224
,
FILE_READ
=
225
;
FILE_READ
=
225
,
TRANSACTION_ID
=
226
;
private
static
final
int
VAR_ARGS
=
-
1
;
private
static
final
int
VAR_ARGS
=
-
1
;
...
@@ -318,6 +318,7 @@ public class Function extends Expression implements FunctionCall {
...
@@ -318,6 +318,7 @@ public class Function extends Expression implements FunctionCall {
addFunction
(
"CANCEL_SESSION"
,
CANCEL_SESSION
,
1
,
Value
.
BOOLEAN
);
addFunction
(
"CANCEL_SESSION"
,
CANCEL_SESSION
,
1
,
Value
.
BOOLEAN
);
addFunction
(
"SET"
,
SET
,
2
,
Value
.
NULL
,
false
,
false
);
addFunction
(
"SET"
,
SET
,
2
,
Value
.
NULL
,
false
,
false
);
addFunction
(
"FILE_READ"
,
FILE_READ
,
VAR_ARGS
,
Value
.
NULL
,
false
,
true
);
addFunction
(
"FILE_READ"
,
FILE_READ
,
VAR_ARGS
,
Value
.
NULL
,
false
,
true
);
addFunctionNotConst
(
"TRANSACTION_ID"
,
TRANSACTION_ID
,
0
,
Value
.
STRING
);
// TableFunction
// TableFunction
addFunctionWithNull
(
"TABLE"
,
TABLE
,
VAR_ARGS
,
Value
.
RESULT_SET
);
addFunctionWithNull
(
"TABLE"
,
TABLE
,
VAR_ARGS
,
Value
.
RESULT_SET
);
...
@@ -817,6 +818,10 @@ public class Function extends Expression implements FunctionCall {
...
@@ -817,6 +818,10 @@ public class Function extends Expression implements FunctionCall {
result
=
ValueBoolean
.
get
(
cancelStatement
(
session
,
v0
.
getInt
()));
result
=
ValueBoolean
.
get
(
cancelStatement
(
session
,
v0
.
getInt
()));
break
;
break
;
}
}
case
TRANSACTION_ID:
{
result
=
session
.
getTransactionId
();
break
;
}
default
:
default
:
result
=
null
;
result
=
null
;
}
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/test/org/h2/test/db/TestFunctions.java
浏览文件 @
da3b22de
...
@@ -44,6 +44,7 @@ public class TestFunctions extends TestBase implements AggregateFunction {
...
@@ -44,6 +44,7 @@ public class TestFunctions extends TestBase implements AggregateFunction {
public
void
test
()
throws
Exception
{
public
void
test
()
throws
Exception
{
deleteDb
(
"functions"
);
deleteDb
(
"functions"
);
testTransactionId
();
testPrecision
();
testPrecision
();
testVarArgs
();
testVarArgs
();
testAggregate
();
testAggregate
();
...
@@ -52,6 +53,30 @@ public class TestFunctions extends TestBase implements AggregateFunction {
...
@@ -52,6 +53,30 @@ public class TestFunctions extends TestBase implements AggregateFunction {
deleteDb
(
"functions"
);
deleteDb
(
"functions"
);
}
}
private
void
testTransactionId
()
throws
SQLException
{
if
(
config
.
memory
)
{
return
;
}
Connection
conn
=
getConnection
(
"functions"
);
Statement
stat
=
conn
.
createStatement
();
stat
.
execute
(
"create table test(id int)"
);
ResultSet
rs
;
rs
=
stat
.
executeQuery
(
"call transaction_id()"
);
rs
.
next
();
assertTrue
(
rs
.
getString
(
1
)
==
null
&&
rs
.
wasNull
());
stat
.
execute
(
"insert into test values(1)"
);
rs
=
stat
.
executeQuery
(
"call transaction_id()"
);
rs
.
next
();
assertTrue
(
rs
.
getString
(
1
)
==
null
&&
rs
.
wasNull
());
conn
.
setAutoCommit
(
false
);
stat
.
execute
(
"delete from test"
);
rs
=
stat
.
executeQuery
(
"call transaction_id()"
);
rs
.
next
();
assertTrue
(
rs
.
getString
(
1
)
!=
null
);
stat
.
execute
(
"drop table test"
);
conn
.
close
();
}
private
void
testPrecision
()
throws
SQLException
{
private
void
testPrecision
()
throws
SQLException
{
Connection
conn
=
getConnection
(
"functions"
);
Connection
conn
=
getConnection
(
"functions"
);
Statement
stat
=
conn
.
createStatement
();
Statement
stat
=
conn
.
createStatement
();
...
...
This diff is collapsed.
Click to expand it.
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论