Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
873aac59
提交
873aac59
authored
2月 22, 2018
作者:
Evgenij Ryazanov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Parse TIMESTAMP WITHOUT TIME ZONE as TIMESTAMP
上级
b9927766
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
55 行增加
和
15 行删除
+55
-15
help.csv
h2/src/docsrc/help/help.csv
+2
-2
Parser.java
h2/src/main/org/h2/command/Parser.java
+28
-12
DataType.java
h2/src/main/org/h2/value/DataType.java
+2
-1
timestamp.sql
h2/src/test/org/h2/test/scripts/datatypes/timestamp.sql
+23
-0
没有找到文件。
h2/src/docsrc/help/help.csv
浏览文件 @
873aac59
...
...
@@ -2309,7 +2309,7 @@ TIME '23:59:59'
"
"Other Grammar","Timestamp","
TIMESTAMP 'yyyy-MM-dd hh:mm:ss[.nnnnnnnnn]'
TIMESTAMP
[ WITHOUT TIME ZONE ]
'yyyy-MM-dd hh:mm:ss[.nnnnnnnnn]'
","
A timestamp literal. The limitations are the same as for the Java data type
""java.sql.Timestamp"", but for compatibility with other databases the suggested
...
...
@@ -2459,7 +2459,7 @@ DATE
"
"Data Types","TIMESTAMP Type","
{ TIMESTAMP | DATETIME | SMALLDATETIME }
{ TIMESTAMP
[ WITHOUT TIME ZONE ]
| DATETIME | SMALLDATETIME }
","
The timestamp data type. The format is yyyy-MM-dd hh:mm:ss[.nnnnnnnnn].
Stored internally as a BCD-encoded date, and nanoseconds since midnight.
...
...
h2/src/main/org/h2/command/Parser.java
浏览文件 @
873aac59
...
...
@@ -3137,17 +3137,30 @@ public class Parser {
read
(
"FOR"
);
Sequence
sequence
=
readSequence
();
r
=
new
SequenceValue
(
sequence
);
}
else
if
(
equalsToken
(
"TIMESTAMP"
,
name
)
&&
readIf
(
"WITH"
))
{
read
(
"TIME"
);
read
(
"ZONE"
);
if
(
currentTokenType
!=
VALUE
||
currentValue
.
getType
()
!=
Value
.
STRING
)
{
throw
getSyntaxError
();
}
else
if
(
equalsToken
(
"TIMESTAMP"
,
name
))
{
if
(
readIf
(
"WITH"
))
{
read
(
"TIME"
);
read
(
"ZONE"
);
if
(
currentTokenType
!=
VALUE
||
currentValue
.
getType
()
!=
Value
.
STRING
)
{
throw
getSyntaxError
();
}
String
timestamp
=
currentValue
.
getString
();
read
();
r
=
ValueExpression
.
get
(
ValueTimestampTimeZone
.
parse
(
timestamp
));
}
else
{
if
(
readIf
(
"WITHOUT"
))
{
read
(
"TIME"
);
read
(
"ZONE"
);
}
if
(
currentTokenType
!=
VALUE
||
currentValue
.
getType
()
!=
Value
.
STRING
)
{
throw
getSyntaxError
();
}
String
timestamp
=
currentValue
.
getString
();
read
();
r
=
ValueExpression
.
get
(
ValueTimestamp
.
parse
(
timestamp
,
database
.
getMode
()));
}
String
timestamp
=
currentValue
.
getString
();
read
();
r
=
ValueExpression
.
get
(
ValueTimestampTimeZone
.
parse
(
timestamp
));
}
else
if
(
currentTokenType
==
VALUE
&&
currentValue
.
getType
()
==
Value
.
STRING
)
{
if
(
equalsToken
(
"DATE"
,
name
)
||
...
...
@@ -3160,8 +3173,7 @@ public class Parser {
String
time
=
currentValue
.
getString
();
read
();
r
=
ValueExpression
.
get
(
ValueTime
.
parse
(
time
));
}
else
if
(
equalsToken
(
"TIMESTAMP"
,
name
)
||
equalsToken
(
"TS"
,
name
))
{
}
else
if
(
equalsToken
(
"TS"
,
name
))
{
String
timestamp
=
currentValue
.
getString
();
read
();
r
=
ValueExpression
...
...
@@ -4340,6 +4352,10 @@ public class Parser {
read
(
"ZONE"
);
original
+=
" WITH TIME ZONE"
;
}
}
else
if
(
readIf
(
"WITHOUT"
))
{
read
(
"TIME"
);
read
(
"ZONE"
);
original
+=
" WITHOUT TIME ZONE"
;
}
}
else
{
regular
=
true
;
...
...
h2/src/main/org/h2/value/DataType.java
浏览文件 @
873aac59
...
...
@@ -302,7 +302,8 @@ public class DataType {
add
(
Value
.
TIMESTAMP
,
Types
.
TIMESTAMP
,
"Timestamp"
,
createDate
(
ValueTimestamp
.
PRECISION
,
"TIMESTAMP"
,
ValueTimestamp
.
DEFAULT_SCALE
,
ValueTimestamp
.
DISPLAY_SIZE
),
new
String
[]{
"TIMESTAMP"
,
"DATETIME"
,
"DATETIME2"
,
"SMALLDATETIME"
},
new
String
[]{
"TIMESTAMP"
,
"TIMESTAMP WITHOUT TIME ZONE"
,
"DATETIME"
,
"DATETIME2"
,
"SMALLDATETIME"
},
// 24 for ValueTimestamp, 32 for java.sql.Timestamp
56
);
...
...
h2/src/test/org/h2/test/scripts/datatypes/timestamp.sql
浏览文件 @
873aac59
...
...
@@ -2,3 +2,26 @@
-- and the EPL 1.0 (http://h2database.com/html/license.html).
-- Initial Developer: H2 Group
--
CREATE
TABLE
TEST
(
T1
TIMESTAMP
,
T2
TIMESTAMP
WITHOUT
TIME
ZONE
);
>
ok
INSERT
INTO
TEST
(
T1
,
T2
)
VALUES
(
TIMESTAMP
'2010-01-01 10:00:00'
,
TIMESTAMP
WITHOUT
TIME
ZONE
'2010-01-01 10:00:00'
);
>
update
count
:
1
SELECT
T1
,
T2
,
T1
=
T2
FROM
TEST
;
>
T1
T2
T1
=
T2
>
--------------------- --------------------- -------
>
2010
-
01
-
01
10
:
00
:
00
.
0
2010
-
01
-
01
10
:
00
:
00
.
0
TRUE
>
rows
:
1
SELECT
COLUMN_NAME
,
DATA_TYPE
,
TYPE_NAME
,
COLUMN_TYPE
FROM
INFORMATION_SCHEMA
.
COLUMNS
WHERE
TABLE_NAME
=
'TEST'
ORDER
BY
ORDINAL_POSITION
;
>
COLUMN_NAME
DATA_TYPE
TYPE_NAME
COLUMN_TYPE
>
----------- --------- --------- ---------------------------
>
T1
93
TIMESTAMP
TIMESTAMP
>
T2
93
TIMESTAMP
TIMESTAMP
WITHOUT
TIME
ZONE
>
rows
(
ordered
):
2
DROP
TABLE
TEST
;
>
ok
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论