Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
3e2bf8da
提交
3e2bf8da
authored
9月 27, 2018
作者:
Evgenij Ryazanov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Use rows / rows (ordered) in TestScript
上级
0462af5c
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
35 行增加
和
17 行删除
+35
-17
TestScript.java
h2/src/test/org/h2/test/scripts/TestScript.java
+35
-17
没有找到文件。
h2/src/test/org/h2/test/scripts/TestScript.java
浏览文件 @
3e2bf8da
...
@@ -20,6 +20,7 @@ import java.sql.ResultSet;
...
@@ -20,6 +20,7 @@ import java.sql.ResultSet;
import
java.sql.ResultSetMetaData
;
import
java.sql.ResultSetMetaData
;
import
java.sql.SQLException
;
import
java.sql.SQLException
;
import
java.sql.Statement
;
import
java.sql.Statement
;
import
java.util.ArrayDeque
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.Map
;
...
@@ -53,7 +54,7 @@ public class TestScript extends TestDb {
...
@@ -53,7 +54,7 @@ public class TestScript extends TestDb {
private
LineNumberReader
in
;
private
LineNumberReader
in
;
private
PrintStream
out
;
private
PrintStream
out
;
private
final
ArrayList
<
String
[]>
result
=
new
ArrayList
<>();
private
final
ArrayList
<
String
[]>
result
=
new
ArrayList
<>();
private
String
putBack
;
private
final
ArrayDeque
<
String
>
putBack
=
new
ArrayDeque
<>()
;
private
StringBuilder
errors
;
private
StringBuilder
errors
;
private
Random
random
=
new
Random
(
1
);
private
Random
random
=
new
Random
(
1
);
...
@@ -199,7 +200,7 @@ public class TestScript extends TestDb {
...
@@ -199,7 +200,7 @@ public class TestScript extends TestDb {
in
=
null
;
in
=
null
;
out
=
null
;
out
=
null
;
result
.
clear
();
result
.
clear
();
putBack
=
null
;
putBack
.
clear
()
;
errors
=
null
;
errors
=
null
;
if
(
statements
==
null
)
{
if
(
statements
==
null
)
{
...
@@ -224,16 +225,13 @@ public class TestScript extends TestDb {
...
@@ -224,16 +225,13 @@ public class TestScript extends TestDb {
}
}
private
String
readLine
()
throws
IOException
{
private
String
readLine
()
throws
IOException
{
if
(
putBack
!=
null
)
{
String
s
=
putBack
.
pollFirst
();
String
s
=
putBack
;
return
s
!=
null
?
s
:
readNextLine
();
putBack
=
null
;
}
return
s
;
}
private
String
readNextLine
()
throws
IOException
{
while
(
true
)
{
String
s
;
String
s
=
in
.
readLine
();
while
((
s
=
in
.
readLine
())
!=
null
)
{
if
(
s
==
null
)
{
return
null
;
}
if
(
s
.
startsWith
(
"#"
))
{
if
(
s
.
startsWith
(
"#"
))
{
int
end
=
s
.
indexOf
(
'#'
,
1
);
int
end
=
s
.
indexOf
(
'#'
,
1
);
if
(
end
<
3
)
{
if
(
end
<
3
)
{
...
@@ -265,10 +263,15 @@ public class TestScript extends TestDb {
...
@@ -265,10 +263,15 @@ public class TestScript extends TestDb {
}
}
}
}
s
=
s
.
trim
();
s
=
s
.
trim
();
if
(
s
.
length
()
>
0
)
{
if
(
!
s
.
isEmpty
()
)
{
return
s
;
break
;
}
}
}
}
return
s
;
}
public
void
putBack
(
String
line
)
{
putBack
.
addLast
(
line
);
}
}
private
void
testFile
(
String
inFile
,
boolean
allowReconnect
)
throws
Exception
{
private
void
testFile
(
String
inFile
,
boolean
allowReconnect
)
throws
Exception
{
...
@@ -448,7 +451,6 @@ public class TestScript extends TestDb {
...
@@ -448,7 +451,6 @@ public class TestScript extends TestDb {
}
}
private
void
writeResultSet
(
String
sql
,
ResultSet
rs
)
throws
Exception
{
private
void
writeResultSet
(
String
sql
,
ResultSet
rs
)
throws
Exception
{
boolean
ordered
=
StringUtils
.
toLowerEnglish
(
sql
).
contains
(
"order by"
);
ResultSetMetaData
meta
=
rs
.
getMetaData
();
ResultSetMetaData
meta
=
rs
.
getMetaData
();
int
len
=
meta
.
getColumnCount
();
int
len
=
meta
.
getColumnCount
();
int
[]
max
=
new
int
[
len
];
int
[]
max
=
new
int
[
len
];
...
@@ -474,7 +476,7 @@ public class TestScript extends TestDb {
...
@@ -474,7 +476,7 @@ public class TestScript extends TestDb {
}
}
rs
.
close
();
rs
.
close
();
String
line
=
readLine
();
String
line
=
readLine
();
putBack
=
line
;
putBack
(
line
)
;
if
(
line
!=
null
&&
line
.
startsWith
(
">> "
))
{
if
(
line
!=
null
&&
line
.
startsWith
(
">> "
))
{
switch
(
result
.
size
())
{
switch
(
result
.
size
())
{
case
0
:
case
0
:
...
@@ -493,6 +495,22 @@ public class TestScript extends TestDb {
...
@@ -493,6 +495,22 @@ public class TestScript extends TestDb {
return
;
return
;
}
}
}
}
boolean
ordered
;
for
(;;)
{
line
=
readNextLine
();
if
(
line
==
null
)
{
addWriteResultError
(
"<row count>"
,
"<eof>"
);
return
;
}
putBack
(
line
);
if
(
line
.
startsWith
(
"> rows: "
))
{
ordered
=
false
;
break
;
}
else
if
(
line
.
startsWith
(
"> rows (ordered): "
))
{
ordered
=
true
;
break
;
}
}
writeResult
(
sql
,
format
(
head
,
max
),
null
);
writeResult
(
sql
,
format
(
head
,
max
),
null
);
writeResult
(
sql
,
format
(
null
,
max
),
null
);
writeResult
(
sql
,
format
(
null
,
max
),
null
);
String
[]
array
=
new
String
[
result
.
size
()];
String
[]
array
=
new
String
[
result
.
size
()];
...
@@ -575,7 +593,7 @@ public class TestScript extends TestDb {
...
@@ -575,7 +593,7 @@ public class TestScript extends TestDb {
}
}
}
else
{
}
else
{
addWriteResultError
(
"<nothing>"
,
s
);
addWriteResultError
(
"<nothing>"
,
s
);
putBack
=
compare
;
putBack
(
compare
)
;
}
}
write
(
s
);
write
(
s
);
}
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论