Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
98d941d3
提交
98d941d3
authored
7月 30, 2010
作者:
christian.peter.io
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
For unecnrypted databases, the automatic upgrade temporary script file is now unencrypted again.
上级
eab1130c
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
39 行增加
和
12 行删除
+39
-12
changelog.html
h2/src/docsrc/html/changelog.html
+1
-0
DbUpgradeNonPageStoreToCurrent.java
...c/main/org/h2/upgrade/DbUpgradeNonPageStoreToCurrent.java
+12
-12
TestUpgrade.java
h2/src/test/org/h2/test/db/TestUpgrade.java
+26
-0
没有找到文件。
h2/src/docsrc/html/changelog.html
浏览文件 @
98d941d3
...
...
@@ -23,6 +23,7 @@ Change Log
</li><li>
LOG=0 is now a bit faster (previously undo log entries were still written).
</li><li>
The command line tools now say so if the source directory of an option doesn't exist.
</li><li>
It is now allowed to truncate a table if referential integrity has been disabled for this table or database.
</li><li>
For unencrypted databases, the automatic upgrade temporary script file is now unencrypted again.
</li></ul>
<h2>
Version 1.2.140 (2010-07-25)
</h2>
...
...
h2/src/main/org/h2/upgrade/DbUpgradeNonPageStoreToCurrent.java
浏览文件 @
98d941d3
...
...
@@ -140,15 +140,16 @@ public class DbUpgradeNonPageStoreToCurrent {
scriptFile
=
new
File
(
oldDataFile
.
getAbsolutePath
()
+
"_script.sql"
);
}
// outputStream.println("H2 Migrating '" + oldFile.getPath() +
// "' to '" + newFile.getPath() + "' via '" + scriptFile.getPath()
// + "'");
Utils
.
callStaticMethod
(
"org.h2.upgrade.v1_1.Driver.load"
);
String
uuid
=
UUID
.
randomUUID
().
toString
();
Connection
connection
=
DriverManager
.
getConnection
(
oldUrl
,
info
);
Statement
stmt
=
connection
.
createStatement
();
stmt
.
execute
(
"script to '"
+
scriptFile
+
"' CIPHER AES PASSWORD '"
+
uuid
+
"' --hide--"
);
boolean
isEncrypted
=
StringUtils
.
toUpperEnglish
(
url
).
indexOf
(
";CIPHER="
)
>=
0
;
String
uuid
=
UUID
.
randomUUID
().
toString
();
if
(
isEncrypted
)
{
stmt
.
execute
(
"script to '"
+
scriptFile
+
"' CIPHER AES PASSWORD '"
+
uuid
+
"' --hide--"
);
}
else
{
stmt
.
execute
(
"script to '"
+
scriptFile
+
"'"
);
}
stmt
.
close
();
connection
.
close
();
...
...
@@ -158,7 +159,11 @@ public class DbUpgradeNonPageStoreToCurrent {
connection
=
DriverManager
.
getConnection
(
newUrl
,
info
);
stmt
=
connection
.
createStatement
();
stmt
.
execute
(
"runscript from '"
+
scriptFile
+
"' CIPHER AES PASSWORD '"
+
uuid
+
"' --hide--"
);
if
(
isEncrypted
)
{
stmt
.
execute
(
"runscript from '"
+
scriptFile
+
"' CIPHER AES PASSWORD '"
+
uuid
+
"' --hide--"
);
}
else
{
stmt
.
execute
(
"runscript from '"
+
scriptFile
+
"'"
);
}
stmt
.
execute
(
"analyze"
);
stmt
.
execute
(
"shutdown compact"
);
stmt
.
close
();
...
...
@@ -169,9 +174,6 @@ public class DbUpgradeNonPageStoreToCurrent {
backupIndexFile
.
delete
();
FileSystem
.
getInstance
(
backupLobsDir
.
getAbsolutePath
()).
deleteRecursive
(
backupLobsDir
.
getAbsolutePath
(),
false
);
}
// outputStream.println("H2 Migration of '" + oldFile.getPath() +
// "' finished successfully");
}
catch
(
Exception
e
)
{
successful
=
false
;
if
(
backupDataFile
.
exists
())
{
...
...
@@ -184,8 +186,6 @@ public class DbUpgradeNonPageStoreToCurrent {
backupLobsDir
.
renameTo
(
oldLobsDir
);
}
newFile
.
delete
();
// errorStream.println("H2 Migration of '" + oldFile.getPath() +
// "' finished with error: " + e.getMessage());
throw
DbException
.
toSQLException
(
e
);
}
finally
{
if
(
scriptFile
!=
null
)
{
...
...
h2/src/test/org/h2/test/db/TestUpgrade.java
浏览文件 @
98d941d3
...
...
@@ -12,6 +12,7 @@ import java.sql.DriverManager;
import
java.sql.SQLException
;
import
java.sql.Statement
;
import
org.h2.test.TestBase
;
import
org.h2.util.IOUtils
;
import
org.h2.util.Utils
;
/**
...
...
@@ -35,6 +36,7 @@ public class TestUpgrade extends TestBase {
testNoDb
();
testNoUpgradeOldAndNew
();
testIfExists
();
testCipher
();
}
private
void
testNoDb
()
throws
SQLException
{
...
...
@@ -130,6 +132,28 @@ public class TestUpgrade extends TestBase {
deleteDb
(
"upgrade"
);
}
private
void
testCipher
()
throws
Exception
{
deleteDb
(
"upgrade"
);
// Create old db
Utils
.
callStaticMethod
(
"org.h2.upgrade.v1_1.Driver.load"
);
Connection
conn
=
DriverManager
.
getConnection
(
"jdbc:h2v1_1:data/test/upgrade;PAGE_STORE=FALSE;CIPHER=AES"
,
"abc"
,
"abc abc"
);
Statement
stat
=
conn
.
createStatement
();
stat
.
execute
(
"create table test(id int)"
);
conn
.
close
();
Utils
.
callStaticMethod
(
"org.h2.upgrade.v1_1.Driver.unload"
);
assertTrue
(
new
File
(
"data/test/upgrade.data.db"
).
exists
());
// Connect to old DB with upgrade
conn
=
DriverManager
.
getConnection
(
"jdbc:h2:data/test/upgrade;CIPHER=AES"
,
"abc"
,
"abc abc"
);
stat
=
conn
.
createStatement
();
stat
.
executeQuery
(
"select * from test"
);
conn
.
close
();
assertTrue
(
new
File
(
"data/test/upgrade.h2.db"
).
exists
());
deleteDb
(
"upgrade"
);
}
public
void
deleteDb
(
String
dbName
)
throws
SQLException
{
super
.
deleteDb
(
dbName
);
try
{
...
...
@@ -137,5 +161,7 @@ public class TestUpgrade extends TestBase {
}
catch
(
Exception
e
)
{
throw
new
SQLException
(
e
.
getMessage
());
}
IOUtils
.
delete
(
"data/test/"
+
dbName
+
".data.db.backup"
);
IOUtils
.
delete
(
"data/test/"
+
dbName
+
".index.db.backup"
);
}
}
\ No newline at end of file
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论