Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
d1ca8df3
提交
d1ca8df3
authored
12月 01, 2017
作者:
Owner
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Code review feedback from grandinj
上级
bf03bc6d
隐藏空白字符变更
内嵌
并排
正在显示
7 个修改的文件
包含
29 行增加
和
30 行删除
+29
-30
Parser.java
h2/src/main/org/h2/command/Parser.java
+17
-15
DropView.java
h2/src/main/org/h2/command/ddl/DropView.java
+2
-1
Select.java
h2/src/main/org/h2/command/dml/Select.java
+2
-2
Database.java
h2/src/main/org/h2/engine/Database.java
+0
-2
Session.java
h2/src/main/org/h2/engine/Session.java
+5
-8
Table.java
h2/src/main/org/h2/table/Table.java
+1
-0
TableView.java
h2/src/main/org/h2/table/TableView.java
+2
-2
没有找到文件。
h2/src/main/org/h2/command/Parser.java
浏览文件 @
d1ca8df3
...
...
@@ -5167,9 +5167,8 @@ public class Parser {
// this WITH statement is not a temporary view - it is part of a persistent view
// as in CREATE VIEW abc AS WITH my_cte - this auto detects that condition
if
(
session
.
isParsingView
()){
if
(
session
.
isParsing
Create
View
()){
isPersistent
=
true
;
System
.
out
.
println
(
"getParsingViewName="
+
session
.
getParsingViewName
());
}
do
{
...
...
@@ -5177,6 +5176,10 @@ public class Parser {
}
while
(
readIf
(
","
));
Prepared
p
=
null
;
// reverse the order of constructed CTE views - as the destruction order
// (since later created view may depend on previously created views -
// we preserve that dependency order in the destruction sequence )
// used in setCteCleanups
Collections
.
reverse
(
viewsCreated
);
if
(
isToken
(
"SELECT"
))
{
...
...
@@ -5224,13 +5227,12 @@ public class Parser {
}
private
TableView
parseSingleCommonTableExpression
(
boolean
isPersistent
)
{
Session
targetSession
=
session
;
String
cteViewName
=
readIdentifierWithSchema
();
Schema
schema
=
getSchema
();
Table
recursiveTable
=
null
;
ArrayList
<
Column
>
columns
=
New
.
arrayList
();
String
[]
cols
=
null
;
Database
db
=
targetS
ession
.
getDatabase
();
Database
db
=
s
ession
.
getDatabase
();
// column names are now optional - they can be inferred from the named
// query, if not supplied by user
...
...
@@ -5245,10 +5247,10 @@ public class Parser {
Table
oldViewFound
=
null
;
if
(
isPersistent
){
oldViewFound
=
getSchema
().
findTableOrView
(
targetS
ession
,
cteViewName
);
oldViewFound
=
getSchema
().
findTableOrView
(
s
ession
,
cteViewName
);
}
else
{
oldViewFound
=
targetS
ession
.
findLocalTempTable
(
cteViewName
);
oldViewFound
=
s
ession
.
findLocalTempTable
(
cteViewName
);
}
// this persistent check conflicts with check 10 lines down
if
(
oldViewFound
!=
null
)
{
...
...
@@ -5262,11 +5264,11 @@ public class Parser {
cteViewName
);
}
if
(
isPersistent
){
oldViewFound
.
lock
(
targetS
ession
,
true
,
true
);
targetSession
.
getDatabase
().
removeSchemaObject
(
targetS
ession
,
oldViewFound
);
oldViewFound
.
lock
(
s
ession
,
true
,
true
);
session
.
getDatabase
().
removeSchemaObject
(
s
ession
,
oldViewFound
);
}
else
{
targetS
ession
.
removeLocalTempTable
(
oldViewFound
);
s
ession
.
removeLocalTempTable
(
oldViewFound
);
}
oldViewFound
=
null
;
}
...
...
@@ -5276,7 +5278,7 @@ public class Parser {
// to work (its removed after creation in this method)
// only create table data and table if we don't have a working CTE already
if
(
oldViewFound
==
null
){
recursiveTable
=
createShadowTableForRecursiveTableExpression
(
isPersistent
,
targetS
ession
,
cteViewName
,
recursiveTable
=
createShadowTableForRecursiveTableExpression
(
isPersistent
,
s
ession
,
cteViewName
,
schema
,
columns
,
db
);
}
List
<
Column
>
columnTemplateList
;
...
...
@@ -5286,20 +5288,20 @@ public class Parser {
read
(
"("
);
Query
withQuery
=
parseSelect
();
if
(
isPersistent
){
withQuery
.
session
=
targetS
ession
;
withQuery
.
session
=
s
ession
;
}
read
(
")"
);
columnTemplateList
=
createQueryColumnTemplateList
(
cols
,
withQuery
,
querySQLOutput
);
}
finally
{
destroyShadowTableForRecursiveExpression
(
isPersistent
,
targetS
ession
,
recursiveTable
);
destroyShadowTableForRecursiveExpression
(
isPersistent
,
s
ession
,
recursiveTable
);
}
TableView
view
=
createCTEView
(
cteViewName
,
querySQLOutput
[
0
],
columnTemplateList
,
true
/* allowRecursiveQueryDetection */
,
true
/* add to session */
,
isPersistent
,
targetS
ession
);
isPersistent
,
s
ession
);
return
view
;
}
...
...
@@ -5452,12 +5454,12 @@ public class Parser {
read
(
"AS"
);
try
{
Query
query
;
session
.
setParsingView
(
true
,
viewName
);
session
.
setParsing
Create
View
(
true
,
viewName
);
try
{
query
=
parseSelect
();
query
.
prepare
();
}
finally
{
session
.
setParsingView
(
false
,
viewName
);
session
.
setParsing
Create
View
(
false
,
viewName
);
}
command
.
setSelect
(
query
);
}
catch
(
DbException
e
)
{
...
...
h2/src/main/org/h2/command/ddl/DropView.java
浏览文件 @
d1ca8df3
...
...
@@ -77,7 +77,6 @@ public class DropView extends SchemaCommand {
view
.
lock
(
session
,
true
,
true
);
session
.
getDatabase
().
removeSchemaObject
(
session
,
view
);
session
.
getDatabase
().
unlockMeta
(
session
);
// remove dependent table expressions
for
(
Table
childTable:
copyOfDependencies
){
...
...
@@ -88,6 +87,8 @@ public class DropView extends SchemaCommand {
}
}
}
// make sure its all unlocked
session
.
getDatabase
().
unlockMeta
(
session
);
}
return
0
;
}
...
...
h2/src/main/org/h2/command/dml/Select.java
浏览文件 @
d1ca8df3
...
...
@@ -875,7 +875,7 @@ public class Select extends Query {
isQuickAggregateQuery
=
isEverything
(
optimizable
);
}
}
cost
=
preparePlan
(
session
.
isParsingView
());
cost
=
preparePlan
(
session
.
isParsing
Create
View
());
if
(
distinct
&&
session
.
getDatabase
().
getSettings
().
optimizeDistinct
&&
!
isGroupQuery
&&
filters
.
size
()
==
1
&&
expressions
.
size
()
==
1
&&
condition
==
null
)
{
...
...
@@ -1087,7 +1087,7 @@ public class Select extends Query {
for
(
TableFilter
f
:
topFilters
)
{
Table
t
=
f
.
getTable
();
TableView
tableView
=
(
t
instanceof
TableView
)
?
(
TableView
)
t
:
null
;
if
(
tableView
!=
null
&&
tableView
.
is
View
()
&&
tableView
.
is
Recursive
()
&&
tableView
.
isTableExpression
())
{
if
(
tableView
!=
null
&&
tableView
.
isRecursive
()
&&
tableView
.
isTableExpression
())
{
if
(
tableView
.
isPersistent
()){
// skip the generation of plan SQL for this already recursive persistent ctes, since using a with
...
...
h2/src/main/org/h2/engine/Database.java
浏览文件 @
d1ca8df3
...
...
@@ -1878,7 +1878,6 @@ public class Database implements DataHandler {
int
type
=
obj
.
getType
();
if
(
type
==
DbObject
.
TABLE_OR_VIEW
)
{
Table
table
=
(
Table
)
obj
;
//table.setBeingDropped(true);
if
(
table
.
isTemporary
()
&&
!
table
.
isGlobalTemporary
())
{
session
.
removeLocalTempTable
(
table
);
return
;
...
...
@@ -1918,7 +1917,6 @@ public class Database implements DataHandler {
}
removeMeta
(
session
,
id
);
return
;
}
}
...
...
h2/src/main/org/h2/engine/Session.java
浏览文件 @
d1ca8df3
...
...
@@ -6,7 +6,6 @@
package
org
.
h2
.
engine
;
import
java.util.ArrayList
;
import
java.util.EmptyStackException
;
import
java.util.HashMap
;
import
java.util.HashSet
;
import
java.util.Iterator
;
...
...
@@ -229,7 +228,7 @@ public class Session extends SessionWithState {
return
subQueryInfo
;
}
public
void
setParsingView
(
boolean
parsingView
,
String
viewName
)
{
public
void
setParsing
Create
View
(
boolean
parsingView
,
String
viewName
)
{
// It can be recursive, thus implemented as counter.
this
.
parsingView
+=
parsingView
?
1
:
-
1
;
assert
this
.
parsingView
>=
0
;
...
...
@@ -241,16 +240,14 @@ public class Session extends SessionWithState {
viewNameStack
.
pop
();
}
}
public
String
getParsingViewName
()
{
try
{
return
viewNameStack
.
peek
();
}
catch
(
EmptyStackException
e
){
public
String
getParsingCreateViewName
()
{
if
(
viewNameStack
.
size
()==
0
){
return
null
;
}
return
viewNameStack
.
peek
();
}
public
boolean
isParsingView
()
{
public
boolean
isParsing
Create
View
()
{
assert
parsingView
>=
0
;
return
parsingView
!=
0
;
}
...
...
h2/src/main/org/h2/table/Table.java
浏览文件 @
d1ca8df3
...
...
@@ -161,6 +161,7 @@ public abstract class Table extends SchemaObjectBase {
* @param key the primary key
* @return the row
*/
@SuppressWarnings
(
"unused"
)
public
Row
getRow
(
Session
session
,
long
key
)
{
return
null
;
}
...
...
h2/src/main/org/h2/table/TableView.java
浏览文件 @
d1ca8df3
...
...
@@ -112,11 +112,11 @@ public class TableView extends Table {
private
Query
compileViewQuery
(
Session
session
,
String
sql
,
boolean
literalsChecked
,
String
viewName
)
{
Prepared
p
;
session
.
setParsingView
(
true
,
viewName
);
session
.
setParsing
Create
View
(
true
,
viewName
);
try
{
p
=
session
.
prepare
(
sql
,
false
,
literalsChecked
);
}
finally
{
session
.
setParsingView
(
false
,
viewName
);
session
.
setParsing
Create
View
(
false
,
viewName
);
}
if
(!(
p
instanceof
Query
))
{
throw
DbException
.
getSyntaxError
(
sql
,
0
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论