Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
c1022e87
提交
c1022e87
authored
8月 27, 2013
作者:
noelgrandin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix DROP ALL OBJECTS and DROP SCHEMA in the presence of tables with computed column dependencies.
上级
16abdf2f
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
93 行增加
和
6 行删除
+93
-6
DropDatabase.java
h2/src/main/org/h2/command/ddl/DropDatabase.java
+16
-4
Schema.java
h2/src/main/org/h2/schema/Schema.java
+22
-2
TestAll.java
h2/src/test/org/h2/test/TestAll.java
+2
-0
TestDrop.java
h2/src/test/org/h2/test/db/TestDrop.java
+53
-0
没有找到文件。
h2/src/main/org/h2/command/ddl/DropDatabase.java
浏览文件 @
c1022e87
...
...
@@ -64,11 +64,23 @@ public class DropDatabase extends DefineCommand {
db
.
removeSchemaObject
(
session
,
t
);
}
}
for
(
Table
t
:
tables
)
{
if
(
t
.
getName
()
!=
null
&&
Table
.
TABLE
.
equals
(
t
.
getTableType
())
&&
!
t
.
isHidden
())
{
db
.
removeSchemaObject
(
session
,
t
);
// There can be dependencies between tables e.g. using computed columns,
// so we might need to loop over them multiple times.
boolean
runLoopAgain
=
false
;
do
{
runLoopAgain
=
false
;
for
(
Table
t
:
tables
)
{
if
(
t
.
getName
()
!=
null
&&
Table
.
TABLE
.
equals
(
t
.
getTableType
())
&&
!
t
.
isHidden
())
{
if
(
db
.
getDependentTable
(
t
,
t
)
==
null
)
{
db
.
removeSchemaObject
(
session
,
t
);
}
else
{
runLoopAgain
=
true
;
}
}
}
}
}
while
(
runLoopAgain
);
for
(
Table
t
:
tables
)
{
if
(
t
.
getName
()
!=
null
&&
Table
.
EXTERNAL_TABLE_ENGINE
.
equals
(
t
.
getTableType
())
&&
!
t
.
isHidden
())
{
db
.
removeSchemaObject
(
session
,
t
);
...
...
h2/src/main/org/h2/schema/Schema.java
浏览文件 @
c1022e87
...
...
@@ -120,10 +120,30 @@ public class Schema extends DbObjectBase {
Constraint
obj
=
(
Constraint
)
constraints
.
values
().
toArray
()[
0
];
database
.
removeSchemaObject
(
session
,
obj
);
}
while
(
tablesAndViews
!=
null
&&
tablesAndView
s
.
size
()
>
0
)
{
Table
obj
=
(
Table
)
tablesAndView
s
.
values
().
toArray
()[
0
];
while
(
constraints
!=
null
&&
constraint
s
.
size
()
>
0
)
{
Constraint
obj
=
(
Constraint
)
constraint
s
.
values
().
toArray
()[
0
];
database
.
removeSchemaObject
(
session
,
obj
);
}
// There can be dependencies between tables e.g. using computed columns,
// so we might need to loop over them multiple times.
boolean
runLoopAgain
=
false
;
do
{
runLoopAgain
=
false
;
if
(
tablesAndViews
!=
null
)
{
// Loop over a copy because the map is modified underneath us.
for
(
Table
obj
:
New
.
arrayList
(
tablesAndViews
.
values
()))
{
// Check for null because multiple tables might be deleted in one go
// underneath us.
if
(
obj
.
getName
()
!=
null
)
{
if
(
database
.
getDependentTable
(
obj
,
obj
)
==
null
)
{
database
.
removeSchemaObject
(
session
,
obj
);
}
else
{
runLoopAgain
=
true
;
}
}
}
}
}
while
(
runLoopAgain
);
while
(
indexes
!=
null
&&
indexes
.
size
()
>
0
)
{
Index
obj
=
(
Index
)
indexes
.
values
().
toArray
()[
0
];
database
.
removeSchemaObject
(
session
,
obj
);
...
...
h2/src/test/org/h2/test/TestAll.java
浏览文件 @
c1022e87
...
...
@@ -26,6 +26,7 @@ import org.h2.test.db.TestCompatibility;
import
org.h2.test.db.TestCsv
;
import
org.h2.test.db.TestDateStorage
;
import
org.h2.test.db.TestDeadlock
;
import
org.h2.test.db.TestDrop
;
import
org.h2.test.db.TestEncryptedDb
;
import
org.h2.test.db.TestExclusive
;
import
org.h2.test.db.TestFullText
;
...
...
@@ -594,6 +595,7 @@ kill -9 `jps -l | grep "org.h2.test." | cut -d " " -f 1`
new
TestCsv
().
runTest
(
this
);
new
TestDateStorage
().
runTest
(
this
);
new
TestDeadlock
().
runTest
(
this
);
new
TestDrop
().
runTest
(
this
);
new
TestEncryptedDb
().
runTest
(
this
);
new
TestExclusive
().
runTest
(
this
);
new
TestFullText
().
runTest
(
this
);
...
...
h2/src/test/org/h2/test/db/TestDrop.java
0 → 100644
浏览文件 @
c1022e87
/*
* Copyright 2004-2013 H2 Group. Multiple-Licensed under the H2 License,
* Version 1.0, and under the Eclipse Public License, Version 1.0
* (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package
org
.
h2
.
test
.
db
;
import
java.sql.Connection
;
import
java.sql.SQLException
;
import
java.sql.Statement
;
import
org.h2.test.TestBase
;
/**
* Test DROP statement
*/
public
class
TestDrop
extends
TestBase
{
private
Connection
conn
;
private
Statement
stat
;
/**
* Run just this test.
*
* @param a ignored
*/
public
static
void
main
(
String
...
a
)
throws
Exception
{
TestBase
.
createCaller
().
init
().
test
();
}
@Override
public
void
test
()
throws
Exception
{
deleteDb
(
"drop"
);
conn
=
getConnection
(
"drop"
);
stat
=
conn
.
createStatement
();
testComputedColumnDependency
();
conn
.
close
();
deleteDb
(
"drop"
);
}
private
void
testComputedColumnDependency
()
throws
SQLException
{
stat
.
execute
(
"DROP ALL OBJECTS"
);
stat
.
execute
(
"CREATE TABLE A (A INT);"
);
stat
.
execute
(
"CREATE TABLE B (B INT AS SELECT A FROM A);"
);
stat
.
execute
(
"DROP ALL OBJECTS"
);
stat
.
execute
(
"CREATE SCHEMA TEST_SCHEMA"
);
stat
.
execute
(
"CREATE TABLE TEST_SCHEMA.A (A INT);"
);
stat
.
execute
(
"CREATE TABLE TEST_SCHEMA.B (B INT AS SELECT A FROM TEST_SCHEMA.A);"
);
stat
.
execute
(
"DROP SCHEMA TEST_SCHEMA"
);
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论