Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
3e77d2fb
提交
3e77d2fb
authored
6月 05, 2017
作者:
Noel Grandin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
couple of cleanups to the CTE merge
上级
5a428e25
显示空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
114 行增加
和
114 行删除
+114
-114
changelog.html
h2/src/docsrc/html/changelog.html
+2
-0
Parser.java
h2/src/main/org/h2/command/Parser.java
+88
-87
TableView.java
h2/src/main/org/h2/table/TableView.java
+24
-27
没有找到文件。
h2/src/docsrc/html/changelog.html
浏览文件 @
3e77d2fb
...
@@ -21,6 +21,8 @@ Change Log
...
@@ -21,6 +21,8 @@ Change Log
<h2>
Next Version (unreleased)
</h2>
<h2>
Next Version (unreleased)
</h2>
<ul>
<ul>
<li>
Issue#479 Allow non-recursive CTEs (WITH statements), patch from stumc
</li>
<li>
Fix startup issue when using "CHECK" as a column name.
<li>
Fix startup issue when using "CHECK" as a column name.
</li>
</li>
<li>
Issue #423: ANALYZE performed multiple times on one table during execution of the same statement.
<li>
Issue #423: ANALYZE performed multiple times on one table during execution of the same statement.
...
...
h2/src/main/org/h2/command/Parser.java
浏览文件 @
3e77d2fb
...
@@ -18,7 +18,6 @@ import java.util.Comparator;
...
@@ -18,7 +18,6 @@ import java.util.Comparator;
import
java.util.HashSet
;
import
java.util.HashSet
;
import
java.util.LinkedHashSet
;
import
java.util.LinkedHashSet
;
import
java.util.List
;
import
java.util.List
;
import
org.h2.api.ErrorCode
;
import
org.h2.api.ErrorCode
;
import
org.h2.api.Trigger
;
import
org.h2.api.Trigger
;
import
org.h2.command.ddl.AlterIndexRename
;
import
org.h2.command.ddl.AlterIndexRename
;
...
@@ -4859,9 +4858,9 @@ public class Parser {
...
@@ -4859,9 +4858,9 @@ public class Parser {
private
Query
parseWith
()
{
private
Query
parseWith
()
{
List
<
TableView
>
viewsCreated
=
new
ArrayList
<
TableView
>();
List
<
TableView
>
viewsCreated
=
new
ArrayList
<
TableView
>();
readIf
(
"RECURSIVE"
);
readIf
(
"RECURSIVE"
);
do
{
do
{
viewsCreated
.
add
(
parseSingleCommonTableExpression
());
viewsCreated
.
add
(
parseSingleCommonTableExpression
());
}
while
(
readIf
(
","
));
}
while
(
readIf
(
","
));
Query
q
=
parseSelectUnion
();
Query
q
=
parseSelectUnion
();
q
.
setPrepareAlways
(
true
);
q
.
setPrepareAlways
(
true
);
...
@@ -4877,10 +4876,11 @@ public class Parser {
...
@@ -4877,10 +4876,11 @@ public class Parser {
// column names are now optional - they can be inferred from the named
// column names are now optional - they can be inferred from the named
// query if not supplied
// query if not supplied
if
(
readIf
(
"("
))
{
if
(
readIf
(
"("
))
{
cols
=
parseColumnList
();
cols
=
parseColumnList
();
for
(
String
c
:
cols
)
{
for
(
String
c
:
cols
)
{
// we dont really know the type of the column, so string will have to do
// we dont really know the type of the column, so string will
// have to do
columns
.
add
(
new
Column
(
c
,
Value
.
STRING
));
columns
.
add
(
new
Column
(
c
,
Value
.
STRING
));
}
}
}
}
...
@@ -4898,7 +4898,8 @@ public class Parser {
...
@@ -4898,7 +4898,8 @@ public class Parser {
session
.
removeLocalTempTable
(
old
);
session
.
removeLocalTempTable
(
old
);
}
}
// this table is created as a work around because recursive
// this table is created as a work around because recursive
// table expressions need to reference something that look like themselves
// table expressions need to reference something that look like
// themselves
// to work (its removed after creation in this method)
// to work (its removed after creation in this method)
CreateTableData
data
=
new
CreateTableData
();
CreateTableData
data
=
new
CreateTableData
();
data
.
id
=
database
.
allocateObjectId
();
data
.
id
=
database
.
allocateObjectId
();
...
@@ -4922,26 +4923,26 @@ public class Parser {
...
@@ -4922,26 +4923,26 @@ public class Parser {
querySQL
=
StringUtils
.
cache
(
withQuery
.
getPlanSQL
());
querySQL
=
StringUtils
.
cache
(
withQuery
.
getPlanSQL
());
ArrayList
<
Expression
>
withExpressions
=
withQuery
.
getExpressions
();
ArrayList
<
Expression
>
withExpressions
=
withQuery
.
getExpressions
();
for
(
int
i
=
0
;
i
<
withExpressions
.
size
();
++
i
)
{
for
(
int
i
=
0
;
i
<
withExpressions
.
size
();
++
i
)
{
String
columnName
=
cols
!=
null
?
cols
[
i
]
:
withExpressions
.
get
(
i
).
getColumnName
();
String
columnName
=
cols
!=
null
?
cols
[
i
]
columnTemplateList
.
add
(
new
Column
(
columnName
,
withExpressions
.
get
(
i
).
getType
()));
:
withExpressions
.
get
(
i
).
getColumnName
();
columnTemplateList
.
add
(
new
Column
(
columnName
,
withExpressions
.
get
(
i
).
getType
()));
}
}
}
finally
{
}
finally
{
session
.
removeLocalTempTable
(
recursiveTable
);
session
.
removeLocalTempTable
(
recursiveTable
);
}
}
int
id
=
database
.
allocateObjectId
();
int
id
=
database
.
allocateObjectId
();
boolean
isRecursive
=
true
;
// No easy way to determine if this is a recursive query up front, so we just compile
TableView
view
=
null
;
// it twice - once without the flag set, and if we didn't see a recursive term,
do
{
// then we just compile it again.
view
=
new
TableView
(
schema
,
id
,
tempViewName
,
querySQL
,
TableView
view
=
new
TableView
(
schema
,
id
,
tempViewName
,
querySQL
,
parameters
,
columnTemplateList
.
toArray
(
new
Column
[
0
]),
session
,
parameters
,
columnTemplateList
.
toArray
(
new
Column
[
0
]),
session
,
isRecursive
);
true
/* recursive */
);
if
(
view
.
isRecursiveQueryDetected
()!=
isRecursive
)
{
if
(!
view
.
isRecursiveQueryDetected
())
{
isRecursive
=
view
.
isRecursiveQueryDetected
();
view
=
new
TableView
(
schema
,
id
,
tempViewName
,
querySQL
,
parameters
,
view
=
null
;
columnTemplateList
.
toArray
(
new
Column
[
0
]),
session
,
continue
;
false
/* recursive */
)
;
}
}
}
while
(
view
==
null
);
view
.
setTableExpression
(
true
);
view
.
setTableExpression
(
true
);
view
.
setTemporary
(
true
);
view
.
setTemporary
(
true
);
session
.
addLocalTempTable
(
view
);
session
.
addLocalTempTable
(
view
);
...
...
h2/src/main/org/h2/table/TableView.java
浏览文件 @
3e77d2fb
...
@@ -205,12 +205,11 @@ public class TableView extends Table {
...
@@ -205,12 +205,11 @@ public class TableView extends Table {
}
catch
(
DbException
e
)
{
}
catch
(
DbException
e
)
{
e
.
addSQL
(
getCreateSQL
());
e
.
addSQL
(
getCreateSQL
());
createException
=
e
;
createException
=
e
;
//
i
f it can't be compiled, then it's a 'zero column table'
//
I
f it can't be compiled, then it's a 'zero column table'
// this avoids problems when creating the view when opening the
// this avoids problems when creating the view when opening the
// database
// database.
// If it can not be compiled - it could also be a recursive common table expression query.
// if it can not be compiled - it could also be a recursive common table expression query
if
(
isRecursiveQueryExceptionDetected
(
createException
))
{
if
(
isRecursiveQueryExceptionDetected
(
createException
)){
this
.
isRecursiveQueryDetected
=
true
;
this
.
isRecursiveQueryDetected
=
true
;
}
}
tables
=
New
.
arrayList
();
tables
=
New
.
arrayList
();
...
@@ -674,25 +673,23 @@ public class TableView extends Table {
...
@@ -674,25 +673,23 @@ public class TableView extends Table {
}
}
/**
/**
* If query recursion is detected (for recursion detection)
* Was query recursion detected during compiling.
* @return is Recursive Query Flag Set
*/
*/
public
boolean
isRecursiveQueryDetected
(){
public
boolean
isRecursiveQueryDetected
()
{
return
isRecursiveQueryDetected
;
return
isRecursiveQueryDetected
;
}
}
/**
/**
* If query an exception indicates query recursion
* Does exception indicate query recursion?
* @return is Recursive Query Exception Detected
*/
*/
private
boolean
isRecursiveQueryExceptionDetected
(
DbException
exception
){
private
boolean
isRecursiveQueryExceptionDetected
(
DbException
exception
)
{
if
(
exception
==
null
)
{
if
(
exception
==
null
)
{
return
false
;
return
false
;
}
}
if
(
exception
.
getErrorCode
()!=
ErrorCode
.
TABLE_OR_VIEW_NOT_FOUND_1
)
{
if
(
exception
.
getErrorCode
()
!=
ErrorCode
.
TABLE_OR_VIEW_NOT_FOUND_1
)
{
return
false
;
return
false
;
}
}
if
(!
exception
.
getMessage
().
contains
(
"\""
+
this
.
getName
()+
"\""
))
{
if
(!
exception
.
getMessage
().
contains
(
"\""
+
this
.
getName
()
+
"\""
))
{
return
false
;
return
false
;
}
}
return
true
;
return
true
;
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论