Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
07e507f3
提交
07e507f3
authored
1月 24, 2018
作者:
Evgenij Ryazanov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Move tests of DATEADD and DATEDIFF to own scripts
上级
43e768fc
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
149 行增加
和
147 行删除
+149
-147
dateadd.sql
...est/org/h2/test/scripts/functions/timeanddate/dateadd.sql
+84
-0
datediff.sql
...st/org/h2/test/scripts/functions/timeanddate/datediff.sql
+65
-0
testScript.sql
h2/src/test/org/h2/test/scripts/testScript.sql
+0
-147
没有找到文件。
h2/src/test/org/h2/test/scripts/functions/timeanddate/dateadd.sql
浏览文件 @
07e507f3
...
...
@@ -20,3 +20,87 @@ select dateadd('year', -1, timestamp '2000-02-29 10:20:30.012345678') d1 from te
>
-----------------------------
>
1999
-
02
-
28
10
:
20
:
30
.
012345678
>
rows
:
1
drop
table
test
;
>
ok
create
table
test
(
d
date
,
t
time
,
ts
timestamp
);
>
ok
insert
into
test
values
(
date
'2001-01-01'
,
time
'01:00:00'
,
timestamp
'2010-01-01 00:00:00'
);
>
update
count
:
1
select
ts
+
t
x
from
test
;
>
X
>
---------------------
>
2010
-
01
-
01
01
:
00
:
00
.
0
>
rows
:
1
select
ts
+
t
+
t
-
t
x
from
test
;
>
X
>
---------------------
>
2010
-
01
-
01
01
:
00
:
00
.
0
>
rows
:
1
select
ts
+
t
*
0
.
5
x
from
test
;
>
X
>
---------------------
>
2010
-
01
-
01
00
:
30
:
00
.
0
>
rows
:
1
select
ts
+
0
.
5
x
from
test
;
>
X
>
---------------------
>
2010
-
01
-
01
12
:
00
:
00
.
0
>
rows
:
1
select
ts
-
1
.
5
x
from
test
;
>
X
>
---------------------
>
2009
-
12
-
30
12
:
00
:
00
.
0
>
rows
:
1
select
ts
+
0
.
5
*
t
+
t
-
t
x
from
test
;
>
X
>
---------------------
>
2010
-
01
-
01
00
:
30
:
00
.
0
>
rows
:
1
select
ts
+
t
/
0
.
5
x
from
test
;
>
X
>
---------------------
>
2010
-
01
-
01
02
:
00
:
00
.
0
>
rows
:
1
select
d
+
t
,
t
+
d
-
t
x
from
test
;
>
T
+
D
X
>
--------------------- ---------------------
>
2001
-
01
-
01
01
:
00
:
00
.
0
2001
-
01
-
01
00
:
00
:
00
.
0
>
rows
:
1
select
1
+
d
+
1
,
d
-
1
,
2
+
ts
+
2
,
ts
-
2
from
test
;
>
DATEADD
(
'DAY'
,
1
,
DATEADD
(
'DAY'
,
1
,
D
))
DATEADD
(
'DAY'
,
-
1
,
D
)
DATEADD
(
'DAY'
,
2
,
DATEADD
(
'DAY'
,
2
,
TS
))
DATEADD
(
'DAY'
,
-
2
,
TS
)
>
--------------------------------------- --------------------- ---------------------------------------- ----------------------
>
2001
-
01
-
03
00
:
00
:
00
.
0
2000
-
12
-
31
00
:
00
:
00
.
0
2010
-
01
-
05
00
:
00
:
00
.
0
2009
-
12
-
30
00
:
00
:
00
.
0
>
rows
:
1
select
1
+
d
+
t
+
1
from
test
;
>
DATEADD
(
'DAY'
,
1
,
(
T
+
DATEADD
(
'DAY'
,
1
,
D
)))
>
---------------------------------------------
>
2001
-
01
-
03
01
:
00
:
00
.
0
>
rows
:
1
select
ts
-
t
-
2
from
test
;
>
DATEADD
(
'DAY'
,
-
2
,
(
TS
-
T
))
>
----------------------------
>
2009
-
12
-
29
23
:
00
:
00
.
0
>
rows
:
1
drop
table
test
;
>
ok
call
dateadd
(
'MS'
,
1
,
TIMESTAMP
'2001-02-03 04:05:06.789001'
);
>
TIMESTAMP
'2001-02-03 04:05:06.790001'
>
--------------------------------------
>
2001
-
02
-
03
04
:
05
:
06
.
790001
>
rows
:
1
h2/src/test/org/h2/test/scripts/functions/timeanddate/datediff.sql
浏览文件 @
07e507f3
...
...
@@ -93,3 +93,68 @@ select datediff('millisecond', timestamp '2004-01-01 10:00:00.5', timestamp '200
>
500
>
rows
:
1
SELECT
DATEDIFF
(
'SECOND'
,
'1900-01-01 00:00:00.001'
,
'1900-01-01 00:00:00.002'
),
DATEDIFF
(
'SECOND'
,
'2000-01-01 00:00:00.001'
,
'2000-01-01 00:00:00.002'
);
>
0
0
>
-
-
>
0
0
>
rows
:
1
SELECT
DATEDIFF
(
'SECOND'
,
'1900-01-01 00:00:00.000'
,
'1900-01-01 00:00:00.001'
),
DATEDIFF
(
'SECOND'
,
'2000-01-01 00:00:00.000'
,
'2000-01-01 00:00:00.001'
);
>
0
0
>
-
-
>
0
0
>
rows
:
1
SELECT
DATEDIFF
(
'MINUTE'
,
'1900-01-01 00:00:00.000'
,
'1900-01-01 00:00:01.000'
),
DATEDIFF
(
'MINUTE'
,
'2000-01-01 00:00:00.000'
,
'2000-01-01 00:00:01.000'
);
>
0
0
>
-
-
>
0
0
>
rows
:
1
SELECT
DATEDIFF
(
'MINUTE'
,
'1900-01-01 00:00:01.000'
,
'1900-01-01 00:00:02.000'
),
DATEDIFF
(
'MINUTE'
,
'2000-01-01 00:00:01.000'
,
'2000-01-01 00:00:02.000'
);
>
0
0
>
-
-
>
0
0
>
rows
:
1
SELECT
DATEDIFF
(
'HOUR'
,
'1900-01-01 00:00:00.000'
,
'1900-01-01 00:00:01.000'
),
DATEDIFF
(
'HOUR'
,
'2000-01-01 00:00:00.000'
,
'2000-01-01 00:00:01.000'
);
>
0
0
>
-
-
>
0
0
>
rows
:
1
SELECT
DATEDIFF
(
'HOUR'
,
'1900-01-01 00:00:00.001'
,
'1900-01-01 00:00:01.000'
),
DATEDIFF
(
'HOUR'
,
'2000-01-01 00:00:00.001'
,
'2000-01-01 00:00:01.000'
);
>
0
0
>
-
-
>
0
0
>
rows
:
1
SELECT
DATEDIFF
(
'HOUR'
,
'1900-01-01 01:00:00.000'
,
'1900-01-01 01:00:01.000'
),
DATEDIFF
(
'HOUR'
,
'2000-01-01 01:00:00.000'
,
'2000-01-01 01:00:01.000'
);
>
0
0
>
-
-
>
0
0
>
rows
:
1
SELECT
DATEDIFF
(
'HOUR'
,
'1900-01-01 01:00:00.001'
,
'1900-01-01 01:00:01.000'
),
DATEDIFF
(
'HOUR'
,
'2000-01-01 01:00:00.001'
,
'2000-01-01 01:00:01.000'
);
>
0
0
>
-
-
>
0
0
>
rows
:
1
select
datediff
(
day
,
'2015-12-09 23:59:00.0'
,
'2016-01-16 23:59:00.0'
),
datediff
(
wk
,
'2015-12-09 23:59:00.0'
,
'2016-01-16 23:59:00.0'
);
>
38
5
>
-- -
>
38
5
>
rows
:
1
call
datediff
(
'MS'
,
TIMESTAMP
'2001-02-03 04:05:06.789001'
,
TIMESTAMP
'2001-02-03 04:05:06.789002'
);
>
0
>
-
>
0
>
rows
:
1
call
datediff
(
'MS'
,
TIMESTAMP
'1900-01-01 00:00:01.000'
,
TIMESTAMP
'2008-01-01 00:00:00.000'
);
>
3408134399000
>
-------------
>
3408134399000
>
rows
:
1
h2/src/test/org/h2/test/scripts/testScript.sql
浏览文件 @
07e507f3
...
...
@@ -557,81 +557,6 @@ explain select * from test limit 10 sample_size 10;
drop
table
test
;
>
ok
create
table
test
(
d
date
,
t
time
,
ts
timestamp
);
>
ok
insert
into
test
values
(
date
'2001-01-01'
,
time
'01:00:00'
,
timestamp
'2010-01-01 00:00:00'
);
>
update
count
:
1
select
ts
+
t
x
from
test
;
>
X
>
---------------------
>
2010
-
01
-
01
01
:
00
:
00
.
0
>
rows
:
1
select
ts
+
t
+
t
-
t
x
from
test
;
>
X
>
---------------------
>
2010
-
01
-
01
01
:
00
:
00
.
0
>
rows
:
1
select
ts
+
t
*
0
.
5
x
from
test
;
>
X
>
---------------------
>
2010
-
01
-
01
00
:
30
:
00
.
0
>
rows
:
1
select
ts
+
0
.
5
x
from
test
;
>
X
>
---------------------
>
2010
-
01
-
01
12
:
00
:
00
.
0
>
rows
:
1
select
ts
-
1
.
5
x
from
test
;
>
X
>
---------------------
>
2009
-
12
-
30
12
:
00
:
00
.
0
>
rows
:
1
select
ts
+
0
.
5
*
t
+
t
-
t
x
from
test
;
>
X
>
---------------------
>
2010
-
01
-
01
00
:
30
:
00
.
0
>
rows
:
1
select
ts
+
t
/
0
.
5
x
from
test
;
>
X
>
---------------------
>
2010
-
01
-
01
02
:
00
:
00
.
0
>
rows
:
1
select
d
+
t
,
t
+
d
-
t
x
from
test
;
>
T
+
D
X
>
--------------------- ---------------------
>
2001
-
01
-
01
01
:
00
:
00
.
0
2001
-
01
-
01
00
:
00
:
00
.
0
>
rows
:
1
select
1
+
d
+
1
,
d
-
1
,
2
+
ts
+
2
,
ts
-
2
from
test
;
>
DATEADD
(
'DAY'
,
1
,
DATEADD
(
'DAY'
,
1
,
D
))
DATEADD
(
'DAY'
,
-
1
,
D
)
DATEADD
(
'DAY'
,
2
,
DATEADD
(
'DAY'
,
2
,
TS
))
DATEADD
(
'DAY'
,
-
2
,
TS
)
>
--------------------------------------- --------------------- ---------------------------------------- ----------------------
>
2001
-
01
-
03
00
:
00
:
00
.
0
2000
-
12
-
31
00
:
00
:
00
.
0
2010
-
01
-
05
00
:
00
:
00
.
0
2009
-
12
-
30
00
:
00
:
00
.
0
>
rows
:
1
select
1
+
d
+
t
+
1
from
test
;
>
DATEADD
(
'DAY'
,
1
,
(
T
+
DATEADD
(
'DAY'
,
1
,
D
)))
>
---------------------------------------------
>
2001
-
01
-
03
01
:
00
:
00
.
0
>
rows
:
1
select
ts
-
t
-
2
from
test
;
>
DATEADD
(
'DAY'
,
-
2
,
(
TS
-
T
))
>
----------------------------
>
2009
-
12
-
29
23
:
00
:
00
.
0
>
rows
:
1
drop
table
test
;
>
ok
create
table
test
(
id
int
primary
key
);
>
ok
...
...
@@ -3904,60 +3829,6 @@ SELECT CASE WHEN NOT (false IN (null)) THEN false END;
> null
> rows: 1
SELECT DATEDIFF('
SECOND
', '
1900
-
01
-
01
00
:
00
:
00
.
001
', '
1900
-
01
-
01
00
:
00
:
00
.
002
'), DATEDIFF('
SECOND
', '
2000
-
01
-
01
00
:
00
:
00
.
001
', '
2000
-
01
-
01
00
:
00
:
00
.
002
');
> 0 0
> - -
> 0 0
> rows: 1
SELECT DATEDIFF('
SECOND
', '
1900
-
01
-
01
00
:
00
:
00
.
000
', '
1900
-
01
-
01
00
:
00
:
00
.
001
'), DATEDIFF('
SECOND
', '
2000
-
01
-
01
00
:
00
:
00
.
000
', '
2000
-
01
-
01
00
:
00
:
00
.
001
');
> 0 0
> - -
> 0 0
> rows: 1
SELECT DATEDIFF('
MINUTE
', '
1900
-
01
-
01
00
:
00
:
00
.
000
', '
1900
-
01
-
01
00
:
00
:
01
.
000
'), DATEDIFF('
MINUTE
', '
2000
-
01
-
01
00
:
00
:
00
.
000
', '
2000
-
01
-
01
00
:
00
:
01
.
000
');
> 0 0
> - -
> 0 0
> rows: 1
SELECT DATEDIFF('
MINUTE
', '
1900
-
01
-
01
00
:
00
:
01
.
000
', '
1900
-
01
-
01
00
:
00
:
02
.
000
'), DATEDIFF('
MINUTE
', '
2000
-
01
-
01
00
:
00
:
01
.
000
', '
2000
-
01
-
01
00
:
00
:
02
.
000
');
> 0 0
> - -
> 0 0
> rows: 1
SELECT DATEDIFF('
HOUR
', '
1900
-
01
-
01
00
:
00
:
00
.
000
', '
1900
-
01
-
01
00
:
00
:
01
.
000
'), DATEDIFF('
HOUR
', '
2000
-
01
-
01
00
:
00
:
00
.
000
', '
2000
-
01
-
01
00
:
00
:
01
.
000
');
> 0 0
> - -
> 0 0
> rows: 1
SELECT DATEDIFF('
HOUR
', '
1900
-
01
-
01
00
:
00
:
00
.
001
', '
1900
-
01
-
01
00
:
00
:
01
.
000
'), DATEDIFF('
HOUR
', '
2000
-
01
-
01
00
:
00
:
00
.
001
', '
2000
-
01
-
01
00
:
00
:
01
.
000
');
> 0 0
> - -
> 0 0
> rows: 1
SELECT DATEDIFF('
HOUR
', '
1900
-
01
-
01
01
:
00
:
00
.
000
', '
1900
-
01
-
01
01
:
00
:
01
.
000
'), DATEDIFF('
HOUR
', '
2000
-
01
-
01
01
:
00
:
00
.
000
', '
2000
-
01
-
01
01
:
00
:
01
.
000
');
> 0 0
> - -
> 0 0
> rows: 1
SELECT DATEDIFF('
HOUR
', '
1900
-
01
-
01
01
:
00
:
00
.
001
', '
1900
-
01
-
01
01
:
00
:
01
.
000
'), DATEDIFF('
HOUR
', '
2000
-
01
-
01
01
:
00
:
00
.
001
', '
2000
-
01
-
01
01
:
00
:
01
.
000
');
> 0 0
> - -
> 0 0
> rows: 1
select datediff(day, '
2015
-
12
-
09
23
:
59
:
00
.
0
', '
2016
-
01
-
16
23
:
59
:
00
.
0
'), datediff(wk, '
2015
-
12
-
09
23
:
59
:
00
.
0
', '
2016
-
01
-
16
23
:
59
:
00
.
0
');
> 38 5
> -- -
> 38 5
> rows: 1
create table test(id int);
> ok
...
...
@@ -3972,30 +3843,12 @@ insert into test values(1), (2), (3), (4);
drop table test;
> ok
call datediff('
MS
', TIMESTAMP '
2001
-
02
-
03
04
:
05
:
06
.
789001
', TIMESTAMP '
2001
-
02
-
03
04
:
05
:
06
.
789002
');
> 0
> -
> 0
> rows: 1
call datediff('
MS
', TIMESTAMP '
1900
-
01
-
01
00
:
00
:
01
.
000
', TIMESTAMP '
2008
-
01
-
01
00
:
00
:
00
.
000
');
> 3408134399000
> -------------
> 3408134399000
> rows: 1
call select 1.0/3.0*3.0, 100.0/2.0, -25.0/100.0, 0.0/3.0, 6.9/2.0, 0.72179425150347250912311550800000 / 5314251955.21;
> SELECT 0.999999999999999999999999990, 50, -0.25, 0, 3.45, 1.35822361752313607260107721120531135706133161972E-10 FROM SYSTEM_RANGE(1, 1) /* PUBLIC.RANGE_INDEX */ /* scanCount: 2 */
> -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
> (0.999999999999999999999999990, 50, -0.25, 0, 3.45, 1.35822361752313607260107721120531135706133161972E-10)
> rows: 1
call dateadd('
MS
', 1, TIMESTAMP '
2001
-
02
-
03
04
:
05
:
06
.
789001
');
> TIMESTAMP '
2001
-
02
-
03
04
:
05
:
06
.
790001
'
> --------------------------------------
> 2001-02-03 04:05:06.790001
> rows: 1
CALL 1 /* comment */ ;;
> 1
> -
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论