Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
bbf4df6f
提交
bbf4df6f
authored
6月 15, 2018
作者:
Evgenij Ryazanov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Pass Mode to convert() methods in all DML commands
上级
6092aecf
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
14 行增加
和
7 行删除
+14
-7
Insert.java
h2/src/main/org/h2/command/dml/Insert.java
+5
-2
Merge.java
h2/src/main/org/h2/command/dml/Merge.java
+4
-2
Replace.java
h2/src/main/org/h2/command/dml/Replace.java
+4
-2
Update.java
h2/src/main/org/h2/command/dml/Update.java
+1
-1
没有找到文件。
h2/src/main/org/h2/command/dml/Insert.java
浏览文件 @
bbf4df6f
...
@@ -14,6 +14,7 @@ import org.h2.command.Command;
...
@@ -14,6 +14,7 @@ import org.h2.command.Command;
import
org.h2.command.CommandInterface
;
import
org.h2.command.CommandInterface
;
import
org.h2.command.Prepared
;
import
org.h2.command.Prepared
;
import
org.h2.engine.GeneratedKeys
;
import
org.h2.engine.GeneratedKeys
;
import
org.h2.engine.Mode
;
import
org.h2.engine.Right
;
import
org.h2.engine.Right
;
import
org.h2.engine.Session
;
import
org.h2.engine.Session
;
import
org.h2.engine.UndoLogRecord
;
import
org.h2.engine.UndoLogRecord
;
...
@@ -151,6 +152,7 @@ public class Insert extends Prepared implements ResultTarget {
...
@@ -151,6 +152,7 @@ public class Insert extends Prepared implements ResultTarget {
generatedKeys
.
initialize
(
table
);
generatedKeys
.
initialize
(
table
);
int
listSize
=
list
.
size
();
int
listSize
=
list
.
size
();
if
(
listSize
>
0
)
{
if
(
listSize
>
0
)
{
Mode
mode
=
session
.
getDatabase
().
getMode
();
int
columnLen
=
columns
.
length
;
int
columnLen
=
columns
.
length
;
for
(
int
x
=
0
;
x
<
listSize
;
x
++)
{
for
(
int
x
=
0
;
x
<
listSize
;
x
++)
{
session
.
startStatementWithinTransaction
();
session
.
startStatementWithinTransaction
();
...
@@ -166,7 +168,7 @@ public class Insert extends Prepared implements ResultTarget {
...
@@ -166,7 +168,7 @@ public class Insert extends Prepared implements ResultTarget {
// e can be null (DEFAULT)
// e can be null (DEFAULT)
e
=
e
.
optimize
(
session
);
e
=
e
.
optimize
(
session
);
try
{
try
{
Value
v
=
c
.
convert
(
e
.
getValue
(
session
),
session
.
getDatabase
().
getMode
()
);
Value
v
=
c
.
convert
(
e
.
getValue
(
session
),
mode
);
newRow
.
setValue
(
index
,
v
);
newRow
.
setValue
(
index
,
v
);
if
(
e
instanceof
SequenceValue
)
{
if
(
e
instanceof
SequenceValue
)
{
generatedKeys
.
add
(
c
);
generatedKeys
.
add
(
c
);
...
@@ -239,11 +241,12 @@ public class Insert extends Prepared implements ResultTarget {
...
@@ -239,11 +241,12 @@ public class Insert extends Prepared implements ResultTarget {
private
Row
addRowImpl
(
Value
[]
values
)
{
private
Row
addRowImpl
(
Value
[]
values
)
{
Row
newRow
=
table
.
getTemplateRow
();
Row
newRow
=
table
.
getTemplateRow
();
setCurrentRowNumber
(++
rowNumber
);
setCurrentRowNumber
(++
rowNumber
);
Mode
mode
=
session
.
getDatabase
().
getMode
();
for
(
int
j
=
0
,
len
=
columns
.
length
;
j
<
len
;
j
++)
{
for
(
int
j
=
0
,
len
=
columns
.
length
;
j
<
len
;
j
++)
{
Column
c
=
columns
[
j
];
Column
c
=
columns
[
j
];
int
index
=
c
.
getColumnId
();
int
index
=
c
.
getColumnId
();
try
{
try
{
Value
v
=
c
.
convert
(
values
[
j
],
session
.
getDatabase
().
getMode
()
);
Value
v
=
c
.
convert
(
values
[
j
],
mode
);
newRow
.
setValue
(
index
,
v
);
newRow
.
setValue
(
index
,
v
);
}
catch
(
DbException
ex
)
{
}
catch
(
DbException
ex
)
{
throw
setRow
(
ex
,
rowNumber
,
getSQL
(
values
));
throw
setRow
(
ex
,
rowNumber
,
getSQL
(
values
));
...
...
h2/src/main/org/h2/command/dml/Merge.java
浏览文件 @
bbf4df6f
...
@@ -13,6 +13,7 @@ import org.h2.command.Command;
...
@@ -13,6 +13,7 @@ import org.h2.command.Command;
import
org.h2.command.CommandInterface
;
import
org.h2.command.CommandInterface
;
import
org.h2.command.Prepared
;
import
org.h2.command.Prepared
;
import
org.h2.engine.GeneratedKeys
;
import
org.h2.engine.GeneratedKeys
;
import
org.h2.engine.Mode
;
import
org.h2.engine.Right
;
import
org.h2.engine.Right
;
import
org.h2.engine.Session
;
import
org.h2.engine.Session
;
import
org.h2.engine.UndoLogRecord
;
import
org.h2.engine.UndoLogRecord
;
...
@@ -88,6 +89,7 @@ public class Merge extends Prepared {
...
@@ -88,6 +89,7 @@ public class Merge extends Prepared {
session
.
getUser
().
checkRight
(
targetTable
,
Right
.
UPDATE
);
session
.
getUser
().
checkRight
(
targetTable
,
Right
.
UPDATE
);
setCurrentRowNumber
(
0
);
setCurrentRowNumber
(
0
);
GeneratedKeys
generatedKeys
=
session
.
getGeneratedKeys
();
GeneratedKeys
generatedKeys
=
session
.
getGeneratedKeys
();
Mode
mode
=
session
.
getDatabase
().
getMode
();
if
(!
valuesExpressionList
.
isEmpty
())
{
if
(!
valuesExpressionList
.
isEmpty
())
{
// process values in list
// process values in list
count
=
0
;
count
=
0
;
...
@@ -104,7 +106,7 @@ public class Merge extends Prepared {
...
@@ -104,7 +106,7 @@ public class Merge extends Prepared {
if
(
e
!=
null
)
{
if
(
e
!=
null
)
{
// e can be null (DEFAULT)
// e can be null (DEFAULT)
try
{
try
{
Value
v
=
c
.
convert
(
e
.
getValue
(
session
));
Value
v
=
c
.
convert
(
e
.
getValue
(
session
)
,
mode
);
newRow
.
setValue
(
index
,
v
);
newRow
.
setValue
(
index
,
v
);
if
(
e
instanceof
SequenceValue
)
{
if
(
e
instanceof
SequenceValue
)
{
generatedKeys
.
add
(
c
);
generatedKeys
.
add
(
c
);
...
@@ -134,7 +136,7 @@ public class Merge extends Prepared {
...
@@ -134,7 +136,7 @@ public class Merge extends Prepared {
Column
c
=
columns
[
j
];
Column
c
=
columns
[
j
];
int
index
=
c
.
getColumnId
();
int
index
=
c
.
getColumnId
();
try
{
try
{
Value
v
=
c
.
convert
(
r
[
j
]);
Value
v
=
c
.
convert
(
r
[
j
]
,
mode
);
newRow
.
setValue
(
index
,
v
);
newRow
.
setValue
(
index
,
v
);
}
catch
(
DbException
ex
)
{
}
catch
(
DbException
ex
)
{
throw
setRow
(
ex
,
count
,
getSQL
(
r
));
throw
setRow
(
ex
,
count
,
getSQL
(
r
));
...
...
h2/src/main/org/h2/command/dml/Replace.java
浏览文件 @
bbf4df6f
...
@@ -12,6 +12,7 @@ import org.h2.api.Trigger;
...
@@ -12,6 +12,7 @@ import org.h2.api.Trigger;
import
org.h2.command.Command
;
import
org.h2.command.Command
;
import
org.h2.command.CommandInterface
;
import
org.h2.command.CommandInterface
;
import
org.h2.command.Prepared
;
import
org.h2.command.Prepared
;
import
org.h2.engine.Mode
;
import
org.h2.engine.Right
;
import
org.h2.engine.Right
;
import
org.h2.engine.Session
;
import
org.h2.engine.Session
;
import
org.h2.engine.UndoLogRecord
;
import
org.h2.engine.UndoLogRecord
;
...
@@ -82,6 +83,7 @@ public class Replace extends Prepared {
...
@@ -82,6 +83,7 @@ public class Replace extends Prepared {
session
.
getUser
().
checkRight
(
table
,
Right
.
INSERT
);
session
.
getUser
().
checkRight
(
table
,
Right
.
INSERT
);
session
.
getUser
().
checkRight
(
table
,
Right
.
UPDATE
);
session
.
getUser
().
checkRight
(
table
,
Right
.
UPDATE
);
setCurrentRowNumber
(
0
);
setCurrentRowNumber
(
0
);
Mode
mode
=
session
.
getDatabase
().
getMode
();
if
(!
list
.
isEmpty
())
{
if
(!
list
.
isEmpty
())
{
count
=
0
;
count
=
0
;
for
(
int
x
=
0
,
size
=
list
.
size
();
x
<
size
;
x
++)
{
for
(
int
x
=
0
,
size
=
list
.
size
();
x
<
size
;
x
++)
{
...
@@ -95,7 +97,7 @@ public class Replace extends Prepared {
...
@@ -95,7 +97,7 @@ public class Replace extends Prepared {
if
(
e
!=
null
)
{
if
(
e
!=
null
)
{
// e can be null (DEFAULT)
// e can be null (DEFAULT)
try
{
try
{
Value
v
=
c
.
convert
(
e
.
getValue
(
session
));
Value
v
=
c
.
convert
(
e
.
getValue
(
session
)
,
mode
);
newRow
.
setValue
(
index
,
v
);
newRow
.
setValue
(
index
,
v
);
}
catch
(
DbException
ex
)
{
}
catch
(
DbException
ex
)
{
throw
setRow
(
ex
,
count
,
getSQL
(
expr
));
throw
setRow
(
ex
,
count
,
getSQL
(
expr
));
...
@@ -119,7 +121,7 @@ public class Replace extends Prepared {
...
@@ -119,7 +121,7 @@ public class Replace extends Prepared {
Column
c
=
columns
[
j
];
Column
c
=
columns
[
j
];
int
index
=
c
.
getColumnId
();
int
index
=
c
.
getColumnId
();
try
{
try
{
Value
v
=
c
.
convert
(
r
[
j
]);
Value
v
=
c
.
convert
(
r
[
j
]
,
mode
);
newRow
.
setValue
(
index
,
v
);
newRow
.
setValue
(
index
,
v
);
}
catch
(
DbException
ex
)
{
}
catch
(
DbException
ex
)
{
throw
setRow
(
ex
,
count
,
getSQL
(
r
));
throw
setRow
(
ex
,
count
,
getSQL
(
r
));
...
...
h2/src/main/org/h2/command/dml/Update.java
浏览文件 @
bbf4df6f
...
@@ -131,7 +131,7 @@ public class Update extends Prepared {
...
@@ -131,7 +131,7 @@ public class Update extends Prepared {
}
else
if
(
newExpr
==
ValueExpression
.
getDefault
())
{
}
else
if
(
newExpr
==
ValueExpression
.
getDefault
())
{
newValue
=
table
.
getDefaultValue
(
session
,
column
);
newValue
=
table
.
getDefaultValue
(
session
,
column
);
}
else
{
}
else
{
newValue
=
column
.
convert
(
newExpr
.
getValue
(
session
));
newValue
=
column
.
convert
(
newExpr
.
getValue
(
session
)
,
session
.
getDatabase
().
getMode
()
);
}
}
newRow
.
setValue
(
i
,
newValue
);
newRow
.
setValue
(
i
,
newValue
);
}
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论