Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
2bfb0743
提交
2bfb0743
authored
6月 05, 2018
作者:
Evgenij Ryazanov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add LOCALTIME function from the SQL standard
上级
695c4a99
隐藏空白字符变更
内嵌
并排
正在显示
8 个修改的文件
包含
40 行增加
和
15 行删除
+40
-15
help.csv
h2/src/docsrc/help/help.csv
+8
-4
advanced.html
h2/src/docsrc/html/advanced.html
+3
-2
Parser.java
h2/src/main/org/h2/command/Parser.java
+2
-0
Function.java
h2/src/main/org/h2/expression/Function.java
+8
-3
JdbcDatabaseMetaData.java
h2/src/main/org/h2/jdbc/JdbcDatabaseMetaData.java
+4
-3
ParserUtil.java
h2/src/main/org/h2/util/ParserUtil.java
+1
-1
current-time.sql
...rg/h2/test/scripts/functions/timeanddate/current-time.sql
+9
-0
current_timestamp.sql
.../test/scripts/functions/timeanddate/current_timestamp.sql
+5
-2
没有找到文件。
h2/src/docsrc/help/help.csv
浏览文件 @
2bfb0743
...
...
@@ -3944,10 +3944,14 @@ CURRENT_DATE()
"
"Functions (Time and Date)","CURRENT_TIME","
{ CURRENT_TIME [ () ] | CURTIME() }
{ CURRENT_TIME [ (
[ int ] ) ] | LOCALTIME [ ( [ int ]
) ] | CURTIME() }
","
Returns the current time.
This method always returns the same value within a transaction.
If fractional seconds precision is specified it should be from 0 to 9, 0 is default.
The specified value can be used only to limit precision of a result.
The actual maximum available precision depends on operating system and JVM and can be 3 (milliseconds) or higher.
Higher precision is not available before Java 9.
These methods always return the same value within a transaction.
","
CURRENT_TIME()
"
...
...
@@ -3957,7 +3961,7 @@ CURRENT_TIMESTAMP [ ( [ int ] ) ]
","
Returns the current timestamp with time zone.
Time zone offset is set to a current time zone offset
If fractional seconds precision is specified it should be from 0 to 9,
9
is default.
If fractional seconds precision is specified it should be from 0 to 9,
6
is default.
The specified value can be used only to limit precision of a result.
The actual maximum available precision depends on operating system and JVM and can be 3 (milliseconds) or higher.
Higher precision is not available before Java 9.
...
...
@@ -3970,7 +3974,7 @@ CURRENT_TIMESTAMP()
{ LOCALTIMESTAMP [ ( [ int ] ) ] | NOW( [ int ] ) }
","
Returns the current timestamp.
If fractional seconds precision is specified it should be from 0 to 9,
9
is default.
If fractional seconds precision is specified it should be from 0 to 9,
6
is default.
The specified value can be used only to limit precision of a result.
The actual maximum available precision depends on operating system and JVM and can be 3 (milliseconds) or higher.
Higher precision is not available before Java 9.
...
...
h2/src/docsrc/html/advanced.html
浏览文件 @
2bfb0743
...
...
@@ -504,8 +504,9 @@ unless they are quoted (surrounded with double quotes). The list is currently:
<code>
ALL, CHECK, CONSTRAINT, CROSS, CURRENT_DATE, CURRENT_TIME, CURRENT_TIMESTAMP, DISTINCT, EXCEPT,
EXISTS, FALSE, FETCH, FOR, FOREIGN, FROM, FULL, GROUP, HAVING, INNER, INTERSECT, INTERSECTS,
IS, JOIN, LIKE, LIMIT, LOCALTIMESTAMP, MINUS, NATURAL, NOT, NULL, OFFSET, ON, ORDER, PRIMARY,
ROWNUM, SELECT, SYSDATE, SYSTIME, SYSTIMESTAMP, TODAY, TOP, TRUE, UNION, UNIQUE, WHERE, WITH
IS, JOIN, LIKE, LIMIT, LOCALTIME, LOCALTIMESTAMP, MINUS, NATURAL, NOT, NULL, OFFSET, ON, ORDER,
PRIMARY, ROWNUM, SELECT, SYSDATE, SYSTIME, SYSTIMESTAMP, TODAY, TOP, TRUE, UNION, UNIQUE, WHERE,
WITH
</code>
</p><p>
Certain words of this list are keywords because they are functions that can be used without '()' for compatibility,
...
...
h2/src/main/org/h2/command/Parser.java
浏览文件 @
2bfb0743
...
...
@@ -3160,6 +3160,8 @@ public class Parser {
r
=
readFunctionWithoutParameters
(
"CURRENT_DATE"
);
}
else
if
(
equalsToken
(
"CURRENT_TIME"
,
name
))
{
r
=
readFunctionWithoutParameters
(
"CURRENT_TIME"
);
}
else
if
(
equalsToken
(
"LOCALTIME"
,
name
))
{
r
=
readFunctionWithoutParameters
(
"LOCALTIME"
);
}
else
if
(
equalsToken
(
"SYSTIME"
,
name
))
{
r
=
readFunctionWithoutParameters
(
"CURRENT_TIME"
);
}
else
if
(
equalsToken
(
"CURRENT"
,
name
))
{
...
...
h2/src/main/org/h2/expression/Function.java
浏览文件 @
2bfb0743
...
...
@@ -63,6 +63,7 @@ import org.h2.value.ValueLong;
import
org.h2.value.ValueNull
;
import
org.h2.value.ValueResultSet
;
import
org.h2.value.ValueString
;
import
org.h2.value.ValueTime
;
import
org.h2.value.ValueTimestamp
;
import
org.h2.value.ValueTimestampTimeZone
;
import
org.h2.value.ValueUuid
;
...
...
@@ -293,7 +294,9 @@ public class Function extends Expression implements FunctionCall {
addFunctionNotDeterministic
(
"GETDATE"
,
CURDATE
,
0
,
Value
.
DATE
);
addFunctionNotDeterministic
(
"CURRENT_TIME"
,
CURRENT_TIME
,
0
,
Value
.
TIME
);
VAR_ARGS
,
Value
.
TIME
);
addFunctionNotDeterministic
(
"LOCALTIME"
,
CURRENT_TIME
,
VAR_ARGS
,
Value
.
TIME
);
addFunctionNotDeterministic
(
"SYSTIME"
,
CURRENT_TIME
,
0
,
Value
.
TIME
);
addFunctionNotDeterministic
(
"CURTIME"
,
CURTIME
,
...
...
@@ -829,7 +832,8 @@ public class Function extends Expression implements FunctionCall {
}
case
CURTIME:
case
CURRENT_TIME:
{
result
=
session
.
getTransactionStart
().
convertTo
(
Value
.
TIME
);
ValueTime
vt
=
(
ValueTime
)
session
.
getTransactionStart
().
convertTo
(
Value
.
TIME
);
result
=
vt
.
convertScale
(
false
,
v0
==
null
?
0
:
v0
.
getInt
());
break
;
}
case
LOCALTIMESTAMP:
{
...
...
@@ -839,7 +843,7 @@ public class Function extends Expression implements FunctionCall {
}
case
CURRENT_TIMESTAMP:
{
ValueTimestampTimeZone
vt
=
session
.
getTransactionStart
();
result
=
v
0
==
null
?
vt
:
vt
.
convertScale
(
false
,
v0
.
getInt
());
result
=
v
t
.
convertScale
(
false
,
v0
==
null
?
6
:
v0
.
getInt
());
break
;
}
case
DATABASE:
...
...
@@ -2063,6 +2067,7 @@ public class Function extends Expression implements FunctionCall {
min
=
1
;
break
;
case
LOCALTIMESTAMP:
case
CURRENT_TIME:
case
CURRENT_TIMESTAMP:
case
RAND:
max
=
1
;
...
...
h2/src/main/org/h2/jdbc/JdbcDatabaseMetaData.java
浏览文件 @
2bfb0743
...
...
@@ -1545,9 +1545,10 @@ public class JdbcDatabaseMetaData extends TraceObject implements
* <pre>
* ALL, CHECK, CONSTRAINT, CROSS, CURRENT_DATE, CURRENT_TIME, CURRENT_TIMESTAMP,
* DISTINCT, EXCEPT, EXISTS, FALSE, FETCH, FOR, FOREIGN, FROM, FULL, GROUP,
* HAVING, INNER, INTERSECT, INTERSECTS, IS, JOIN, LIKE, LIMIT, LOCALTIMESTAMP,
* MINUS, NATURAL, NOT, NULL, OFFSET, ON, ORDER, PRIMARY, ROWNUM, SELECT, SYSDATE,
* SYSTIME, SYSTIMESTAMP, TODAY, TOP, TRUE, UNION, UNIQUE, WHERE, WITH
* HAVING, INNER, INTERSECT, INTERSECTS, IS, JOIN, LIKE, LIMIT, LOCALTIME,
* LOCALTIMESTAMP, MINUS, NATURAL, NOT, NULL, OFFSET, ON, ORDER, PRIMARY, ROWNUM,
* SELECT, SYSDATE, SYSTIME, SYSTIMESTAMP, TODAY, TOP, TRUE, UNION, UNIQUE, WHERE,
* WITH
* </pre>
*
* @return a list of additional the keywords
...
...
h2/src/main/org/h2/util/ParserUtil.java
浏览文件 @
2bfb0743
...
...
@@ -151,7 +151,7 @@ public class ParserUtil {
return
KEYWORD
;
}
if
(
additionalKeywords
)
{
if
(
"LOCALTIMESTAMP"
.
equals
(
s
))
{
if
(
"LOCALTIME
"
.
equals
(
s
)
||
"LOCALTIME
STAMP"
.
equals
(
s
))
{
return
KEYWORD
;
}
}
...
...
h2/src/test/org/h2/test/scripts/functions/timeanddate/current-time.sql
浏览文件 @
2bfb0743
...
...
@@ -21,3 +21,12 @@ select length(now())>18 c1, length(current_timestamp())>18 c2, length(now(0))>18
>
---- ---- ---- ----
>
TRUE
TRUE
TRUE
TRUE
>
rows
:
1
SELECT
CAST
(
CURRENT_TIME
AS
TIME
(
9
))
=
LOCALTIME
;
>>
TRUE
SELECT
CAST
(
CURRENT_TIME
(
0
)
AS
TIME
(
9
))
=
LOCALTIME
(
0
);
>>
TRUE
SELECT
CAST
(
CURRENT_TIME
(
9
)
AS
TIME
(
9
))
=
LOCALTIME
(
9
);
>>
TRUE
h2/src/test/org/h2/test/scripts/functions/timeanddate/current_timestamp.sql
浏览文件 @
2bfb0743
...
...
@@ -3,8 +3,11 @@
-- Initial Developer: H2 Group
--
SELECT
CAST
(
CURRENT_TIMESTAMP
AS
TIMESTAMP
)
=
LOCALTIMESTAMP
;
SELECT
CAST
(
CURRENT_TIMESTAMP
AS
TIMESTAMP
(
9
)
)
=
LOCALTIMESTAMP
;
>>
TRUE
SELECT
CAST
(
CURRENT_TIMESTAMP
(
0
)
AS
TIMESTAMP
)
=
LOCALTIMESTAMP
(
0
);
SELECT
CAST
(
CURRENT_TIMESTAMP
(
0
)
AS
TIMESTAMP
(
9
))
=
LOCALTIMESTAMP
(
0
);
>>
TRUE
SELECT
CAST
(
CURRENT_TIMESTAMP
(
9
)
AS
TIMESTAMP
(
9
))
=
LOCALTIMESTAMP
(
9
);
>>
TRUE
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论