Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
b24cbdf5
提交
b24cbdf5
authored
11月 10, 2015
作者:
S.Vladykin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
more tests and fixes
上级
9ad1ffae
显示空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
52 行增加
和
13 行删除
+52
-13
Parser.java
h2/src/main/org/h2/command/Parser.java
+8
-2
ViewIndex.java
h2/src/main/org/h2/index/ViewIndex.java
+6
-2
TestTableEngines.java
h2/src/test/org/h2/test/db/TestTableEngines.java
+38
-9
没有找到文件。
h2/src/main/org/h2/command/Parser.java
浏览文件 @
b24cbdf5
...
...
@@ -4729,8 +4729,14 @@ public class Parser {
.
substring
(
parseIndex
));
read
(
"AS"
);
try
{
Query
query
=
parseSelect
();
Query
query
;
session
.
setParsingView
(
true
);
try
{
query
=
parseSelect
();
query
.
prepare
();
}
finally
{
session
.
setParsingView
(
false
);
}
command
.
setSelect
(
query
);
}
catch
(
DbException
e
)
{
if
(
force
)
{
...
...
h2/src/main/org/h2/index/ViewIndex.java
浏览文件 @
b24cbdf5
...
...
@@ -88,7 +88,7 @@ public class ViewIndex extends BaseIndex implements SpatialIndex {
this
.
indexMasks
=
masks
;
this
.
createSession
=
session
;
columns
=
new
Column
[
0
];
if
(!
recursive
)
{
if
(!
recursive
&&
filters
!=
null
)
{
query
=
getQuery
(
session
,
masks
,
filters
,
filter
,
sortOrder
);
}
}
...
...
@@ -136,7 +136,7 @@ public class ViewIndex extends BaseIndex implements SpatialIndex {
@Override
public
synchronized
double
getCost
(
Session
session
,
int
[]
masks
,
TableFilter
[]
filters
,
int
filter
,
SortOrder
sortOrder
)
{
if
(
recursive
)
{
if
(
recursive
||
filters
==
null
)
{
return
1000
;
}
IntArray
masksArray
=
new
IntArray
(
masks
==
null
?
...
...
@@ -177,6 +177,10 @@ public class ViewIndex extends BaseIndex implements SpatialIndex {
String
sql
=
q
.
getPlanSQL
();
q
=
prepareSubQuery
(
sql
,
session
,
masks
,
filters
,
filter
,
sortOrder
,
false
);
}
if
(
query
==
null
)
{
// this is possible when scan index has been taken and the cost was recalculated
query
=
q
;
}
double
cost
=
q
.
getCost
();
cachedCost
=
new
CostElement
();
cachedCost
.
evaluatedAt
=
System
.
currentTimeMillis
();
...
...
h2/src/test/org/h2/test/db/TestTableEngines.java
浏览文件 @
b24cbdf5
...
...
@@ -41,6 +41,7 @@ import org.h2.result.Row;
import
org.h2.result.SearchRow
;
import
org.h2.result.SortOrder
;
import
org.h2.table.IndexColumn
;
import
org.h2.table.SubQueryInfo
;
import
org.h2.table.Table
;
import
org.h2.table.TableBase
;
import
org.h2.table.TableFilter
;
...
...
@@ -350,11 +351,20 @@ public class TestTableEngines extends TestBase {
Statement
stat
=
conn
.
createStatement
();
stat
.
execute
(
"create table SUB_QUERY_TEST(id int primary key, name varchar) ENGINE \""
+
TreeSetIndexTableEngine
.
class
.
getName
()
+
"\""
);
stat
.
execute
(
"create table t1(id int, birthday date)"
);
stat
.
executeQuery
(
"select t1.birthday from t1, "
+
"(select t2.id from sub_query_test t2, "
+
"(select t3.id from sub_query_test t3 where t3.name = '') t4 "
+
"where t2.id = t4.id) t5 where t1.id = t5.id"
);
// test sub-queries
stat
.
executeQuery
(
"select * from "
+
"(select t2.id from "
+
"(select t3.id from sub_query_test t3 where t3.name = '') t4, "
+
"sub_query_test t2 "
+
"where t2.id = t4.id) t5"
).
next
();
// test view 1
stat
.
execute
(
"create view t4 as (select t3.id from sub_query_test t3 where t3.name = '')"
);
stat
.
executeQuery
(
"select * from "
+
"(select t2.id from t4, sub_query_test t2 where t2.id = t4.id) t5"
).
next
();
// test view 2
stat
.
execute
(
"create view t5 as "
+
"(select t2.id from t4, sub_query_test t2 where t2.id = t4.id)"
);
stat
.
executeQuery
(
"select * from t5"
).
next
();
deleteDb
(
"testSubQueryInfo"
);
}
...
...
@@ -478,6 +488,12 @@ public class TestTableEngines extends TestBase {
}
}
private
static
void
assert0
(
boolean
condition
,
String
message
)
{
if
(!
condition
)
{
throw
new
AssertionError
(
message
);
}
}
private
static
void
setBatchSize
(
ArrayList
<
TreeSetTable
>
tables
,
int
...
batchSizes
)
{
for
(
int
i
=
0
;
i
<
batchSizes
.
length
;
i
++)
{
int
batchSize
=
batchSizes
[
i
];
...
...
@@ -1219,13 +1235,26 @@ public class TestTableEngines extends TestBase {
return
new
IteratorCursor
(
subSet
.
iterator
());
}
private
void
checkInfo
(
SubQueryInfo
info
)
{
if
(
info
.
getUpper
()
==
null
)
{
// check 1st level info
assert0
(
info
.
getFilters
().
length
==
1
,
"getFilters().length "
+
info
.
getFilters
().
length
);
String
alias
=
info
.
getFilters
()[
info
.
getFilter
()].
getTableAlias
();
assert0
(
"T5"
.
equals
(
alias
),
"alias: "
+
alias
);
}
else
{
// check 2nd level info
assert0
(
info
.
getFilters
().
length
==
2
,
"getFilters().length "
+
info
.
getFilters
().
length
);
String
alias
=
info
.
getFilters
()[
info
.
getFilter
()].
getTableAlias
();
assert0
(
"T4"
.
equals
(
alias
),
"alias: "
+
alias
);
checkInfo
(
info
.
getUpper
());
}
}
@Override
public
double
getCost
(
Session
session
,
int
[]
masks
,
TableFilter
[]
filters
,
int
filter
,
SortOrder
sortOrder
)
{
if
(
getTable
().
getName
().
equals
(
"SUB_QUERY_TEST"
))
{
if
(
session
.
getSubQueryInfo
()
==
null
)
{
throw
new
IllegalStateException
(
"No qubquery info found."
);
}
checkInfo
(
session
.
getSubQueryInfo
());
}
return
getCostRangeIndex
(
masks
,
set
.
size
(),
filters
,
filter
,
sortOrder
);
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论