Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
26b991b4
提交
26b991b4
authored
7月 16, 2017
作者:
Niklas Mehner
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove unused variable "resolvedTable"
上级
bb06b10c
显示空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
28 行增加
和
31 行删除
+28
-31
Delete.java
h2/src/main/org/h2/command/dml/Delete.java
+8
-9
Replace.java
h2/src/main/org/h2/command/dml/Replace.java
+5
-6
Update.java
h2/src/main/org/h2/command/dml/Update.java
+15
-16
没有找到文件。
h2/src/main/org/h2/command/dml/Delete.java
浏览文件 @
26b991b4
...
@@ -55,9 +55,8 @@ public class Delete extends Prepared {
...
@@ -55,9 +55,8 @@ public class Delete extends Prepared {
tableFilter
.
reset
();
tableFilter
.
reset
();
Table
table
=
tableFilter
.
getTable
();
Table
table
=
tableFilter
.
getTable
();
session
.
getUser
().
checkRight
(
table
,
Right
.
DELETE
);
session
.
getUser
().
checkRight
(
table
,
Right
.
DELETE
);
Table
resolvedTable
=
table
;
table
.
fire
(
session
,
Trigger
.
DELETE
,
true
);
resolvedTable
.
fire
(
session
,
Trigger
.
DELETE
,
true
);
table
.
lock
(
session
,
true
,
false
);
resolvedTable
.
lock
(
session
,
true
,
false
);
RowList
rows
=
new
RowList
(
session
);
RowList
rows
=
new
RowList
(
session
);
int
limitRows
=
-
1
;
int
limitRows
=
-
1
;
if
(
limitExpr
!=
null
)
{
if
(
limitExpr
!=
null
)
{
...
@@ -75,8 +74,8 @@ public class Delete extends Prepared {
...
@@ -75,8 +74,8 @@ public class Delete extends Prepared {
condition
.
getBooleanValue
(
session
)))
{
condition
.
getBooleanValue
(
session
)))
{
Row
row
=
tableFilter
.
get
();
Row
row
=
tableFilter
.
get
();
boolean
done
=
false
;
boolean
done
=
false
;
if
(
resolvedT
able
.
fireRow
())
{
if
(
t
able
.
fireRow
())
{
done
=
resolvedT
able
.
fireBeforeRow
(
session
,
row
,
null
);
done
=
t
able
.
fireBeforeRow
(
session
,
row
,
null
);
}
}
if
(!
done
)
{
if
(!
done
)
{
rows
.
add
(
row
);
rows
.
add
(
row
);
...
@@ -93,16 +92,16 @@ public class Delete extends Prepared {
...
@@ -93,16 +92,16 @@ public class Delete extends Prepared {
checkCanceled
();
checkCanceled
();
}
}
Row
row
=
rows
.
next
();
Row
row
=
rows
.
next
();
resolvedT
able
.
removeRow
(
session
,
row
);
t
able
.
removeRow
(
session
,
row
);
session
.
log
(
table
,
UndoLogRecord
.
DELETE
,
row
);
session
.
log
(
table
,
UndoLogRecord
.
DELETE
,
row
);
}
}
if
(
resolvedT
able
.
fireRow
())
{
if
(
t
able
.
fireRow
())
{
for
(
rows
.
reset
();
rows
.
hasNext
();)
{
for
(
rows
.
reset
();
rows
.
hasNext
();)
{
Row
row
=
rows
.
next
();
Row
row
=
rows
.
next
();
resolvedT
able
.
fireAfterRow
(
session
,
row
,
null
,
false
);
t
able
.
fireAfterRow
(
session
,
row
,
null
,
false
);
}
}
}
}
resolvedT
able
.
fire
(
session
,
Trigger
.
DELETE
,
false
);
t
able
.
fire
(
session
,
Trigger
.
DELETE
,
false
);
return
count
;
return
count
;
}
finally
{
}
finally
{
rows
.
close
();
rows
.
close
();
...
...
h2/src/main/org/h2/command/dml/Replace.java
浏览文件 @
26b991b4
...
@@ -82,13 +82,12 @@ public class Replace extends Prepared {
...
@@ -82,13 +82,12 @@ 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
);
Table
resolvedTable
=
table
;
if
(
list
.
size
()
>
0
)
{
if
(
list
.
size
()
>
0
)
{
count
=
0
;
count
=
0
;
for
(
int
x
=
0
,
size
=
list
.
size
();
x
<
size
;
x
++)
{
for
(
int
x
=
0
,
size
=
list
.
size
();
x
<
size
;
x
++)
{
setCurrentRowNumber
(
x
+
1
);
setCurrentRowNumber
(
x
+
1
);
Expression
[]
expr
=
list
.
get
(
x
);
Expression
[]
expr
=
list
.
get
(
x
);
Row
newRow
=
resolvedT
able
.
getTemplateRow
();
Row
newRow
=
t
able
.
getTemplateRow
();
for
(
int
i
=
0
,
len
=
columns
.
length
;
i
<
len
;
i
++)
{
for
(
int
i
=
0
,
len
=
columns
.
length
;
i
<
len
;
i
++)
{
Column
c
=
columns
[
i
];
Column
c
=
columns
[
i
];
int
index
=
c
.
getColumnId
();
int
index
=
c
.
getColumnId
();
...
@@ -109,12 +108,12 @@ public class Replace extends Prepared {
...
@@ -109,12 +108,12 @@ public class Replace extends Prepared {
}
else
{
}
else
{
ResultInterface
rows
=
query
.
query
(
0
);
ResultInterface
rows
=
query
.
query
(
0
);
count
=
0
;
count
=
0
;
resolvedT
able
.
fire
(
session
,
Trigger
.
UPDATE
|
Trigger
.
INSERT
,
true
);
t
able
.
fire
(
session
,
Trigger
.
UPDATE
|
Trigger
.
INSERT
,
true
);
resolvedT
able
.
lock
(
session
,
true
,
false
);
t
able
.
lock
(
session
,
true
,
false
);
while
(
rows
.
next
())
{
while
(
rows
.
next
())
{
count
++;
count
++;
Value
[]
r
=
rows
.
currentRow
();
Value
[]
r
=
rows
.
currentRow
();
Row
newRow
=
resolvedT
able
.
getTemplateRow
();
Row
newRow
=
t
able
.
getTemplateRow
();
setCurrentRowNumber
(
count
);
setCurrentRowNumber
(
count
);
for
(
int
j
=
0
;
j
<
columns
.
length
;
j
++)
{
for
(
int
j
=
0
;
j
<
columns
.
length
;
j
++)
{
Column
c
=
columns
[
j
];
Column
c
=
columns
[
j
];
...
@@ -129,7 +128,7 @@ public class Replace extends Prepared {
...
@@ -129,7 +128,7 @@ public class Replace extends Prepared {
replace
(
newRow
);
replace
(
newRow
);
}
}
rows
.
close
();
rows
.
close
();
resolvedT
able
.
fire
(
session
,
Trigger
.
UPDATE
|
Trigger
.
INSERT
,
false
);
t
able
.
fire
(
session
,
Trigger
.
UPDATE
|
Trigger
.
INSERT
,
false
);
}
}
return
count
;
return
count
;
}
}
...
...
h2/src/main/org/h2/command/dml/Update.java
浏览文件 @
26b991b4
...
@@ -85,14 +85,13 @@ public class Update extends Prepared {
...
@@ -85,14 +85,13 @@ public class Update extends Prepared {
try
{
try
{
Table
table
=
tableFilter
.
getTable
();
Table
table
=
tableFilter
.
getTable
();
session
.
getUser
().
checkRight
(
table
,
Right
.
UPDATE
);
session
.
getUser
().
checkRight
(
table
,
Right
.
UPDATE
);
Table
resolvedTable
=
table
;
table
.
fire
(
session
,
Trigger
.
UPDATE
,
true
);
resolvedTable
.
fire
(
session
,
Trigger
.
UPDATE
,
true
);
table
.
lock
(
session
,
true
,
false
);
resolvedTable
.
lock
(
session
,
true
,
false
);
int
columnCount
=
table
.
getColumns
().
length
;
int
columnCount
=
resolvedTable
.
getColumns
().
length
;
// get the old rows, compute the new rows
// get the old rows, compute the new rows
setCurrentRowNumber
(
0
);
setCurrentRowNumber
(
0
);
int
count
=
0
;
int
count
=
0
;
Column
[]
columns
=
resolvedT
able
.
getColumns
();
Column
[]
columns
=
t
able
.
getColumns
();
int
limitRows
=
-
1
;
int
limitRows
=
-
1
;
if
(
limitExpr
!=
null
)
{
if
(
limitExpr
!=
null
)
{
Value
v
=
limitExpr
.
getValue
(
session
);
Value
v
=
limitExpr
.
getValue
(
session
);
...
@@ -108,25 +107,25 @@ public class Update extends Prepared {
...
@@ -108,25 +107,25 @@ public class Update extends Prepared {
if
(
condition
==
null
||
if
(
condition
==
null
||
Boolean
.
TRUE
.
equals
(
condition
.
getBooleanValue
(
session
)))
{
Boolean
.
TRUE
.
equals
(
condition
.
getBooleanValue
(
session
)))
{
Row
oldRow
=
tableFilter
.
get
();
Row
oldRow
=
tableFilter
.
get
();
Row
newRow
=
resolvedT
able
.
getTemplateRow
();
Row
newRow
=
t
able
.
getTemplateRow
();
for
(
int
i
=
0
;
i
<
columnCount
;
i
++)
{
for
(
int
i
=
0
;
i
<
columnCount
;
i
++)
{
Expression
newExpr
=
expressionMap
.
get
(
columns
[
i
]);
Expression
newExpr
=
expressionMap
.
get
(
columns
[
i
]);
Value
newValue
;
Value
newValue
;
if
(
newExpr
==
null
)
{
if
(
newExpr
==
null
)
{
newValue
=
oldRow
.
getValue
(
i
);
newValue
=
oldRow
.
getValue
(
i
);
}
else
if
(
newExpr
==
ValueExpression
.
getDefault
())
{
}
else
if
(
newExpr
==
ValueExpression
.
getDefault
())
{
Column
column
=
resolvedT
able
.
getColumn
(
i
);
Column
column
=
t
able
.
getColumn
(
i
);
newValue
=
resolvedT
able
.
getDefaultValue
(
session
,
column
);
newValue
=
t
able
.
getDefaultValue
(
session
,
column
);
}
else
{
}
else
{
Column
column
=
resolvedT
able
.
getColumn
(
i
);
Column
column
=
t
able
.
getColumn
(
i
);
newValue
=
column
.
convert
(
newExpr
.
getValue
(
session
));
newValue
=
column
.
convert
(
newExpr
.
getValue
(
session
));
}
}
newRow
.
setValue
(
i
,
newValue
);
newRow
.
setValue
(
i
,
newValue
);
}
}
resolvedT
able
.
validateConvertUpdateSequence
(
session
,
newRow
);
t
able
.
validateConvertUpdateSequence
(
session
,
newRow
);
boolean
done
=
false
;
boolean
done
=
false
;
if
(
resolvedT
able
.
fireRow
())
{
if
(
t
able
.
fireRow
())
{
done
=
resolvedT
able
.
fireBeforeRow
(
session
,
oldRow
,
newRow
);
done
=
t
able
.
fireBeforeRow
(
session
,
oldRow
,
newRow
);
}
}
if
(!
done
)
{
if
(!
done
)
{
rows
.
add
(
oldRow
);
rows
.
add
(
oldRow
);
...
@@ -143,16 +142,16 @@ public class Update extends Prepared {
...
@@ -143,16 +142,16 @@ public class Update extends Prepared {
// we need to update all indexes) before row triggers
// we need to update all indexes) before row triggers
// the cached row is already updated - we need the old values
// the cached row is already updated - we need the old values
resolvedT
able
.
updateRows
(
this
,
session
,
rows
);
t
able
.
updateRows
(
this
,
session
,
rows
);
if
(
resolvedT
able
.
fireRow
())
{
if
(
t
able
.
fireRow
())
{
rows
.
invalidateCache
();
rows
.
invalidateCache
();
for
(
rows
.
reset
();
rows
.
hasNext
();)
{
for
(
rows
.
reset
();
rows
.
hasNext
();)
{
Row
o
=
rows
.
next
();
Row
o
=
rows
.
next
();
Row
n
=
rows
.
next
();
Row
n
=
rows
.
next
();
resolvedT
able
.
fireAfterRow
(
session
,
o
,
n
,
false
);
t
able
.
fireAfterRow
(
session
,
o
,
n
,
false
);
}
}
}
}
resolvedT
able
.
fire
(
session
,
Trigger
.
UPDATE
,
false
);
t
able
.
fire
(
session
,
Trigger
.
UPDATE
,
false
);
return
count
;
return
count
;
}
finally
{
}
finally
{
rows
.
close
();
rows
.
close
();
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论