Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
95c8ef4c
提交
95c8ef4c
authored
17 年前
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
--no commit message
--no commit message
上级
99a149ea
显示空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
52 行增加
和
4 行删除
+52
-4
changelog.html
h2/src/docsrc/html/changelog.html
+1
-1
Parser.java
h2/src/main/org/h2/command/Parser.java
+6
-1
Update.java
h2/src/main/org/h2/command/dml/Update.java
+4
-0
ValueExpression.java
h2/src/main/org/h2/expression/ValueExpression.java
+6
-1
help.csv
h2/src/main/org/h2/res/help.csv
+1
-1
test.in.txt
h2/src/test/org/h2/test/test.in.txt
+34
-0
没有找到文件。
h2/src/docsrc/html/changelog.html
浏览文件 @
95c8ef4c
...
@@ -15,7 +15,7 @@ Change Log
...
@@ -15,7 +15,7 @@ Change Log
<h2>
Next Version (unreleased)
</h2>
<h2>
Next Version (unreleased)
</h2>
<ul>
<ul>
<li>
-
<li>
UPDATE SET column=DEFAULT is now supported.
</li></ul>
</li></ul>
<h2>
Version 1.0.67 (2008-02-22)
</h2>
<h2>
Version 1.0.67 (2008-02-22)
</h2>
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/command/Parser.java
浏览文件 @
95c8ef4c
...
@@ -635,7 +635,12 @@ public class Parser {
...
@@ -635,7 +635,12 @@ public class Parser {
do
{
do
{
Column
column
=
readTableColumn
(
filter
);
Column
column
=
readTableColumn
(
filter
);
read
(
"="
);
read
(
"="
);
Expression
expression
=
readExpression
();
Expression
expression
;
if
(
readIf
(
"DEFAULT"
))
{
expression
=
ValueExpression
.
DEFAULT
;
}
else
{
expression
=
readExpression
();
}
command
.
setAssignment
(
column
,
expression
);
command
.
setAssignment
(
column
,
expression
);
}
while
(
readIf
(
","
));
}
while
(
readIf
(
","
));
}
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/command/dml/Update.java
浏览文件 @
95c8ef4c
...
@@ -11,6 +11,7 @@ import org.h2.constant.ErrorCode;
...
@@ -11,6 +11,7 @@ import org.h2.constant.ErrorCode;
import
org.h2.engine.Right
;
import
org.h2.engine.Right
;
import
org.h2.engine.Session
;
import
org.h2.engine.Session
;
import
org.h2.expression.Expression
;
import
org.h2.expression.Expression
;
import
org.h2.expression.ValueExpression
;
import
org.h2.message.Message
;
import
org.h2.message.Message
;
import
org.h2.result.LocalResult
;
import
org.h2.result.LocalResult
;
import
org.h2.result.Row
;
import
org.h2.result.Row
;
...
@@ -80,6 +81,9 @@ public class Update extends Prepared {
...
@@ -80,6 +81,9 @@ public class Update extends Prepared {
Value
newValue
;
Value
newValue
;
if
(
newExpr
==
null
)
{
if
(
newExpr
==
null
)
{
newValue
=
oldRow
.
getValue
(
i
);
newValue
=
oldRow
.
getValue
(
i
);
}
else
if
(
newExpr
==
ValueExpression
.
DEFAULT
)
{
Column
column
=
table
.
getColumn
(
i
);
newValue
=
column
.
getDefaultExpression
().
getValue
(
session
).
convertTo
(
column
.
getType
());
}
else
{
}
else
{
Column
column
=
table
.
getColumn
(
i
);
Column
column
=
table
.
getColumn
(
i
);
newValue
=
newExpr
.
getValue
(
session
).
convertTo
(
column
.
getType
());
newValue
=
newExpr
.
getValue
(
session
).
convertTo
(
column
.
getType
());
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/expression/ValueExpression.java
浏览文件 @
95c8ef4c
...
@@ -22,6 +22,7 @@ public class ValueExpression extends Expression {
...
@@ -22,6 +22,7 @@ public class ValueExpression extends Expression {
private
Value
value
;
private
Value
value
;
public
static
final
ValueExpression
NULL
=
new
ValueExpression
(
ValueNull
.
INSTANCE
);
public
static
final
ValueExpression
NULL
=
new
ValueExpression
(
ValueNull
.
INSTANCE
);
public
static
final
ValueExpression
DEFAULT
=
new
ValueExpression
(
ValueNull
.
INSTANCE
);
public
static
ValueExpression
get
(
Value
v
)
{
public
static
ValueExpression
get
(
Value
v
)
{
if
(
v
==
ValueNull
.
INSTANCE
)
{
if
(
v
==
ValueNull
.
INSTANCE
)
{
...
@@ -86,8 +87,12 @@ public class ValueExpression extends Expression {
...
@@ -86,8 +87,12 @@ public class ValueExpression extends Expression {
}
}
public
String
getSQL
()
{
public
String
getSQL
()
{
if
(
this
==
DEFAULT
)
{
return
"DEFAULT"
;
}
else
{
return
value
.
getSQL
();
return
value
.
getSQL
();
}
}
}
public
void
updateAggregate
(
Session
session
)
throws
SQLException
{
public
void
updateAggregate
(
Session
session
)
throws
SQLException
{
}
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/res/help.csv
浏览文件 @
95c8ef4c
...
@@ -29,7 +29,7 @@ INSERT INTO TEST VALUES(1, 'Hello')
...
@@ -29,7 +29,7 @@ INSERT INTO TEST VALUES(1, 'Hello')
"Commands (DML)","UPDATE","
"Commands (DML)","UPDATE","
UPDATE tableName
UPDATE tableName
SET {columnName=
expression
} [,...]
SET {columnName=
{DEFAULT | expression}
} [,...]
[WHERE expression]
[WHERE expression]
","
","
Updates data in a table.
Updates data in a table.
...
...
This diff is collapsed.
Click to expand it.
h2/src/test/org/h2/test/test.in.txt
浏览文件 @
95c8ef4c
--- special grammar and test cases ---------------------------------------------------------------------------------------------
--- special grammar and test cases ---------------------------------------------------------------------------------------------
create table test(a int, b int default 1);
> ok
insert into test values(1, default), (2, 2), (3, null);
> update count: 3
select * from test;
> A B
> - ----
> 1 1
> 2 2
> 3 null
> rows: 3
update test set b = default where a = 2;
> update count: 1
explain update test set b = default where a = 2;
> PLAN
> ---------------------------------------------------------------------------
> UPDATE PUBLIC.TEST /* PUBLIC.TEST_TABLE_SCAN */ SET B = DEFAULT WHERE A = 2
> rows: 1
select * from test;
> A B
> - ----
> 1 1
> 2 1
> 3 null
> rows: 3
drop table test;
> ok
CREATE ROLE X;
CREATE ROLE X;
> ok
> ok
...
...
This diff is collapsed.
Click to expand it.
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论