Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
5a84a557
提交
5a84a557
authored
11月 16, 2011
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
New experimental system property "h2.modifyOnWrite".
上级
d744354c
隐藏空白字符变更
内嵌
并排
正在显示
8 个修改的文件
包含
92 行增加
和
24 行删除
+92
-24
Command.java
h2/src/main/org/h2/command/Command.java
+13
-4
Constants.java
h2/src/main/org/h2/engine/Constants.java
+5
-0
Session.java
h2/src/main/org/h2/engine/Session.java
+2
-2
SessionInterface.java
h2/src/main/org/h2/engine/SessionInterface.java
+7
-0
SessionRemote.java
h2/src/main/org/h2/engine/SessionRemote.java
+27
-1
JdbcConnection.java
h2/src/main/org/h2/jdbc/JdbcConnection.java
+11
-9
TcpServerThread.java
h2/src/main/org/h2/server/TcpServerThread.java
+26
-7
FileLock.java
h2/src/main/org/h2/store/FileLock.java
+1
-1
没有找到文件。
h2/src/main/org/h2/command/Command.java
浏览文件 @
5a84a557
...
...
@@ -174,7 +174,9 @@ public abstract class Command implements CommandInterface {
session
.
waitIfExclusiveModeEnabled
();
boolean
writing
=
!
isReadOnly
();
if
(
writing
)
{
database
.
beforeWriting
();
while
(!
database
.
beforeWriting
())
{
// wait
}
}
synchronized
(
sync
)
{
session
.
setCurrentCommand
(
this
);
...
...
@@ -208,9 +210,14 @@ public abstract class Command implements CommandInterface {
Object
sync
=
database
.
isMultiThreaded
()
?
(
Object
)
session
:
(
Object
)
database
;
session
.
waitIfExclusiveModeEnabled
();
boolean
callStop
=
true
;
database
.
beforeWriting
();
boolean
writing
=
!
isReadOnly
();
if
(
writing
)
{
while
(!
database
.
beforeWriting
())
{
// wait
}
}
synchronized
(
sync
)
{
int
rollback
=
session
.
get
LogId
();
int
rollback
=
session
.
get
UndoLogPos
();
session
.
setCurrentCommand
(
this
);
try
{
while
(
true
)
{
...
...
@@ -248,7 +255,9 @@ public abstract class Command implements CommandInterface {
stop
();
}
}
finally
{
database
.
afterWriting
();
if
(
writing
)
{
database
.
afterWriting
();
}
}
}
}
...
...
h2/src/main/org/h2/engine/Constants.java
浏览文件 @
5a84a557
...
...
@@ -61,6 +61,11 @@ public class Constants {
*/
public
static
final
int
TCP_PROTOCOL_VERSION_9
=
9
;
/**
* The TCP protocol version number 10.
*/
public
static
final
int
TCP_PROTOCOL_VERSION_10
=
10
;
/**
* The major version of this database.
*/
...
...
h2/src/main/org/h2/engine/Session.java
浏览文件 @
5a84a557
...
...
@@ -542,7 +542,7 @@ public class Session extends SessionWithState {
}
}
public
int
get
LogId
()
{
public
int
get
UndoLogPos
()
{
return
undoLog
.
size
();
}
...
...
@@ -755,7 +755,7 @@ public class Session extends SessionWithState {
if
(
savepoints
==
null
)
{
savepoints
=
database
.
newStringMap
();
}
savepoints
.
put
(
name
,
get
LogId
());
savepoints
.
put
(
name
,
get
UndoLogPos
());
}
/**
...
...
h2/src/main/org/h2/engine/SessionInterface.java
浏览文件 @
5a84a557
...
...
@@ -67,6 +67,13 @@ public interface SessionInterface extends Closeable {
*/
DataHandler
getDataHandler
();
/**
* Get the undo log position.
*
* @return the position (0 means no pending transaction)
*/
int
getUndoLogPos
();
/**
* Cancel the current or next command (called when closing a connection).
*/
...
...
h2/src/main/org/h2/engine/SessionRemote.java
浏览文件 @
5a84a557
...
...
@@ -55,6 +55,7 @@ public class SessionRemote extends SessionWithState implements DataHandler {
public
static
final
int
SESSION_CANCEL_STATEMENT
=
13
;
public
static
final
int
SESSION_CHECK_KEY
=
14
;
public
static
final
int
SESSION_SET_AUTOCOMMIT
=
15
;
public
static
final
int
SESSION_UNDO_LOG_POS
=
16
;
public
static
final
int
STATUS_ERROR
=
0
;
public
static
final
int
STATUS_OK
=
1
;
...
...
@@ -94,7 +95,7 @@ public class SessionRemote extends SessionWithState implements DataHandler {
trans
.
setSSL
(
ci
.
isSSL
());
trans
.
init
();
trans
.
writeInt
(
Constants
.
TCP_PROTOCOL_VERSION_6
);
trans
.
writeInt
(
Constants
.
TCP_PROTOCOL_VERSION_
9
);
trans
.
writeInt
(
Constants
.
TCP_PROTOCOL_VERSION_
10
);
trans
.
writeString
(
db
);
trans
.
writeString
(
ci
.
getOriginalURL
());
trans
.
writeString
(
ci
.
getUserName
());
...
...
@@ -120,6 +121,24 @@ public class SessionRemote extends SessionWithState implements DataHandler {
return
trans
;
}
public
int
getUndoLogPos
()
{
if
(
clientVersion
<
Constants
.
TCP_PROTOCOL_VERSION_10
)
{
return
1
;
}
for
(
int
i
=
0
,
count
=
0
;
i
<
transferList
.
size
();
i
++)
{
Transfer
transfer
=
transferList
.
get
(
i
);
try
{
traceOperation
(
"SESSION_UNDO_LOG_POS"
,
0
);
transfer
.
writeInt
(
SessionRemote
.
SESSION_UNDO_LOG_POS
);
done
(
transfer
);
return
transfer
.
readInt
();
}
catch
(
IOException
e
)
{
removeServer
(
e
,
i
--,
++
count
);
}
}
return
1
;
}
public
void
cancel
()
{
// this method is called when closing the connection
// the statement that is currently running is not canceled in this case
...
...
@@ -482,6 +501,7 @@ public class SessionRemote extends SessionWithState implements DataHandler {
}
public
void
close
()
{
RuntimeException
closeError
=
null
;
if
(
transferList
!=
null
)
{
synchronized
(
this
)
{
for
(
Transfer
transfer
:
transferList
)
{
...
...
@@ -490,6 +510,9 @@ public class SessionRemote extends SessionWithState implements DataHandler {
transfer
.
writeInt
(
SessionRemote
.
SESSION_CLOSE
);
done
(
transfer
);
transfer
.
close
();
}
catch
(
RuntimeException
e
)
{
trace
.
error
(
e
,
"close"
);
closeError
=
e
;
}
catch
(
Exception
e
)
{
trace
.
error
(
e
,
"close"
);
}
...
...
@@ -502,6 +525,9 @@ public class SessionRemote extends SessionWithState implements DataHandler {
embedded
.
close
();
embedded
=
null
;
}
if
(
closeError
!=
null
)
{
throw
closeError
;
}
}
public
Trace
getTrace
()
{
...
...
h2/src/main/org/h2/jdbc/JdbcConnection.java
浏览文件 @
5a84a557
...
...
@@ -345,15 +345,17 @@ public class JdbcConnection extends TraceObject implements Connection {
try
{
if
(!
session
.
isClosed
())
{
try
{
// roll back unless that would require to re-connect
// (the transaction can't be rolled back after re-connecting)
if
(!
session
.
isReconnectNeeded
(
true
))
{
try
{
rollbackInternal
();
}
catch
(
DbException
e
)
{
// ignore if the connection is broken right now
if
(
e
.
getErrorCode
()
!=
ErrorCode
.
CONNECTION_BROKEN_1
)
{
throw
e
;
if
(
session
.
getUndoLogPos
()
!=
0
)
{
// roll back unless that would require to re-connect
// (the transaction can't be rolled back after re-connecting)
if
(!
session
.
isReconnectNeeded
(
true
))
{
try
{
rollbackInternal
();
}
catch
(
DbException
e
)
{
// ignore if the connection is broken right now
if
(
e
.
getErrorCode
()
!=
ErrorCode
.
CONNECTION_BROKEN_1
)
{
throw
e
;
}
}
}
session
.
afterWriting
();
...
...
h2/src/main/org/h2/server/TcpServerThread.java
浏览文件 @
5a84a557
...
...
@@ -71,12 +71,12 @@ public class TcpServerThread implements Runnable {
int
minClientVersion
=
transfer
.
readInt
();
if
(
minClientVersion
<
Constants
.
TCP_PROTOCOL_VERSION_6
)
{
throw
DbException
.
get
(
ErrorCode
.
DRIVER_VERSION_ERROR_2
,
""
+
clientVersion
,
""
+
Constants
.
TCP_PROTOCOL_VERSION_6
);
}
else
if
(
minClientVersion
>
Constants
.
TCP_PROTOCOL_VERSION_
9
)
{
throw
DbException
.
get
(
ErrorCode
.
DRIVER_VERSION_ERROR_2
,
""
+
clientVersion
,
""
+
Constants
.
TCP_PROTOCOL_VERSION_
9
);
}
else
if
(
minClientVersion
>
Constants
.
TCP_PROTOCOL_VERSION_
10
)
{
throw
DbException
.
get
(
ErrorCode
.
DRIVER_VERSION_ERROR_2
,
""
+
clientVersion
,
""
+
Constants
.
TCP_PROTOCOL_VERSION_
10
);
}
int
maxClientVersion
=
transfer
.
readInt
();
if
(
maxClientVersion
>=
Constants
.
TCP_PROTOCOL_VERSION_
9
)
{
clientVersion
=
Constants
.
TCP_PROTOCOL_VERSION_
9
;
if
(
maxClientVersion
>=
Constants
.
TCP_PROTOCOL_VERSION_
10
)
{
clientVersion
=
Constants
.
TCP_PROTOCOL_VERSION_
10
;
}
else
{
clientVersion
=
minClientVersion
;
}
...
...
@@ -149,20 +149,32 @@ public class TcpServerThread implements Runnable {
private
void
closeSession
()
{
if
(
session
!=
null
)
{
RuntimeException
closeError
=
null
;
try
{
Command
rollback
=
session
.
prepareLocal
(
"ROLLBACK"
);
rollback
.
executeUpdate
();
}
catch
(
RuntimeException
e
)
{
closeError
=
e
;
server
.
traceError
(
e
);
}
catch
(
Exception
e
)
{
server
.
traceError
(
e
);
}
try
{
session
.
close
();
server
.
removeConnection
(
threadId
);
}
catch
(
RuntimeException
e
)
{
if
(
closeError
==
null
)
{
closeError
=
e
;
server
.
traceError
(
e
);
}
}
catch
(
Exception
e
)
{
server
.
traceError
(
e
);
}
finally
{
session
=
null
;
}
if
(
closeError
!=
null
)
{
throw
closeError
;
}
}
}
...
...
@@ -173,12 +185,13 @@ public class TcpServerThread implements Runnable {
try
{
stop
=
true
;
closeSession
();
transfer
.
close
();
trace
(
"Close"
);
}
catch
(
Exception
e
)
{
server
.
traceError
(
e
);
}
finally
{
transfer
.
close
();
trace
(
"Close"
);
server
.
remove
(
this
);
}
server
.
remove
(
this
);
}
private
void
sendError
(
Throwable
t
)
{
...
...
@@ -241,6 +254,7 @@ public class TcpServerThread implements Runnable {
break
;
}
case
SessionRemote
.
SESSION_CLOSE
:
{
stop
=
true
;
closeSession
();
transfer
.
writeInt
(
SessionRemote
.
STATUS_OK
).
flush
();
close
();
...
...
@@ -364,6 +378,11 @@ public class TcpServerThread implements Runnable {
transfer
.
writeInt
(
SessionRemote
.
STATUS_OK
).
flush
();
break
;
}
case
SessionRemote
.
SESSION_UNDO_LOG_POS
:
{
transfer
.
writeInt
(
SessionRemote
.
STATUS_OK
).
writeInt
(
session
.
getUndoLogPos
()).
flush
();
break
;
}
default
:
trace
(
"Unknown operation: "
+
operation
);
closeSession
();
...
...
h2/src/main/org/h2/store/FileLock.java
浏览文件 @
5a84a557
...
...
@@ -224,7 +224,7 @@ public class FileLock implements Runnable {
transfer
.
setSocket
(
socket
);
transfer
.
init
();
transfer
.
writeInt
(
Constants
.
TCP_PROTOCOL_VERSION_6
);
transfer
.
writeInt
(
Constants
.
TCP_PROTOCOL_VERSION_
9
);
transfer
.
writeInt
(
Constants
.
TCP_PROTOCOL_VERSION_
10
);
transfer
.
writeString
(
null
);
transfer
.
writeString
(
null
);
transfer
.
writeString
(
id
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论