Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
59e254f4
提交
59e254f4
authored
4月 08, 2011
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Issue 308: Statement.getGeneratedKeys() now returns an empty result set if no key was generated.
上级
a32eff44
显示空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
20 行增加
和
13 行删除
+20
-13
CommandContainer.java
h2/src/main/org/h2/command/CommandContainer.java
+2
-0
Merge.java
h2/src/main/org/h2/command/dml/Merge.java
+0
-2
JdbcConnection.java
h2/src/main/org/h2/jdbc/JdbcConnection.java
+1
-1
JdbcStatement.java
h2/src/main/org/h2/jdbc/JdbcStatement.java
+9
-8
TestPreparedStatement.java
h2/src/test/org/h2/test/jdbc/TestPreparedStatement.java
+7
-0
TestStatement.java
h2/src/test/org/h2/test/jdbc/TestStatement.java
+1
-2
没有找到文件。
h2/src/main/org/h2/command/CommandContainer.java
浏览文件 @
59e254f4
...
...
@@ -11,6 +11,7 @@ import org.h2.expression.Parameter;
import
org.h2.expression.ParameterInterface
;
import
org.h2.result.ResultInterface
;
import
org.h2.value.Value
;
import
org.h2.value.ValueNull
;
/**
* Represents a single SQL statements.
...
...
@@ -65,6 +66,7 @@ class CommandContainer extends Command {
public
int
update
()
{
recompileIfRequired
();
start
();
session
.
setLastIdentity
(
ValueNull
.
INSTANCE
);
prepared
.
checkParameters
();
int
updateCount
=
prepared
.
update
();
prepared
.
trace
(
startTime
,
updateCount
);
...
...
h2/src/main/org/h2/command/dml/Merge.java
浏览文件 @
59e254f4
...
...
@@ -26,7 +26,6 @@ import org.h2.table.Table;
import
org.h2.util.New
;
import
org.h2.util.StatementBuilder
;
import
org.h2.value.Value
;
import
org.h2.value.ValueLong
;
/**
* This class represents the statement
...
...
@@ -82,7 +81,6 @@ public class Merge extends Prepared {
session
.
getUser
().
checkRight
(
table
,
Right
.
INSERT
);
session
.
getUser
().
checkRight
(
table
,
Right
.
UPDATE
);
setCurrentRowNumber
(
0
);
session
.
setLastIdentity
(
ValueLong
.
get
(
0
));
if
(
list
.
size
()
>
0
)
{
count
=
0
;
for
(
int
x
=
0
,
size
=
list
.
size
();
x
<
size
;
x
++)
{
...
...
h2/src/main/org/h2/jdbc/JdbcConnection.java
浏览文件 @
59e254f4
...
...
@@ -1440,7 +1440,7 @@ public class JdbcConnection extends TraceObject implements Connection {
* INTERNAL
*/
ResultSet
getGeneratedKeys
(
JdbcStatement
stat
,
int
id
)
{
getGeneratedKeys
=
prepareCommand
(
"
CALL SCOPE_IDENTITY()
"
,
getGeneratedKeys
);
getGeneratedKeys
=
prepareCommand
(
"
SELECT SCOPE_IDENTITY() WHERE SCOPE_IDENTITY() IS NOT NULL
"
,
getGeneratedKeys
);
ResultInterface
result
=
getGeneratedKeys
.
executeQuery
(
0
,
false
);
ResultSet
rs
=
new
JdbcResultSet
(
this
,
stat
,
result
,
id
,
false
,
true
,
false
);
return
rs
;
...
...
h2/src/main/org/h2/jdbc/JdbcStatement.java
浏览文件 @
59e254f4
...
...
@@ -657,8 +657,9 @@ public class JdbcStatement extends TraceObject implements Statement {
}
/**
* Return a result set that contains the last generated autoincrement key
* for this connection.
* Return a result set that contains the last generated auto-increment key
* for this connection, if there was one. If no key was generated by the
* last modification statement, then an empty result set is returned.
*
* @return the result set with one row and one column containing the key
* @throws SQLException if this object is closed
...
...
@@ -710,7 +711,7 @@ public class JdbcStatement extends TraceObject implements Statement {
/**
* Executes a statement and returns the update count.
* This method just calls executeUpdate(String sql) internally.
* The method getGeneratedKeys
only supports one column
.
* The method getGeneratedKeys
supports at most one columns and row
.
*
* @param sql the SQL statement
* @param autoGeneratedKeys ignored
...
...
@@ -734,7 +735,7 @@ public class JdbcStatement extends TraceObject implements Statement {
/**
* Executes a statement and returns the update count.
* This method just calls executeUpdate(String sql) internally.
* The method getGeneratedKeys
only supports one column
.
* The method getGeneratedKeys
supports at most one columns and row
.
*
* @param sql the SQL statement
* @param columnIndexes ignored
...
...
@@ -758,7 +759,7 @@ public class JdbcStatement extends TraceObject implements Statement {
/**
* Executes a statement and returns the update count.
* This method just calls executeUpdate(String sql) internally.
* The method getGeneratedKeys
only supports one column
.
* The method getGeneratedKeys
supports at most one columns and row
.
*
* @param sql the SQL statement
* @param columnNames ignored
...
...
@@ -782,7 +783,7 @@ public class JdbcStatement extends TraceObject implements Statement {
/**
* Executes a statement and returns the update count.
* This method just calls execute(String sql) internally.
* The method getGeneratedKeys
only supports one column
.
* The method getGeneratedKeys
supports at most one columns and row
.
*
* @param sql the SQL statement
* @param autoGeneratedKeys ignored
...
...
@@ -806,7 +807,7 @@ public class JdbcStatement extends TraceObject implements Statement {
/**
* Executes a statement and returns the update count.
* This method just calls execute(String sql) internally.
* The method getGeneratedKeys
only supports one column
.
* The method getGeneratedKeys
supports at most one columns and row
.
*
* @param sql the SQL statement
* @param columnIndexes ignored
...
...
@@ -830,7 +831,7 @@ public class JdbcStatement extends TraceObject implements Statement {
/**
* Executes a statement and returns the update count.
* This method just calls execute(String sql) internally.
* The method getGeneratedKeys
only supports one column
.
* The method getGeneratedKeys
supports at most one columns and row
.
*
* @param sql the SQL statement
* @param columnNames ignored
...
...
h2/src/test/org/h2/test/jdbc/TestPreparedStatement.java
浏览文件 @
59e254f4
...
...
@@ -356,6 +356,9 @@ public class TestPreparedStatement extends TestBase {
rs
.
next
();
byte
[]
data
=
rs
.
getBytes
(
1
);
assertEquals
(
16
,
data
.
length
);
stat
.
execute
(
"INSERT INTO TEST_UUID VALUES(random_UUID())"
);
rs
=
stat
.
getGeneratedKeys
();
assertFalse
(
rs
.
next
());
stat
.
execute
(
"DROP TABLE TEST_UUID"
);
}
...
...
@@ -394,6 +397,10 @@ public class TestPreparedStatement extends TestBase {
ResultSet
rs
=
stat
.
getGeneratedKeys
();
rs
.
next
();
assertEquals
(
1
,
rs
.
getLong
(
1
));
stat
.
execute
(
"insert into test values(100)"
);
rs
=
stat
.
getGeneratedKeys
();
rs
.
next
();
assertEquals
(
100
,
rs
.
getLong
(
1
));
stat
.
execute
(
"drop sequence seq"
);
stat
.
execute
(
"drop table test"
);
}
...
...
h2/src/test/org/h2/test/jdbc/TestStatement.java
浏览文件 @
59e254f4
...
...
@@ -337,8 +337,7 @@ public class TestStatement extends TestBase {
stat
.
execute
(
"insert into test2(x) values(10), (11), (12)"
);
stat
.
execute
(
"merge into test1(x) key(x) values(5)"
);
keys
=
stat
.
getGeneratedKeys
();
keys
.
next
();
assertEquals
(
0
,
keys
.
getInt
(
1
));
assertFalse
(
keys
.
next
());
stat
.
execute
(
"merge into test1(x) key(x) values(6)"
);
keys
=
stat
.
getGeneratedKeys
();
keys
.
next
();
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论