Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
23c0fae8
提交
23c0fae8
authored
11月 07, 2009
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
New function SCOPE_IDENTITY().
上级
9b5cd887
显示空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
38 行增加
和
5 行删除
+38
-5
help.csv
h2/src/docsrc/help/help.csv
+16
-3
Database.java
h2/src/main/org/h2/engine/Database.java
+4
-0
FunctionAlias.java
h2/src/main/org/h2/engine/FunctionAlias.java
+2
-0
Session.java
h2/src/main/org/h2/engine/Session.java
+10
-0
Function.java
h2/src/main/org/h2/expression/Function.java
+6
-2
没有找到文件。
h2/src/docsrc/help/help.csv
浏览文件 @
23c0fae8
...
...
@@ -44,12 +44,13 @@ INSERT INTO TEST VALUES(1, 'Hello')
"
"Commands (DML)","UPDATE","
UPDATE tableName SET { columnName= { DEFAULT | expression } } [,...]
UPDATE tableName
[ [ AS ] newTableAlias ]
SET { columnName= { DEFAULT | expression } } [,...]
[ WHERE expression ]
","
Updates data in a table.
","
UPDATE TEST SET NAME='Hi' WHERE ID=1
UPDATE TEST SET NAME='Hi' WHERE ID=1;
UPDATE PERSON P SET NAME=(SELECT A.NAME FROM ADDRESS A WHERE A.ID=P.ID);
"
"Commands (DML)","DELETE","
...
...
@@ -1034,7 +1035,7 @@ SET IGNORECASE TRUE
SET LOCK_MODE int
","
Sets the lock mode. The values 0, 1, 2, and 3 are supported. The default is 3
(READ_COMMITTED).
(READ_COMMITTED).
This setting affects all connections.
The value 0 means no locking (should only be used for testing; also known as
READ_UNCOMMITTED). Please note that using SET LOCK_MODE 0 while at the same time
...
...
@@ -3229,6 +3230,8 @@ CALL GREATEST(1, 2, 3);
IDENTITY()
","
Returns the last inserted identity value for this session.
This value changes whenever a new sequence number was generated,
even within a trigger or Java function. See also SCOPE_IDENTITY().
This method returns a long.
","
CALL IDENTITY();
...
...
@@ -3351,6 +3354,16 @@ Returns the name of the default schema for this session.
CALL SCHEMA()
"
"Functions (System)","SCOPE_IDENTITY","
SCOPE_IDENTITY()
","
Returns the last inserted identity value for this session for the current scope.
Changes within triggers and Java functions are ignored. See also IDENTITY().
This method returns a long.
","
CALL SCOPE_IDENTITY();
"
"Functions (System)","SESSION_ID","
SESSION_ID()
","
...
...
h2/src/main/org/h2/engine/Database.java
浏览文件 @
23c0fae8
...
...
@@ -1993,6 +1993,10 @@ public class Database implements DataHandler {
public
void
setLockMode
(
int
lockMode
)
throws
SQLException
{
switch
(
lockMode
)
{
case
Constants
.
LOCK_MODE_OFF
:
if
(
multiThreaded
)
{
// currently the combination of LOCK_MODE=0 and MULTI_THREADED is not supported
throw
Message
.
getSQLException
(
ErrorCode
.
CANNOT_CHANGE_SETTING_WHEN_OPEN_1
,
"LOCK_MODE=0 & MULTI_THREADED"
);
}
case
Constants
.
LOCK_MODE_READ_COMMITTED
:
case
Constants
.
LOCK_MODE_TABLE
:
case
Constants
.
LOCK_MODE_TABLE_GC
:
...
...
h2/src/main/org/h2/engine/FunctionAlias.java
浏览文件 @
23c0fae8
...
...
@@ -292,6 +292,7 @@ public class FunctionAlias extends DbObjectBase {
}
}
boolean
old
=
session
.
getAutoCommit
();
Value
identity
=
session
.
getScopeIdentity
();
try
{
session
.
setAutoCommit
(
false
);
try
{
...
...
@@ -306,6 +307,7 @@ public class FunctionAlias extends DbObjectBase {
throw
Message
.
convert
(
e
);
}
}
finally
{
session
.
setScopeIdentity
(
identity
);
session
.
setAutoCommit
(
old
);
}
}
...
...
h2/src/main/org/h2/engine/Session.java
浏览文件 @
23c0fae8
...
...
@@ -67,6 +67,7 @@ public class Session extends SessionWithState {
private
LogSystem
logSystem
;
private
int
lockTimeout
;
private
Value
lastIdentity
=
ValueLong
.
get
(
0
);
private
Value
scopeIdentity
=
ValueLong
.
get
(
0
);
private
int
firstUncommittedLog
=
LogSystem
.
LOG_WRITTEN
;
private
int
firstUncommittedPos
=
LogSystem
.
LOG_WRITTEN
;
private
HashMap
<
String
,
Integer
>
savepoints
;
...
...
@@ -686,6 +687,7 @@ public class Session extends SessionWithState {
}
public
void
setLastIdentity
(
Value
last
)
{
this
.
scopeIdentity
=
last
;
this
.
lastIdentity
=
last
;
}
...
...
@@ -1161,4 +1163,12 @@ public class Session extends SessionWithState {
return
objectId
++;
}
public
void
setScopeIdentity
(
Value
scopeIdentity
)
{
this
.
scopeIdentity
=
scopeIdentity
;
}
public
Value
getScopeIdentity
()
{
return
scopeIdentity
;
}
}
h2/src/main/org/h2/expression/Function.java
浏览文件 @
23c0fae8
...
...
@@ -91,8 +91,8 @@ public class Function extends Expression implements FunctionCall {
CURRENT_TIMESTAMP
=
119
,
EXTRACT
=
120
,
FORMATDATETIME
=
121
,
PARSEDATETIME
=
122
,
ISO_YEAR
=
123
,
ISO_WEEK
=
124
,
ISO_DAY_OF_WEEK
=
125
;
public
static
final
int
DATABASE
=
150
,
USER
=
151
,
CURRENT_USER
=
152
,
IDENTITY
=
153
,
AUTOCOMMIT
=
154
,
READONLY
=
155
,
DATABASE_PATH
=
156
,
LOCK_TIMEOUT
=
157
;
public
static
final
int
DATABASE
=
150
,
USER
=
151
,
CURRENT_USER
=
152
,
IDENTITY
=
153
,
SCOPE_IDENTITY
=
154
,
AUTOCOMMIT
=
155
,
READONLY
=
156
,
DATABASE_PATH
=
157
,
LOCK_TIMEOUT
=
158
;
public
static
final
int
IFNULL
=
200
,
CASEWHEN
=
201
,
CONVERT
=
202
,
CAST
=
203
,
COALESCE
=
204
,
NULLIF
=
205
,
CASE
=
206
,
NEXTVAL
=
207
,
CURRVAL
=
208
,
ARRAY_GET
=
209
,
CSVREAD
=
210
,
CSVWRITE
=
211
,
...
...
@@ -286,6 +286,7 @@ public class Function extends Expression implements FunctionCall {
addFunctionNotDeterministic
(
"USER"
,
USER
,
0
,
Value
.
STRING
);
addFunctionNotDeterministic
(
"CURRENT_USER"
,
CURRENT_USER
,
0
,
Value
.
STRING
);
addFunctionNotDeterministic
(
"IDENTITY"
,
IDENTITY
,
0
,
Value
.
LONG
);
addFunctionNotDeterministic
(
"SCOPE_IDENTITY"
,
SCOPE_IDENTITY
,
0
,
Value
.
LONG
);
addFunctionNotDeterministic
(
"IDENTITY_VAL_LOCAL"
,
IDENTITY
,
0
,
Value
.
LONG
);
addFunctionNotDeterministic
(
"LAST_INSERT_ID"
,
IDENTITY
,
0
,
Value
.
LONG
);
addFunctionNotDeterministic
(
"LASTVAL"
,
IDENTITY
,
0
,
Value
.
LONG
);
...
...
@@ -688,6 +689,9 @@ public class Function extends Expression implements FunctionCall {
case
IDENTITY:
result
=
session
.
getLastIdentity
();
break
;
case
SCOPE_IDENTITY:
result
=
session
.
getScopeIdentity
();
break
;
case
AUTOCOMMIT:
result
=
ValueBoolean
.
get
(
session
.
getAutoCommit
());
break
;
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论