Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
3f26a9ef
提交
3f26a9ef
authored
5月 26, 2009
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
The Recover tool did not always work when the database contains referential integrity constraints.
上级
25d46b58
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
27 行增加
和
19 行删除
+27
-19
Recover.java
h2/src/main/org/h2/tools/Recover.java
+12
-1
TestRecovery.java
h2/src/test/org/h2/test/unit/TestRecovery.java
+15
-18
没有找到文件。
h2/src/main/org/h2/tools/Recover.java
浏览文件 @
3f26a9ef
...
...
@@ -1207,7 +1207,11 @@ public class Recover extends Tool implements DataHandler {
private
void
writeSchema
(
PrintWriter
writer
)
{
MetaRecord
.
sort
(
schema
);
for
(
MetaRecord
m
:
schema
)
{
writer
.
println
(
m
.
getSQL
()
+
";"
);
String
sql
=
m
.
getSQL
();
// create, but not referential integrity constraints and so on
if
(
sql
.
startsWith
(
"CREATE "
))
{
writer
.
println
(
sql
+
";"
);
}
}
for
(
Map
.
Entry
<
Integer
,
String
>
entry
:
tableMap
.
entrySet
())
{
Integer
objectId
=
entry
.
getKey
();
...
...
@@ -1221,6 +1225,13 @@ public class Recover extends Tool implements DataHandler {
}
writer
.
println
(
"DROP ALIAS READ_CLOB;"
);
writer
.
println
(
"DROP ALIAS READ_BLOB;"
);
for
(
MetaRecord
m
:
schema
)
{
String
sql
=
m
.
getSQL
();
// everything except create
if
(!
sql
.
startsWith
(
"CREATE "
))
{
writer
.
println
(
sql
+
";"
);
}
}
}
private
void
createTemporaryTable
(
PrintWriter
writer
)
{
...
...
h2/src/test/org/h2/test/unit/TestRecovery.java
浏览文件 @
3f26a9ef
...
...
@@ -7,12 +7,11 @@
package
org
.
h2
.
test
.
unit
;
import
java.sql.Connection
;
import
java.sql.DriverManager
;
import
java.sql.SQLException
;
import
java.sql.Statement
;
import
org.h2.test.TestBase
;
import
org.h2.tools.DeleteDbFiles
;
import
org.h2.tools.Recover
;
/**
* Tests database recovery.
...
...
@@ -31,24 +30,22 @@ public class TestRecovery extends TestBase {
public
void
test
()
throws
SQLException
{
DeleteDbFiles
.
execute
(
baseDir
,
"recovery"
,
true
);
org
.
h2
.
Driver
.
load
();
String
url
=
"jdbc:h2:"
+
baseDir
+
"/recovery;write_delay=0"
;
Connection
conn1
=
DriverManager
.
getConnection
(
url
,
"sa"
,
"sa"
);
Statement
stat1
=
conn1
.
createStatement
();
Connection
conn2
=
DriverManager
.
getConnection
(
url
,
"sa"
,
"sa"
);
Statement
stat2
=
conn2
.
createStatement
();
stat1
.
execute
(
"create table test as select * from system_range(1, 100)"
);
stat1
.
execute
(
"create table abc(id int)"
);
conn2
.
setAutoCommit
(
false
);
// this is not committed
// recovery might try to roll back this
stat2
.
execute
(
"delete from test"
);
// overwrite the data of test
stat1
.
execute
(
"insert into abc select * from system_range(1, 100)"
);
stat1
.
execute
(
"shutdown immediately"
);
// Recover.execute("data", null);
Connection
conn
=
DriverManager
.
getConnection
(
url
,
"sa"
,
"sa"
);
Connection
conn
=
getConnection
(
"recovery"
);
Statement
stat
=
conn
.
createStatement
();
stat
.
execute
(
"create table test as select * from system_range(1, 100)"
);
stat
.
execute
(
"create table a(id int primary key) as select * from system_range(1, 100)"
);
stat
.
execute
(
"create table b(id int references a(id)) as select * from system_range(1, 100)"
);
stat
.
execute
(
"alter table a add foreign key(id) references b(id)"
);
conn
.
close
();
Recover
.
execute
(
baseDir
,
"recovery"
);
DeleteDbFiles
.
execute
(
baseDir
,
"recovery"
,
true
);
conn
=
getConnection
(
"recovery"
,
"diff"
,
""
);
stat
=
conn
.
createStatement
();
stat
.
execute
(
"runscript from '"
+
baseDir
+
"/recovery.data.sql'"
);
stat
.
execute
(
"select * from test"
);
conn
.
close
();
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论