Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
fac4118b
Unverified
提交
fac4118b
authored
2月 27, 2019
作者:
Evgenij Ryazanov
提交者:
GitHub
2月 27, 2019
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1765 from katzyn/select
Fix concurrent deletion handling in SELECT FOR UPDATE
上级
5e137043
1548e103
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
13 行增加
和
8 行删除
+13
-8
Select.java
h2/src/main/org/h2/command/dml/Select.java
+6
-1
TestTransaction.java
h2/src/test/org/h2/test/db/TestTransaction.java
+7
-7
没有找到文件。
h2/src/main/org/h2/command/dml/Select.java
浏览文件 @
fac4118b
...
...
@@ -35,6 +35,7 @@ import org.h2.result.LazyResult;
import
org.h2.result.LocalResult
;
import
org.h2.result.ResultInterface
;
import
org.h2.result.ResultTarget
;
import
org.h2.result.Row
;
import
org.h2.result.SearchRow
;
import
org.h2.result.SortOrder
;
import
org.h2.table.Column
;
...
...
@@ -429,7 +430,11 @@ public class Select extends Query {
int
count
=
filters
.
size
();
for
(
int
i
=
0
;
i
<
count
;
i
++)
{
TableFilter
tableFilter
=
filters
.
get
(
i
);
tableFilter
.
set
(
tableFilter
.
getTable
().
lockRow
(
session
,
tableFilter
.
get
()));
Row
row
=
tableFilter
.
getTable
().
lockRow
(
session
,
tableFilter
.
get
());
if
(
row
==
null
)
{
return
false
;
}
tableFilter
.
set
(
row
);
}
return
isConditionMet
();
}
...
...
h2/src/test/org/h2/test/db/TestTransaction.java
浏览文件 @
fac4118b
...
...
@@ -231,7 +231,6 @@ public class TestTransaction extends TestDb {
Connection
conn2
=
getConnection
(
"transaction"
);
Statement
stat1
=
conn1
.
createStatement
();
stat1
.
execute
(
"CREATE TABLE TEST (ID INT PRIMARY KEY, V INT)"
);
stat1
.
execute
(
"INSERT INTO TEST VALUES (1, 0)"
);
conn1
.
setAutoCommit
(
false
);
conn2
.
createStatement
().
execute
(
"SET LOCK_TIMEOUT 2000"
);
if
(
config
.
mvStore
)
{
...
...
@@ -250,15 +249,16 @@ public class TestTransaction extends TestDb {
void
testForUpdate2
(
Connection
conn1
,
Statement
stat1
,
Connection
conn2
,
boolean
forUpdate
,
boolean
window
)
throws
Exception
{
testForUpdate2
(
conn1
,
stat1
,
conn2
,
forUpdate
,
window
,
false
);
testForUpdate2
(
conn1
,
stat1
,
conn2
,
forUpdate
,
window
,
true
);
testForUpdate2
(
conn1
,
stat1
,
conn2
,
forUpdate
,
window
,
false
,
false
);
testForUpdate2
(
conn1
,
stat1
,
conn2
,
forUpdate
,
window
,
false
,
true
);
testForUpdate2
(
conn1
,
stat1
,
conn2
,
forUpdate
,
window
,
true
,
false
);
}
void
testForUpdate2
(
Connection
conn1
,
Statement
stat1
,
final
Connection
conn2
,
boolean
forUpdate
,
boolean
window
,
boolean
excluded
)
throws
Exception
{
stat1
.
execute
(
"
UPDATE TEST SET V = 1 WHERE ID = 1
"
);
boolean
window
,
boolean
deleted
,
boolean
excluded
)
throws
Exception
{
stat1
.
execute
(
"
MERGE INTO TEST KEY(ID) VALUES (1, 1)
"
);
conn1
.
commit
();
stat1
.
execute
(
"UPDATE TEST SET V = 2 WHERE ID = 1"
);
stat1
.
execute
(
deleted
?
"DELETE FROM TEST WHERE ID = 1"
:
"UPDATE TEST SET V = 2 WHERE ID = 1"
);
final
int
[]
res
=
new
int
[
1
];
final
Exception
[]
ex
=
new
Exception
[
1
];
StringBuilder
builder
=
new
StringBuilder
(
"SELECT V"
);
...
...
@@ -293,7 +293,7 @@ public class TestTransaction extends TestDb {
if
(
ex
[
0
]
!=
null
)
{
throw
ex
[
0
];
}
assertEquals
(
forUpdate
?
excluded
?
-
1
:
2
:
1
,
res
[
0
]);
assertEquals
(
forUpdate
?
(
deleted
||
excluded
)
?
-
1
:
2
:
1
,
res
[
0
]);
}
private
void
testRollback
()
throws
SQLException
{
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论