Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
83b86da8
提交
83b86da8
authored
5月 15, 2010
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
New system property h2.selectForUpdateMvcc, the default is false (the feature is disabled).
上级
43e31e6f
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
63 行增加
和
20 行删除
+63
-20
TableFilter.java
h2/src/main/org/h2/table/TableFilter.java
+7
-5
TestMvcc1.java
h2/src/test/org/h2/test/mvcc/TestMvcc1.java
+0
-12
TestMvcc2.java
h2/src/test/org/h2/test/mvcc/TestMvcc2.java
+55
-2
TestFuzzOptimizations.java
h2/src/test/org/h2/test/synth/TestFuzzOptimizations.java
+1
-1
没有找到文件。
h2/src/main/org/h2/table/TableFilter.java
浏览文件 @
83b86da8
...
...
@@ -718,14 +718,16 @@ public class TableFilter implements ColumnResolver {
return
false
;
}
public
void
lockRow
()
{
public
void
lockRow
(
ArrayList
<
Row
>
rows
)
{
if
(
state
==
FOUND
)
{
Row
row
=
get
();
rows
.
add
(
get
());
}
}
public
void
lockRows
(
ArrayList
<
Row
>
forUpdateRows
)
{
for
(
Row
row
:
forUpdateRows
)
{
table
.
removeRow
(
session
,
row
);
table
.
addRow
(
session
,
row
);
if
(
join
!=
null
)
{
join
.
lockRow
();
}
}
}
...
...
h2/src/test/org/h2/test/mvcc/TestMvcc1.java
浏览文件 @
83b86da8
...
...
@@ -61,23 +61,11 @@ public class TestMvcc1 extends TestBase {
if
(!
config
.
mvcc
)
{
return
;
}
// TODO Prio 1: row level locking for update / delete (as PostgreSQL)
// TODO Prio 1: document: exclusive table lock still used when altering
// tables, adding indexes, select ... for update; table level locks are
// checked
// TODO Prio 1: free up disk space (for deleted rows and old versions of
// updated rows) on commit
// TODO Prio 1: ScanIndex: never remove uncommitted data from cache
// (lost sessionId)
// TODO Prio 1: test with Hibernate
// TODO Prio 2: if MVCC is used, rows of transactions need to fit in
// memory
// TODO Prio 2: write the log only when committed; remove restriction at
// Record.canRemove
// TODO Prio 2: getRowCount: different row count for different indexes
// (MultiVersionIndex)
// TODO Prio 2: getRowCount: different row count for different sessions:
// TableLink (use different connections?)
// TODO Prio 2: getFirst / getLast in MultiVersionIndex
// TODO Prio 2: snapshot isolation (currently read-committed, not
// repeatable read)
...
...
h2/src/test/org/h2/test/mvcc/TestMvcc2.java
浏览文件 @
83b86da8
...
...
@@ -9,7 +9,8 @@ package org.h2.test.mvcc;
import
java.sql.Connection
;
import
java.sql.SQLException
;
import
java.sql.Statement
;
import
org.h2.constant.ErrorCode
;
import
org.h2.constant.SysProperties
;
import
org.h2.test.TestBase
;
/**
...
...
@@ -28,7 +29,10 @@ public class TestMvcc2 extends TestBase {
* @param a ignored
*/
public
static
void
main
(
String
...
a
)
throws
Exception
{
TestBase
.
createCaller
().
init
().
test
();
System
.
setProperty
(
"h2.selectForUpdateMvcc"
,
"true"
);
TestBase
test
=
TestBase
.
createCaller
().
init
();
test
.
config
.
mvcc
=
true
;
test
.
test
();
}
public
void
test
()
throws
SQLException
{
...
...
@@ -36,6 +40,7 @@ public class TestMvcc2 extends TestBase {
return
;
}
deleteDb
(
"mvcc2"
);
testSelectForUpdate
();
testInsertUpdateRollback
();
testInsertRollback
();
deleteDb
(
"mvcc2"
);
...
...
@@ -45,6 +50,54 @@ public class TestMvcc2 extends TestBase {
return
getConnection
(
"mvcc2"
);
}
private
void
testSelectForUpdate
()
throws
SQLException
{
if
(!
SysProperties
.
SELECT_FOR_UPDATE_MVCC
)
{
return
;
}
Connection
conn
=
getConnection
();
Connection
conn2
=
getConnection
();
Statement
stat
=
conn
.
createStatement
();
stat
.
execute
(
"create table test(id int primary key, name varchar)"
);
conn
.
setAutoCommit
(
false
);
stat
.
execute
(
"insert into test select x, 'Hello' from system_range(1, 10)"
);
stat
.
execute
(
"select * from test where id = 3 for update"
);
conn
.
commit
();
try
{
stat
.
execute
(
"select sum(id) from test for update"
);
fail
();
}
catch
(
SQLException
e
)
{
assertEquals
(
ErrorCode
.
FEATURE_NOT_SUPPORTED_1
,
e
.
getErrorCode
());
}
try
{
stat
.
execute
(
"select distinct id from test for update"
);
fail
();
}
catch
(
SQLException
e
)
{
assertEquals
(
ErrorCode
.
FEATURE_NOT_SUPPORTED_1
,
e
.
getErrorCode
());
}
try
{
stat
.
execute
(
"select id from test group by id for update"
);
fail
();
}
catch
(
SQLException
e
)
{
assertEquals
(
ErrorCode
.
FEATURE_NOT_SUPPORTED_1
,
e
.
getErrorCode
());
}
try
{
stat
.
execute
(
"select t1.id from test t1, test t2 for update"
);
fail
();
}
catch
(
SQLException
e
)
{
assertEquals
(
ErrorCode
.
FEATURE_NOT_SUPPORTED_1
,
e
.
getErrorCode
());
}
stat
.
execute
(
"select * from test where id = 3 for update"
);
conn2
.
setAutoCommit
(
false
);
conn2
.
createStatement
().
execute
(
"select * from test where id = 4 for update"
);
try
{
conn2
.
createStatement
().
execute
(
"select * from test where id = 3 for update"
);
fail
();
}
catch
(
SQLException
e
)
{
assertEquals
(
ErrorCode
.
CONCURRENT_UPDATE_1
,
e
.
getErrorCode
());
}
conn
.
close
();
}
private
void
testInsertUpdateRollback
()
throws
SQLException
{
Connection
conn
=
getConnection
();
conn
.
setAutoCommit
(
false
);
...
...
h2/src/test/org/h2/test/synth/TestFuzzOptimizations.java
浏览文件 @
83b86da8
...
...
@@ -84,7 +84,7 @@ public class TestFuzzOptimizations extends TestBase {
String
[]
columns
=
new
String
[]
{
"a"
,
"b"
,
"c"
};
String
[]
values
=
new
String
[]
{
null
,
"0"
,
"0"
,
"1"
,
"2"
,
"10"
,
"a"
,
"?"
};
String
[]
compares
=
new
String
[]
{
"in("
,
"not in("
,
"="
,
"="
,
">"
,
"<"
,
">="
,
"<="
,
"<>"
,
"in(select"
,
"not in(select"
};
int
size
=
getSize
(
1000
,
10
000
);
int
size
=
getSize
(
500
,
5
000
);
for
(
int
i
=
0
;
i
<
size
;
i
++)
{
long
seed
=
seedGenerator
.
nextLong
();
println
(
"seed: "
+
seed
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论