Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
b252eeac
提交
b252eeac
authored
9月 14, 2017
作者:
Noel Grandin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
start splitting up the test script file
上级
a189c7bd
显示空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
192 行增加
和
182 行删除
+192
-182
TestScript.java
h2/src/test/org/h2/test/scripts/TestScript.java
+30
-20
datatypes-enum.sql
h2/src/test/org/h2/test/scripts/datatypes-enum.sql
+150
-0
functions-system-rownum.sql
h2/src/test/org/h2/test/scripts/functions-system-rownum.sql
+12
-0
testScript.sql
h2/src/test/org/h2/test/scripts/testScript.sql
+0
-162
没有找到文件。
h2/src/test/org/h2/test/scripts/TestScript.java
浏览文件 @
b252eeac
...
...
@@ -30,20 +30,21 @@ import org.h2.util.StringUtils;
*/
public
class
TestScript
extends
TestBase
{
private
static
final
String
FILENAME
=
"org/h2/test/scripts/testScript.sql
"
;
private
static
final
String
BASE_DIR
=
"org/h2/test/scripts/
"
;
/** If set to true, the test will exit at the first failure. */
private
boolean
failFast
;
private
final
ArrayList
<
String
>
statements
=
New
.
arrayList
();
private
boolean
reconnectOften
;
private
Connection
conn
;
private
Statement
stat
;
private
LineNumberReader
in
;
private
int
line
;
private
int
outputLineNo
;
private
PrintStream
out
;
private
final
ArrayList
<
String
[]>
result
=
New
.
arrayList
();
private
String
putBack
;
private
StringBuilder
errors
;
private
ArrayList
<
String
>
statements
;
private
Random
random
=
new
Random
(
1
);
...
...
@@ -64,8 +65,9 @@ public class TestScript extends TestBase {
*/
public
ArrayList
<
String
>
getAllStatements
(
TestAll
conf
)
throws
Exception
{
config
=
conf
;
statements
=
New
.
arrayList
();
if
(
statements
.
isEmpty
())
{
test
();
}
return
statements
;
}
...
...
@@ -74,24 +76,34 @@ public class TestScript extends TestBase {
if
(
config
.
networked
&&
config
.
big
)
{
return
;
}
reconnectOften
=
false
;
if
(!
config
.
memory
)
{
if
(
config
.
big
)
{
reconnectOften
=
true
;
}
}
testScript
();
reconnectOften
=
!
config
.
memory
&&
config
.
big
;
testScript
(
"testScript.sql"
);
testScript
(
"functions-system-rownum.sql"
);
testScript
(
"datatypes-enum.sql"
);
deleteDb
(
"script"
);
System
.
out
.
flush
();
}
private
void
testScript
()
throws
Exception
{
private
void
testScript
(
String
scriptFileName
)
throws
Exception
{
deleteDb
(
"script"
);
String
outFile
=
"test.out.txt"
;
// Reset all the state in case there is anything left over from the previous file we processed.
conn
=
null
;
stat
=
null
;
in
=
null
;
outputLineNo
=
0
;
out
=
null
;
result
.
clear
();
putBack
=
null
;
errors
=
null
;
println
(
"Running commands in "
+
scriptFileName
);
final
String
outFile
=
"test.out.txt"
;
conn
=
getConnection
(
"script"
);
stat
=
conn
.
createStatement
();
out
=
new
PrintStream
(
new
FileOutputStream
(
outFile
));
errors
=
new
StringBuilder
();
testFile
(
FILENAME
);
testFile
(
BASE_DIR
+
scriptFileName
);
conn
.
close
();
out
.
close
();
if
(
errors
.
length
()
>
0
)
{
...
...
@@ -172,9 +184,7 @@ public class TestScript extends TestBase {
}
}
}
if
(
statements
!=
null
)
{
statements
.
add
(
sql
);
}
if
(
sql
.
indexOf
(
'?'
)
==
-
1
)
{
processStatement
(
sql
);
}
else
{
...
...
@@ -358,7 +368,7 @@ public class TestScript extends TestBase {
return
;
}
errors
.
append
(
"line: "
);
errors
.
append
(
line
);
errors
.
append
(
outputLineNo
);
errors
.
append
(
"\n"
+
"exp: "
);
errors
.
append
(
compare
);
errors
.
append
(
"\n"
+
"got: "
);
...
...
@@ -380,7 +390,7 @@ public class TestScript extends TestBase {
}
private
void
write
(
String
s
)
{
line
++;
outputLineNo
++;
out
.
println
(
s
);
}
...
...
h2/src/test/org/h2/test/scripts/datatypes-enum.sql
0 → 100644
浏览文件 @
b252eeac
----------------
--- ENUM support
----------------
--- ENUM basic operations
create
table
card
(
rank
int
,
suit
enum
(
'hearts'
,
'clubs'
,
'spades'
));
>
ok
insert
into
card
(
rank
,
suit
)
values
(
0
,
'clubs'
),
(
3
,
'hearts'
);
>
update
count
:
2
alter
table
card
alter
column
suit
enum
(
'hearts'
,
'clubs'
,
'spades'
,
'diamonds'
);
>
ok
select
*
from
card
;
>
RANK
SUIT
>
---- ------
>
0
clubs
>
3
hearts
select
*
from
card
order
by
suit
;
>
RANK
SUIT
>
---- ------
>
3
hearts
>
0
clubs
insert
into
card
(
rank
,
suit
)
values
(
8
,
'diamonds'
),
(
10
,
'clubs'
),
(
7
,
'hearts'
);
>
update
count
:
3
select
suit
,
count
(
rank
)
from
card
group
by
suit
order
by
suit
,
count
(
rank
);
>
SUIT
COUNT
(
RANK
)
>
-------- -----------
>
hearts
2
>
clubs
2
>
diamonds
1
select
rank
from
card
where
suit
=
'diamonds'
;
>
RANK
>
----
>
8
--- ENUM integer-based operations
select
rank
from
card
where
suit
=
1
;
>
RANK
>
----
>
0
>
10
insert
into
card
(
rank
,
suit
)
values
(
5
,
2
);
>
update
count
:
1
select
*
from
card
where
rank
=
5
;
>
RANK
SUIT
>
---- ------
>
5
spades
--- ENUM edge cases
insert
into
card
(
rank
,
suit
)
values
(
6
,
' '
);
>
exception
alter
table
card
alter
column
suit
enum
(
'hearts'
,
'clubs'
,
'spades'
,
'diamonds'
,
'clubs'
);
>
exception
alter
table
card
alter
column
suit
enum
(
'hearts'
,
'clubs'
,
'spades'
,
'diamonds'
,
''
);
>
exception
drop
table
card
;
>
ok
--- ENUM as custom user data type
create
type
CARD_SUIT
as
enum
(
'hearts'
,
'clubs'
,
'spades'
,
'diamonds'
);
>
ok
create
table
card
(
rank
int
,
suit
CARD_SUIT
);
>
ok
insert
into
card
(
rank
,
suit
)
values
(
0
,
'clubs'
),
(
3
,
'hearts'
);
>
update
count
:
2
select
*
from
card
;
>
RANK
SUIT
>
---- ------
>
0
clubs
>
3
hearts
drop
table
card
;
>
ok
drop
type
CARD_SUIT
;
>
ok
--- ENUM in primary key with another column
create
type
CARD_SUIT
as
enum
(
'hearts'
,
'clubs'
,
'spades'
,
'diamonds'
);
>
ok
create
table
card
(
rank
int
,
suit
CARD_SUIT
,
primary
key
(
rank
,
suit
));
>
ok
insert
into
card
(
rank
,
suit
)
values
(
0
,
'clubs'
),
(
3
,
'hearts'
),
(
1
,
'clubs'
);
>
update
count
:
3
insert
into
card
(
rank
,
suit
)
values
(
0
,
'clubs'
);
>
exception
select
rank
from
card
where
suit
=
'clubs'
;
>
RANK
>
----
>
0
>
1
drop
table
card
;
>
ok
drop
type
CARD_SUIT
;
>
ok
--- ENUM with index
create
type
CARD_SUIT
as
enum
(
'hearts'
,
'clubs'
,
'spades'
,
'diamonds'
);
>
ok
create
table
card
(
rank
int
,
suit
CARD_SUIT
,
primary
key
(
rank
,
suit
));
>
ok
insert
into
card
(
rank
,
suit
)
values
(
0
,
'clubs'
),
(
3
,
'hearts'
),
(
1
,
'clubs'
);
>
update
count
:
3
create
index
idx_card_suite
on
card
(
`suit`
);
select
rank
from
card
where
suit
=
'clubs'
;
>
RANK
>
----
>
0
>
1
select
rank
from
card
where
suit
in
(
'clubs'
);
>
RANK
>
----
>
0
>
1
drop
table
card
;
>
ok
drop
type
CARD_SUIT
;
>
ok
h2/src/test/org/h2/test/scripts/functions-system-rownum.sql
0 → 100644
浏览文件 @
b252eeac
----- Issue#600 -----
create
table
test
as
(
select
char
(
x
)
as
str
from
system_range
(
48
,
90
));
>
ok
select
row_number
()
over
()
as
rnum
,
str
from
test
where
str
=
'A'
;
>
RNUM
STR
>
---- ---
>
1
A
drop
table
test
;
>
ok
h2/src/test/org/h2/test/scripts/testScript.sql
浏览文件 @
b252eeac
...
...
@@ -10593,156 +10593,6 @@ create table z.z (id int);
drop
schema
z
;
>
ok
----------------
--- ENUM support
----------------
--- ENUM basic operations
create
table
card
(
rank
int
,
suit
enum
(
'hearts'
,
'clubs'
,
'spades'
));
>
ok
insert
into
card
(
rank
,
suit
)
values
(
0
,
'clubs'
),
(
3
,
'hearts'
);
>
update
count
:
2
alter
table
card
alter
column
suit
enum
(
'hearts'
,
'clubs'
,
'spades'
,
'diamonds'
);
>
ok
select
*
from
card
;
>
RANK
SUIT
>
---- ------
>
0
clubs
>
3
hearts
select
*
from
card
order
by
suit
;
>
RANK
SUIT
>
---- ------
>
3
hearts
>
0
clubs
insert
into
card
(
rank
,
suit
)
values
(
8
,
'diamonds'
),
(
10
,
'clubs'
),
(
7
,
'hearts'
);
>
update
count
:
3
select
suit
,
count
(
rank
)
from
card
group
by
suit
order
by
suit
,
count
(
rank
);
>
SUIT
COUNT
(
RANK
)
>
-------- -----------
>
hearts
2
>
clubs
2
>
diamonds
1
select
rank
from
card
where
suit
=
'diamonds'
;
>
RANK
>
----
>
8
--- ENUM integer-based operations
select
rank
from
card
where
suit
=
1
;
>
RANK
>
----
>
0
>
10
insert
into
card
(
rank
,
suit
)
values
(
5
,
2
);
>
update
count
:
1
select
*
from
card
where
rank
=
5
;
>
RANK
SUIT
>
---- ------
>
5
spades
--- ENUM edge cases
insert
into
card
(
rank
,
suit
)
values
(
6
,
' '
);
>
exception
alter
table
card
alter
column
suit
enum
(
'hearts'
,
'clubs'
,
'spades'
,
'diamonds'
,
'clubs'
);
>
exception
alter
table
card
alter
column
suit
enum
(
'hearts'
,
'clubs'
,
'spades'
,
'diamonds'
,
''
);
>
exception
drop
table
card
;
>
ok
--- ENUM as custom user data type
create
type
CARD_SUIT
as
enum
(
'hearts'
,
'clubs'
,
'spades'
,
'diamonds'
);
>
ok
create
table
card
(
rank
int
,
suit
CARD_SUIT
);
>
ok
insert
into
card
(
rank
,
suit
)
values
(
0
,
'clubs'
),
(
3
,
'hearts'
);
>
update
count
:
2
select
*
from
card
;
>
RANK
SUIT
>
---- ------
>
0
clubs
>
3
hearts
drop
table
card
;
>
ok
drop
type
CARD_SUIT
;
>
ok
--- ENUM in primary key with another column
create
type
CARD_SUIT
as
enum
(
'hearts'
,
'clubs'
,
'spades'
,
'diamonds'
);
>
ok
create
table
card
(
rank
int
,
suit
CARD_SUIT
,
primary
key
(
rank
,
suit
));
>
ok
insert
into
card
(
rank
,
suit
)
values
(
0
,
'clubs'
),
(
3
,
'hearts'
),
(
1
,
'clubs'
);
>
update
count
:
3
insert
into
card
(
rank
,
suit
)
values
(
0
,
'clubs'
);
>
exception
select
rank
from
card
where
suit
=
'clubs'
;
>
RANK
>
----
>
0
>
1
drop
table
card
;
>
ok
drop
type
CARD_SUIT
;
>
ok
--- ENUM with index
create
type
CARD_SUIT
as
enum
(
'hearts'
,
'clubs'
,
'spades'
,
'diamonds'
);
>
ok
create
table
card
(
rank
int
,
suit
CARD_SUIT
,
primary
key
(
rank
,
suit
));
>
ok
insert
into
card
(
rank
,
suit
)
values
(
0
,
'clubs'
),
(
3
,
'hearts'
),
(
1
,
'clubs'
);
>
update
count
:
3
create
index
idx_card_suite
on
card
(
`suit`
);
select
rank
from
card
where
suit
=
'clubs'
;
>
RANK
>
----
>
0
>
1
select
rank
from
card
where
suit
in
(
'clubs'
);
>
RANK
>
----
>
0
>
1
drop
table
card
;
>
ok
drop
type
CARD_SUIT
;
>
ok
----- Issue#493 -----
create
table
test
(
year
int
,
action
varchar
(
10
));
>
ok
...
...
@@ -10762,15 +10612,3 @@ select * from test where year in (select distinct year from test order by year d
drop
table
test
;
>
ok
----- Issue#600 -----
create
table
test
as
(
select
char
(
x
)
as
str
from
system_range
(
48
,
90
));
>
ok
select
row_number
()
over
()
as
rnum
,
str
from
test
where
str
=
'A'
;
>
RNUM
STR
>
---- ---
>
1
A
drop
table
test
;
>
ok
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论