Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
19cae1cd
提交
19cae1cd
authored
5月 03, 2013
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Test
上级
64e6b5b8
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
74 行增加
和
72 行删除
+74
-72
TestPageStore.java
h2/src/test/org/h2/test/unit/TestPageStore.java
+74
-72
没有找到文件。
h2/src/test/org/h2/test/unit/TestPageStore.java
浏览文件 @
19cae1cd
...
@@ -46,6 +46,7 @@ public class TestPageStore extends TestBase implements DatabaseEventListener {
...
@@ -46,6 +46,7 @@ public class TestPageStore extends TestBase implements DatabaseEventListener {
}
}
public
void
test
()
throws
Exception
{
public
void
test
()
throws
Exception
{
deleteDb
(
null
);
testDropTempTable
();
testDropTempTable
();
testLogLimitFalsePositive
();
testLogLimitFalsePositive
();
testLogLimit
();
testLogLimit
();
...
@@ -76,7 +77,7 @@ public class TestPageStore extends TestBase implements DatabaseEventListener {
...
@@ -76,7 +77,7 @@ public class TestPageStore extends TestBase implements DatabaseEventListener {
testUniqueIndex
();
testUniqueIndex
();
testCreateIndexLater
();
testCreateIndexLater
();
testFuzzOperations
();
testFuzzOperations
();
deleteDb
(
"pageStore"
);
deleteDb
(
null
);
}
}
private
void
testDropTempTable
()
throws
SQLException
{
private
void
testDropTempTable
()
throws
SQLException
{
...
@@ -135,8 +136,8 @@ public class TestPageStore extends TestBase implements DatabaseEventListener {
...
@@ -135,8 +136,8 @@ public class TestPageStore extends TestBase implements DatabaseEventListener {
}
}
private
void
testLogLimitFalsePositive
()
throws
Exception
{
private
void
testLogLimitFalsePositive
()
throws
Exception
{
deleteDb
(
"pageStore"
);
deleteDb
(
"pageStore
LogLimitFalsePositive
"
);
String
url
=
"pageStore;TRACE_LEVEL_FILE=2"
;
String
url
=
"pageStore
LogLimitFalsePositive
;TRACE_LEVEL_FILE=2"
;
Connection
conn
=
getConnection
(
url
);
Connection
conn
=
getConnection
(
url
);
Statement
stat
=
conn
.
createStatement
();
Statement
stat
=
conn
.
createStatement
();
stat
.
execute
(
"set max_log_size 1"
);
stat
.
execute
(
"set max_log_size 1"
);
...
@@ -145,15 +146,16 @@ public class TestPageStore extends TestBase implements DatabaseEventListener {
...
@@ -145,15 +146,16 @@ public class TestPageStore extends TestBase implements DatabaseEventListener {
stat
.
execute
(
"insert into test values (space(2000))"
);
stat
.
execute
(
"insert into test values (space(2000))"
);
}
}
stat
.
execute
(
"checkpoint"
);
stat
.
execute
(
"checkpoint"
);
InputStream
in
=
FileUtils
.
newInputStream
(
getBaseDir
()
+
"/pageStore.trace.db"
);
InputStream
in
=
FileUtils
.
newInputStream
(
getBaseDir
()
+
"/pageStoreLogLimitFalsePositive.trace.db"
);
String
s
=
IOUtils
.
readStringAndClose
(
new
InputStreamReader
(
in
),
-
1
);
String
s
=
IOUtils
.
readStringAndClose
(
new
InputStreamReader
(
in
),
-
1
);
assertFalse
(
s
.
indexOf
(
"Transaction log could not be truncated"
)
>
0
);
assertFalse
(
s
.
indexOf
(
"Transaction log could not be truncated"
)
>
0
);
conn
.
close
();
conn
.
close
();
}
}
private
void
testRecoverLobInDatabase
()
throws
SQLException
{
private
void
testRecoverLobInDatabase
()
throws
SQLException
{
deleteDb
(
"pageStore"
);
deleteDb
(
"pageStore
RecoverLobInDatabase
"
);
String
url
=
getURL
(
"pageStore;MVCC=TRUE;CACHE_SIZE=1"
,
true
);
String
url
=
getURL
(
"pageStore
RecoverLobInDatabase
;MVCC=TRUE;CACHE_SIZE=1"
,
true
);
Connection
conn
;
Connection
conn
;
Statement
stat
;
Statement
stat
;
conn
=
getConnection
(
url
,
getUser
(),
getPassword
());
conn
=
getConnection
(
url
,
getUser
(),
getPassword
());
...
@@ -187,8 +189,8 @@ public class TestPageStore extends TestBase implements DatabaseEventListener {
...
@@ -187,8 +189,8 @@ public class TestPageStore extends TestBase implements DatabaseEventListener {
}
}
private
void
testWriteTransactionLogBeforeData
()
throws
SQLException
{
private
void
testWriteTransactionLogBeforeData
()
throws
SQLException
{
deleteDb
(
"pageStore"
);
deleteDb
(
"pageStore
WriteTransactionLogBeforeData
"
);
String
url
=
getURL
(
"pageStore;CACHE_SIZE=16;WRITE_DELAY=1000000"
,
true
);
String
url
=
getURL
(
"pageStore
WriteTransactionLogBeforeData
;CACHE_SIZE=16;WRITE_DELAY=1000000"
,
true
);
Connection
conn
;
Connection
conn
;
Statement
stat
;
Statement
stat
;
conn
=
getConnection
(
url
,
getUser
(),
getPassword
());
conn
=
getConnection
(
url
,
getUser
(),
getPassword
());
...
@@ -220,8 +222,8 @@ public class TestPageStore extends TestBase implements DatabaseEventListener {
...
@@ -220,8 +222,8 @@ public class TestPageStore extends TestBase implements DatabaseEventListener {
if
(
config
.
reopen
)
{
if
(
config
.
reopen
)
{
return
;
return
;
}
}
deleteDb
(
"pageStore"
);
deleteDb
(
"pageStore
Defrag
"
);
Connection
conn
=
getConnection
(
"pageStore;LOG=0;UNDO_LOG=0;LOCK_MODE=0"
);
Connection
conn
=
getConnection
(
"pageStore
Defrag
;LOG=0;UNDO_LOG=0;LOCK_MODE=0"
);
Statement
stat
=
conn
.
createStatement
();
Statement
stat
=
conn
.
createStatement
();
int
tableCount
=
10
;
int
tableCount
=
10
;
int
rowCount
=
getSize
(
1000
,
100000
);
int
rowCount
=
getSize
(
1000
,
100000
);
...
@@ -244,9 +246,9 @@ public class TestPageStore extends TestBase implements DatabaseEventListener {
...
@@ -244,9 +246,9 @@ public class TestPageStore extends TestBase implements DatabaseEventListener {
}
}
private
void
testInsertReverse
()
throws
SQLException
{
private
void
testInsertReverse
()
throws
SQLException
{
deleteDb
(
"pageStore"
);
deleteDb
(
"pageStore
InsertReverse
"
);
Connection
conn
;
Connection
conn
;
conn
=
getConnection
(
"pageStore"
);
conn
=
getConnection
(
"pageStore
InsertReverse
"
);
Statement
stat
=
conn
.
createStatement
();
Statement
stat
=
conn
.
createStatement
();
stat
.
execute
(
"create table test(id int primary key, data varchar)"
);
stat
.
execute
(
"create table test(id int primary key, data varchar)"
);
stat
.
execute
(
"insert into test select -x, space(100) from system_range(1, 1000)"
);
stat
.
execute
(
"insert into test select -x, space(100) from system_range(1, 1000)"
);
...
@@ -280,9 +282,9 @@ public class TestPageStore extends TestBase implements DatabaseEventListener {
...
@@ -280,9 +282,9 @@ public class TestPageStore extends TestBase implements DatabaseEventListener {
}
}
private
void
testCheckpoint
()
throws
SQLException
{
private
void
testCheckpoint
()
throws
SQLException
{
deleteDb
(
"pageStore"
);
deleteDb
(
"pageStore
Checkpoint
"
);
Connection
conn
;
Connection
conn
;
conn
=
getConnection
(
"pageStore"
);
conn
=
getConnection
(
"pageStore
Checkpoint
"
);
Statement
stat
=
conn
.
createStatement
();
Statement
stat
=
conn
.
createStatement
();
stat
.
execute
(
"create table test(data varchar)"
);
stat
.
execute
(
"create table test(data varchar)"
);
stat
.
execute
(
"create sequence seq"
);
stat
.
execute
(
"create sequence seq"
);
...
@@ -307,9 +309,9 @@ public class TestPageStore extends TestBase implements DatabaseEventListener {
...
@@ -307,9 +309,9 @@ public class TestPageStore extends TestBase implements DatabaseEventListener {
if
(
config
.
memory
)
{
if
(
config
.
memory
)
{
return
;
return
;
}
}
deleteDb
(
"pageStore"
);
deleteDb
(
"pageStore
DropRecreate
"
);
Connection
conn
;
Connection
conn
;
conn
=
getConnection
(
"pageStore"
);
conn
=
getConnection
(
"pageStore
DropRecreate
"
);
Statement
stat
=
conn
.
createStatement
();
Statement
stat
=
conn
.
createStatement
();
stat
.
execute
(
"create table test(id int)"
);
stat
.
execute
(
"create table test(id int)"
);
stat
.
execute
(
"create index idx_test on test(id)"
);
stat
.
execute
(
"create index idx_test on test(id)"
);
...
@@ -319,14 +321,14 @@ public class TestPageStore extends TestBase implements DatabaseEventListener {
...
@@ -319,14 +321,14 @@ public class TestPageStore extends TestBase implements DatabaseEventListener {
// which is lower than the object id of test2
// which is lower than the object id of test2
stat
.
execute
(
"create index idx_test on test2(id)"
);
stat
.
execute
(
"create index idx_test on test2(id)"
);
conn
.
close
();
conn
.
close
();
conn
=
getConnection
(
"pageStore"
);
conn
=
getConnection
(
"pageStore
DropRecreate
"
);
conn
.
close
();
conn
.
close
();
}
}
private
void
testDropAll
()
throws
SQLException
{
private
void
testDropAll
()
throws
SQLException
{
deleteDb
(
"pageStore"
);
deleteDb
(
"pageStore
DropAll
"
);
Connection
conn
;
Connection
conn
;
String
url
=
"pageStore"
;
String
url
=
"pageStore
DropAll
"
;
conn
=
getConnection
(
url
);
conn
=
getConnection
(
url
);
Statement
stat
=
conn
.
createStatement
();
Statement
stat
=
conn
.
createStatement
();
stat
.
execute
(
"CREATE TEMP TABLE A(A INT)"
);
stat
.
execute
(
"CREATE TEMP TABLE A(A INT)"
);
...
@@ -340,9 +342,9 @@ public class TestPageStore extends TestBase implements DatabaseEventListener {
...
@@ -340,9 +342,9 @@ public class TestPageStore extends TestBase implements DatabaseEventListener {
}
}
private
void
testCloseTempTable
()
throws
SQLException
{
private
void
testCloseTempTable
()
throws
SQLException
{
deleteDb
(
"pageStore"
);
deleteDb
(
"pageStore
CloseTempTable
"
);
Connection
conn
;
Connection
conn
;
String
url
=
"pageStore;CACHE_SIZE=0"
;
String
url
=
"pageStore
CloseTempTable
;CACHE_SIZE=0"
;
conn
=
getConnection
(
url
);
conn
=
getConnection
(
url
);
Statement
stat
=
conn
.
createStatement
();
Statement
stat
=
conn
.
createStatement
();
stat
.
execute
(
"create local temporary table test(id int)"
);
stat
.
execute
(
"create local temporary table test(id int)"
);
...
@@ -356,9 +358,9 @@ public class TestPageStore extends TestBase implements DatabaseEventListener {
...
@@ -356,9 +358,9 @@ public class TestPageStore extends TestBase implements DatabaseEventListener {
}
}
private
void
testDuplicateKey
()
throws
SQLException
{
private
void
testDuplicateKey
()
throws
SQLException
{
deleteDb
(
"pageStore"
);
deleteDb
(
"pageStore
DuplicateKey
"
);
Connection
conn
;
Connection
conn
;
conn
=
getConnection
(
"pageStore"
);
conn
=
getConnection
(
"pageStore
DuplicateKey
"
);
Statement
stat
=
conn
.
createStatement
();
Statement
stat
=
conn
.
createStatement
();
stat
.
execute
(
"create table test(id int primary key, name varchar)"
);
stat
.
execute
(
"create table test(id int primary key, name varchar)"
);
stat
.
execute
(
"insert into test values(0, space(3000))"
);
stat
.
execute
(
"insert into test values(0, space(3000))"
);
...
@@ -375,18 +377,18 @@ public class TestPageStore extends TestBase implements DatabaseEventListener {
...
@@ -375,18 +377,18 @@ public class TestPageStore extends TestBase implements DatabaseEventListener {
if
(
config
.
memory
)
{
if
(
config
.
memory
)
{
return
;
return
;
}
}
deleteDb
(
"pageStore"
);
deleteDb
(
"pageStore
TruncateReconnect
"
);
Connection
conn
;
Connection
conn
;
conn
=
getConnection
(
"pageStore"
);
conn
=
getConnection
(
"pageStore
TruncateReconnect
"
);
conn
.
createStatement
().
execute
(
"create table test(id int primary key, name varchar)"
);
conn
.
createStatement
().
execute
(
"create table test(id int primary key, name varchar)"
);
conn
.
createStatement
().
execute
(
"insert into test(id) select x from system_range(1, 390)"
);
conn
.
createStatement
().
execute
(
"insert into test(id) select x from system_range(1, 390)"
);
conn
.
createStatement
().
execute
(
"checkpoint"
);
conn
.
createStatement
().
execute
(
"checkpoint"
);
conn
.
createStatement
().
execute
(
"shutdown immediately"
);
conn
.
createStatement
().
execute
(
"shutdown immediately"
);
conn
=
getConnection
(
"pageStore"
);
conn
=
getConnection
(
"pageStore
TruncateReconnect
"
);
conn
.
createStatement
().
execute
(
"truncate table test"
);
conn
.
createStatement
().
execute
(
"truncate table test"
);
conn
.
createStatement
().
execute
(
"insert into test(id) select x from system_range(1, 390)"
);
conn
.
createStatement
().
execute
(
"insert into test(id) select x from system_range(1, 390)"
);
conn
.
createStatement
().
execute
(
"shutdown immediately"
);
conn
.
createStatement
().
execute
(
"shutdown immediately"
);
conn
=
getConnection
(
"pageStore"
);
conn
=
getConnection
(
"pageStore
TruncateReconnect
"
);
conn
.
close
();
conn
.
close
();
}
}
...
@@ -394,19 +396,19 @@ public class TestPageStore extends TestBase implements DatabaseEventListener {
...
@@ -394,19 +396,19 @@ public class TestPageStore extends TestBase implements DatabaseEventListener {
if
(
config
.
memory
)
{
if
(
config
.
memory
)
{
return
;
return
;
}
}
deleteDb
(
"pageStore"
);
deleteDb
(
"pageStore
UpdateOverflow
"
);
Connection
conn
;
Connection
conn
;
conn
=
getConnection
(
"pageStore"
);
conn
=
getConnection
(
"pageStore
UpdateOverflow
"
);
conn
.
createStatement
().
execute
(
"create table test(id int primary key, name varchar)"
);
conn
.
createStatement
().
execute
(
"create table test(id int primary key, name varchar)"
);
conn
.
createStatement
().
execute
(
"insert into test values(0, space(3000))"
);
conn
.
createStatement
().
execute
(
"insert into test values(0, space(3000))"
);
conn
.
createStatement
().
execute
(
"checkpoint"
);
conn
.
createStatement
().
execute
(
"checkpoint"
);
conn
.
createStatement
().
execute
(
"shutdown immediately"
);
conn
.
createStatement
().
execute
(
"shutdown immediately"
);
conn
=
getConnection
(
"pageStore"
);
conn
=
getConnection
(
"pageStore
UpdateOverflow
"
);
conn
.
createStatement
().
execute
(
"update test set id = 1"
);
conn
.
createStatement
().
execute
(
"update test set id = 1"
);
conn
.
createStatement
().
execute
(
"shutdown immediately"
);
conn
.
createStatement
().
execute
(
"shutdown immediately"
);
conn
=
getConnection
(
"pageStore"
);
conn
=
getConnection
(
"pageStore
UpdateOverflow
"
);
conn
.
close
();
conn
.
close
();
}
}
...
@@ -414,8 +416,8 @@ public class TestPageStore extends TestBase implements DatabaseEventListener {
...
@@ -414,8 +416,8 @@ public class TestPageStore extends TestBase implements DatabaseEventListener {
if
(
config
.
memory
)
{
if
(
config
.
memory
)
{
return
;
return
;
}
}
deleteDb
(
"pageStore"
);
deleteDb
(
"pageStore
ReverseIndex
"
);
Connection
conn
=
getConnection
(
"pageStore"
);
Connection
conn
=
getConnection
(
"pageStore
ReverseIndex
"
);
Statement
stat
=
conn
.
createStatement
();
Statement
stat
=
conn
.
createStatement
();
stat
.
execute
(
"create table test(x int, y varchar default space(200))"
);
stat
.
execute
(
"create table test(x int, y varchar default space(200))"
);
for
(
int
i
=
30
;
i
<
100
;
i
++)
{
for
(
int
i
=
30
;
i
<
100
;
i
++)
{
...
@@ -435,9 +437,9 @@ public class TestPageStore extends TestBase implements DatabaseEventListener {
...
@@ -435,9 +437,9 @@ public class TestPageStore extends TestBase implements DatabaseEventListener {
if
(
config
.
memory
)
{
if
(
config
.
memory
)
{
return
;
return
;
}
}
deleteDb
(
"pageStore"
);
deleteDb
(
"pageStore
LargeUpdates
"
);
Connection
conn
;
Connection
conn
;
conn
=
getConnection
(
"pageStore"
);
conn
=
getConnection
(
"pageStore
LargeUpdates
"
);
Statement
stat
=
conn
.
createStatement
();
Statement
stat
=
conn
.
createStatement
();
int
size
=
1500
;
int
size
=
1500
;
stat
.
execute
(
"call rand(1)"
);
stat
.
execute
(
"call rand(1)"
);
...
@@ -454,7 +456,7 @@ public class TestPageStore extends TestBase implements DatabaseEventListener {
...
@@ -454,7 +456,7 @@ public class TestPageStore extends TestBase implements DatabaseEventListener {
prep
.
execute
();
prep
.
execute
();
}
}
conn
.
close
();
conn
.
close
();
conn
=
getConnection
(
"pageStore"
);
conn
=
getConnection
(
"pageStore
LargeUpdates
"
);
stat
=
conn
.
createStatement
();
stat
=
conn
.
createStatement
();
ResultSet
rs
=
stat
.
executeQuery
(
"select * from test where test<>123"
);
ResultSet
rs
=
stat
.
executeQuery
(
"select * from test where test<>123"
);
assertFalse
(
rs
.
next
());
assertFalse
(
rs
.
next
());
...
@@ -465,9 +467,9 @@ public class TestPageStore extends TestBase implements DatabaseEventListener {
...
@@ -465,9 +467,9 @@ public class TestPageStore extends TestBase implements DatabaseEventListener {
if
(
config
.
memory
)
{
if
(
config
.
memory
)
{
return
;
return
;
}
}
deleteDb
(
"pageStore"
);
deleteDb
(
"pageStore
LargeInserts
"
);
Connection
conn
;
Connection
conn
;
conn
=
getConnection
(
"pageStore"
);
conn
=
getConnection
(
"pageStore
LargeInserts
"
);
Statement
stat
=
conn
.
createStatement
();
Statement
stat
=
conn
.
createStatement
();
stat
.
execute
(
"create table test(data varchar)"
);
stat
.
execute
(
"create table test(data varchar)"
);
stat
.
execute
(
"insert into test values(space(1024 * 1024))"
);
stat
.
execute
(
"insert into test values(space(1024 * 1024))"
);
...
@@ -479,9 +481,9 @@ public class TestPageStore extends TestBase implements DatabaseEventListener {
...
@@ -479,9 +481,9 @@ public class TestPageStore extends TestBase implements DatabaseEventListener {
if
(
config
.
memory
)
{
if
(
config
.
memory
)
{
return
;
return
;
}
}
deleteDb
(
"pageStore"
);
deleteDb
(
"pageStore
LargeDatabaseFastOpen
"
);
Connection
conn
;
Connection
conn
;
String
url
=
"pageStore"
;
String
url
=
"pageStore
LargeDatabaseFastOpen
"
;
conn
=
getConnection
(
url
);
conn
=
getConnection
(
url
);
conn
.
createStatement
().
execute
(
"CREATE TABLE TEST(ID INT PRIMARY KEY, NAME VARCHAR)"
);
conn
.
createStatement
().
execute
(
"CREATE TABLE TEST(ID INT PRIMARY KEY, NAME VARCHAR)"
);
conn
.
createStatement
().
execute
(
"create unique index idx_test_name on test(name)"
);
conn
.
createStatement
().
execute
(
"create unique index idx_test_name on test(name)"
);
...
@@ -506,9 +508,9 @@ public class TestPageStore extends TestBase implements DatabaseEventListener {
...
@@ -506,9 +508,9 @@ public class TestPageStore extends TestBase implements DatabaseEventListener {
if
(
config
.
memory
)
{
if
(
config
.
memory
)
{
return
;
return
;
}
}
deleteDb
(
"pageStore"
);
deleteDb
(
"pageStore
UniqueIndexReopen
"
);
Connection
conn
;
Connection
conn
;
String
url
=
"pageStore"
;
String
url
=
"pageStore
UniqueIndexReopen
"
;
conn
=
getConnection
(
url
);
conn
=
getConnection
(
url
);
conn
.
createStatement
().
execute
(
"CREATE TABLE test(ID INT PRIMARY KEY, NAME VARCHAR(255))"
);
conn
.
createStatement
().
execute
(
"CREATE TABLE test(ID INT PRIMARY KEY, NAME VARCHAR(255))"
);
conn
.
createStatement
().
execute
(
"create unique index idx_test_name on test(name)"
);
conn
.
createStatement
().
execute
(
"create unique index idx_test_name on test(name)"
);
...
@@ -525,9 +527,9 @@ public class TestPageStore extends TestBase implements DatabaseEventListener {
...
@@ -525,9 +527,9 @@ public class TestPageStore extends TestBase implements DatabaseEventListener {
return
;
return
;
}
}
Connection
conn
;
Connection
conn
;
deleteDb
(
"pageStore"
);
deleteDb
(
"pageStore
ExistingOld
"
);
String
url
;
String
url
;
url
=
"jdbc:h2:"
+
getBaseDir
()
+
"/pageStore"
;
url
=
"jdbc:h2:"
+
getBaseDir
()
+
"/pageStore
ExistingOld
"
;
conn
=
DriverManager
.
getConnection
(
url
);
conn
=
DriverManager
.
getConnection
(
url
);
conn
.
createStatement
().
execute
(
"create table test(id int) as select 1"
);
conn
.
createStatement
().
execute
(
"create table test(id int) as select 1"
);
conn
.
close
();
conn
.
close
();
...
@@ -550,8 +552,8 @@ public class TestPageStore extends TestBase implements DatabaseEventListener {
...
@@ -550,8 +552,8 @@ public class TestPageStore extends TestBase implements DatabaseEventListener {
}
}
private
void
testLargeRows
(
int
seed
)
throws
Exception
{
private
void
testLargeRows
(
int
seed
)
throws
Exception
{
deleteDb
(
"pageStore"
);
deleteDb
(
"pageStore
LargeRows
"
);
String
url
=
getURL
(
"pageStore;CACHE_SIZE=16"
,
true
);
String
url
=
getURL
(
"pageStore
LargeRows
;CACHE_SIZE=16"
,
true
);
Connection
conn
=
null
;
Connection
conn
=
null
;
Statement
stat
=
null
;
Statement
stat
=
null
;
int
count
=
0
;
int
count
=
0
;
...
@@ -606,9 +608,9 @@ public class TestPageStore extends TestBase implements DatabaseEventListener {
...
@@ -606,9 +608,9 @@ public class TestPageStore extends TestBase implements DatabaseEventListener {
conn
.
close
();
conn
.
close
();
conn
=
DriverManager
.
getConnection
(
url
);
conn
=
DriverManager
.
getConnection
(
url
);
stat
=
conn
.
createStatement
();
stat
=
conn
.
createStatement
();
stat
.
execute
(
"script to '"
+
getBaseDir
()
+
"/pageStore.sql'"
);
stat
.
execute
(
"script to '"
+
getBaseDir
()
+
"/pageStore
LargeRows
.sql'"
);
conn
.
close
();
conn
.
close
();
FileUtils
.
delete
(
getBaseDir
()
+
"/pageStore.sql"
);
FileUtils
.
delete
(
getBaseDir
()
+
"/pageStore
LargeRows
.sql"
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
if
(
stat
!=
null
)
{
if
(
stat
!=
null
)
{
try
{
try
{
...
@@ -632,14 +634,14 @@ public class TestPageStore extends TestBase implements DatabaseEventListener {
...
@@ -632,14 +634,14 @@ public class TestPageStore extends TestBase implements DatabaseEventListener {
if
(
config
.
memory
)
{
if
(
config
.
memory
)
{
return
;
return
;
}
}
deleteDb
(
"pageStore"
);
deleteDb
(
"pageStore
RecoverDropIndex
"
);
Connection
conn
=
getConnection
(
"pageStore"
);
Connection
conn
=
getConnection
(
"pageStore
RecoverDropIndex
"
);
Statement
stat
=
conn
.
createStatement
();
Statement
stat
=
conn
.
createStatement
();
stat
.
execute
(
"set write_delay 0"
);
stat
.
execute
(
"set write_delay 0"
);
stat
.
execute
(
"create table test(id int, name varchar) as select x, x from system_range(1, 1400)"
);
stat
.
execute
(
"create table test(id int, name varchar) as select x, x from system_range(1, 1400)"
);
stat
.
execute
(
"create index idx_name on test(name)"
);
stat
.
execute
(
"create index idx_name on test(name)"
);
conn
.
close
();
conn
.
close
();
conn
=
getConnection
(
"pageStore"
);
conn
=
getConnection
(
"pageStore
RecoverDropIndex
"
);
stat
=
conn
.
createStatement
();
stat
=
conn
.
createStatement
();
stat
.
execute
(
"drop index idx_name"
);
stat
.
execute
(
"drop index idx_name"
);
stat
.
execute
(
"shutdown immediately"
);
stat
.
execute
(
"shutdown immediately"
);
...
@@ -648,7 +650,7 @@ public class TestPageStore extends TestBase implements DatabaseEventListener {
...
@@ -648,7 +650,7 @@ public class TestPageStore extends TestBase implements DatabaseEventListener {
}
catch
(
SQLException
e
)
{
}
catch
(
SQLException
e
)
{
// ignore
// ignore
}
}
conn
=
getConnection
(
"pageStore;cache_size=1"
);
conn
=
getConnection
(
"pageStore
RecoverDropIndex
;cache_size=1"
);
conn
.
close
();
conn
.
close
();
}
}
...
@@ -656,16 +658,16 @@ public class TestPageStore extends TestBase implements DatabaseEventListener {
...
@@ -656,16 +658,16 @@ public class TestPageStore extends TestBase implements DatabaseEventListener {
if
(
config
.
memory
)
{
if
(
config
.
memory
)
{
return
;
return
;
}
}
deleteDb
(
"pageStore"
);
deleteDb
(
"pageStore
DropPk
"
);
Connection
conn
;
Connection
conn
;
Statement
stat
;
Statement
stat
;
conn
=
getConnection
(
"pageStore"
);
conn
=
getConnection
(
"pageStore
DropPk
"
);
stat
=
conn
.
createStatement
();
stat
=
conn
.
createStatement
();
stat
.
execute
(
"create table test(id int primary key)"
);
stat
.
execute
(
"create table test(id int primary key)"
);
stat
.
execute
(
"insert into test values("
+
Integer
.
MIN_VALUE
+
"), ("
+
Integer
.
MAX_VALUE
+
")"
);
stat
.
execute
(
"insert into test values("
+
Integer
.
MIN_VALUE
+
"), ("
+
Integer
.
MAX_VALUE
+
")"
);
stat
.
execute
(
"alter table test drop primary key"
);
stat
.
execute
(
"alter table test drop primary key"
);
conn
.
close
();
conn
.
close
();
conn
=
getConnection
(
"pageStore"
);
conn
=
getConnection
(
"pageStore
DropPk
"
);
stat
=
conn
.
createStatement
();
stat
=
conn
.
createStatement
();
stat
.
execute
(
"insert into test values("
+
Integer
.
MIN_VALUE
+
"), ("
+
Integer
.
MAX_VALUE
+
")"
);
stat
.
execute
(
"insert into test values("
+
Integer
.
MIN_VALUE
+
"), ("
+
Integer
.
MAX_VALUE
+
")"
);
conn
.
close
();
conn
.
close
();
...
@@ -675,15 +677,15 @@ public class TestPageStore extends TestBase implements DatabaseEventListener {
...
@@ -675,15 +677,15 @@ public class TestPageStore extends TestBase implements DatabaseEventListener {
if
(
config
.
memory
)
{
if
(
config
.
memory
)
{
return
;
return
;
}
}
deleteDb
(
"pageStore"
);
deleteDb
(
"pageStore
CreatePkLater
"
);
Connection
conn
;
Connection
conn
;
Statement
stat
;
Statement
stat
;
conn
=
getConnection
(
"pageStore"
);
conn
=
getConnection
(
"pageStore
CreatePkLater
"
);
stat
=
conn
.
createStatement
();
stat
=
conn
.
createStatement
();
stat
.
execute
(
"create table test(id int not null) as select 100"
);
stat
.
execute
(
"create table test(id int not null) as select 100"
);
stat
.
execute
(
"create primary key on test(id)"
);
stat
.
execute
(
"create primary key on test(id)"
);
conn
.
close
();
conn
.
close
();
conn
=
getConnection
(
"pageStore"
);
conn
=
getConnection
(
"pageStore
CreatePkLater
"
);
stat
=
conn
.
createStatement
();
stat
=
conn
.
createStatement
();
ResultSet
rs
=
stat
.
executeQuery
(
"select * from test where id = 100"
);
ResultSet
rs
=
stat
.
executeQuery
(
"select * from test where id = 100"
);
assertTrue
(
rs
.
next
());
assertTrue
(
rs
.
next
());
...
@@ -694,8 +696,8 @@ public class TestPageStore extends TestBase implements DatabaseEventListener {
...
@@ -694,8 +696,8 @@ public class TestPageStore extends TestBase implements DatabaseEventListener {
if
(
config
.
memory
)
{
if
(
config
.
memory
)
{
return
;
return
;
}
}
deleteDb
(
"pageStore"
);
deleteDb
(
"pageStore
Truncate
"
);
Connection
conn
=
getConnection
(
"pageStore"
);
Connection
conn
=
getConnection
(
"pageStore
Truncate
"
);
Statement
stat
=
conn
.
createStatement
();
Statement
stat
=
conn
.
createStatement
();
stat
.
execute
(
"set write_delay 0"
);
stat
.
execute
(
"set write_delay 0"
);
stat
.
execute
(
"create table test(id int) as select 1"
);
stat
.
execute
(
"create table test(id int) as select 1"
);
...
@@ -707,7 +709,7 @@ public class TestPageStore extends TestBase implements DatabaseEventListener {
...
@@ -707,7 +709,7 @@ public class TestPageStore extends TestBase implements DatabaseEventListener {
}
catch
(
SQLException
e
)
{
}
catch
(
SQLException
e
)
{
// ignore
// ignore
}
}
conn
=
getConnection
(
"pageStore"
);
conn
=
getConnection
(
"pageStore
Truncate
"
);
conn
.
close
();
conn
.
close
();
}
}
...
@@ -715,8 +717,8 @@ public class TestPageStore extends TestBase implements DatabaseEventListener {
...
@@ -715,8 +717,8 @@ public class TestPageStore extends TestBase implements DatabaseEventListener {
if
(
config
.
memory
)
{
if
(
config
.
memory
)
{
return
;
return
;
}
}
deleteDb
(
"pageStore"
);
deleteDb
(
"pageStore
LargeIndex
"
);
Connection
conn
=
getConnection
(
"pageStore"
);
Connection
conn
=
getConnection
(
"pageStore
LargeIndex
"
);
conn
.
createStatement
().
execute
(
"create table test(id varchar primary key, d varchar)"
);
conn
.
createStatement
().
execute
(
"create table test(id varchar primary key, d varchar)"
);
PreparedStatement
prep
=
conn
.
prepareStatement
(
"insert into test values(?, space(500))"
);
PreparedStatement
prep
=
conn
.
prepareStatement
(
"insert into test values(?, space(500))"
);
for
(
int
i
=
0
;
i
<
20000
;
i
++)
{
for
(
int
i
=
0
;
i
<
20000
;
i
++)
{
...
@@ -730,21 +732,21 @@ public class TestPageStore extends TestBase implements DatabaseEventListener {
...
@@ -730,21 +732,21 @@ public class TestPageStore extends TestBase implements DatabaseEventListener {
if
(
config
.
memory
)
{
if
(
config
.
memory
)
{
return
;
return
;
}
}
deleteDb
(
"pageStore"
);
deleteDb
(
"pageStore
UniqueIndex
"
);
Connection
conn
=
getConnection
(
"pageStore"
);
Connection
conn
=
getConnection
(
"pageStore
UniqueIndex
"
);
Statement
stat
=
conn
.
createStatement
();
Statement
stat
=
conn
.
createStatement
();
stat
.
execute
(
"CREATE TABLE TEST(ID INT UNIQUE)"
);
stat
.
execute
(
"CREATE TABLE TEST(ID INT UNIQUE)"
);
stat
.
execute
(
"INSERT INTO TEST VALUES(1)"
);
stat
.
execute
(
"INSERT INTO TEST VALUES(1)"
);
conn
.
close
();
conn
.
close
();
conn
=
getConnection
(
"pageStore"
);
conn
=
getConnection
(
"pageStore
UniqueIndex
"
);
assertThrows
(
ErrorCode
.
DUPLICATE_KEY_1
,
conn
.
createStatement
()).
assertThrows
(
ErrorCode
.
DUPLICATE_KEY_1
,
conn
.
createStatement
()).
execute
(
"INSERT INTO TEST VALUES(1)"
);
execute
(
"INSERT INTO TEST VALUES(1)"
);
conn
.
close
();
conn
.
close
();
}
}
private
void
testCreateIndexLater
()
throws
SQLException
{
private
void
testCreateIndexLater
()
throws
SQLException
{
deleteDb
(
"pageStore"
);
deleteDb
(
"pageStore
CreateIndexLater
"
);
Connection
conn
=
getConnection
(
"pageStore"
);
Connection
conn
=
getConnection
(
"pageStore
CreateIndexLater
"
);
Statement
stat
=
conn
.
createStatement
();
Statement
stat
=
conn
.
createStatement
();
stat
.
execute
(
"CREATE TABLE TEST(NAME VARCHAR) AS SELECT 1"
);
stat
.
execute
(
"CREATE TABLE TEST(NAME VARCHAR) AS SELECT 1"
);
stat
.
execute
(
"CREATE INDEX IDX_N ON TEST(NAME)"
);
stat
.
execute
(
"CREATE INDEX IDX_N ON TEST(NAME)"
);
...
@@ -752,7 +754,7 @@ public class TestPageStore extends TestBase implements DatabaseEventListener {
...
@@ -752,7 +754,7 @@ public class TestPageStore extends TestBase implements DatabaseEventListener {
stat
.
execute
(
"INSERT INTO TEST SELECT X FROM SYSTEM_RANGE(1000, 1100)"
);
stat
.
execute
(
"INSERT INTO TEST SELECT X FROM SYSTEM_RANGE(1000, 1100)"
);
stat
.
execute
(
"SHUTDOWN IMMEDIATELY"
);
stat
.
execute
(
"SHUTDOWN IMMEDIATELY"
);
assertThrows
(
ErrorCode
.
DATABASE_IS_CLOSED
,
conn
).
close
();
assertThrows
(
ErrorCode
.
DATABASE_IS_CLOSED
,
conn
).
close
();
conn
=
getConnection
(
"pageStore"
);
conn
=
getConnection
(
"pageStore
CreateIndexLater
"
);
conn
.
close
();
conn
.
close
();
}
}
...
@@ -768,8 +770,8 @@ public class TestPageStore extends TestBase implements DatabaseEventListener {
...
@@ -768,8 +770,8 @@ public class TestPageStore extends TestBase implements DatabaseEventListener {
}
}
private
int
testFuzzOperationsSeed
(
int
seed
,
int
len
)
throws
SQLException
{
private
int
testFuzzOperationsSeed
(
int
seed
,
int
len
)
throws
SQLException
{
deleteDb
(
"pageStore"
);
deleteDb
(
"pageStore
Fuzz
"
);
Connection
conn
=
getConnection
(
"pageStore"
);
Connection
conn
=
getConnection
(
"pageStore
Fuzz
"
);
Statement
stat
=
conn
.
createStatement
();
Statement
stat
=
conn
.
createStatement
();
log
(
"DROP TABLE IF EXISTS TEST;"
);
log
(
"DROP TABLE IF EXISTS TEST;"
);
stat
.
execute
(
"DROP TABLE IF EXISTS TEST"
);
stat
.
execute
(
"DROP TABLE IF EXISTS TEST"
);
...
@@ -797,7 +799,7 @@ public class TestPageStore extends TestBase implements DatabaseEventListener {
...
@@ -797,7 +799,7 @@ public class TestPageStore extends TestBase implements DatabaseEventListener {
break
;
break
;
case
2
:
case
2
:
conn
.
close
();
conn
.
close
();
conn
=
getConnection
(
"pageStore"
);
conn
=
getConnection
(
"pageStore
Fuzz
"
);
stat
=
conn
.
createStatement
();
stat
=
conn
.
createStatement
();
ResultSet
rs
=
stat
.
executeQuery
(
"SELECT * FROM TEST ORDER BY ID"
);
ResultSet
rs
=
stat
.
executeQuery
(
"SELECT * FROM TEST ORDER BY ID"
);
log
(
"--reconnect"
);
log
(
"--reconnect"
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论