Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
5a7685a3
提交
5a7685a3
authored
4月 23, 2009
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
After truncating tables, opening large databases could become slow.
上级
f7eebbbb
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
40 行增加
和
1 行删除
+40
-1
TestDatabaseEventListener.java
h2/src/test/org/h2/test/jdbc/TestDatabaseEventListener.java
+40
-1
没有找到文件。
h2/src/test/org/h2/test/jdbc/TestDatabaseEventListener.java
浏览文件 @
5a7685a3
...
@@ -32,6 +32,7 @@ public class TestDatabaseEventListener extends TestBase implements DatabaseEvent
...
@@ -32,6 +32,7 @@ public class TestDatabaseEventListener extends TestBase implements DatabaseEvent
}
}
public
void
test
()
throws
SQLException
{
public
void
test
()
throws
SQLException
{
testIndexRebuiltOnce
();
testIndexNotRebuilt
();
testIndexNotRebuilt
();
testCalled
();
testCalled
();
testCloseLog0
(
false
);
testCloseLog0
(
false
);
...
@@ -39,6 +40,45 @@ public class TestDatabaseEventListener extends TestBase implements DatabaseEvent
...
@@ -39,6 +40,45 @@ public class TestDatabaseEventListener extends TestBase implements DatabaseEvent
deleteDb
(
"databaseEventListener"
);
deleteDb
(
"databaseEventListener"
);
}
}
private
void
testIndexRebuiltOnce
()
throws
SQLException
{
if
(
config
.
memory
)
{
return
;
}
deleteDb
(
"databaseEventListener"
);
String
url
=
getURL
(
"databaseEventListener"
,
true
);
String
user
=
getUser
(),
password
=
getPassword
();
Properties
p
=
new
Properties
();
p
.
setProperty
(
"user"
,
user
);
p
.
setProperty
(
"password"
,
password
);
Connection
conn
=
DriverManager
.
getConnection
(
url
,
p
);
Statement
stat
=
conn
.
createStatement
();
// the old.id index head is at position 0
stat
.
execute
(
"create table old(id identity) as select 1"
);
// the test.id index head is at position 1
stat
.
execute
(
"create table test(id identity) as select 1"
);
conn
.
close
();
conn
=
DriverManager
.
getConnection
(
url
,
p
);
stat
=
conn
.
createStatement
();
// free up space at position 0
stat
.
execute
(
"drop table old"
);
stat
.
execute
(
"insert into test values(2)"
);
stat
.
execute
(
"checkpoint sync"
);
stat
.
execute
(
"shutdown immediately"
);
try
{
conn
.
close
();
}
catch
(
SQLException
e
)
{
assertKnownException
(
e
);
}
// now the index should be re-built
conn
=
DriverManager
.
getConnection
(
url
,
p
);
conn
.
close
();
TestDatabaseEventListener
l
=
new
TestDatabaseEventListener
();
p
.
put
(
"DATABASE_EVENT_LISTENER_OBJECT"
,
l
);
conn
=
org
.
h2
.
Driver
.
load
().
connect
(
url
,
p
);
conn
.
close
();
assertTrue
(!
l
.
calledCreateIndex
);
}
private
void
testIndexNotRebuilt
()
throws
SQLException
{
private
void
testIndexNotRebuilt
()
throws
SQLException
{
if
(
config
.
memory
)
{
if
(
config
.
memory
)
{
return
;
return
;
...
@@ -69,7 +109,6 @@ public class TestDatabaseEventListener extends TestBase implements DatabaseEvent
...
@@ -69,7 +109,6 @@ public class TestDatabaseEventListener extends TestBase implements DatabaseEvent
conn
=
org
.
h2
.
Driver
.
load
().
connect
(
url
,
p
);
conn
=
org
.
h2
.
Driver
.
load
().
connect
(
url
,
p
);
conn
.
close
();
conn
.
close
();
assertTrue
(!
l
.
calledCreateIndex
);
assertTrue
(!
l
.
calledCreateIndex
);
}
}
private
void
testCloseLog0
(
boolean
shutdown
)
throws
SQLException
{
private
void
testCloseLog0
(
boolean
shutdown
)
throws
SQLException
{
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论