Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
81155475
提交
81155475
authored
15 年前
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
SHUTDOWN COMPACT now fully compacts the database.
上级
9a695218
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
31 行增加
和
9 行删除
+31
-9
Parser.java
h2/src/main/org/h2/command/Parser.java
+3
-3
TransactionCommand.java
h2/src/main/org/h2/command/dml/TransactionCommand.java
+11
-2
Database.java
h2/src/main/org/h2/engine/Database.java
+17
-4
没有找到文件。
h2/src/main/org/h2/command/Parser.java
浏览文件 @
81155475
...
...
@@ -517,10 +517,10 @@ public class Parser {
int
type
=
TransactionCommand
.
SHUTDOWN
;
if
(
readIf
(
"IMMEDIATELY"
))
{
type
=
TransactionCommand
.
SHUTDOWN_IMMEDIATELY
;
}
else
if
(
readIf
(
"COMPACT"
))
{
type
=
TransactionCommand
.
SHUTDOWN_COMPACT
;
}
else
{
if
(!
readIf
(
"COMPACT"
))
{
readIf
(
"SCRIPT"
);
}
readIf
(
"SCRIPT"
);
}
return
new
TransactionCommand
(
session
,
type
);
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/command/dml/TransactionCommand.java
浏览文件 @
81155475
...
...
@@ -85,10 +85,15 @@ public class TransactionCommand extends Prepared {
*/
public
static
final
int
SHUTDOWN_IMMEDIATELY
=
13
;
/**
* The type of a SHUTDOWN COMPACT statement.
*/
public
static
final
int
SHUTDOWN_COMPACT
=
14
;
/**
* The type of a BEGIN {WORK|TRANSACTION} statement.
*/
public
static
final
int
BEGIN
=
1
4
;
public
static
final
int
BEGIN
=
1
5
;
private
int
type
;
private
String
savepointName
;
...
...
@@ -149,9 +154,13 @@ public class TransactionCommand extends Prepared {
session
.
getUser
().
checkAdmin
();
session
.
getDatabase
().
shutdownImmediately
();
break
;
case
SHUTDOWN:
{
case
SHUTDOWN:
case
SHUTDOWN_COMPACT:
{
session
.
getUser
().
checkAdmin
();
session
.
commit
(
false
);
if
(
type
==
SHUTDOWN_COMPACT
)
{
session
.
getDatabase
().
setCompactFully
(
true
);
}
// close the database, but don't update the persistent setting
session
.
getDatabase
().
setCloseDelay
(
0
);
Database
db
=
session
.
getDatabase
();
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/engine/Database.java
浏览文件 @
81155475
...
...
@@ -15,7 +15,6 @@ import java.util.HashSet;
import
java.util.Properties
;
import
java.util.Set
;
import
java.util.StringTokenizer
;
import
org.h2.api.DatabaseEventListener
;
import
org.h2.command.ddl.CreateTableData
;
import
org.h2.command.dml.SetTypes
;
...
...
@@ -55,6 +54,7 @@ import org.h2.table.TableData;
import
org.h2.table.TableLinkConnection
;
import
org.h2.table.TableView
;
import
org.h2.tools.DeleteDbFiles
;
import
org.h2.tools.Recover
;
import
org.h2.tools.Server
;
import
org.h2.util.BitField
;
import
org.h2.util.ByteUtils
;
...
...
@@ -174,6 +174,8 @@ public class Database implements DataHandler {
private
int
cacheSize
;
private
boolean
compactFully
;
public
Database
(
String
name
,
ConnectionInfo
ci
,
String
cipher
)
throws
SQLException
{
this
.
compareMode
=
CompareMode
.
getInstance
(
null
,
0
);
this
.
persistent
=
ci
.
isPersistent
();
...
...
@@ -550,10 +552,17 @@ public class Database implements DataHandler {
private
synchronized
void
open
(
int
traceLevelFile
,
int
traceLevelSystemOut
)
throws
SQLException
{
if
(
persistent
)
{
String
pageFileName
=
databaseName
+
Constants
.
SUFFIX_PAGE_FILE
;
boolean
existsPage
=
FileUtils
.
exists
(
pageFileName
);
String
dataFileName
=
databaseName
+
Constants
.
SUFFIX_DATA_FILE
;
boolean
existsData
=
FileUtils
.
exists
(
dataFileName
);
String
pageFileName
=
databaseName
+
Constants
.
SUFFIX_PAGE_FILE
;
boolean
existsPage
=
FileUtils
.
exists
(
pageFileName
);
if
(
usePageStoreSet
&&
usePageStore
&&
existsData
&&
!
existsPage
)
{
String
dir
=
FileUtils
.
getParent
(
databaseName
);
String
db
=
FileUtils
.
getFileName
(
databaseName
);
Recover
.
convert
(
dir
,
db
);
existsData
=
FileUtils
.
exists
(
dataFileName
);
existsPage
=
FileUtils
.
exists
(
pageFileName
);
}
if
(!
usePageStoreSet
)
{
// if the URL flag is not set
if
(
existsData
&&
!
existsPage
)
{
...
...
@@ -1278,7 +1287,7 @@ public class Database implements DataHandler {
try
{
pageStore
.
checkpoint
();
if
(!
readOnly
)
{
pageStore
.
trim
(
);
pageStore
.
compact
(
compactFully
);
}
}
catch
(
Throwable
e
)
{
// TODO don't ignore exceptions
...
...
@@ -2480,4 +2489,8 @@ public class Database implements DataHandler {
this
.
readOnly
=
readOnly
;
}
public
void
setCompactFully
(
boolean
compactFully
)
{
this
.
compactFully
=
compactFully
;
}
}
This diff is collapsed.
Click to expand it.
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论