Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
4abe8639
提交
4abe8639
authored
11月 08, 2009
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Issue 117: Multi-version concurrency: concurrent MERGE statements now work.
上级
7322a5e7
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
23 行增加
和
21 行删除
+23
-21
changelog.html
h2/src/docsrc/html/changelog.html
+1
-1
Command.java
h2/src/main/org/h2/command/Command.java
+2
-2
Merge.java
h2/src/main/org/h2/command/dml/Merge.java
+15
-8
TestAll.java
h2/src/test/org/h2/test/TestAll.java
+0
-1
TestMvccMultiThreaded.java
h2/src/test/org/h2/test/mvcc/TestMvccMultiThreaded.java
+5
-9
没有找到文件。
h2/src/docsrc/html/changelog.html
浏览文件 @
4abe8639
...
...
@@ -18,7 +18,7 @@ Change Log
<h1>
Change Log
</h1>
<h2>
Next Version (unreleased)
</h2>
<ul><li>
-
<ul><li>
Issue 117: Multi-version concurrency: concurrent MERGE statements now work.
</li></ul>
<h2>
Version 1.2.123 (2009-11-08)
</h2>
...
...
h2/src/main/org/h2/command/Command.java
浏览文件 @
4abe8639
...
...
@@ -215,9 +215,9 @@ public abstract class Command implements CommandInterface {
}
try
{
if
(
sync
==
database
)
{
database
.
wait
(
10
0
);
database
.
wait
(
10
);
}
else
{
Thread
.
sleep
(
10
0
);
Thread
.
sleep
(
10
);
}
}
catch
(
InterruptedException
e1
)
{
// ignore
...
...
h2/src/main/org/h2/command/dml/Merge.java
浏览文件 @
4abe8639
...
...
@@ -173,14 +173,21 @@ public class Merge extends Prepared {
}
int
count
=
update
.
update
();
if
(
count
==
0
)
{
table
.
fireBefore
(
session
);
table
.
validateConvertUpdateSequence
(
session
,
row
);
table
.
fireBeforeRow
(
session
,
null
,
row
);
table
.
lock
(
session
,
true
,
false
);
table
.
addRow
(
session
,
row
);
session
.
log
(
table
,
UndoLogRecord
.
INSERT
,
row
);
table
.
fireAfter
(
session
);
table
.
fireAfterRow
(
session
,
null
,
row
);
try
{
table
.
fireBefore
(
session
);
table
.
validateConvertUpdateSequence
(
session
,
row
);
table
.
fireBeforeRow
(
session
,
null
,
row
);
table
.
lock
(
session
,
true
,
false
);
table
.
addRow
(
session
,
row
);
session
.
log
(
table
,
UndoLogRecord
.
INSERT
,
row
);
table
.
fireAfter
(
session
);
table
.
fireAfterRow
(
session
,
null
,
row
);
}
catch
(
SQLException
e
)
{
if
(
e
.
getErrorCode
()
==
ErrorCode
.
DUPLICATE_KEY_1
)
{
// concurrent merge or insert
throw
Message
.
getSQLException
(
ErrorCode
.
CONCURRENT_UPDATE_1
,
table
.
getName
());
}
}
}
else
if
(
count
!=
1
)
{
throw
Message
.
getSQLException
(
ErrorCode
.
DUPLICATE_KEY_1
,
table
.
getSQL
());
}
...
...
h2/src/test/org/h2/test/TestAll.java
浏览文件 @
4abe8639
...
...
@@ -297,7 +297,6 @@ java org.h2.test.TestAll timer
/*
mvcc merge problem (testConcurrentMerge)
http://www.apache.org/dev/contrib-email-tips.html
google app engine
documentation: rolling review at history.html
...
...
h2/src/test/org/h2/test/mvcc/TestMvccMultiThreaded.java
浏览文件 @
4abe8639
...
...
@@ -9,8 +9,6 @@ package org.h2.test.mvcc;
import
java.sql.Connection
;
import
java.sql.ResultSet
;
import
java.sql.SQLException
;
import
java.util.Random
;
import
org.h2.test.TestBase
;
/**
...
...
@@ -28,7 +26,7 @@ public class TestMvccMultiThreaded extends TestBase {
}
public
void
test
()
throws
Exception
{
//
testConcurrentMerge();
testConcurrentMerge
();
testConcurrentUpdate
(
""
);
// not supported currently
// testConcurrentUpdate(";MULTI_THREADED=TRUE");
...
...
@@ -36,14 +34,14 @@ public class TestMvccMultiThreaded extends TestBase {
private
void
testConcurrentMerge
()
throws
Exception
{
deleteDb
(
"mvccMultiThreaded"
);
int
len
=
10
;
int
len
=
3
;
final
Connection
[]
connList
=
new
Connection
[
len
];
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
Connection
conn
=
getConnection
(
"mvccMultiThreaded;MVCC=TRUE"
);
Connection
conn
=
getConnection
(
"mvccMultiThreaded;MVCC=TRUE
;LOCK_TIMEOUT=1000
"
);
connList
[
i
]
=
conn
;
}
Connection
conn
=
connList
[
0
];
conn
.
createStatement
().
execute
(
"create table test(id int primary key,
value int
)"
);
conn
.
createStatement
().
execute
(
"create table test(id int primary key,
name varchar
)"
);
final
SQLException
[]
ex
=
new
SQLException
[
1
];
Thread
[]
threads
=
new
Thread
[
len
];
final
boolean
[]
stop
=
new
boolean
[
1
];
...
...
@@ -52,11 +50,9 @@ public class TestMvccMultiThreaded extends TestBase {
c
.
setAutoCommit
(
false
);
threads
[
i
]
=
new
Thread
()
{
public
void
run
()
{
Random
random
=
new
Random
();
while
(!
stop
[
0
])
{
try
{
int
k
=
random
.
nextInt
(
100
);
c
.
createStatement
().
execute
(
"merge into test values("
+
k
+
", "
+
k
+
")"
);
c
.
createStatement
().
execute
(
"merge into test values(1, 'x')"
);
c
.
commit
();
}
catch
(
SQLException
e
)
{
ex
[
0
]
=
e
;
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论