Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
9e3dfffa
提交
9e3dfffa
authored
12 年前
作者:
noelgrandin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix Issue 406: support "SELECT h2version()"
上级
6c21d32d
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
36 行增加
和
0 行删除
+36
-0
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
+11
-0
TestFunctions.java
h2/src/test/org/h2/test/db/TestFunctions.java
+16
-0
没有找到文件。
h2/src/docsrc/help/help.csv
浏览文件 @
9e3dfffa
...
@@ -3837,6 +3837,14 @@ Returns the name of the current user of this session.
...
@@ -3837,6 +3837,14 @@ Returns the name of the current user of this session.
CURRENT_USER()
CURRENT_USER()
"
"
"Functions (System)","H2VERSION","
H2VERSION()
","
Returns the H2 version as a String.
","
H2VERSION()
"
"System Tables","Information Schema","
"System Tables","Information Schema","
INFORMATION_SCHEMA
INFORMATION_SCHEMA
","
","
...
...
This diff is collapsed.
Click to expand it.
h2/src/docsrc/html/changelog.html
浏览文件 @
9e3dfffa
...
@@ -27,6 +27,7 @@ Change Log
...
@@ -27,6 +27,7 @@ Change Log
</li><li>
Add new collation command SET BINARY_COLLATION UNSIGNED, helps with people testing BINARY columns in MySQL mode.
</li><li>
Add new collation command SET BINARY_COLLATION UNSIGNED, helps with people testing BINARY columns in MySQL mode.
</li><li>
Fix issue #453, ABBA race conditions in TABLE LINK connection sharing.
</li><li>
Fix issue #453, ABBA race conditions in TABLE LINK connection sharing.
</li><li>
Fix Issue 449: Postgres Serial data type should not automatically be marked as primary key
</li><li>
Fix Issue 449: Postgres Serial data type should not automatically be marked as primary key
</li><li>
Fix Issue 406: support "SELECT h2version()"
</li></ul>
</li></ul>
<h2>
Version 1.3.171 (2013-03-17)
</h2>
<h2>
Version 1.3.171 (2013-03-17)
</h2>
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/expression/Function.java
浏览文件 @
9e3dfffa
...
@@ -26,6 +26,7 @@ import java.util.regex.PatternSyntaxException;
...
@@ -26,6 +26,7 @@ import java.util.regex.PatternSyntaxException;
import
org.h2.command.Command
;
import
org.h2.command.Command
;
import
org.h2.command.Parser
;
import
org.h2.command.Parser
;
import
org.h2.constant.ErrorCode
;
import
org.h2.constant.ErrorCode
;
import
org.h2.engine.Constants
;
import
org.h2.engine.Database
;
import
org.h2.engine.Database
;
import
org.h2.engine.Mode
;
import
org.h2.engine.Mode
;
import
org.h2.engine.Session
;
import
org.h2.engine.Session
;
...
@@ -101,6 +102,12 @@ public class Function extends Expression implements FunctionCall {
...
@@ -101,6 +102,12 @@ public class Function extends Expression implements FunctionCall {
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
,
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
;
/**
* This is called H2VERSION() and not VERSION(), because we return a fake value
* for VERSION() when running under the PostgreSQL ODBC driver.
*/
public
static
final
int
H2VERSION
=
231
;
public
static
final
int
ROW_NUMBER
=
300
;
public
static
final
int
ROW_NUMBER
=
300
;
private
static
final
int
VAR_ARGS
=
-
1
;
private
static
final
int
VAR_ARGS
=
-
1
;
...
@@ -346,6 +353,7 @@ public class Function extends Expression implements FunctionCall {
...
@@ -346,6 +353,7 @@ public class Function extends Expression implements FunctionCall {
addFunctionNotDeterministic
(
"TRANSACTION_ID"
,
TRANSACTION_ID
,
0
,
Value
.
STRING
);
addFunctionNotDeterministic
(
"TRANSACTION_ID"
,
TRANSACTION_ID
,
0
,
Value
.
STRING
);
addFunctionWithNull
(
"DECODE"
,
DECODE
,
VAR_ARGS
,
Value
.
NULL
);
addFunctionWithNull
(
"DECODE"
,
DECODE
,
VAR_ARGS
,
Value
.
NULL
);
addFunctionNotDeterministic
(
"DISK_SPACE_USED"
,
DISK_SPACE_USED
,
1
,
Value
.
LONG
);
addFunctionNotDeterministic
(
"DISK_SPACE_USED"
,
DISK_SPACE_USED
,
1
,
Value
.
LONG
);
addFunction
(
"H2VERSION"
,
H2VERSION
,
0
,
Value
.
STRING
);
// TableFunction
// TableFunction
addFunctionWithNull
(
"TABLE"
,
TABLE
,
VAR_ARGS
,
Value
.
RESULT_SET
);
addFunctionWithNull
(
"TABLE"
,
TABLE
,
VAR_ARGS
,
Value
.
RESULT_SET
);
...
@@ -1138,6 +1146,9 @@ public class Function extends Expression implements FunctionCall {
...
@@ -1138,6 +1146,9 @@ public class Function extends Expression implements FunctionCall {
case
LPAD:
case
LPAD:
result
=
ValueString
.
get
(
StringUtils
.
pad
(
v0
.
getString
(),
v1
.
getInt
(),
v2
==
null
?
null
:
v2
.
getString
(),
false
));
result
=
ValueString
.
get
(
StringUtils
.
pad
(
v0
.
getString
(),
v1
.
getInt
(),
v2
==
null
?
null
:
v2
.
getString
(),
false
));
break
;
break
;
case
H2VERSION:
result
=
ValueString
.
get
(
Constants
.
getVersion
());
break
;
case
DATE_ADD:
case
DATE_ADD:
result
=
ValueTimestamp
.
get
(
dateadd
(
v0
.
getString
(),
v1
.
getInt
(),
v2
.
getTimestamp
()));
result
=
ValueTimestamp
.
get
(
dateadd
(
v0
.
getString
(),
v1
.
getInt
(),
v2
.
getTimestamp
()));
break
;
break
;
...
...
This diff is collapsed.
Click to expand it.
h2/src/test/org/h2/test/db/TestFunctions.java
浏览文件 @
9e3dfffa
...
@@ -31,6 +31,7 @@ import java.util.Properties;
...
@@ -31,6 +31,7 @@ import java.util.Properties;
import
java.util.UUID
;
import
java.util.UUID
;
import
org.h2.api.AggregateFunction
;
import
org.h2.api.AggregateFunction
;
import
org.h2.constant.ErrorCode
;
import
org.h2.constant.ErrorCode
;
import
org.h2.engine.Constants
;
import
org.h2.store.fs.FileUtils
;
import
org.h2.store.fs.FileUtils
;
import
org.h2.test.TestBase
;
import
org.h2.test.TestBase
;
import
org.h2.tools.SimpleResultSet
;
import
org.h2.tools.SimpleResultSet
;
...
@@ -56,6 +57,7 @@ public class TestFunctions extends TestBase implements AggregateFunction {
...
@@ -56,6 +57,7 @@ public class TestFunctions extends TestBase implements AggregateFunction {
public
void
test
()
throws
Exception
{
public
void
test
()
throws
Exception
{
deleteDb
(
"functions"
);
deleteDb
(
"functions"
);
testVersion
();
testFunctionTable
();
testFunctionTable
();
testArrayParameters
();
testArrayParameters
();
testDefaultConnection
();
testDefaultConnection
();
...
@@ -82,6 +84,20 @@ public class TestFunctions extends TestBase implements AggregateFunction {
...
@@ -82,6 +84,20 @@ public class TestFunctions extends TestBase implements AggregateFunction {
FileUtils
.
deleteRecursive
(
TEMP_DIR
,
true
);
FileUtils
.
deleteRecursive
(
TEMP_DIR
,
true
);
}
}
private
void
testVersion
()
throws
SQLException
{
Connection
conn
=
getConnection
(
"functions"
);
Statement
stat
=
conn
.
createStatement
();
String
query
=
"select h2version()"
;
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
{
private
void
testFunctionTable
()
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
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论