Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Gpdb
提交
6e8596a1
G
Gpdb
项目概览
Greenplum
/
Gpdb
通知
7
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
Gpdb
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
6e8596a1
编写于
9月 02, 2006
作者:
B
Bruce Momjian
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add UPDATE tab SET ROW (col, ...) = (val, ...) for updating
multiple columns Susanne Ebrecht
上级
9e522d08
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
81 addition
and
6 deletion
+81
-6
doc/src/sgml/ref/update.sgml
doc/src/sgml/ref/update.sgml
+7
-2
src/backend/parser/gram.y
src/backend/parser/gram.y
+74
-4
未找到文件。
doc/src/sgml/ref/update.sgml
浏览文件 @
6e8596a1
<!--
$PostgreSQL: pgsql/doc/src/sgml/ref/update.sgml,v 1.3
8 2006/08/12 02:52:03 tgl
Exp $
$PostgreSQL: pgsql/doc/src/sgml/ref/update.sgml,v 1.3
9 2006/09/02 20:34:47 momjian
Exp $
PostgreSQL documentation
-->
...
...
@@ -21,7 +21,8 @@ PostgreSQL documentation
<refsynopsisdiv>
<synopsis>
UPDATE [ ONLY ] <replaceable class="PARAMETER">table</replaceable> [ [ AS ] <replaceable class="parameter">alias</replaceable> ]
SET <replaceable class="PARAMETER">column</replaceable> = { <replaceable class="PARAMETER">expression</replaceable> | DEFAULT } [, ...]
[ SET <replaceable class="PARAMETER">column</replaceable> = { <replaceable class="PARAMETER">expression</replaceable> | DEFAULT } [, ...] |
SET ( <replaceable class="PARAMETER">column</replaceable> [, ...] ) = ( { <replaceable class="PARAMETER">expression</replaceable> | DEFAULT } [, ...] ) [, ...] ]
[ FROM <replaceable class="PARAMETER">fromlist</replaceable> ]
[ WHERE <replaceable class="PARAMETER">condition</replaceable> ]
[ RETURNING * | <replaceable class="parameter">output_expression</replaceable> [ AS <replaceable class="parameter">output_name</replaceable> ] [, ...] ]
...
...
@@ -250,6 +251,10 @@ UPDATE films SET kind = 'Dramatic' WHERE kind = 'Drama';
<programlisting>
UPDATE weather SET temp_lo = temp_lo+1, temp_hi = temp_lo+15, prcp = DEFAULT
WHERE city = 'San Francisco' AND date = '2003-07-03';
</programlisting>
<programlisting>
UPDATE weather SET (temp_lo, temp_hi, prcp) = (temp_lo+1, temp_lo+15, DEFAULT)
WHERE city = 'San Francisco' AND date = '2003-07-03';
</programlisting>
</para>
...
...
src/backend/parser/gram.y
浏览文件 @
6e8596a1
...
...
@@ -11,7 +11,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/parser/gram.y,v 2.56
0 2006/09/02 18:17:1
7 momjian Exp $
* $PostgreSQL: pgsql/src/backend/parser/gram.y,v 2.56
1 2006/09/02 20:34:4
7 momjian Exp $
*
* HISTORY
* AUTHOR DATE MAJOR EVENT
...
...
@@ -237,7 +237,8 @@ static void doNegateFloat(Value *v);
name_list from_clause from_list opt_array_bounds
qualified_name_list any_name any_name_list
any_operator expr_list attrs
target_list update_target_list insert_column_list
target_list update_col_list update_target_list
update_value_list insert_column_list
values_list def_list indirection opt_indirection
group_clause TriggerFuncArgs select_limit
opt_select_limit opclass_item_list
...
...
@@ -308,7 +309,8 @@ static void doNegateFloat(Value *v);
%type <jexpr> joined_table
%type <range> relation_expr
%type <range> relation_expr_opt_alias
%type <target> target_el update_target_el insert_column_item
%type <target> target_el update_target_el update_col_list_el insert_column_item
%type <list> update_target_lists_list update_target_lists_el
%type <typnam> Typename SimpleTypename ConstTypename
GenericType Numeric opt_float
...
...
@@ -5537,6 +5539,20 @@ UpdateStmt: UPDATE relation_expr_opt_alias
n->returningList = $7;
$$ = (Node *)n;
}
| UPDATE relation_expr_opt_alias
SET update_target_lists_list
from_clause
where_clause
returning_clause
{
UpdateStmt *n = makeNode(UpdateStmt);
n->relation = $2;
n->targetList = $4;
n->fromClause = $5;
n->whereClause = $6;
n->returningList = $7;
$$ = (Node *)n;
}
;
...
...
@@ -5941,6 +5957,60 @@ values_item:
| DEFAULT { $$ = (Node *) makeNode(SetToDefault); }
;
update_target_lists_list:
update_target_lists_el { $$ = $1; }
| update_target_lists_list ',' update_target_lists_el { $$ = list_concat($1, $3); }
;
update_target_lists_el:
'(' update_col_list ')' '=' '(' update_value_list ')'
{
ListCell *col_cell;
ListCell *val_cell;
if (list_length($2) != list_length($6))
{
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("number of columns does not match to number of values")));
}
for (col_cell = list_head($2), val_cell = list_head($6);
col_cell != NULL && val_cell != NULL;
col_cell = lnext(col_cell), val_cell = lnext(val_cell))
{
/* merge update_value_list with update_col_list */
ResTarget *res_col = (ResTarget *) lfirst(col_cell);
ResTarget *res_val = (ResTarget *) lfirst(val_cell);
res_col->val = (Node *)copyObject(res_val);
}
$$ = $2;
}
;
update_col_list:
update_col_list_el { $$ = list_make1($1); }
| update_col_list ',' update_col_list_el { $$ = lappend($1, $3); }
;
update_col_list_el:
ColId opt_indirection
{
$$ = makeNode(ResTarget);
$$->name = $1;
$$->indirection = $2;
$$->val = NULL;
$$->location = @1;
}
;
update_value_list:
values_item { $$ = list_make1($1); }
| update_value_list ',' values_item { $$ = lappend($1, $3); }
;
/*****************************************************************************
*
...
...
@@ -8253,7 +8323,7 @@ target_el: a_expr AS ColLabel
;
update_target_list:
update_target_el
{ $$ = list_make1($1); }
update_target_el
{ $$ = list_make1($1); }
| update_target_list ',' update_target_el { $$ = lappend($1,$3); }
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录