Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
61f2493e
提交
61f2493e
authored
12月 12, 2012
作者:
noelgrandin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Support "SELECT version()"
Patch from Andrew Gaul argaul@gmail.com Fixes issue 406.
上级
9d53c2d0
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
32 行增加
和
1 行删除
+32
-1
help.csv
h2/src/docsrc/help/help.csv
+8
-0
changelog.html
h2/src/docsrc/html/changelog.html
+1
-0
Function.java
h2/src/main/org/h2/expression/Function.java
+7
-1
TestFunctions.java
h2/src/test/org/h2/test/db/TestFunctions.java
+16
-0
没有找到文件。
h2/src/docsrc/help/help.csv
浏览文件 @
61f2493e
...
...
@@ -3811,6 +3811,14 @@ Returns the name of the current user of this session.
CURRENT_USER()
"
"Functions (System)","VERSION","
VERSION()
","
Returns the H2 version as a String.
","
VERSION()
"
"System Tables","Information Schema","
INFORMATION_SCHEMA
","
...
...
h2/src/docsrc/html/changelog.html
浏览文件 @
61f2493e
...
...
@@ -25,6 +25,7 @@ Change Log
</li><li>
MVStore: old data is now retained for 45 seconds by default.
</ul><li>
MVStore: compress is now disabled by default, and can be enabled on request.
</ul><li>
Support ALTER TABLE ADD ... AFTER. Patch from Andrew Gaul argaul@gmail.com. Fixes issue 401.
</ul><li>
support "SELECT version()". Patch from Andrew Gaul argaul@gmail.com. Fixes issue 406.
</li></ul>
<h2>
Version 1.3.170 (2012-11-30)
</h2>
...
...
h2/src/main/org/h2/expression/Function.java
浏览文件 @
61f2493e
...
...
@@ -26,6 +26,7 @@ import java.util.regex.PatternSyntaxException;
import
org.h2.command.Command
;
import
org.h2.command.Parser
;
import
org.h2.constant.ErrorCode
;
import
org.h2.engine.Constants
;
import
org.h2.engine.Database
;
import
org.h2.engine.Mode
;
import
org.h2.engine.Session
;
...
...
@@ -97,7 +98,8 @@ public class Function extends Expression implements FunctionCall {
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
,
LINK_SCHEMA
=
218
,
GREATEST
=
219
,
LEAST
=
220
,
CANCEL_SESSION
=
221
,
SET
=
222
,
TABLE
=
223
,
TABLE_DISTINCT
=
224
,
FILE_READ
=
225
,
TRANSACTION_ID
=
226
,
TRUNCATE_VALUE
=
227
,
NVL2
=
228
,
DECODE
=
229
,
ARRAY_CONTAINS
=
230
;
FILE_READ
=
225
,
TRANSACTION_ID
=
226
,
TRUNCATE_VALUE
=
227
,
NVL2
=
228
,
DECODE
=
229
,
ARRAY_CONTAINS
=
230
,
VERSION
=
231
;
public
static
final
int
ROW_NUMBER
=
300
;
...
...
@@ -343,6 +345,7 @@ public class Function extends Expression implements FunctionCall {
addFunction
(
"FILE_READ"
,
FILE_READ
,
VAR_ARGS
,
Value
.
NULL
,
false
,
false
,
false
);
addFunctionNotDeterministic
(
"TRANSACTION_ID"
,
TRANSACTION_ID
,
0
,
Value
.
STRING
);
addFunctionWithNull
(
"DECODE"
,
DECODE
,
VAR_ARGS
,
Value
.
NULL
);
addFunction
(
"VERSION"
,
VERSION
,
0
,
Value
.
STRING
);
// TableFunction
addFunctionWithNull
(
"TABLE"
,
TABLE
,
VAR_ARGS
,
Value
.
RESULT_SET
);
...
...
@@ -1114,6 +1117,9 @@ public class Function extends Expression implements FunctionCall {
case
LPAD:
result
=
ValueString
.
get
(
StringUtils
.
pad
(
v0
.
getString
(),
v1
.
getInt
(),
v2
==
null
?
null
:
v2
.
getString
(),
false
));
break
;
case
VERSION:
result
=
ValueString
.
get
(
Constants
.
getVersion
());
break
;
// date
case
DATE_ADD:
result
=
ValueTimestamp
.
get
(
dateadd
(
v0
.
getString
(),
v1
.
getInt
(),
v2
.
getTimestamp
()));
...
...
h2/src/test/org/h2/test/db/TestFunctions.java
浏览文件 @
61f2493e
...
...
@@ -29,6 +29,7 @@ import java.util.Properties;
import
java.util.UUID
;
import
org.h2.api.AggregateFunction
;
import
org.h2.constant.ErrorCode
;
import
org.h2.engine.Constants
;
import
org.h2.store.fs.FileUtils
;
import
org.h2.test.TestBase
;
import
org.h2.tools.SimpleResultSet
;
...
...
@@ -54,6 +55,7 @@ public class TestFunctions extends TestBase implements AggregateFunction {
public
void
test
()
throws
Exception
{
deleteDb
(
"functions"
);
testVersion
();
testFunctionTable
();
testArrayParameters
();
testDefaultConnection
();
...
...
@@ -79,6 +81,20 @@ public class TestFunctions extends TestBase implements AggregateFunction {
FileUtils
.
deleteRecursive
(
TEMP_DIR
,
true
);
}
private
void
testVersion
()
throws
SQLException
{
Connection
conn
=
getConnection
(
"functions"
);
Statement
stat
=
conn
.
createStatement
();
String
query
=
"select version()"
;
ResultSet
rs
=
stat
.
executeQuery
(
query
);
assertTrue
(
rs
.
next
());
String
version
=
rs
.
getString
(
1
);
assertEquals
(
Constants
.
getVersion
(),
version
);
assertFalse
(
rs
.
next
());
rs
.
close
();
stat
.
close
();
conn
.
close
();
}
private
void
testFunctionTable
()
throws
SQLException
{
Connection
conn
=
getConnection
(
"functions"
);
Statement
stat
=
conn
.
createStatement
();
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论