Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
48942c18
提交
48942c18
authored
9 年前
作者:
S.Vladykin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
create or replace view fixed
上级
b3eb9567
显示空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
17 行增加
和
18 行删除
+17
-18
AlterView.java
h2/src/main/org/h2/command/ddl/AlterView.java
+1
-1
Database.java
h2/src/main/org/h2/engine/Database.java
+2
-12
TableView.java
h2/src/main/org/h2/table/TableView.java
+14
-5
没有找到文件。
h2/src/main/org/h2/command/ddl/AlterView.java
浏览文件 @
48942c18
...
@@ -31,7 +31,7 @@ public class AlterView extends DefineCommand {
...
@@ -31,7 +31,7 @@ public class AlterView extends DefineCommand {
public
int
update
()
{
public
int
update
()
{
session
.
commit
(
true
);
session
.
commit
(
true
);
session
.
getUser
().
checkRight
(
view
,
Right
.
ALL
);
session
.
getUser
().
checkRight
(
view
,
Right
.
ALL
);
DbException
e
=
view
.
recompile
(
session
,
false
);
DbException
e
=
view
.
recompile
(
session
,
false
,
true
);
if
(
e
!=
null
)
{
if
(
e
!=
null
)
{
throw
e
;
throw
e
;
}
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/engine/Database.java
浏览文件 @
48942c18
...
@@ -811,7 +811,7 @@ public class Database implements DataHandler {
...
@@ -811,7 +811,7 @@ public class Database implements DataHandler {
if
(
obj
instanceof
TableView
)
{
if
(
obj
instanceof
TableView
)
{
TableView
view
=
(
TableView
)
obj
;
TableView
view
=
(
TableView
)
obj
;
if
(
view
.
isInvalid
())
{
if
(
view
.
isInvalid
())
{
view
.
recompile
(
session
,
true
);
view
.
recompile
(
session
,
true
,
false
);
if
(!
view
.
isInvalid
())
{
if
(!
view
.
isInvalid
())
{
recompileSuccessful
=
true
;
recompileSuccessful
=
true
;
}
}
...
@@ -819,17 +819,7 @@ public class Database implements DataHandler {
...
@@ -819,17 +819,7 @@ public class Database implements DataHandler {
}
}
}
}
}
while
(
recompileSuccessful
);
}
while
(
recompileSuccessful
);
// when opening a database, views are initialized before indexes,
TableView
.
clearIndexCaches
(
session
.
getDatabase
());
// so they may not have the optimal plan yet
// this is not a problem, it is just nice to see the newest plan
for
(
Table
obj
:
getAllTablesAndViews
(
false
))
{
if
(
obj
instanceof
TableView
)
{
TableView
view
=
(
TableView
)
obj
;
if
(!
view
.
isInvalid
())
{
view
.
recompile
(
systemSession
,
true
);
}
}
}
}
}
private
void
initMetaTables
()
{
private
void
initMetaTables
()
{
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/table/TableView.java
浏览文件 @
48942c18
...
@@ -13,6 +13,7 @@ import org.h2.api.ErrorCode;
...
@@ -13,6 +13,7 @@ import org.h2.api.ErrorCode;
import
org.h2.command.Prepared
;
import
org.h2.command.Prepared
;
import
org.h2.command.dml.Query
;
import
org.h2.command.dml.Query
;
import
org.h2.engine.Constants
;
import
org.h2.engine.Constants
;
import
org.h2.engine.Database
;
import
org.h2.engine.DbObject
;
import
org.h2.engine.DbObject
;
import
org.h2.engine.Session
;
import
org.h2.engine.Session
;
import
org.h2.engine.User
;
import
org.h2.engine.User
;
...
@@ -80,10 +81,10 @@ public class TableView extends Table {
...
@@ -80,10 +81,10 @@ public class TableView extends Table {
String
[]
oldColumnNames
=
this
.
columnNames
;
String
[]
oldColumnNames
=
this
.
columnNames
;
boolean
oldRecursive
=
this
.
recursive
;
boolean
oldRecursive
=
this
.
recursive
;
init
(
querySQL
,
null
,
columnNames
,
session
,
recursive
);
init
(
querySQL
,
null
,
columnNames
,
session
,
recursive
);
DbException
e
=
recompile
(
session
,
force
);
DbException
e
=
recompile
(
session
,
force
,
true
);
if
(
e
!=
null
)
{
if
(
e
!=
null
)
{
init
(
oldQuerySQL
,
null
,
oldColumnNames
,
session
,
oldRecursive
);
init
(
oldQuerySQL
,
null
,
oldColumnNames
,
session
,
oldRecursive
);
recompile
(
session
,
true
);
recompile
(
session
,
true
,
false
);
throw
e
;
throw
e
;
}
}
}
}
...
@@ -116,10 +117,11 @@ public class TableView extends Table {
...
@@ -116,10 +117,11 @@ public class TableView extends Table {
*
*
* @param session the session
* @param session the session
* @param force if exceptions should be ignored
* @param force if exceptions should be ignored
* @param clearIndexCache if we need to clear view index cache
* @return the exception if re-compiling this or any dependent view failed
* @return the exception if re-compiling this or any dependent view failed
* (only when force is disabled)
* (only when force is disabled)
*/
*/
public
synchronized
DbException
recompile
(
Session
session
,
boolean
force
)
{
public
synchronized
DbException
recompile
(
Session
session
,
boolean
force
,
boolean
clearIndexCache
)
{
try
{
try
{
compileViewQuery
(
session
,
querySQL
);
compileViewQuery
(
session
,
querySQL
);
}
catch
(
DbException
e
)
{
}
catch
(
DbException
e
)
{
...
@@ -134,12 +136,15 @@ public class TableView extends Table {
...
@@ -134,12 +136,15 @@ public class TableView extends Table {
initColumnsAndTables
(
session
);
initColumnsAndTables
(
session
);
if
(
views
!=
null
)
{
if
(
views
!=
null
)
{
for
(
TableView
v
:
views
)
{
for
(
TableView
v
:
views
)
{
DbException
e
=
v
.
recompile
(
session
,
force
);
DbException
e
=
v
.
recompile
(
session
,
force
,
false
);
if
(
e
!=
null
&&
!
force
)
{
if
(
e
!=
null
&&
!
force
)
{
return
e
;
return
e
;
}
}
}
}
}
}
if
(
clearIndexCache
)
{
clearIndexCaches
(
database
);
}
return
force
?
null
:
createException
;
return
force
?
null
:
createException
;
}
}
...
@@ -399,10 +404,14 @@ public class TableView extends Table {
...
@@ -399,10 +404,14 @@ public class TableView extends Table {
database
.
removeMeta
(
session
,
getId
());
database
.
removeMeta
(
session
,
getId
());
querySQL
=
null
;
querySQL
=
null
;
index
=
null
;
index
=
null
;
clearIndexCaches
(
database
);
invalidate
();
}
public
static
void
clearIndexCaches
(
Database
database
)
{
for
(
Session
s
:
database
.
getSessions
(
true
))
{
for
(
Session
s
:
database
.
getSessions
(
true
))
{
s
.
clearViewIndexCache
();
s
.
clearViewIndexCache
();
}
}
invalidate
();
}
}
@Override
@Override
...
...
This diff is collapsed.
Click to expand it.
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论