Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
816461dd
提交
816461dd
authored
2月 18, 2018
作者:
Evgenij Ryazanov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add constants for modes of generated keys' gathering
上级
d2867279
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
86 行增加
和
17 行删除
+86
-17
CommandRemote.java
h2/src/main/org/h2/command/CommandRemote.java
+12
-11
GeneratedKeysMode.java
h2/src/main/org/h2/engine/GeneratedKeysMode.java
+63
-0
TcpServerThread.java
h2/src/main/org/h2/server/TcpServerThread.java
+11
-6
没有找到文件。
h2/src/main/org/h2/command/CommandRemote.java
浏览文件 @
816461dd
...
...
@@ -9,6 +9,7 @@ import java.io.IOException;
import
java.util.ArrayList
;
import
org.h2.engine.Constants
;
import
org.h2.engine.GeneratedKeysMode
;
import
org.h2.engine.SessionRemote
;
import
org.h2.engine.SysProperties
;
import
org.h2.expression.ParameterInterface
;
...
...
@@ -212,28 +213,28 @@ public class CommandRemote implements CommandInterface {
transfer
.
writeInt
(
SessionRemote
.
COMMAND_EXECUTE_UPDATE
).
writeInt
(
id
);
sendParameters
(
transfer
);
if
(
supportsGeneratedKeys
)
{
if
(
Boolean
.
FALSE
.
equals
(
generatedKeysRequest
))
{
transfer
.
writeInt
(
0
);
int
mode
=
GeneratedKeysMode
.
valueOf
(
generatedKeysRequest
);
transfer
.
writeInt
(
mode
);
switch
(
mode
)
{
case
GeneratedKeysMode
.
NONE
:
readGeneratedKeys
=
false
;
}
else
if
(
Boolean
.
TRUE
.
equals
(
generatedKeysRequest
))
{
transfer
.
writeInt
(
1
);
}
else
if
(
generatedKeysRequest
instanceof
int
[])
{
break
;
case
GeneratedKeysMode
.
COLUMN_NUMBERS
:
{
int
[]
keys
=
(
int
[])
generatedKeysRequest
;
transfer
.
writeInt
(
2
);
transfer
.
writeInt
(
keys
.
length
);
for
(
int
key
:
keys
)
{
transfer
.
writeInt
(
key
);
}
}
else
if
(
generatedKeysRequest
instanceof
String
[])
{
break
;
}
case
GeneratedKeysMode
.
COLUMN_NAMES
:
{
String
[]
keys
=
(
String
[])
generatedKeysRequest
;
transfer
.
writeInt
(
3
);
transfer
.
writeInt
(
keys
.
length
);
for
(
String
key
:
keys
)
{
transfer
.
writeString
(
key
);
}
}
else
{
transfer
.
writeInt
(
0
);
readGeneratedKeys
=
false
;
break
;
}
}
}
session
.
done
(
transfer
);
...
...
h2/src/main/org/h2/engine/GeneratedKeysMode.java
0 → 100644
浏览文件 @
816461dd
/*
* Copyright 2004-2018 H2 Group. Multiple-Licensed under the MPL 2.0,
* and the EPL 1.0 (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package
org
.
h2
.
engine
;
/**
* Modes of generated keys' gathering.
*/
public
final
class
GeneratedKeysMode
{
/**
* Generated keys are not needed.
*/
public
static
final
int
NONE
=
0
;
/**
* Generated keys should be configured automatically.
*/
public
static
final
int
AUTO
=
1
;
/**
* Use specified column indices to return generated keys from.
*/
public
static
final
int
COLUMN_NUMBERS
=
2
;
/**
* Use specified column names to return generated keys from.
*/
public
static
final
int
COLUMN_NAMES
=
3
;
/**
* Determines mode of generated keys' gathering.
*
* @param generatedKeysRequest
* {@code false} if generated keys are not needed, {@code true} if
* generated keys should be configured automatically, {@code int[]}
* to specify column indices to return generated keys from, or
* {@code String[]} to specify column names to return generated keys
* from
* @return mode for the specified generated keys request
*/
public
static
int
valueOf
(
Object
generatedKeysRequest
)
{
if
(
Boolean
.
FALSE
.
equals
(
generatedKeysRequest
))
{
return
NONE
;
}
if
(
Boolean
.
TRUE
.
equals
(
generatedKeysRequest
))
{
return
AUTO
;
}
if
(
generatedKeysRequest
instanceof
int
[])
{
return
COLUMN_NUMBERS
;
}
if
(
generatedKeysRequest
instanceof
String
[])
{
return
COLUMN_NAMES
;
}
return
NONE
;
}
private
GeneratedKeysMode
()
{
}
}
h2/src/main/org/h2/server/TcpServerThread.java
浏览文件 @
816461dd
...
...
@@ -21,6 +21,7 @@ import org.h2.command.Command;
import
org.h2.engine.ConnectionInfo
;
import
org.h2.engine.Constants
;
import
org.h2.engine.Engine
;
import
org.h2.engine.GeneratedKeysMode
;
import
org.h2.engine.Session
;
import
org.h2.engine.SessionRemote
;
import
org.h2.engine.SysProperties
;
...
...
@@ -358,16 +359,16 @@ public class TcpServerThread implements Runnable {
boolean
writeGeneratedKeys
=
supportsGeneratedKeys
;
Object
generatedKeysRequest
;
if
(
supportsGeneratedKeys
)
{
int
typ
e
=
transfer
.
readInt
();
switch
(
typ
e
)
{
default
:
int
mod
e
=
transfer
.
readInt
();
switch
(
mod
e
)
{
case
GeneratedKeysMode
.
NONE
:
generatedKeysRequest
=
false
;
writeGeneratedKeys
=
false
;
break
;
case
1
:
case
GeneratedKeysMode
.
AUTO
:
generatedKeysRequest
=
true
;
break
;
case
2
:
{
case
GeneratedKeysMode
.
COLUMN_NUMBERS
:
{
int
len
=
transfer
.
readInt
();
int
[]
keys
=
new
int
[
len
];
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
...
...
@@ -376,14 +377,18 @@ public class TcpServerThread implements Runnable {
generatedKeysRequest
=
keys
;
break
;
}
case
3
:
{
case
GeneratedKeysMode
.
COLUMN_NAMES
:
{
int
len
=
transfer
.
readInt
();
String
[]
keys
=
new
String
[
len
];
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
keys
[
i
]
=
transfer
.
readString
();
}
generatedKeysRequest
=
keys
;
break
;
}
default
:
throw
DbException
.
get
(
ErrorCode
.
CONNECTION_BROKEN_1
,
"Unsupported generated keys' mode "
+
mode
);
}
}
else
{
generatedKeysRequest
=
false
;
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论