Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
a729e2cd
Unverified
提交
a729e2cd
authored
6月 21, 2018
作者:
Evgenij Ryazanov
提交者:
GitHub
6月 21, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1226 from katzyn/misc
Fix inconsistencies in checks for transaction isolation level
上级
f97a3dcc
dc815183
隐藏空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
42 行增加
和
27 行删除
+42
-27
advanced.html
h2/src/docsrc/html/advanced.html
+4
-2
Database.java
h2/src/main/org/h2/engine/Database.java
+7
-7
JdbcDatabaseMetaData.java
h2/src/main/org/h2/jdbc/JdbcDatabaseMetaData.java
+24
-9
LocalResult.java
h2/src/main/org/h2/result/LocalResult.java
+1
-1
TestMultiThread.java
h2/src/test/org/h2/test/db/TestMultiThread.java
+2
-3
TestMetaData.java
h2/src/test/org/h2/test/jdbc/TestMetaData.java
+4
-5
没有找到文件。
h2/src/docsrc/html/advanced.html
浏览文件 @
a729e2cd
...
...
@@ -229,7 +229,7 @@ Transaction isolation is provided for all data manipulation language (DML) state
<p>
Please note that with default MVStore storage engine table level locking is not used.
Instead, rows are locked for update, and read committed is used in all cases
(changing the isolation level has no effect)
.
except for explicitly selected read uncommitted transaction isolation level
.
</p>
<p>
This database supports the following transaction isolation levels:
...
...
@@ -247,7 +247,9 @@ This database supports the following transaction isolation levels:
To enable, execute the SQL statement
<code>
SET LOCK_MODE 1
</code><br
/>
or append
<code>
;LOCK_MODE=1
</code>
to the database URL:
<code>
jdbc:h2:~/test;LOCK_MODE=1
</code>
</li><li><b>
Read Uncommitted
</b><br
/>
This level means that transaction isolation is disabled.
<br
/>
This level means that transaction isolation is disabled.
This level is not supported by PageStore engine if multi-threaded mode is enabled.
<br
/>
To enable, execute the SQL statement
<code>
SET LOCK_MODE 0
</code><br
/>
or append
<code>
;LOCK_MODE=0
</code>
to the database URL:
<code>
jdbc:h2:~/test;LOCK_MODE=0
</code>
</li>
...
...
h2/src/main/org/h2/engine/Database.java
浏览文件 @
a729e2cd
...
...
@@ -2265,12 +2265,12 @@ public class Database implements DataHandler {
switch
(
lockMode
)
{
case
Constants
.
LOCK_MODE_OFF
:
if
(
multiThreaded
&&
!
isMVStore
())
{
//
currently the combination of MVCC=FALSE, LOCK_MODE=0 and MULTI_THREADED
//
is not supported. a
lso see code in
//
Currently the combination of MV_STORE=FALSE, LOCK_MODE=0 and
//
MULTI_THREADED=TRUE is not supported. A
lso see code in
// JdbcDatabaseMetaData#supportsTransactionIsolationLevel(int)
throw
DbException
.
get
(
ErrorCode
.
UNSUPPORTED_SETTING_COMBINATION
,
"MV
CC=FALSE & LOCK_MODE=0 & MULTI_THREADED
"
);
"MV
_STORE=FALSE & LOCK_MODE=0 & MULTI_THREADED=TRUE
"
);
}
break
;
case
Constants
.
LOCK_MODE_READ_COMMITTED
:
...
...
@@ -2457,12 +2457,12 @@ public class Database implements DataHandler {
public
void
setMultiThreaded
(
boolean
multiThreaded
)
{
if
(
multiThreaded
&&
this
.
multiThreaded
!=
multiThreaded
)
{
if
(
lockMode
==
0
)
{
//
currently the combination of LOCK_MODE=0 and MULTI_THREADED
//
is not supported
if
(
lockMode
==
Constants
.
LOCK_MODE_OFF
&&
!
isMVStore
()
)
{
//
Currently the combination of MV_STORE=FALSE, LOCK_MODE=0 and
//
MULTI_THREADED=TRUE is not supported.
throw
DbException
.
get
(
ErrorCode
.
UNSUPPORTED_SETTING_COMBINATION
,
"
LOCK_MODE=0 & MULTI_THREADED
"
);
"
MV_STORE=FALSE & LOCK_MODE=0 & MULTI_THREADED=TRUE
"
);
}
}
this
.
multiThreaded
=
multiThreaded
;
...
...
h2/src/main/org/h2/jdbc/JdbcDatabaseMetaData.java
浏览文件 @
a729e2cd
...
...
@@ -2315,16 +2315,31 @@ public class JdbcDatabaseMetaData extends TraceObject implements
@Override
public
boolean
supportsTransactionIsolationLevel
(
int
level
)
throws
SQLException
{
debugCodeCall
(
"supportsTransactionIsolationLevel"
);
if
(
level
==
Connection
.
TRANSACTION_READ_UNCOMMITTED
)
{
// currently the combination of LOCK_MODE=0 and MULTI_THREADED
// is not supported, also see code in Database#setLockMode(int)
PreparedStatement
prep
=
conn
.
prepareAutoCloseStatement
(
"SELECT VALUE FROM INFORMATION_SCHEMA.SETTINGS WHERE NAME=?"
);
prep
.
setString
(
1
,
"MULTI_THREADED"
);
ResultSet
rs
=
prep
.
executeQuery
();
return
!
rs
.
next
()
||
!
rs
.
getString
(
1
).
equals
(
"1"
);
switch
(
level
)
{
case
Connection
.
TRANSACTION_READ_UNCOMMITTED
:
{
// Currently the combination of MV_STORE=FALSE, LOCK_MODE=0 and
// MULTI_THREADED=TRUE is not supported. Also see code in
// Database#setLockMode(int)
try
(
PreparedStatement
prep
=
conn
.
prepareStatement
(
"SELECT VALUE FROM INFORMATION_SCHEMA.SETTINGS WHERE NAME=?"
))
{
// TODO skip MV_STORE check for H2 <= 1.4.197
prep
.
setString
(
1
,
"MV_STORE"
);
ResultSet
rs
=
prep
.
executeQuery
();
if
(
rs
.
next
()
&&
Boolean
.
parseBoolean
(
rs
.
getString
(
1
)))
{
return
true
;
}
prep
.
setString
(
1
,
"MULTI_THREADED"
);
rs
=
prep
.
executeQuery
();
return
!
rs
.
next
()
||
!
rs
.
getString
(
1
).
equals
(
"1"
);
}
}
case
Connection
.
TRANSACTION_READ_COMMITTED
:
case
Connection
.
TRANSACTION_REPEATABLE_READ
:
case
Connection
.
TRANSACTION_SERIALIZABLE
:
return
true
;
default
:
return
false
;
}
return
true
;
}
/**
...
...
h2/src/main/org/h2/result/LocalResult.java
浏览文件 @
a729e2cd
...
...
@@ -292,7 +292,7 @@ public class LocalResult implements ResultInterface, ResultTarget {
private
void
createExternalResult
()
{
Database
database
=
session
.
getDatabase
();
external
=
database
.
getMvStore
()
!=
null
external
=
database
.
isMVStore
()
?
MVTempResult
.
of
(
database
,
expressions
,
distinct
,
sort
)
:
new
ResultTempTable
(
session
,
expressions
,
distinct
,
sort
);
}
...
...
h2/src/test/org/h2/test/db/TestMultiThread.java
浏览文件 @
a729e2cd
...
...
@@ -288,13 +288,12 @@ public class TestMultiThread extends TestDb implements Runnable {
}
private
void
testLockModeWithMultiThreaded
()
throws
Exception
{
// currently the combination of LOCK_MODE=0 and MULTI_THREADED
// is not supported
deleteDb
(
"lockMode"
);
final
String
url
=
getURL
(
"lockMode;MULTI_THREADED=1"
,
true
);
try
(
Connection
conn
=
getConnection
(
url
))
{
DatabaseMetaData
meta
=
conn
.
getMetaData
();
assertFalse
(
meta
.
supportsTransactionIsolationLevel
(
// LOCK_MODE=0 with MULTI_THREADED=TRUE is supported only by MVStore
assertEquals
(
config
.
mvStore
,
meta
.
supportsTransactionIsolationLevel
(
Connection
.
TRANSACTION_READ_UNCOMMITTED
));
}
deleteDb
(
"lockMode"
);
...
...
h2/src/test/org/h2/test/jdbc/TestMetaData.java
浏览文件 @
a729e2cd
...
...
@@ -611,14 +611,13 @@ public class TestMetaData extends TestDb {
assertTrue
(
meta
.
supportsSubqueriesInQuantifieds
());
assertTrue
(
meta
.
supportsTableCorrelationNames
());
assertTrue
(
meta
.
supportsTransactions
());
assert
Tru
e
(
meta
.
supportsTransactionIsolationLevel
(
assert
Fals
e
(
meta
.
supportsTransactionIsolationLevel
(
Connection
.
TRANSACTION_NONE
));
assertTrue
(
meta
.
supportsTransactionIsolationLevel
(
Connection
.
TRANSACTION_READ_COMMITTED
));
if
(!
config
.
multiThreaded
)
{
assertTrue
(
meta
.
supportsTransactionIsolationLevel
(
Connection
.
TRANSACTION_READ_UNCOMMITTED
));
}
assertEquals
(
config
.
mvStore
||
!
config
.
multiThreaded
,
meta
.
supportsTransactionIsolationLevel
(
Connection
.
TRANSACTION_READ_UNCOMMITTED
));
assertTrue
(
meta
.
supportsTransactionIsolationLevel
(
Connection
.
TRANSACTION_REPEATABLE_READ
));
assertTrue
(
meta
.
supportsTransactionIsolationLevel
(
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论