Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
1b17b3d6
提交
1b17b3d6
authored
3月 07, 2018
作者:
Evgenij Ryazanov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Move some tests from testSimple.in.txt into appropriate test scripts
上级
92b4f44a
显示空白字符变更
内嵌
并排
正在显示
10 个修改的文件
包含
171 行增加
和
115 行删除
+171
-115
lpad.sql
h2/src/test/org/h2/test/scripts/functions/string/lpad.sql
+3
-0
rpad.sql
h2/src/test/org/h2/test/scripts/functions/string/rpad.sql
+3
-0
substring.sql
...c/test/org/h2/test/scripts/functions/string/substring.sql
+6
-0
array-contains.sql
...t/org/h2/test/scripts/functions/system/array-contains.sql
+27
-0
cast.sql
h2/src/test/org/h2/test/scripts/functions/system/cast.sql
+72
-0
decode.sql
h2/src/test/org/h2/test/scripts/functions/system/decode.sql
+24
-0
datediff.sql
...st/org/h2/test/scripts/functions/timeanddate/datediff.sql
+24
-0
extract.sql
...est/org/h2/test/scripts/functions/timeanddate/extract.sql
+9
-0
hour.sql
...c/test/org/h2/test/scripts/functions/timeanddate/hour.sql
+3
-0
testSimple.in.txt
h2/src/test/org/h2/test/scripts/testSimple.in.txt
+0
-115
没有找到文件。
h2/src/test/org/h2/test/scripts/functions/string/lpad.sql
浏览文件 @
1b17b3d6
...
...
@@ -2,3 +2,6 @@
-- and the EPL 1.0 (http://h2database.com/html/license.html).
-- Initial Developer: H2 Group
--
select
lpad
(
'string'
,
10
,
'+'
);
>>
++++
string
h2/src/test/org/h2/test/scripts/functions/string/rpad.sql
浏览文件 @
1b17b3d6
...
...
@@ -2,3 +2,6 @@
-- and the EPL 1.0 (http://h2database.com/html/license.html).
-- Initial Developer: H2 Group
--
select
rpad
(
'string'
,
10
,
'+'
);
>>
string
++++
h2/src/test/org/h2/test/scripts/functions/string/substring.sql
浏览文件 @
1b17b3d6
...
...
@@ -26,3 +26,9 @@ select substring(null from null) en, substring(null from null for null) e1, subs
>
---- ---- ---- --
>
null
null
ob
o
>
rows
:
1
select
substr
(
'[Hello]'
,
2
,
5
);
>>
Hello
select
substr
(
'Hello World'
,
-
5
);
>>
World
h2/src/test/org/h2/test/scripts/functions/system/array-contains.sql
浏览文件 @
1b17b3d6
...
...
@@ -2,3 +2,30 @@
-- and the EPL 1.0 (http://h2database.com/html/license.html).
-- Initial Developer: H2 Group
--
select
array_contains
((
4
.
0
,
2
.
0
,
2
.
0
),
2
.
0
);
>>
TRUE
select
array_contains
((
4
.
0
,
2
.
0
,
2
.
0
),
5
.
0
);
>>
FALSE
select
array_contains
((
'one'
,
'two'
),
'one'
);
>>
TRUE
select
array_contains
((
'one'
,
'two'
),
'xxx'
);
>>
FALSE
select
array_contains
((
'one'
,
'two'
),
null
);
>>
FALSE
select
array_contains
((
null
,
'two'
),
null
);
>>
TRUE
select
array_contains
(
null
,
'one'
);
>>
FALSE
select
array_contains
(((
1
,
2
),
(
3
,
4
)),
(
1
,
2
));
>>
TRUE
select
array_contains
(((
1
,
2
),
(
3
,
4
)),
(
5
,
6
));
>>
FALSE
h2/src/test/org/h2/test/scripts/functions/system/cast.sql
浏览文件 @
1b17b3d6
...
...
@@ -15,3 +15,75 @@ select cast(null as varchar(255)) xn, cast(' 10' as int) x10, cast(' 20 ' as int
>
---- --- ---
>
null
10
20
>
rows
:
1
select
cast
(
128
as
binary
);
>>
00000080
select
cast
(
65535
as
binary
);
>>
0000
ffff
select
cast
(
cast
(
'ff'
as
binary
)
as
tinyint
)
x
;
>>
-
1
select
cast
(
cast
(
'7f'
as
binary
)
as
tinyint
)
x
;
>>
127
select
cast
(
cast
(
'ff'
as
binary
)
as
smallint
)
x
;
>>
255
select
cast
(
cast
(
'ff'
as
binary
)
as
int
)
x
;
>>
255
select
cast
(
cast
(
'ffff'
as
binary
)
as
long
)
x
;
>>
65535
select
cast
(
cast
(
65535
as
long
)
as
binary
);
>>
000000000000
ffff
select
cast
(
cast
(
-
1
as
tinyint
)
as
binary
);
>>
ff
select
cast
(
cast
(
-
1
as
smallint
)
as
binary
);
>>
ffff
select
cast
(
cast
(
-
1
as
int
)
as
binary
);
>>
ffffffff
select
cast
(
cast
(
-
1
as
long
)
as
binary
);
>>
ffffffffffffffff
select
cast
(
cast
(
1
as
tinyint
)
as
binary
);
>>
01
select
cast
(
cast
(
1
as
smallint
)
as
binary
);
>>
0001
select
cast
(
cast
(
1
as
int
)
as
binary
);
>>
00000001
select
cast
(
cast
(
1
as
long
)
as
binary
);
>>
0000000000000001
select
cast
(
X
'ff'
as
tinyint
);
>>
-
1
select
cast
(
X
'ffff'
as
smallint
);
>>
-
1
select
cast
(
X
'ffffffff'
as
int
);
>>
-
1
select
cast
(
X
'ffffffffffffffff'
as
long
);
>>
-
1
select
cast
(
' 011 '
as
int
);
>>
11
select
cast
(
cast
(
0
.
1
as
real
)
as
decimal
);
>>
0
.
1
select
cast
(
cast
(
95605327
.
73
as
float
)
as
decimal
);
>>
95605327
.
73
select
cast
(
cast
(
'01020304-0506-0708-090a-0b0c0d0e0f00'
as
uuid
)
as
binary
);
>>
0102030405060708090
a0b0c0d0e0f00
h2/src/test/org/h2/test/scripts/functions/system/decode.sql
浏览文件 @
1b17b3d6
...
...
@@ -2,3 +2,27 @@
-- and the EPL 1.0 (http://h2database.com/html/license.html).
-- Initial Developer: H2 Group
--
select
select
decode
(
null
,
null
,
'a'
);
>>
a
select
select
decode
(
1
,
1
,
'a'
);
>>
a
select
select
decode
(
1
,
2
,
'a'
);
>>
null
select
select
decode
(
1
,
1
,
'a'
,
'else'
);
>>
a
select
select
decode
(
1
,
2
,
'a'
,
'else'
);
>>
else
select
decode
(
4
.
0
,
2
.
0
,
2
.
0
,
3
.
0
,
3
.
0
);
>>
null
select
decode
(
'3'
,
2
.
0
,
2
.
0
,
3
,
3
.
0
);
>>
3
.
0
select
decode
(
4
.
0
,
2
.
0
,
2
.
0
,
3
.
0
,
3
.
0
,
4
.
0
,
4
.
0
,
9
.
0
);
>>
4
.
0
h2/src/test/org/h2/test/scripts/functions/timeanddate/datediff.sql
浏览文件 @
1b17b3d6
...
...
@@ -188,3 +188,27 @@ SELECT DATEDIFF('TIMEZONE_HOUR', TIMESTAMP WITH TIME ZONE '2010-01-01 10:00:00+0
SELECT
DATEDIFF
(
'TIMEZONE_MINUTE'
,
TIMESTAMP
WITH
TIME
ZONE
'2010-01-01 10:00:00+01:15'
,
TIMESTAMP
WITH
TIME
ZONE
'2012-02-02 12:00:00+02'
);
>>
45
select
datediff
(
'HOUR'
,
timestamp
'2007-01-06 10:00:00Z'
,
'2007-01-06 10:00:00Z'
);
>>
0
select
datediff
(
'HOUR'
,
timestamp
'1234-05-06 10:00:00+01:00'
,
'1234-05-06 10:00:00+02:00'
);
>>
-
1
select
datediff
(
'HOUR'
,
timestamp
'1234-05-06 10:00:00+01:00'
,
'1234-05-06 10:00:00-02:00'
);
>>
3
select
timestampdiff
(
month
,
'2003-02-01'
,
'2003-05-01'
);
>>
3
select
timestampdiff
(
YEAR
,
'2002-05-01'
,
'2001-01-01'
);
>>
-
1
select
timestampdiff
(
YEAR
,
'2017-01-01'
,
'2016-12-31 23:59:59'
);
>>
-
1
select
timestampdiff
(
YEAR
,
'2017-01-01'
,
'2017-12-31 23:59:59'
);
>>
0
select
timestampdiff
(
MINUTE
,
'2003-02-01'
,
'2003-05-01 12:05:55'
);
>>
128885
h2/src/test/org/h2/test/scripts/functions/timeanddate/extract.sql
浏览文件 @
1b17b3d6
...
...
@@ -67,3 +67,12 @@ SELECT EXTRACT(TIMEZONE_MINUTE FROM TIMESTAMP WITH TIME ZONE '2010-01-02 5:00:00
SELECT
EXTRACT
(
TIMEZONE_MINUTE
FROM
TIMESTAMP
WITH
TIME
ZONE
'2010-01-02 5:00:00-08:30'
);
>>
-
30
select
extract
(
hour
from
timestamp
'2001-02-03 14:15:16'
);
>>
14
select
extract
(
hour
from
'2001-02-03 14:15:16'
);
>>
14
select
extract
(
week
from
timestamp
'2001-02-03 14:15:16'
);
>>
5
h2/src/test/org/h2/test/scripts/functions/timeanddate/hour.sql
浏览文件 @
1b17b3d6
...
...
@@ -30,3 +30,6 @@ select hour(ts) h from test;
drop
table
test
;
>
ok
select
hour
(
'2001-02-03 14:15:16'
);
>>
14
h2/src/test/org/h2/test/scripts/testSimple.in.txt
浏览文件 @
1b17b3d6
...
...
@@ -14,46 +14,8 @@ select 1.0000000 / 3 * 0.00000;
> 0.0000000000000000000000000000000000000;
select 1.0000000 / 3 * 0.000000;
> 0E-38;
select substr('[Hello]', 2, 5);
> Hello;
select substr('Hello World', -5);
> World;
create table test(id null);
drop table test;
select select decode(null, null, 'a');
> a;
select select decode(1, 1, 'a');
> a;
select select decode(1, 2, 'a');
> null;
select select decode(1, 1, 'a', 'else');
> a;
select select decode(1, 2, 'a', 'else');
> else;
select decode(4.0, 2.0, 2.0, 3.0, 3.0);
> null;
select decode('3', 2.0, 2.0, 3, 3.0);
> 3.0;
select decode(4.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0, 9.0);
> 4.0;
select array_contains((4.0, 2.0, 2.0), 2.0);
> TRUE;
select array_contains((4.0, 2.0, 2.0), 5.0);
> FALSE;
select array_contains(('one', 'two'), 'one');
> TRUE;
select array_contains(('one', 'two'), 'xxx');
> FALSE;
select array_contains(('one', 'two'), null);
> FALSE;
select array_contains((null, 'two'), null);
> TRUE;
select array_contains(null, 'one');
> FALSE;
select array_contains(((1, 2), (3, 4)), (1, 2));
> TRUE;
select array_contains(((1, 2), (3, 4)), (5, 6));
> FALSE;
select * from (select group_concat(distinct 1) from system_range(1, 3));
> 1;
select sum(mod(x, 2) = 1) from system_range(1, 10);
...
...
@@ -69,50 +31,8 @@ select {fn TIMESTAMPADD(SQL_TSI_DAY, 1, {ts '2011-10-20 20:30:40.001'})};
> 2011-10-21 20:30:40.001;
select {fn TIMESTAMPADD(SQL_TSI_SECOND, 1, cast('2011-10-20 20:30:40.001' as timestamp))};
> 2011-10-20 20:30:41.001;
select cast(128 as binary);
> 00000080;
select cast(65535 as binary);
> 0000ffff;
select cast(cast('ff' as binary) as tinyint) x;
> -1;
select cast(cast('7f' as binary) as tinyint) x;
> 127;
select cast(cast('ff' as binary) as smallint) x;
> 255;
select cast(cast('ff' as binary) as int) x;
> 255;
select cast(cast('ffff' as binary) as long) x;
> 65535;
select cast(cast(65535 as long) as binary);
> 000000000000ffff;
select cast(cast(-1 as tinyint) as binary);
> ff;
select cast(cast(-1 as smallint) as binary);
> ffff;
select cast(cast(-1 as int) as binary);
> ffffffff;
select cast(cast(-1 as long) as binary);
> ffffffffffffffff;
select cast(cast(1 as tinyint) as binary);
> 01;
select cast(cast(1 as smallint) as binary);
> 0001;
select cast(cast(1 as int) as binary);
> 00000001;
select cast(cast(1 as long) as binary);
> 0000000000000001;
select cast(X'ff' as tinyint);
> -1;
select cast(X'ffff' as smallint);
> -1;
select cast(X'ffffffff' as int);
> -1;
select cast(X'ffffffffffffffff' as long);
> -1;
select N'test';
> test;
select cast(' 011 ' as int);
> 11;
select E'test\\test';
> test\test;
create table a(id int) as select null;
...
...
@@ -156,24 +76,8 @@ alter table test alter column id drop not null;
select is_nullable from information_schema.columns c where c.table_name = 'TEST' and c.column_name = 'ID';
> YES;
drop table test;
select cast(cast(0.1 as real) as decimal);
> 0.1;
select cast(cast(95605327.73 as float) as decimal);
> 95605327.73;
select timestampdiff(month, '2003-02-01','2003-05-01');
> 3;
select timestampdiff(YEAR,'2002-05-01','2001-01-01');
> -1;
select timestampdiff(YEAR,'2017-01-01','2016-12-31 23:59:59');
> -1;
select timestampdiff(YEAR,'2017-01-01','2017-12-31 23:59:59');
> 0;
select timestampdiff(MINUTE,'2003-02-01','2003-05-01 12:05:55');
> 128885;
select x from (select *, rownum as r from system_range(1, 3)) where r=2;
> 2;
select cast(cast('01020304-0506-0708-090a-0b0c0d0e0f00' as uuid) as binary);
> 0102030405060708090a0b0c0d0e0f00;
create table test(name varchar(255)) as select 'Hello+World+';
select count(*) from test where name like 'Hello++World++' escape '+';
> 1;
...
...
@@ -356,15 +260,6 @@ CREATE TABLE Contact.Contact (id BIGINT primary key, FOREIGN KEY (id) REFERENCES
drop schema contact cascade;
drop table account, person;
select extract(hour from timestamp '2001-02-03 14:15:16');
> 14;
select extract(hour from '2001-02-03 14:15:16');
> 14;
select hour('2001-02-03 14:15:16');
> 14;
select extract(week from timestamp '2001-02-03 14:15:16');
> 5;
CREATE TABLE TEST(A int NOT NULL, B int NOT NULL, C int) ;
ALTER TABLE TEST ADD CONSTRAINT CON UNIQUE(A,B);
ALTER TABLE TEST DROP C;
...
...
@@ -385,10 +280,6 @@ select count(*) from (select * from (select * from test union select * from test
select 1 from ((test d1 inner join test d2 on d1.id = d2.id) inner join test d3 on d1.id = d3.id) inner join test d4 on d4.id = d1.id;
drop table test;
select lpad('string', 10, '+');
> ++++string;
select rpad('string', 10, '+');
> string++++;
select lpad('string', 10);
> string;
...
...
@@ -561,12 +452,6 @@ select date '+0011-01-01';
> 0011-01-01;
select date'-0010-01-01';
> -10-01-01;
select datediff('HOUR', timestamp '2007-01-06 10:00:00Z', '2007-01-06 10:00:00Z');
> 0;
select datediff('HOUR', timestamp '1234-05-06 10:00:00+01:00', '1234-05-06 10:00:00+02:00');
> -1;
select datediff('HOUR', timestamp '1234-05-06 10:00:00+01:00', '1234-05-06 10:00:00-02:00');
> 3;
create schema TEST_SCHEMA;
create table TEST_SCHEMA.test(id int);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论