Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
b8de4ae5
提交
b8de4ae5
authored
3月 10, 2008
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
--no commit message
--no commit message
上级
b9c3b28c
显示空白字符变更
内嵌
并排
正在显示
7 个修改的文件
包含
69 行增加
和
11 行删除
+69
-11
ErrorCode.java
h2/src/main/org/h2/constant/ErrorCode.java
+10
-1
Constants.java
h2/src/main/org/h2/engine/Constants.java
+1
-1
Session.java
h2/src/main/org/h2/engine/Session.java
+16
-0
TriggerObject.java
h2/src/main/org/h2/schema/TriggerObject.java
+5
-0
Console.java
h2/src/main/org/h2/tools/Console.java
+6
-3
TestAll.java
h2/src/test/org/h2/test/TestAll.java
+6
-6
TestTriggersConstraints.java
h2/src/test/org/h2/test/db/TestTriggersConstraints.java
+25
-0
没有找到文件。
h2/src/main/org/h2/constant/ErrorCode.java
浏览文件 @
b8de4ae5
...
@@ -912,6 +912,15 @@ public class ErrorCode {
...
@@ -912,6 +912,15 @@ public class ErrorCode {
*/
*/
public
static
final
int
CONSTRAINT_NOT_FOUND_1
=
90057
;
public
static
final
int
CONSTRAINT_NOT_FOUND_1
=
90057
;
/**
* The error with code <code>90058</code> is thrown when trying to call
* commit or rollback inside a trigger, or when trying to call a method
* inside a trigger that implicitly commits the current transaction, if an
* object is locked. This is not because it would release the lock too
* early.
*/
public
static
final
int
COMMIT_ROLLBACK_NOT_ALLOWED
=
90058
;
/**
/**
* The error with code <code>90059</code> is thrown when
* The error with code <code>90059</code> is thrown when
* a query contains a column that could belong to multiple tables.
* a query contains a column that could belong to multiple tables.
...
@@ -1753,7 +1762,7 @@ public class ErrorCode {
...
@@ -1753,7 +1762,7 @@ public class ErrorCode {
*/
*/
public
static
final
int
CAN_ONLY_ASSIGN_TO_VARIABLE_1
=
90137
;
public
static
final
int
CAN_ONLY_ASSIGN_TO_VARIABLE_1
=
90137
;
// next is 90
058, 90
108
// next is 90108
/**
/**
* INTERNAL
* INTERNAL
...
...
h2/src/main/org/h2/engine/Constants.java
浏览文件 @
b8de4ae5
...
@@ -11,7 +11,7 @@ package org.h2.engine;
...
@@ -11,7 +11,7 @@ package org.h2.engine;
* - Test with Hibernate
* - Test with Hibernate
* - Run FindBugs
* - Run FindBugs
* - ant jarClient, check jar file size
* - ant jarClient, check jar file size
*
*
- ant jar, test with IKVM
* - Compile with JDK 1.4, 1.5 and 1.6:
* - Compile with JDK 1.4, 1.5 and 1.6:
* set path=C:\Programme\Java\jdk1.6.0\bin;%PATH%
* set path=C:\Programme\Java\jdk1.6.0\bin;%PATH%
* set JAVA_HOME=C:\Programme\Java\jdk1.6.0
* set JAVA_HOME=C:\Programme\Java\jdk1.6.0
...
...
h2/src/main/org/h2/engine/Session.java
浏览文件 @
b8de4ae5
...
@@ -85,10 +85,17 @@ public class Session implements SessionInterface {
...
@@ -85,10 +85,17 @@ public class Session implements SessionInterface {
private
HashSet
temporaryResults
;
private
HashSet
temporaryResults
;
private
int
queryTimeout
=
SysProperties
.
getMaxQueryTimeout
();
private
int
queryTimeout
=
SysProperties
.
getMaxQueryTimeout
();
private
int
lastUncommittedDelete
;
private
int
lastUncommittedDelete
;
private
boolean
commitOrRollbackDisabled
;
public
Session
()
{
public
Session
()
{
}
}
public
boolean
setCommitOrRollbackDisabled
(
boolean
x
)
{
boolean
old
=
commitOrRollbackDisabled
;
commitOrRollbackDisabled
=
x
;
return
old
;
}
private
void
initVariables
()
{
private
void
initVariables
()
{
if
(
variables
==
null
)
{
if
(
variables
==
null
)
{
variables
=
new
HashMap
();
variables
=
new
HashMap
();
...
@@ -238,6 +245,7 @@ public class Session implements SessionInterface {
...
@@ -238,6 +245,7 @@ public class Session implements SessionInterface {
}
}
public
void
commit
(
boolean
ddl
)
throws
SQLException
{
public
void
commit
(
boolean
ddl
)
throws
SQLException
{
checkCommitRollback
();
lastUncommittedDelete
=
0
;
lastUncommittedDelete
=
0
;
currentTransactionName
=
null
;
currentTransactionName
=
null
;
if
(
containsUncommitted
())
{
if
(
containsUncommitted
())
{
...
@@ -285,7 +293,14 @@ public class Session implements SessionInterface {
...
@@ -285,7 +293,14 @@ public class Session implements SessionInterface {
unlockAll
();
unlockAll
();
}
}
private
void
checkCommitRollback
()
throws
SQLException
{
if
(
commitOrRollbackDisabled
&&
locks
.
size
()
>
0
)
{
throw
Message
.
getSQLException
(
ErrorCode
.
COMMIT_ROLLBACK_NOT_ALLOWED
);
}
}
public
void
rollback
()
throws
SQLException
{
public
void
rollback
()
throws
SQLException
{
checkCommitRollback
();
currentTransactionName
=
null
;
currentTransactionName
=
null
;
boolean
needCommit
=
false
;
boolean
needCommit
=
false
;
if
(
undoLog
.
size
()
>
0
)
{
if
(
undoLog
.
size
()
>
0
)
{
...
@@ -491,6 +506,7 @@ public class Session implements SessionInterface {
...
@@ -491,6 +506,7 @@ public class Session implements SessionInterface {
}
}
public
void
rollbackToSavepoint
(
String
name
)
throws
SQLException
{
public
void
rollbackToSavepoint
(
String
name
)
throws
SQLException
{
checkCommitRollback
();
if
(
savepoints
==
null
)
{
if
(
savepoints
==
null
)
{
throw
Message
.
getSQLException
(
ErrorCode
.
SAVEPOINT_IS_INVALID_1
,
name
);
throw
Message
.
getSQLException
(
ErrorCode
.
SAVEPOINT_IS_INVALID_1
,
name
);
}
}
...
...
h2/src/main/org/h2/schema/TriggerObject.java
浏览文件 @
b8de4ae5
...
@@ -80,11 +80,14 @@ public class TriggerObject extends SchemaObjectBase {
...
@@ -80,11 +80,14 @@ public class TriggerObject extends SchemaObjectBase {
}
}
load
(
session
);
load
(
session
);
Connection
c2
=
session
.
createConnection
(
false
);
Connection
c2
=
session
.
createConnection
(
false
);
boolean
old
=
session
.
setCommitOrRollbackDisabled
(
true
);
try
{
try
{
triggerCallback
.
fire
(
c2
,
null
,
null
);
triggerCallback
.
fire
(
c2
,
null
,
null
);
}
catch
(
Throwable
e
)
{
}
catch
(
Throwable
e
)
{
throw
Message
.
getSQLException
(
ErrorCode
.
ERROR_EXECUTING_TRIGGER_3
,
new
String
[]
{
getName
(),
throw
Message
.
getSQLException
(
ErrorCode
.
ERROR_EXECUTING_TRIGGER_3
,
new
String
[]
{
getName
(),
triggerClassName
,
e
.
toString
()
},
e
);
triggerClassName
,
e
.
toString
()
},
e
);
}
finally
{
session
.
setCommitOrRollbackDisabled
(
old
);
}
}
}
}
...
@@ -147,6 +150,7 @@ public class TriggerObject extends SchemaObjectBase {
...
@@ -147,6 +150,7 @@ public class TriggerObject extends SchemaObjectBase {
}
}
Connection
c2
=
session
.
createConnection
(
false
);
Connection
c2
=
session
.
createConnection
(
false
);
boolean
old
=
session
.
getAutoCommit
();
boolean
old
=
session
.
getAutoCommit
();
boolean
oldDisabled
=
session
.
setCommitOrRollbackDisabled
(
true
);
try
{
try
{
session
.
setAutoCommit
(
false
);
session
.
setAutoCommit
(
false
);
triggerCallback
.
fire
(
c2
,
oldList
,
newList
);
triggerCallback
.
fire
(
c2
,
oldList
,
newList
);
...
@@ -160,6 +164,7 @@ public class TriggerObject extends SchemaObjectBase {
...
@@ -160,6 +164,7 @@ public class TriggerObject extends SchemaObjectBase {
}
}
}
}
}
finally
{
}
finally
{
session
.
setCommitOrRollbackDisabled
(
oldDisabled
);
session
.
setAutoCommit
(
old
);
session
.
setAutoCommit
(
old
);
}
}
}
}
...
...
h2/src/main/org/h2/tools/Console.java
浏览文件 @
b8de4ae5
...
@@ -56,6 +56,7 @@ ShutdownHandler {
...
@@ -56,6 +56,7 @@ ShutdownHandler {
private
Font
font
;
private
Font
font
;
private
Image
icon16
,
icon24
;
private
Image
icon16
,
icon24
;
private
Frame
frame
;
private
Frame
frame
;
private
Button
startBrowser
;
//#endif
//#endif
private
static
final
int
EXIT_ERROR
=
1
;
private
static
final
int
EXIT_ERROR
=
1
;
private
Server
web
,
tcp
,
pg
;
private
Server
web
,
tcp
,
pg
;
...
@@ -302,7 +303,7 @@ ShutdownHandler {
...
@@ -302,7 +303,7 @@ ShutdownHandler {
}
}
mainPanel
.
add
(
text
,
constraintsTextField
);
mainPanel
.
add
(
text
,
constraintsTextField
);
Button
startBrowser
=
new
Button
(
"Start Browser"
);
startBrowser
=
new
Button
(
"Start Browser"
);
startBrowser
.
setFocusable
(
false
);
startBrowser
.
setFocusable
(
false
);
startBrowser
.
setActionCommand
(
"console"
);
startBrowser
.
setActionCommand
(
"console"
);
startBrowser
.
addActionListener
(
this
);
startBrowser
.
addActionListener
(
this
);
...
@@ -317,10 +318,9 @@ ShutdownHandler {
...
@@ -317,10 +318,9 @@ ShutdownHandler {
try
{
try
{
frame
.
setVisible
(
true
);
frame
.
setVisible
(
true
);
}
catch
(
Throwable
t
)
{
}
catch
(
Throwable
t
)
{
// ignore
// some systems don't support this method, for example IKVM
// some systems don't support this method, for example IKVM
// however it still works
// however it still works
// ignore
System
.
out
.
println
(
"URL: "
+
web
.
getURL
());
}
}
}
}
...
@@ -343,6 +343,9 @@ ShutdownHandler {
...
@@ -343,6 +343,9 @@ ShutdownHandler {
startBrowser
();
startBrowser
();
}
else
if
(
"status"
.
equals
(
command
))
{
}
else
if
(
"status"
.
equals
(
command
))
{
showWindow
(
false
);
showWindow
(
false
);
}
else
if
(
startBrowser
==
e
.
getSource
())
{
// for some reason, IKVM ignores setActionCommand
startBrowser
();
}
}
}
}
//#endif
//#endif
...
...
h2/src/test/org/h2/test/TestAll.java
浏览文件 @
b8de4ae5
...
@@ -159,10 +159,10 @@ java org.h2.test.TestAll timer
...
@@ -159,10 +159,10 @@ java org.h2.test.TestAll timer
/*
/*
CREATE TABLE in a before trigger results in an internal error.
add link to new in use, links
merge query and result frames
merge query and result frames
auto-complete in-place
in-place auto-complete
scheduler: what if invoke takes more than...
scheduler: what if invoke takes more than...
scheduler: log at startup next 5
scheduler: log at startup next 5
...
@@ -176,10 +176,6 @@ read uncommitted and multi-threaded mode at the same time is dangerous
...
@@ -176,10 +176,6 @@ read uncommitted and multi-threaded mode at the same time is dangerous
add @author
add @author
console autocomplete with pos
remove old in use, links
test multi-threaded kernel fulltext
test multi-threaded kernel fulltext
fix or disable the linear hash index
fix or disable the linear hash index
...
@@ -189,6 +185,10 @@ Can sometimes not delete log file? need test case
...
@@ -189,6 +185,10 @@ Can sometimes not delete log file? need test case
Add where required // TODO: change in version 1.1
Add where required // TODO: change in version 1.1
History:
History:
Improved support for IKVM.
A error is now thrown when trying to call a method
inside a trigger that implicitly commits the current transaction,
if an object is locked.
Roadmap:
Roadmap:
...
...
h2/src/test/org/h2/test/db/TestTriggersConstraints.java
浏览文件 @
b8de4ae5
...
@@ -131,12 +131,37 @@ public class TestTriggersConstraints extends TestBase implements Trigger {
...
@@ -131,12 +131,37 @@ public class TestTriggersConstraints extends TestBase implements Trigger {
if
(!
newRow
[
1
].
toString
().
endsWith
(
"-updated"
))
{
if
(!
newRow
[
1
].
toString
().
endsWith
(
"-updated"
))
{
throw
new
Error
(
"supposed to be updated"
);
throw
new
Error
(
"supposed to be updated"
);
}
}
checkCommit
(
conn
);
}
else
if
(
triggerName
.
startsWith
(
"UPD_BEFORE"
))
{
}
else
if
(
triggerName
.
startsWith
(
"UPD_BEFORE"
))
{
newRow
[
1
]
=
newRow
[
1
]
+
"-updated2"
;
newRow
[
1
]
=
newRow
[
1
]
+
"-updated2"
;
}
else
if
(
triggerName
.
startsWith
(
"UPD_AFTER"
))
{
}
else
if
(
triggerName
.
startsWith
(
"UPD_AFTER"
))
{
if
(!
newRow
[
1
].
toString
().
endsWith
(
"-updated2"
))
{
if
(!
newRow
[
1
].
toString
().
endsWith
(
"-updated2"
))
{
throw
new
Error
(
"supposed to be updated2"
);
throw
new
Error
(
"supposed to be updated2"
);
}
}
checkCommit
(
conn
);
}
}
private
void
checkCommit
(
Connection
conn
)
{
try
{
conn
.
commit
();
throw
new
Error
(
"Commit must not work here"
);
}
catch
(
SQLException
e
)
{
try
{
checkNotGeneralException
(
e
);
}
catch
(
Exception
e2
)
{
throw
new
Error
(
"Unexpected: "
+
e
.
toString
());
}
}
try
{
conn
.
createStatement
().
execute
(
"CREATE TABLE X(ID INT)"
);
throw
new
Error
(
"CREATE TABLE WORKED, but implicitly commits"
);
}
catch
(
SQLException
e
)
{
try
{
checkNotGeneralException
(
e
);
}
catch
(
Exception
e2
)
{
throw
new
Error
(
"Unexpected: "
+
e
.
toString
());
}
}
}
}
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论