提交 1b17b3d6 authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov

Move some tests from testSimple.in.txt into appropriate test scripts

上级 92b4f44a
...@@ -2,3 +2,6 @@ ...@@ -2,3 +2,6 @@
-- and the EPL 1.0 (http://h2database.com/html/license.html). -- and the EPL 1.0 (http://h2database.com/html/license.html).
-- Initial Developer: H2 Group -- Initial Developer: H2 Group
-- --
select lpad('string', 10, '+');
>> ++++string
...@@ -2,3 +2,6 @@ ...@@ -2,3 +2,6 @@
-- and the EPL 1.0 (http://h2database.com/html/license.html). -- and the EPL 1.0 (http://h2database.com/html/license.html).
-- Initial Developer: H2 Group -- Initial Developer: H2 Group
-- --
select rpad('string', 10, '+');
>> string++++
...@@ -26,3 +26,9 @@ select substring(null from null) en, substring(null from null for null) e1, subs ...@@ -26,3 +26,9 @@ select substring(null from null) en, substring(null from null for null) e1, subs
> ---- ---- ---- -- > ---- ---- ---- --
> null null ob o > null null ob o
> rows: 1 > rows: 1
select substr('[Hello]', 2, 5);
>> Hello
select substr('Hello World', -5);
>> World
...@@ -2,3 +2,30 @@ ...@@ -2,3 +2,30 @@
-- and the EPL 1.0 (http://h2database.com/html/license.html). -- and the EPL 1.0 (http://h2database.com/html/license.html).
-- Initial Developer: H2 Group -- 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
...@@ -15,3 +15,75 @@ select cast(null as varchar(255)) xn, cast(' 10' as int) x10, cast(' 20 ' as int ...@@ -15,3 +15,75 @@ select cast(null as varchar(255)) xn, cast(' 10' as int) x10, cast(' 20 ' as int
> ---- --- --- > ---- --- ---
> null 10 20 > null 10 20
> rows: 1 > rows: 1
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 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);
>> 0102030405060708090a0b0c0d0e0f00
...@@ -2,3 +2,27 @@ ...@@ -2,3 +2,27 @@
-- and the EPL 1.0 (http://h2database.com/html/license.html). -- and the EPL 1.0 (http://h2database.com/html/license.html).
-- Initial Developer: H2 Group -- 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
...@@ -188,3 +188,27 @@ SELECT DATEDIFF('TIMEZONE_HOUR', TIMESTAMP WITH TIME ZONE '2010-01-01 10:00:00+0 ...@@ -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', 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'); TIMESTAMP WITH TIME ZONE '2012-02-02 12:00:00+02');
>> 45 >> 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
...@@ -67,3 +67,12 @@ SELECT EXTRACT(TIMEZONE_MINUTE FROM TIMESTAMP WITH TIME ZONE '2010-01-02 5:00:00 ...@@ -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'); SELECT EXTRACT(TIMEZONE_MINUTE FROM TIMESTAMP WITH TIME ZONE '2010-01-02 5:00:00-08:30');
>> -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
...@@ -30,3 +30,6 @@ select hour(ts) h from test; ...@@ -30,3 +30,6 @@ select hour(ts) h from test;
drop table test; drop table test;
> ok > ok
select hour('2001-02-03 14:15:16');
>> 14
...@@ -14,46 +14,8 @@ select 1.0000000 / 3 * 0.00000; ...@@ -14,46 +14,8 @@ select 1.0000000 / 3 * 0.00000;
> 0.0000000000000000000000000000000000000; > 0.0000000000000000000000000000000000000;
select 1.0000000 / 3 * 0.000000; select 1.0000000 / 3 * 0.000000;
> 0E-38; > 0E-38;
select substr('[Hello]', 2, 5);
> Hello;
select substr('Hello World', -5);
> World;
create table test(id null); create table test(id null);
drop table test; 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)); select * from (select group_concat(distinct 1) from system_range(1, 3));
> 1; > 1;
select sum(mod(x, 2) = 1) from system_range(1, 10); 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'})}; ...@@ -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; > 2011-10-21 20:30:40.001;
select {fn TIMESTAMPADD(SQL_TSI_SECOND, 1, cast('2011-10-20 20:30:40.001' as timestamp))}; select {fn TIMESTAMPADD(SQL_TSI_SECOND, 1, cast('2011-10-20 20:30:40.001' as timestamp))};
> 2011-10-20 20:30:41.001; > 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'; select N'test';
> test; > test;
select cast(' 011 ' as int);
> 11;
select E'test\\test'; select E'test\\test';
> test\test; > test\test;
create table a(id int) as select null; create table a(id int) as select null;
...@@ -156,24 +76,8 @@ alter table test alter column id drop not 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'; select is_nullable from information_schema.columns c where c.table_name = 'TEST' and c.column_name = 'ID';
> YES; > YES;
drop table test; 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; select x from (select *, rownum as r from system_range(1, 3)) where r=2;
> 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+'; create table test(name varchar(255)) as select 'Hello+World+';
select count(*) from test where name like 'Hello++World++' escape '+'; select count(*) from test where name like 'Hello++World++' escape '+';
> 1; > 1;
...@@ -356,15 +260,6 @@ CREATE TABLE Contact.Contact (id BIGINT primary key, FOREIGN KEY (id) REFERENCES ...@@ -356,15 +260,6 @@ CREATE TABLE Contact.Contact (id BIGINT primary key, FOREIGN KEY (id) REFERENCES
drop schema contact cascade; drop schema contact cascade;
drop table account, person; 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) ; 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 ADD CONSTRAINT CON UNIQUE(A,B);
ALTER TABLE TEST DROP C; ALTER TABLE TEST DROP C;
...@@ -385,10 +280,6 @@ select count(*) from (select * from (select * from test union select * from test ...@@ -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; 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; drop table test;
select lpad('string', 10, '+');
> ++++string;
select rpad('string', 10, '+');
> string++++;
select lpad('string', 10); select lpad('string', 10);
> string; > string;
...@@ -561,12 +452,6 @@ select date '+0011-01-01'; ...@@ -561,12 +452,6 @@ select date '+0011-01-01';
> 0011-01-01; > 0011-01-01;
select date'-0010-01-01'; select date'-0010-01-01';
> -10-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 schema TEST_SCHEMA;
create table TEST_SCHEMA.test(id int); create table TEST_SCHEMA.test(id int);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论