Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
401e069b
提交
401e069b
authored
11月 20, 2017
作者:
Noel Grandin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
more dependent views field and method naming more obvious
上级
c2b4d9db
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
34 行增加
和
31 行删除
+34
-31
AlterTableAlterColumn.java
h2/src/main/org/h2/command/ddl/AlterTableAlterColumn.java
+6
-6
DropTable.java
h2/src/main/org/h2/command/ddl/DropTable.java
+3
-3
Table.java
h2/src/main/org/h2/table/Table.java
+15
-12
TableView.java
h2/src/main/org/h2/table/TableView.java
+10
-10
没有找到文件。
h2/src/main/org/h2/command/ddl/AlterTableAlterColumn.java
浏览文件 @
401e069b
...
...
@@ -275,10 +275,10 @@ public class AlterTableAlterColumn extends SchemaCommand {
throw
DbException
.
get
(
ErrorCode
.
VIEW_IS_INVALID_2
,
e
,
getSQL
(),
e
.
getMessage
());
}
String
tableName
=
table
.
getName
();
CopyOnWriteArrayList
<
TableView
>
views
=
table
.
ge
tViews
();
if
(
v
iews
!=
null
)
{
for
(
TableView
view
:
v
iews
)
{
table
.
removeView
(
view
);
CopyOnWriteArrayList
<
TableView
>
dependentViews
=
table
.
getDependen
tViews
();
if
(
dependentV
iews
!=
null
)
{
for
(
TableView
view
:
dependentV
iews
)
{
table
.
remove
Dependent
View
(
view
);
}
}
execute
(
"DROP TABLE "
+
table
.
getSQL
()
+
" IGNORE"
,
true
);
...
...
@@ -306,8 +306,8 @@ public class AlterTableAlterColumn extends SchemaCommand {
db
.
renameSchemaObject
(
session
,
so
,
name
);
}
}
if
(
v
iews
!=
null
)
{
for
(
TableView
view
:
v
iews
)
{
if
(
dependentV
iews
!=
null
)
{
for
(
TableView
view
:
dependentV
iews
)
{
String
sql
=
view
.
getCreateSQL
(
true
,
true
);
execute
(
sql
,
true
);
}
...
...
h2/src/main/org/h2/command/ddl/DropTable.java
浏览文件 @
401e069b
...
...
@@ -73,10 +73,10 @@ public class DropTable extends SchemaCommand {
throw
DbException
.
get
(
ErrorCode
.
CANNOT_DROP_TABLE_1
,
tableName
);
}
if
(
dropAction
==
ConstraintReferential
.
RESTRICT
)
{
CopyOnWriteArrayList
<
TableView
>
views
=
table
.
ge
tViews
();
if
(
views
!=
null
&&
v
iews
.
size
()
>
0
)
{
CopyOnWriteArrayList
<
TableView
>
dependentViews
=
table
.
getDependen
tViews
();
if
(
dependentViews
!=
null
&&
dependentV
iews
.
size
()
>
0
)
{
StatementBuilder
buff
=
new
StatementBuilder
();
for
(
TableView
v
:
v
iews
)
{
for
(
TableView
v
:
dependentV
iews
)
{
buff
.
appendExceptFirst
(
", "
);
buff
.
append
(
v
.
getName
());
}
...
...
h2/src/main/org/h2/table/Table.java
浏览文件 @
401e069b
...
...
@@ -79,7 +79,10 @@ public abstract class Table extends SchemaObjectBase {
private
ArrayList
<
TriggerObject
>
triggers
;
private
ArrayList
<
Constraint
>
constraints
;
private
ArrayList
<
Sequence
>
sequences
;
private
AtomicReference
<
CopyOnWriteArrayList
<
TableView
>>
views
;
/**
* views that depend on this table
*/
private
AtomicReference
<
CopyOnWriteArrayList
<
TableView
>>
dependentViews
;
private
ArrayList
<
TableSynonym
>
synonyms
;
private
boolean
checkForeignKeyConstraints
=
true
;
private
boolean
onCommitDrop
,
onCommitTruncate
;
...
...
@@ -400,8 +403,8 @@ public abstract class Table extends SchemaObjectBase {
if
(
sequences
!=
null
)
{
children
.
addAll
(
sequences
);
}
if
(
v
iews
.
get
()
!=
null
)
{
children
.
addAll
(
v
iews
.
get
());
if
(
dependentV
iews
.
get
()
!=
null
)
{
children
.
addAll
(
dependentV
iews
.
get
());
}
if
(
synonyms
!=
null
)
{
children
.
addAll
(
synonyms
);
...
...
@@ -521,15 +524,15 @@ public abstract class Table extends SchemaObjectBase {
}
}
public
CopyOnWriteArrayList
<
TableView
>
getViews
()
{
return
v
iews
.
get
();
public
CopyOnWriteArrayList
<
TableView
>
get
Dependent
Views
()
{
return
dependentV
iews
.
get
();
}
@Override
public
void
removeChildrenAndResources
(
Session
session
)
{
while
(
views
.
get
()
!=
null
&&
v
iews
.
get
().
size
()
>
0
)
{
TableView
view
=
v
iews
.
get
().
get
(
0
);
v
iews
.
get
().
remove
(
0
);
while
(
dependentViews
.
get
()
!=
null
&&
dependentV
iews
.
get
().
size
()
>
0
)
{
TableView
view
=
dependentV
iews
.
get
().
get
(
0
);
dependentV
iews
.
get
().
remove
(
0
);
database
.
removeSchemaObject
(
session
,
view
);
}
while
(
synonyms
!=
null
&&
synonyms
.
size
()
>
0
)
{
...
...
@@ -845,8 +848,8 @@ public abstract class Table extends SchemaObjectBase {
*
* @param view the view to remove
*/
public
void
removeView
(
TableView
view
)
{
remove
(
v
iews
,
view
);
public
void
remove
Dependent
View
(
TableView
view
)
{
remove
(
dependentV
iews
,
view
);
}
/**
...
...
@@ -890,8 +893,8 @@ public abstract class Table extends SchemaObjectBase {
*
* @param view the view to add
*/
public
void
addView
(
TableView
view
)
{
add
(
v
iews
,
view
);
public
void
add
Dependent
View
(
TableView
view
)
{
add
(
dependentV
iews
,
view
);
}
/**
...
...
h2/src/main/org/h2/table/TableView.java
浏览文件 @
401e069b
...
...
@@ -136,10 +136,10 @@ public class TableView extends Table {
return
e
;
}
}
CopyOnWriteArrayList
<
TableView
>
views
=
ge
tViews
();
CopyOnWriteArrayList
<
TableView
>
dependentViews
=
getDependen
tViews
();
initColumnsAndTables
(
session
,
false
);
if
(
v
iews
!=
null
)
{
for
(
TableView
v
:
v
iews
)
{
if
(
dependentV
iews
!=
null
)
{
for
(
TableView
v
:
dependentV
iews
)
{
DbException
e
=
v
.
recompile
(
session
,
force
,
false
);
if
(
e
!=
null
&&
!
force
)
{
return
e
;
...
...
@@ -154,7 +154,7 @@ public class TableView extends Table {
private
void
initColumnsAndTables
(
Session
session
,
boolean
literalsChecked
)
{
Column
[]
cols
;
removeViewFromTables
();
remove
Dependent
ViewFromTables
();
try
{
Query
query
=
compileViewQuery
(
session
,
querySQL
,
literalsChecked
);
this
.
querySQL
=
query
.
getPlanSQL
();
...
...
@@ -229,7 +229,7 @@ public class TableView extends Table {
}
setColumns
(
cols
);
if
(
getId
()
!=
0
)
{
addViewToTables
();
add
Dependent
ViewToTables
();
}
}
...
...
@@ -420,7 +420,7 @@ public class TableView extends Table {
@Override
public
void
removeChildrenAndResources
(
Session
session
)
{
removeViewFromTables
();
remove
Dependent
ViewFromTables
();
super
.
removeChildrenAndResources
(
session
);
database
.
removeMeta
(
session
,
getId
());
querySQL
=
null
;
...
...
@@ -504,18 +504,18 @@ public class TableView extends Table {
return
null
;
}
private
void
removeViewFromTables
()
{
private
void
remove
Dependent
ViewFromTables
()
{
if
(
tables
!=
null
)
{
for
(
Table
t
:
tables
)
{
t
.
removeView
(
this
);
t
.
remove
Dependent
View
(
this
);
}
tables
.
clear
();
}
}
private
void
addViewToTables
()
{
private
void
add
Dependent
ViewToTables
()
{
for
(
Table
t
:
tables
)
{
t
.
addView
(
this
);
t
.
add
Dependent
View
(
this
);
}
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论