Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
c722ed60
提交
c722ed60
authored
1月 15, 2015
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Use constants where possible.
上级
42a65e3f
显示空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
30 行增加
和
16 行删除
+30
-16
Constants.java
h2/src/main/org/h2/engine/Constants.java
+5
-1
Database.java
h2/src/main/org/h2/engine/Database.java
+1
-1
DbUpgrade.java
h2/src/main/org/h2/upgrade/DbUpgrade.java
+4
-3
TestSpaceReuse.java
h2/src/test/org/h2/test/db/TestSpaceReuse.java
+18
-9
Migrate.java
h2/src/tools/org/h2/dev/util/Migrate.java
+2
-2
没有找到文件。
h2/src/main/org/h2/engine/Constants.java
浏览文件 @
c722ed60
...
@@ -431,11 +431,15 @@ public class Constants {
...
@@ -431,11 +431,15 @@ public class Constants {
*/
*/
public
static
final
String
SUFFIX_LOCK_FILE
=
".lock.db"
;
public
static
final
String
SUFFIX_LOCK_FILE
=
".lock.db"
;
/**
* The file name suffix of a H2 version 1.1 database file.
*/
public
static
final
String
SUFFIX_OLD_DATABASE_FILE
=
".data.db"
;
/**
/**
* The file name suffix of page files.
* The file name suffix of page files.
*/
*/
public
static
final
String
SUFFIX_PAGE_FILE
=
".h2.db"
;
public
static
final
String
SUFFIX_PAGE_FILE
=
".h2.db"
;
/**
/**
* The file name suffix of a MVStore file.
* The file name suffix of a MVStore file.
*/
*/
...
...
h2/src/main/org/h2/engine/Database.java
浏览文件 @
c722ed60
...
@@ -568,7 +568,7 @@ public class Database implements DataHandler {
...
@@ -568,7 +568,7 @@ public class Database implements DataHandler {
private
synchronized
void
open
(
int
traceLevelFile
,
int
traceLevelSystemOut
)
{
private
synchronized
void
open
(
int
traceLevelFile
,
int
traceLevelSystemOut
)
{
if
(
persistent
)
{
if
(
persistent
)
{
String
dataFileName
=
databaseName
+
".data.db"
;
String
dataFileName
=
databaseName
+
Constants
.
SUFFIX_OLD_DATABASE_FILE
;
boolean
existsData
=
FileUtils
.
exists
(
dataFileName
);
boolean
existsData
=
FileUtils
.
exists
(
dataFileName
);
String
pageFileName
=
databaseName
+
Constants
.
SUFFIX_PAGE_FILE
;
String
pageFileName
=
databaseName
+
Constants
.
SUFFIX_PAGE_FILE
;
String
mvFileName
=
databaseName
+
Constants
.
SUFFIX_MV_FILE
;
String
mvFileName
=
databaseName
+
Constants
.
SUFFIX_MV_FILE
;
...
...
h2/src/main/org/h2/upgrade/DbUpgrade.java
浏览文件 @
c722ed60
...
@@ -13,6 +13,7 @@ import java.sql.Statement;
...
@@ -13,6 +13,7 @@ import java.sql.Statement;
import
java.util.Properties
;
import
java.util.Properties
;
import
java.util.UUID
;
import
java.util.UUID
;
import
org.h2.engine.ConnectionInfo
;
import
org.h2.engine.ConnectionInfo
;
import
org.h2.engine.Constants
;
import
org.h2.jdbc.JdbcConnection
;
import
org.h2.jdbc.JdbcConnection
;
import
org.h2.message.DbException
;
import
org.h2.message.DbException
;
import
org.h2.store.fs.FileUtils
;
import
org.h2.store.fs.FileUtils
;
...
@@ -62,10 +63,10 @@ public class DbUpgrade {
...
@@ -62,10 +63,10 @@ public class DbUpgrade {
return
null
;
return
null
;
}
}
String
name
=
ci
.
getName
();
String
name
=
ci
.
getName
();
if
(
FileUtils
.
exists
(
name
+
".h2.db"
))
{
if
(
FileUtils
.
exists
(
name
+
Constants
.
SUFFIX_PAGE_FILE
))
{
return
null
;
return
null
;
}
}
if
(!
FileUtils
.
exists
(
name
+
".data.db"
))
{
if
(!
FileUtils
.
exists
(
name
+
Constants
.
SUFFIX_OLD_DATABASE_FILE
))
{
return
null
;
return
null
;
}
}
if
(
ci
.
removeProperty
(
"NO_UPGRADE"
,
false
))
{
if
(
ci
.
removeProperty
(
"NO_UPGRADE"
,
false
))
{
...
@@ -110,7 +111,7 @@ public class DbUpgrade {
...
@@ -110,7 +111,7 @@ public class DbUpgrade {
private
static
void
upgrade
(
ConnectionInfo
ci
,
Properties
info
)
private
static
void
upgrade
(
ConnectionInfo
ci
,
Properties
info
)
throws
SQLException
{
throws
SQLException
{
String
name
=
ci
.
getName
();
String
name
=
ci
.
getName
();
String
data
=
name
+
".data.db"
;
String
data
=
name
+
Constants
.
SUFFIX_OLD_DATABASE_FILE
;
String
index
=
name
+
".index.db"
;
String
index
=
name
+
".index.db"
;
String
lobs
=
name
+
".lobs.db"
;
String
lobs
=
name
+
".lobs.db"
;
String
backupData
=
data
+
".backup"
;
String
backupData
=
data
+
".backup"
;
...
...
h2/src/test/org/h2/test/db/TestSpaceReuse.java
浏览文件 @
c722ed60
...
@@ -5,11 +5,12 @@
...
@@ -5,11 +5,12 @@
*/
*/
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.SQLException
;
import
java.sql.SQLException
;
import
java.sql.Statement
;
import
java.sql.Statement
;
import
org.h2.engine.Constants
;
import
org.h2.store.fs.FileUtils
;
import
org.h2.test.TestBase
;
import
org.h2.test.TestBase
;
/**
/**
...
@@ -32,24 +33,32 @@ public class TestSpaceReuse extends TestBase {
...
@@ -32,24 +33,32 @@ public class TestSpaceReuse extends TestBase {
return
;
return
;
}
}
deleteDb
(
"spaceReuse"
);
deleteDb
(
"spaceReuse"
);
long
first
=
0
,
now
=
0
;
long
max
=
0
,
now
=
0
,
min
=
Long
.
MAX_VALUE
;
for
(
int
i
=
0
;
i
<
1
0
;
i
++)
{
for
(
int
i
=
0
;
i
<
2
0
;
i
++)
{
Connection
conn
=
getConnection
(
"spaceReuse"
);
Connection
conn
=
getConnection
(
"spaceReuse"
);
Statement
stat
=
conn
.
createStatement
();
Statement
stat
=
conn
.
createStatement
();
stat
.
execute
(
"set retention_time 0"
);
stat
.
execute
(
"create table if not exists t(i int)"
);
stat
.
execute
(
"create table if not exists t(i int)"
);
stat
.
execute
(
"insert into t select x from system_range(1, 500)"
);
stat
.
execute
(
"insert into t select x from system_range(1, 500)"
);
conn
.
close
();
conn
.
close
();
conn
=
getConnection
(
"spaceReuse"
);
conn
=
getConnection
(
"spaceReuse"
);
conn
.
createStatement
().
execute
(
"delete from t"
);
conn
.
createStatement
().
execute
(
"delete from t"
);
conn
.
close
();
conn
.
close
();
now
=
new
File
(
getBaseDir
()
+
"/spaceReuse.data.db"
).
length
();
String
fileName
=
getBaseDir
()
+
"/spaceReuse"
;
if
(
first
==
0
)
{
if
(
Constants
.
VERSION_MINOR
>=
4
)
{
first
=
now
;
fileName
+=
Constants
.
SUFFIX_MV_FILE
;
}
else
{
fileName
+=
Constants
.
SUFFIX_PAGE_FILE
;
}
}
now
=
FileUtils
.
size
(
fileName
);
assertTrue
(
now
>
0
);
if
(
i
<
10
)
{
max
=
Math
.
max
(
max
,
now
);
}
else
{
min
=
Math
.
min
(
min
,
now
);
}
}
if
(
now
>
first
)
{
fail
(
"first: "
+
first
+
" now: "
+
now
);
}
}
assertTrue
(
"min: "
+
min
+
" max: "
+
max
,
min
<=
max
);
deleteDb
(
"spaceReuse"
);
deleteDb
(
"spaceReuse"
);
}
}
...
...
h2/src/tools/org/h2/dev/util/Migrate.java
浏览文件 @
c722ed60
...
@@ -73,7 +73,7 @@ public class Migrate {
...
@@ -73,7 +73,7 @@ public class Migrate {
}
}
return
;
return
;
}
}
if
(!
file
.
getName
().
endsWith
(
".data.db"
))
{
if
(!
file
.
getName
().
endsWith
(
Constants
.
SUFFIX_OLD_DATABASE_FILE
))
{
return
;
return
;
}
}
println
(
"Migrating "
+
file
.
getName
());
println
(
"Migrating "
+
file
.
getName
());
...
@@ -81,7 +81,7 @@ public class Migrate {
...
@@ -81,7 +81,7 @@ public class Migrate {
download
(
OLD_H2_FILE
.
getAbsolutePath
(),
DOWNLOAD_URL
,
CHECKSUM
);
download
(
OLD_H2_FILE
.
getAbsolutePath
(),
DOWNLOAD_URL
,
CHECKSUM
);
}
}
String
url
=
"jdbc:h2:"
+
file
.
getAbsolutePath
();
String
url
=
"jdbc:h2:"
+
file
.
getAbsolutePath
();
url
=
url
.
substring
(
0
,
url
.
length
()
-
".data.db"
.
length
());
url
=
url
.
substring
(
0
,
url
.
length
()
-
Constants
.
SUFFIX_OLD_DATABASE_FILE
.
length
());
exec
(
new
String
[]
{
exec
(
new
String
[]
{
pathToJavaExe
,
pathToJavaExe
,
"-Xmx128m"
,
"-Xmx128m"
,
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论