Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
2084502c
提交
2084502c
authored
6月 25, 2013
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
MVTableEngine: recovery
上级
5362d7af
显示空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
44 行增加
和
24 行删除
+44
-24
Recover.java
h2/src/main/org/h2/tools/Recover.java
+28
-4
TestAll.java
h2/src/test/org/h2/test/TestAll.java
+3
-14
TestMVTableEngine.java
h2/src/test/org/h2/test/store/TestMVTableEngine.java
+13
-6
没有找到文件。
h2/src/main/org/h2/tools/Recover.java
浏览文件 @
2084502c
...
...
@@ -64,6 +64,7 @@ import org.h2.util.TempFileDeleter;
import
org.h2.util.Tool
;
import
org.h2.util.Utils
;
import
org.h2.value.Value
;
import
org.h2.value.ValueArray
;
import
org.h2.value.ValueLob
;
import
org.h2.value.ValueLobDb
;
import
org.h2.value.ValueLong
;
...
...
@@ -501,18 +502,41 @@ public class Recover extends Tool implements DataHandler {
String
mapName
=
key
.
substring
(
"name."
.
length
());
String
tableId
=
mapName
.
substring
(
"table."
.
length
());
ValueDataType
keyType
=
new
ValueDataType
(
null
,
null
,
null
);
null
,
this
,
null
);
ValueDataType
valueType
=
new
ValueDataType
(
null
,
null
,
null
);
null
,
this
,
null
);
MVMap
.
Builder
<
Value
,
Value
>
mapBuilder
=
new
MVMap
.
Builder
<
Value
,
Value
>().
keyType
(
keyType
).
valueType
(
valueType
);
TransactionMap
<
Value
,
Value
>
dataMap
=
store
.
begin
().
openMap
(
mapName
,
mapBuilder
);
Iterator
<
Value
>
dataIt
=
dataMap
.
keyIterator
(
null
);
boolean
init
=
false
;
while
(
dataIt
.
hasNext
())
{
Value
rowId
=
dataIt
.
next
();
Value
values
=
dataMap
.
get
(
rowId
);
writer
.
println
(
"-- insert into O_"
+
tableId
+
" key="
+
rowId
+
" values="
+
values
);
Value
[]
values
=
((
ValueArray
)
dataMap
.
get
(
rowId
)).
getList
();
recordLength
=
values
.
length
;
if
(!
init
)
{
setStorage
(
Integer
.
parseInt
(
tableId
));
// init the column types
for
(
valueId
=
0
;
valueId
<
recordLength
;
valueId
++)
{
String
columnName
=
storageName
+
"."
+
valueId
;
getSQL
(
columnName
,
values
[
valueId
]);
}
createTemporaryTable
(
writer
);
init
=
true
;
}
StringBuilder
buff
=
new
StringBuilder
();
buff
.
append
(
"INSERT INTO O_"
).
append
(
tableId
)
.
append
(
" VALUES("
);
for
(
valueId
=
0
;
valueId
<
recordLength
;
valueId
++)
{
if
(
valueId
>
0
)
{
buff
.
append
(
", "
);
}
String
columnName
=
storageName
+
"."
+
valueId
;
buff
.
append
(
getSQL
(
columnName
,
values
[
valueId
]));
}
buff
.
append
(
");"
);
writer
.
println
(
buff
.
toString
());
}
}
}
catch
(
Throwable
e
)
{
...
...
h2/src/test/org/h2/test/TestAll.java
浏览文件 @
2084502c
...
...
@@ -6,11 +6,6 @@
*/
package
org
.
h2
.
test
;
import
java.io.ByteArrayInputStream
;
import
java.io.ByteArrayOutputStream
;
import
java.io.IOException
;
import
java.io.ObjectInputStream
;
import
java.io.ObjectOutputStream
;
import
java.sql.SQLException
;
import
java.util.Properties
;
import
org.h2.Driver
;
...
...
@@ -612,10 +607,7 @@ kill -9 `jps -l | grep "org.h2.test." | cut -d " " -f 1`
new
TestReadOnly
().
runTest
(
this
);
new
TestRecursiveQueries
().
runTest
(
this
);
new
TestRights
().
runTest
(
this
);
if
(!
mvStore
)
{
// Recover is not yet implemented
new
TestRunscript
().
runTest
(
this
);
}
new
TestSQLInjection
().
runTest
(
this
);
new
TestSessionsLocks
().
runTest
(
this
);
new
TestSelectCountNonNullColumn
().
runTest
(
this
);
...
...
@@ -752,7 +744,7 @@ kill -9 `jps -l | grep "org.h2.test." | cut -d " " -f 1`
new
TestPgServer
().
runTest
(
this
);
new
TestReader
().
runTest
(
this
);
if
(!
mvStore
)
{
// Recover is not yet implemented
// Recover is not yet
fully
implemented
new
TestRecovery
().
runTest
(
this
);
}
new
TestSampleApps
().
runTest
(
this
);
...
...
@@ -764,10 +756,7 @@ kill -9 `jps -l | grep "org.h2.test." | cut -d " " -f 1`
new
TestStreams
().
runTest
(
this
);
new
TestStringCache
().
runTest
(
this
);
new
TestStringUtils
().
runTest
(
this
);
if
(!
mvStore
)
{
// Recover is not yet implemented
new
TestTools
().
runTest
(
this
);
}
new
TestTraceSystem
().
runTest
(
this
);
new
TestUpgrade
().
runTest
(
this
);
new
TestUtils
().
runTest
(
this
);
...
...
h2/src/test/org/h2/test/store/TestMVTableEngine.java
浏览文件 @
2084502c
...
...
@@ -23,9 +23,9 @@ import org.h2.engine.Database;
import
org.h2.jdbc.JdbcConnection
;
import
org.h2.store.fs.FileUtils
;
import
org.h2.test.TestBase
;
import
org.h2.tools.DeleteDbFiles
;
import
org.h2.tools.Recover
;
import
org.h2.tools.Restore
;
import
org.h2.tools.Script
;
import
org.h2.util.Task
;
/**
...
...
@@ -45,7 +45,7 @@ public class TestMVTableEngine extends TestBase {
@Override
public
void
test
()
throws
Exception
{
// testSpeed();
//
testRecover();
testRecover
();
testSeparateKey
();
testRollback
();
testRollbackAfterCrash
();
...
...
@@ -122,21 +122,28 @@ int test;
Connection
conn
;
Statement
stat
;
String
url
=
"mvstore;default_table_engine=org.h2.mvstore.db.MVTableEngine"
;
url
=
getURL
(
url
,
true
);
conn
=
getConnection
(
url
);
stat
=
conn
.
createStatement
();
stat
.
execute
(
"create table test(id int primary key)"
);
stat
.
execute
(
"insert into test values(1)"
);
stat
.
execute
(
"create table test(id int primary key, name varchar)"
);
stat
.
execute
(
"insert into test values(1, 'Hello')"
);
stat
.
execute
(
"create table test2(name varchar)"
);
stat
.
execute
(
"insert into test2 values('Hello World')"
);
conn
.
close
();
Recover
.
execute
(
getBaseDir
(),
"mvstore"
);
FileUtils
.
deleteRecursive
(
getBaseDir
(),
true
);
Script
.
execute
(
url
,
getUser
(),
getPassword
(),
System
.
out
);
DeleteDbFiles
.
execute
(
getBaseDir
(),
"mvstore"
,
true
);
conn
=
getConnection
(
url
);
stat
=
conn
.
createStatement
();
stat
.
execute
(
"runscript from '"
+
getBaseDir
()
+
"/mvstore.h2.sql'"
);
ResultSet
rs
;
rs
=
stat
.
executeQuery
(
"select * from test"
);
assertTrue
(
rs
.
next
());
assertEquals
(
1
,
rs
.
getInt
(
1
));
assertEquals
(
"Hello"
,
rs
.
getString
(
2
));
rs
=
stat
.
executeQuery
(
"select * from test2"
);
assertTrue
(
rs
.
next
());
assertEquals
(
"Hello World"
,
rs
.
getString
(
1
));
conn
.
close
();
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论