Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
005714ec
提交
005714ec
authored
11月 26, 2017
作者:
Owner
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fixed SQL plan test errors for with statement
上级
b04995eb
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
33 行增加
和
53 行删除
+33
-53
Parser.java
h2/src/main/org/h2/command/Parser.java
+2
-2
CreateView.java
h2/src/main/org/h2/command/ddl/CreateView.java
+1
-1
Select.java
h2/src/main/org/h2/command/dml/Select.java
+15
-41
TableView.java
h2/src/main/org/h2/table/TableView.java
+15
-9
没有找到文件。
h2/src/main/org/h2/command/Parser.java
浏览文件 @
005714ec
...
@@ -5389,7 +5389,7 @@ public class Parser {
...
@@ -5389,7 +5389,7 @@ public class Parser {
synchronized
(
targetSession
){
synchronized
(
targetSession
){
view
=
new
TableView
(
schema
,
id
,
cteViewName
,
querySQL
,
view
=
new
TableView
(
schema
,
id
,
cteViewName
,
querySQL
,
parameters
,
columnTemplateArray
,
targetSession
,
parameters
,
columnTemplateArray
,
targetSession
,
allowRecursiveQueryDetection
,
false
/* literalsChecked */
,
true
/* isTableExpression */
);
allowRecursiveQueryDetection
,
false
/* literalsChecked */
,
true
/* isTableExpression */
,
isPersistent
);
if
(!
view
.
isRecursiveQueryDetected
()
&&
allowRecursiveQueryDetection
)
{
if
(!
view
.
isRecursiveQueryDetected
()
&&
allowRecursiveQueryDetection
)
{
if
(
isPersistent
){
if
(
isPersistent
){
db
.
addSchemaObject
(
targetSession
,
view
);
db
.
addSchemaObject
(
targetSession
,
view
);
...
@@ -5400,7 +5400,7 @@ public class Parser {
...
@@ -5400,7 +5400,7 @@ public class Parser {
}
}
view
=
new
TableView
(
schema
,
id
,
cteViewName
,
querySQL
,
parameters
,
view
=
new
TableView
(
schema
,
id
,
cteViewName
,
querySQL
,
parameters
,
columnTemplateArray
,
targetSession
,
columnTemplateArray
,
targetSession
,
false
/* assume recursive */
,
false
/* literalsChecked */
,
true
/* isTableExpression */
);
false
/* assume recursive */
,
false
/* literalsChecked */
,
true
/* isTableExpression */
,
isPersistent
);
}
}
}
}
view
.
setTableExpression
(
true
);
view
.
setTableExpression
(
true
);
...
...
h2/src/main/org/h2/command/ddl/CreateView.java
浏览文件 @
005714ec
...
@@ -116,7 +116,7 @@ public class CreateView extends SchemaCommand {
...
@@ -116,7 +116,7 @@ public class CreateView extends SchemaCommand {
}
}
else
else
{
{
view
=
new
TableView
(
getSchema
(),
id
,
viewName
,
querySQL
,
null
,
columnTemplates
,
session
,
false
/* allow recursive */
,
false
/* literalsChecked */
,
isTableExpression
);
view
=
new
TableView
(
getSchema
(),
id
,
viewName
,
querySQL
,
null
,
columnTemplates
,
session
,
false
/* allow recursive */
,
false
/* literalsChecked */
,
isTableExpression
,
true
);
}
}
}
else
{
}
else
{
// TODO support isTableExpression in replace function...
// TODO support isTableExpression in replace function...
...
...
h2/src/main/org/h2/command/dml/Select.java
浏览文件 @
005714ec
...
@@ -1086,47 +1086,21 @@ public class Select extends Query {
...
@@ -1086,47 +1086,21 @@ public class Select extends Query {
StatementBuilder
buff
=
new
StatementBuilder
();
StatementBuilder
buff
=
new
StatementBuilder
();
for
(
TableFilter
f
:
topFilters
)
{
for
(
TableFilter
f
:
topFilters
)
{
Table
t
=
f
.
getTable
();
Table
t
=
f
.
getTable
();
if
(
t
.
isView
()
&&
((
TableView
)
t
).
isRecursive
())
{
TableView
tableView
=
(
t
instanceof
TableView
)
?
(
TableView
)
t
:
null
;
continue
;
if
(
tableView
!=
null
&&
tableView
.
isView
()
&&
tableView
.
isRecursive
()
&&
tableView
.
isTableExpression
())
{
// boolean isPersistent = !t.isTemporary();
// // hmmm - how do you generate a plan sql which is recursive
if
(
tableView
.
isPersistent
()){
// // for a system which does not natively support recursive SQLs... ?
continue
;
// // answer: you can't
}
// TableView tv = ((TableView) t);
else
{
// buff.append("WITH ");
buff
.
append
(
"WITH RECURSIVE "
).
append
(
t
.
getName
()).
append
(
'('
);
// if(tv.isRecursive()){
buff
.
resetCount
();
// buff.append("RECURSIVE ");
for
(
Column
c
:
t
.
getColumns
())
{
// }
buff
.
appendExceptFirst
(
","
);
// if(isPersistent){
buff
.
append
(
c
.
getName
());
// buff.append("PERSISTENT ");
}
// }
buff
.
append
(
") AS "
).
append
(
t
.
getSQL
()).
append
(
"\n"
);
// buff.append(t.getName()).append('(');
}
// buff.resetCount();
// for (Column c : t.getColumns()) {
// buff.appendExceptFirst(",");
// buff.append(c.getName());
// }
// String theSQL = t.getSQL();
// System.out.println("getPlanSQL.theSQL="+theSQL);
// System.out.println("getPlanSQL.sqlStatement="+sqlStatement);
// if(!sqlStatement.contains("?") && sqlStatement.toUpperCase().contains("SELECT") && session.isParsingView()){
// theSQL = extractNamedCTEQueryFromSQL(t.getName(),sqlStatement);
// if(!(theSQL.startsWith("(")&&theSQL.endsWith(")"))){
// theSQL = "( "+theSQL+" )";
// }
// }
// else if(!(theSQL.startsWith("(")&&theSQL.endsWith(")"))){
// StatementBuilder buffSelect = new StatementBuilder();
// buffSelect.append("( SELECT ");
// buffSelect.resetCount();
// for (Column c : t.getColumns()) {
// buffSelect.appendExceptFirst(",");
// buffSelect.append(c.getName());
// }
// buffSelect.append(" FROM "+t.getSQL()+" ) ");
// theSQL = buffSelect.toString();
// }
// buff.append(") AS ").append(theSQL).append("\n");
}
}
}
}
buff
.
resetCount
();
buff
.
resetCount
();
...
...
h2/src/main/org/h2/table/TableView.java
浏览文件 @
005714ec
...
@@ -60,13 +60,13 @@ public class TableView extends Table {
...
@@ -60,13 +60,13 @@ public class TableView extends Table {
private
ResultInterface
recursiveResult
;
private
ResultInterface
recursiveResult
;
private
boolean
isRecursiveQueryDetected
;
private
boolean
isRecursiveQueryDetected
;
private
boolean
isTableExpression
;
private
boolean
isTableExpression
;
// private Session session
;
private
boolean
isPersistent
;
public
TableView
(
Schema
schema
,
int
id
,
String
name
,
String
querySQL
,
public
TableView
(
Schema
schema
,
int
id
,
String
name
,
String
querySQL
,
ArrayList
<
Parameter
>
params
,
Column
[]
columnTemplates
,
Session
session
,
ArrayList
<
Parameter
>
params
,
Column
[]
columnTemplates
,
Session
session
,
boolean
allowRecursive
,
boolean
literalsChecked
,
boolean
isTableExpression
)
{
boolean
allowRecursive
,
boolean
literalsChecked
,
boolean
isTableExpression
,
boolean
isPersistent
)
{
super
(
schema
,
id
,
name
,
false
,
true
);
super
(
schema
,
id
,
name
,
false
,
true
);
init
(
querySQL
,
params
,
columnTemplates
,
session
,
allowRecursive
,
literalsChecked
,
isTableExpression
);
init
(
querySQL
,
params
,
columnTemplates
,
session
,
allowRecursive
,
literalsChecked
,
isTableExpression
,
isPersistent
);
}
}
/**
/**
...
@@ -86,23 +86,25 @@ public class TableView extends Table {
...
@@ -86,23 +86,25 @@ public class TableView extends Table {
init
(
querySQL
,
null
,
init
(
querySQL
,
null
,
newColumnTemplates
==
null
?
this
.
columnTemplates
newColumnTemplates
==
null
?
this
.
columnTemplates
:
newColumnTemplates
,
:
newColumnTemplates
,
session
,
recursive
,
literalsChecked
,
isTableExpression
);
session
,
recursive
,
literalsChecked
,
isTableExpression
,
isPersistent
);
DbException
e
=
recompile
(
session
,
force
,
true
);
DbException
e
=
recompile
(
session
,
force
,
true
);
if
(
e
!=
null
)
{
if
(
e
!=
null
)
{
init
(
oldQuerySQL
,
null
,
oldColumnTemplates
,
session
,
oldRecursive
,
init
(
oldQuerySQL
,
null
,
oldColumnTemplates
,
session
,
oldRecursive
,
literalsChecked
,
isTableExpression
);
literalsChecked
,
isTableExpression
,
isPersistent
);
recompile
(
session
,
true
,
false
);
recompile
(
session
,
true
,
false
);
throw
e
;
throw
e
;
}
}
}
}
private
synchronized
void
init
(
String
querySQL
,
ArrayList
<
Parameter
>
params
,
private
synchronized
void
init
(
String
querySQL
,
ArrayList
<
Parameter
>
params
,
Column
[]
columnTemplates
,
Session
session
,
boolean
allowRecursive
,
boolean
literalsChecked
,
boolean
isTableExpression
)
{
Column
[]
columnTemplates
,
Session
session
,
boolean
allowRecursive
,
boolean
literalsChecked
,
boolean
isTableExpression
,
boolean
isPersistent
)
{
this
.
querySQL
=
querySQL
;
this
.
querySQL
=
querySQL
;
this
.
columnTemplates
=
columnTemplates
;
this
.
columnTemplates
=
columnTemplates
;
this
.
allowRecursive
=
allowRecursive
;
this
.
allowRecursive
=
allowRecursive
;
this
.
isRecursiveQueryDetected
=
false
;
this
.
isRecursiveQueryDetected
=
false
;
this
.
isTableExpression
=
isTableExpression
;
this
.
isTableExpression
=
isTableExpression
;
this
.
isPersistent
=
isPersistent
;
//this.session = session;
//this.session = session;
index
=
new
ViewIndex
(
this
,
querySQL
,
params
,
allowRecursive
);
index
=
new
ViewIndex
(
this
,
querySQL
,
params
,
allowRecursive
);
initColumnsAndTables
(
session
,
literalsChecked
);
initColumnsAndTables
(
session
,
literalsChecked
);
...
@@ -550,7 +552,7 @@ public class TableView extends Table {
...
@@ -550,7 +552,7 @@ public class TableView extends Table {
String
querySQL
=
query
.
getPlanSQL
();
String
querySQL
=
query
.
getPlanSQL
();
TableView
v
=
new
TableView
(
mainSchema
,
0
,
name
,
TableView
v
=
new
TableView
(
mainSchema
,
0
,
name
,
querySQL
,
query
.
getParameters
(),
null
,
session
,
querySQL
,
query
.
getParameters
(),
null
,
session
,
false
,
true
/* literals have already been checked when parsing original query */
,
false
);
false
,
true
/* literals have already been checked when parsing original query */
,
false
,
false
/* is persistent*/
);
if
(
v
.
createException
!=
null
)
{
if
(
v
.
createException
!=
null
)
{
throw
v
.
createException
;
throw
v
.
createException
;
}
}
...
@@ -712,7 +714,7 @@ public class TableView extends Table {
...
@@ -712,7 +714,7 @@ public class TableView extends Table {
TableView
view
=
new
TableView
(
schema
,
id
,
name
,
querySQL
,
TableView
view
=
new
TableView
(
schema
,
id
,
name
,
querySQL
,
parameters
,
columnTemplates
,
session
,
parameters
,
columnTemplates
,
session
,
true
/* try recursive */
,
literalsChecked
,
isTableExpression
);
true
/* try recursive */
,
literalsChecked
,
isTableExpression
,
isPersistent
);
//System.out.println("create recursive view:"+view);
//System.out.println("create recursive view:"+view);
//if(shadowTable!=null){
//if(shadowTable!=null){
...
@@ -734,10 +736,14 @@ public class TableView extends Table {
...
@@ -734,10 +736,14 @@ public class TableView extends Table {
}
}
view
=
new
TableView
(
schema
,
id
,
name
,
querySQL
,
parameters
,
view
=
new
TableView
(
schema
,
id
,
name
,
querySQL
,
parameters
,
columnTemplates
,
session
,
columnTemplates
,
session
,
false
/* detected not recursive */
,
literalsChecked
,
isTableExpression
);
false
/* detected not recursive */
,
literalsChecked
,
isTableExpression
,
isPersistent
);
//System.out.println("create nr view:"+view);
//System.out.println("create nr view:"+view);
}
}
return
view
;
return
view
;
}
}
public
boolean
isPersistent
()
{
return
isPersistent
;
}
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论