Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
eb1babad
提交
eb1babad
authored
10月 24, 2010
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Improved test case; undoing some unrelated changes.
上级
b4713b27
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
55 行增加
和
52 行删除
+55
-52
Constants.java
h2/src/main/org/h2/engine/Constants.java
+0
-5
FileLister.java
h2/src/main/org/h2/store/FileLister.java
+0
-2
FileSystemSplit.java
h2/src/main/org/h2/store/fs/FileSystemSplit.java
+4
-3
TestBase.java
h2/src/test/org/h2/test/TestBase.java
+10
-1
TestRunscript.java
h2/src/test/org/h2/test/db/TestRunscript.java
+41
-41
没有找到文件。
h2/src/main/org/h2/engine/Constants.java
浏览文件 @
eb1babad
...
@@ -353,11 +353,6 @@ public class Constants {
...
@@ -353,11 +353,6 @@ public class Constants {
* The file name suffix of trace files.
* The file name suffix of trace files.
*/
*/
public
static
final
String
SUFFIX_TRACE_FILE
=
".trace.db"
;
public
static
final
String
SUFFIX_TRACE_FILE
=
".trace.db"
;
/**
* The file name suffix of split files.
*/
public
static
final
String
SUFFIX_SPLIT_FILE
=
".part"
;
/**
/**
* The delay that is to be used if throttle has been enabled.
* The delay that is to be used if throttle has been enabled.
...
...
h2/src/main/org/h2/store/FileLister.java
浏览文件 @
eb1babad
...
@@ -107,8 +107,6 @@ public class FileLister {
...
@@ -107,8 +107,6 @@ public class FileLister {
ok
=
true
;
ok
=
true
;
}
else
if
(
f
.
endsWith
(
Constants
.
SUFFIX_TRACE_FILE
))
{
}
else
if
(
f
.
endsWith
(
Constants
.
SUFFIX_TRACE_FILE
))
{
ok
=
true
;
ok
=
true
;
}
else
if
(
f
.
endsWith
(
Constants
.
SUFFIX_SPLIT_FILE
))
{
ok
=
true
;
}
}
}
}
if
(
ok
)
{
if
(
ok
)
{
...
...
h2/src/main/org/h2/store/fs/FileSystemSplit.java
浏览文件 @
eb1babad
...
@@ -13,7 +13,6 @@ import java.io.SequenceInputStream;
...
@@ -13,7 +13,6 @@ import java.io.SequenceInputStream;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
org.h2.constant.SysProperties
;
import
org.h2.constant.SysProperties
;
import
org.h2.engine.Constants
;
import
org.h2.message.DbException
;
import
org.h2.message.DbException
;
import
org.h2.util.New
;
import
org.h2.util.New
;
...
@@ -25,6 +24,8 @@ public class FileSystemSplit extends FileSystem {
...
@@ -25,6 +24,8 @@ public class FileSystemSplit extends FileSystem {
private
static
final
String
PREFIX
=
"split:"
;
private
static
final
String
PREFIX
=
"split:"
;
private
static
final
String
PART_SUFFIX
=
".part"
;
private
long
defaultMaxSize
=
1L
<<
SysProperties
.
SPLIT_FILE_SIZE_SHIFT
;
private
long
defaultMaxSize
=
1L
<<
SysProperties
.
SPLIT_FILE_SIZE_SHIFT
;
static
{
static
{
...
@@ -174,7 +175,7 @@ public class FileSystemSplit extends FileSystem {
...
@@ -174,7 +175,7 @@ public class FileSystemSplit extends FileSystem {
ArrayList
<
String
>
list
=
New
.
arrayList
();
ArrayList
<
String
>
list
=
New
.
arrayList
();
for
(
int
i
=
0
;
i
<
array
.
length
;
i
++)
{
for
(
int
i
=
0
;
i
<
array
.
length
;
i
++)
{
String
f
=
array
[
i
];
String
f
=
array
[
i
];
if
(
f
.
endsWith
(
Constants
.
SUFFIX_SPLIT_FILE
))
{
if
(
f
.
endsWith
(
PART_SUFFIX
))
{
continue
;
continue
;
}
}
array
[
i
]
=
f
=
PREFIX
+
f
;
array
[
i
]
=
f
=
PREFIX
+
f
;
...
@@ -312,7 +313,7 @@ public class FileSystemSplit extends FileSystem {
...
@@ -312,7 +313,7 @@ public class FileSystemSplit extends FileSystem {
*/
*/
static
String
getFileName
(
String
fileName
,
int
id
)
{
static
String
getFileName
(
String
fileName
,
int
id
)
{
if
(
id
>
0
)
{
if
(
id
>
0
)
{
fileName
+=
"."
+
id
+
Constants
.
SUFFIX_SPLIT_FILE
;
fileName
+=
"."
+
id
+
PART_SUFFIX
;
}
}
return
fileName
;
return
fileName
;
}
}
...
...
h2/src/test/org/h2/test/TestBase.java
浏览文件 @
eb1babad
...
@@ -184,7 +184,16 @@ public abstract class TestBase {
...
@@ -184,7 +184,16 @@ public abstract class TestBase {
* @return the login password
* @return the login password
*/
*/
protected
String
getPassword
(
String
userPassword
)
{
protected
String
getPassword
(
String
userPassword
)
{
return
config
==
null
||
config
.
cipher
==
null
?
userPassword
:
"filePassword "
+
userPassword
;
return
config
==
null
||
config
.
cipher
==
null
?
userPassword
:
getFilePassword
()
+
" "
+
userPassword
;
}
/**
* Get the file password (only required if file encryption is used).
*
* @return the file password
*/
protected
String
getFilePassword
()
{
return
"filePassword"
;
}
}
/**
/**
...
...
h2/src/test/org/h2/test/db/TestRunscript.java
浏览文件 @
eb1babad
...
@@ -6,7 +6,6 @@
...
@@ -6,7 +6,6 @@
*/
*/
package
org
.
h2
.
test
.
db
;
package
org
.
h2
.
test
.
db
;
import
java.io.File
;
import
java.sql.Connection
;
import
java.sql.Connection
;
import
java.sql.PreparedStatement
;
import
java.sql.PreparedStatement
;
import
java.sql.SQLException
;
import
java.sql.SQLException
;
...
@@ -151,14 +150,9 @@ public class TestRunscript extends TestBase implements Trigger {
...
@@ -151,14 +150,9 @@ public class TestRunscript extends TestBase implements Trigger {
private
void
test
(
boolean
password
)
throws
SQLException
{
private
void
test
(
boolean
password
)
throws
SQLException
{
deleteDb
(
"runscript"
);
deleteDb
(
"runscript"
);
Connection
conn1
,
conn2
,
conn3
;
Connection
conn1
,
conn2
;
Statement
stat1
,
stat2
,
stat3
;
Statement
stat1
,
stat2
;
String
connectionString1
=
"jdbc:h2:split:16:"
+
getBaseDir
()
+
"/runscript;MAX_LENGTH_INPLACE_LOB=1"
;
conn1
=
getConnection
(
"runscript"
);
String
connectionString2
=
"jdbc:h2:split:16:"
+
getBaseDir
()
+
"/runscriptRestore;MAX_LENGTH_INPLACE_LOB=1"
;
String
connectionString3
=
"jdbc:h2:split:16:"
+
getBaseDir
()
+
"/runscriptRestoreRecover;MAX_LENGTH_INPLACE_LOB=1"
;
conn1
=
getConnection
(
connectionString1
+
";CIPHER=AES"
,
"user"
,
"pw pw"
);
stat1
=
conn1
.
createStatement
();
stat1
=
conn1
.
createStatement
();
stat1
.
execute
(
"create table test (id identity, name varchar(12))"
);
stat1
.
execute
(
"create table test (id identity, name varchar(12))"
);
stat1
.
execute
(
"insert into test (name) values ('first'), ('second')"
);
stat1
.
execute
(
"insert into test (name) values ('first'), ('second')"
);
...
@@ -171,8 +165,7 @@ public class TestRunscript extends TestBase implements Trigger {
...
@@ -171,8 +165,7 @@ public class TestRunscript extends TestBase implements Trigger {
stat1
.
execute
(
"create schema testSchema authorization testAdmin"
);
stat1
.
execute
(
"create schema testSchema authorization testAdmin"
);
stat1
.
execute
(
"create table testSchema.parent(id int primary key, name varchar)"
);
stat1
.
execute
(
"create table testSchema.parent(id int primary key, name varchar)"
);
stat1
.
execute
(
"create index idxname on testSchema.parent(name)"
);
stat1
.
execute
(
"create index idxname on testSchema.parent(name)"
);
stat1
stat1
.
execute
(
"create table testSchema.child(id int primary key, parentId int, name varchar, foreign key(parentId) references parent(id))"
);
.
execute
(
"create table testSchema.child(id int primary key, parentId int, name varchar, foreign key(parentId) references parent(id))"
);
stat1
.
execute
(
"create user testUser salt '02' hash '03'"
);
stat1
.
execute
(
"create user testUser salt '02' hash '03'"
);
stat1
.
execute
(
"create role testRole"
);
stat1
.
execute
(
"create role testRole"
);
stat1
.
execute
(
"grant all on testSchema.child to testUser"
);
stat1
.
execute
(
"grant all on testSchema.child to testUser"
);
...
@@ -187,9 +180,9 @@ public class TestRunscript extends TestBase implements Trigger {
...
@@ -187,9 +180,9 @@ public class TestRunscript extends TestBase implements Trigger {
sql
+=
" CIPHER AES PASSWORD 't1e2s3t4'"
;
sql
+=
" CIPHER AES PASSWORD 't1e2s3t4'"
;
}
}
stat1
.
execute
(
sql
);
stat1
.
execute
(
sql
);
deleteDb
(
"runscriptRestore"
);
deleteDb
(
"runscriptRestore"
);
conn2
=
getConnection
(
connectionString2
,
"user"
,
"pw pw
"
);
conn2
=
getConnection
(
"runscriptRestore
"
);
stat2
=
conn2
.
createStatement
();
stat2
=
conn2
.
createStatement
();
sql
=
"runscript from '"
+
getBaseDir
()
+
"/backup.2.sql'"
;
sql
=
"runscript from '"
+
getBaseDir
()
+
"/backup.2.sql'"
;
if
(
password
)
{
if
(
password
)
{
...
@@ -209,39 +202,46 @@ public class TestRunscript extends TestBase implements Trigger {
...
@@ -209,39 +202,46 @@ public class TestRunscript extends TestBase implements Trigger {
}
}
stat2
.
execute
(
sql
);
stat2
.
execute
(
sql
);
stat2
.
execute
(
"script to '"
+
getBaseDir
()
+
"/backup.3.sql'"
);
stat2
.
execute
(
"script to '"
+
getBaseDir
()
+
"/backup.3.sql'"
);
conn1
.
close
();
ChangeFileEncryption
.
execute
(
"split:"
+
getBaseDir
(),
"runscript"
,
"AES"
,
"pw"
.
toCharArray
(),
null
,
true
);
Recover
.
execute
(
"split:"
+
getBaseDir
(),
"runscript"
);
deleteDb
(
"runscriptRestoreRecover"
);
conn3
=
getConnection
(
connectionString3
,
"abc"
,
"pw"
);
stat3
=
conn3
.
createStatement
();
stat3
.
execute
(
"runscript from '"
+
getBaseDir
()
+
"/runscript.h2.sql'"
);
conn3
.
close
();
conn3
=
getConnection
(
connectionString3
,
"user"
,
"pw"
);
stat3
=
conn3
.
createStatement
();
stat3
.
execute
(
"drop user abc"
);
conn1
=
getConnection
(
connectionString1
,
"user"
,
"pw"
);
stat1
=
conn1
.
createStatement
();
assertEqualDatabases
(
stat1
,
stat2
);
assertEqualDatabases
(
stat1
,
stat2
);
assertEqualDatabases
(
stat1
,
stat3
);
if
(!
config
.
memory
)
{
conn1
.
close
();
if
(
config
.
cipher
!=
null
)
{
ChangeFileEncryption
.
execute
(
getBaseDir
(),
"runscript"
,
config
.
cipher
,
getFilePassword
().
toCharArray
(),
null
,
true
);
}
Recover
.
execute
(
getBaseDir
(),
"runscript"
);
deleteDb
(
"runscriptRestoreRecover"
);
Connection
conn3
=
getConnection
(
"runscriptRestoreRecover"
,
"tempUser"
,
getPassword
());
Statement
stat3
=
conn3
.
createStatement
();
stat3
.
execute
(
"runscript from '"
+
getBaseDir
()
+
"/runscript.h2.sql'"
);
conn3
.
close
();
conn3
=
getConnection
(
"runscriptRestoreRecover"
);
stat3
=
conn3
.
createStatement
();
stat3
.
execute
(
"drop user tempUser"
);
if
(
config
.
cipher
!=
null
)
{
ChangeFileEncryption
.
execute
(
getBaseDir
(),
"runscript"
,
config
.
cipher
,
null
,
getFilePassword
().
toCharArray
(),
true
);
}
conn1
=
getConnection
(
"runscript"
);
stat1
=
conn1
.
createStatement
();
assertEqualDatabases
(
stat1
,
stat3
);
conn3
.
close
();
}
assertEqualDatabases
(
stat1
,
stat2
);
conn1
.
close
();
conn1
.
close
();
conn2
.
close
();
conn2
.
close
();
conn3
.
close
();
// .txt file from recovery
File
[]
files
=
new
File
(
getBaseDir
()
+
"/runscript.lobs.db"
).
listFiles
();
for
(
File
file
:
files
)
{
IOUtils
.
delete
(
file
.
getAbsolutePath
());
}
IOUtils
.
delete
(
getBaseDir
()
+
"/backup.2.sql"
);
IOUtils
.
delete
(
getBaseDir
()
+
"/backup.3.sql"
);
IOUtils
.
delete
(
getBaseDir
()
+
"/runscript.h2.sql"
);
deleteDb
(
"runscript"
);
deleteDb
(
"runscriptRestore"
);
deleteDb
(
"runscriptRestore"
);
deleteDb
(
"runscriptRestoreRecover"
);
deleteDb
(
"runscriptRestoreRecover"
);
IOUtils
.
delete
(
getBaseDir
()
+
"/backup.2.sql"
);
IOUtils
.
delete
(
getBaseDir
()
+
"/backup.3.sql"
);
}
}
public
void
init
(
Connection
conn
,
String
schemaName
,
String
triggerName
,
String
tableName
,
boolean
before
,
int
type
)
{
public
void
init
(
Connection
conn
,
String
schemaName
,
String
triggerName
,
String
tableName
,
boolean
before
,
int
type
)
{
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论