Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
5e0b3cc8
提交
5e0b3cc8
authored
12月 17, 2017
作者:
Owner
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Tried but failed to recreate test case
上级
75f5b528
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
80 行增加
和
12 行删除
+80
-12
Select.java
h2/src/main/org/h2/command/dml/Select.java
+12
-12
TestGeneralCommonTableQueries.java
...rc/test/org/h2/test/db/TestGeneralCommonTableQueries.java
+68
-0
没有找到文件。
h2/src/main/org/h2/command/dml/Select.java
浏览文件 @
5e0b3cc8
...
...
@@ -569,8 +569,8 @@ public class Select extends Query {
}
boolean
lazy
=
session
.
isLazyQueryExecution
()
&&
target
==
null
&&
!
isForUpdate
&&
!
isQuickAggregateQuery
&&
limitRows
!=
0
&&
offsetExpr
==
null
&&
isReadOnly
()
&&
!
hasRecursiveTableView
();
limitRows
!=
0
&&
offsetExpr
==
null
&&
isReadOnly
()
/*
&&
!hasRecursiveTableView()
*/
;
int
columnCount
=
expressions
.
size
();
LocalResult
result
=
null
;
if
(!
lazy
&&
(
target
==
null
||
...
...
@@ -664,16 +664,16 @@ public class Select extends Query {
return
null
;
}
private
boolean
hasRecursiveTableView
()
{
//check the top table filter only to see if we have a recursive table query
if
(
this
.
topTableFilter
.
getTable
().
isTableExpression
()){
TableView
v
=
(
TableView
)
this
.
topTableFilter
.
getTable
();
if
(
v
.
isRecursive
()){
return
true
;
}
}
return
false
;
}
//
private boolean hasRecursiveTableView() {
//
//check the top table filter only to see if we have a recursive table query
////
if(this.topTableFilter.getTable().isTableExpression()){
////
TableView v = (TableView)this.topTableFilter.getTable();
////
if(v.isRecursive()){
////
return true;
////
}
////
}
//
return false;
//
}
private
void
resetJoinBatchAfterQuery
()
{
JoinBatch
jb
=
getJoinBatch
();
...
...
h2/src/test/org/h2/test/db/TestGeneralCommonTableQueries.java
浏览文件 @
5e0b3cc8
...
...
@@ -10,6 +10,7 @@ import java.sql.PreparedStatement;
import
java.sql.ResultSet
;
import
java.sql.Statement
;
import
org.h2.jdbc.JdbcSQLException
;
import
org.h2.test.TestAll
;
import
org.h2.test.TestBase
;
/**
...
...
@@ -43,6 +44,7 @@ public class TestGeneralCommonTableQueries extends AbstractBaseForCommonTableExp
testNestedSQL
();
testSimple4RowRecursiveQuery
();
testSimple2By4RowRecursiveQuery
();
testSimple4RowRecursiveQueryWithLazy
();
}
private
void
testSimpleSelect
()
throws
Exception
{
...
...
@@ -510,4 +512,70 @@ public class TestGeneralCommonTableQueries extends AbstractBaseForCommonTableExp
WITH_QUERY
,
maxRetries
-
1
,
expectedColumnTypes
);
}
/*
Caused by: java.lang.StackOverflowError
at org.h2.result.LazyResult.reset(LazyResult.java:43)
at org.h2.command.dml.Select$LazyResultSelect.reset(Select.java:1464)
at org.h2.index.ViewIndex.findRecursive(ViewIndex.java:187)
at org.h2.index.ViewIndex.find(ViewIndex.java:284)
at org.h2.index.ViewIndex.find(ViewIndex.java:161)
at org.h2.index.BaseIndex.find(BaseIndex.java:127)
at org.h2.index.IndexCursor.find(IndexCursor.java:169)
at org.h2.table.TableFilter.next(TableFilter.java:468)
at org.h2.command.dml.Select$LazyResultQueryFlat.fetchNextRow(Select.java:1487)
at org.h2.result.LazyResult.hasNext(LazyResult.java:79)
at org.h2.result.LazyResult.next(LazyResult.java:59)
at org.h2.index.ViewCursor.next(ViewCursor.java:49)
at org.h2.index.IndexCursor.next(IndexCursor.java:309)
at org.h2.table.TableFilter.next(TableFilter.java:499)
at org.h2.command.dml.Select$LazyResultQueryFlat.fetchNextRow(Select.java:1487)
at org.h2.result.LazyResult.hasNext(LazyResult.java:79)
at org.h2.result.LazyResult.next(LazyResult.java:59)
at org.h2.index.ViewCursor.next(ViewCursor.java:49)
at org.h2.index.IndexCursor.next(IndexCursor.java:309)
at org.h2.table.TableFilter.next(TableFilter.java:499)
at org.h2.command.dml.Select$LazyResultQueryFlat.fetchNextRow(Select.java:1487)
*/
private
void
testSimple4RowRecursiveQueryWithLazy
()
throws
Exception
{
String
[]
expectedRowData
=
new
String
[]{
"|1"
,
"|2"
,
"|3"
};
String
[]
expectedColumnTypes
=
new
String
[]{
"INTEGER"
};
String
[]
expectedColumnNames
=
new
String
[]{
"N"
};
// back up the config - to restore it after this test
TestAll
backupConfig
=
config
;
config
=
new
TestAll
();
try
{
//Test with settings: lazy mvStore memory mvcc multiThreaded
// url=mem:script;MV_STORE=true;LOG=1;LOCK_TIMEOUT=50;MVCC=TRUE;MULTI_THREADED=TRUE;LAZY_QUERY_EXECUTION=1
config
.
lazy
=
true
;
config
.
mvStore
=
true
;
config
.
memory
=
true
;
config
.
mvcc
=
true
;
config
.
multiThreaded
=
true
;
String
SETUP_SQL
=
"--no config set"
;
String
WITH_QUERY
=
"with recursive r(n) as (\n"
+
"(select 1) union all (select n+1 from r where n < 3)\n"
+
")\n"
+
"select n from r"
;
int
maxRetries
=
10
;
int
expectedNumberOfRows
=
expectedRowData
.
length
;
//System.out.println();
//System.out.println("Test " + config.toString() +
// " (" + Utils.getMemoryUsed() + " KB used)");
testRepeatedQueryWithSetup
(
maxRetries
,
expectedRowData
,
expectedColumnNames
,
expectedNumberOfRows
,
SETUP_SQL
,
WITH_QUERY
,
maxRetries
-
1
,
expectedColumnTypes
);
}
finally
{
config
=
backupConfig
;
}
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论