Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Gpdb
提交
e49c1a92
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,发现更多精彩内容 >>
提交
e49c1a92
编写于
10月 21, 2002
作者:
B
Bruce Momjian
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix ALTER TABLE ... ADD COLUMN for inheritance cases.
Alvaro Herrera
上级
b47c3598
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
42 addition
and
17 deletion
+42
-17
src/backend/commands/tablecmds.c
src/backend/commands/tablecmds.c
+38
-12
src/backend/tcop/utility.c
src/backend/tcop/utility.c
+1
-2
src/include/commands/tablecmds.h
src/include/commands/tablecmds.h
+2
-3
src/test/regress/output/misc.source
src/test/regress/output/misc.source
+1
-0
未找到文件。
src/backend/commands/tablecmds.c
浏览文件 @
e49c1a92
...
...
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/tablecmds.c,v 1.4
8 2002/10/19 03:01:09
momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/commands/tablecmds.c,v 1.4
9 2002/10/21 20:31:51
momjian Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -1584,7 +1584,6 @@ update_ri_trigger_args(Oid relid,
void
AlterTableAddColumn
(
Oid
myrelid
,
bool
recurse
,
bool
recursing
,
ColumnDef
*
colDef
)
{
Relation
rel
,
...
...
@@ -1643,22 +1642,50 @@ AlterTableAddColumn(Oid myrelid,
colDefChild
->
inhcount
=
1
;
colDefChild
->
is_local
=
false
;
/*
this routine is actually in the planner
*/
children
=
find_
all_inheritors
(
myrelid
);
/*
We only want direct inheritors
*/
children
=
find_
inheritance_children
(
myrelid
);
/*
* find_all_inheritors does the recursive search of the
* inheritance hierarchy, so all we have to do is process all of
* the relids in the list that it returns.
*/
foreach
(
child
,
children
)
{
Oid
childrelid
=
lfirsti
(
child
);
HeapTuple
tuple
;
Form_pg_attribute
childatt
;
Relation
childrel
;
if
(
childrelid
==
myrelid
)
continue
;
AlterTableAddColumn
(
childrelid
,
false
,
true
,
colDefChild
);
attrdesc
=
heap_openr
(
AttributeRelationName
,
RowExclusiveLock
);
tuple
=
SearchSysCacheCopyAttName
(
childrelid
,
colDef
->
colname
);
if
(
!
HeapTupleIsValid
(
tuple
))
{
heap_close
(
attrdesc
,
RowExclusiveLock
);
AlterTableAddColumn
(
childrelid
,
true
,
colDefChild
);
continue
;
}
childatt
=
(
Form_pg_attribute
)
GETSTRUCT
(
tuple
);
typeTuple
=
typenameType
(
colDef
->
typename
);
if
(
HeapTupleGetOid
(
typeTuple
)
!=
childatt
->
atttypid
||
colDef
->
typename
->
typmod
!=
childatt
->
atttypmod
)
elog
(
ERROR
,
"ALTER TABLE: child table %u has different "
"type for column
\"
%s
\"
"
,
childrelid
,
colDef
->
colname
);
childatt
->
attinhcount
++
;
simple_heap_update
(
attrdesc
,
&
tuple
->
t_self
,
tuple
);
CatalogUpdateIndexes
(
attrdesc
,
tuple
);
childrel
=
RelationIdGetRelation
(
childrelid
);
elog
(
NOTICE
,
"ALTER TABLE: merging definition of column "
"
\"
%s
\"
for child %s"
,
colDef
->
colname
,
RelationGetRelationName
(
childrel
));
RelationClose
(
childrel
);
heap_close
(
attrdesc
,
RowExclusiveLock
);
heap_freetuple
(
tuple
);
ReleaseSysCache
(
typeTuple
);
}
}
else
...
...
@@ -1667,8 +1694,7 @@ AlterTableAddColumn(Oid myrelid,
* If we are told not to recurse, there had better not be any
* child tables; else the addition would put them out of step.
*/
if
(
!
recursing
&&
find_inheritance_children
(
myrelid
)
!=
NIL
)
if
(
find_inheritance_children
(
myrelid
)
!=
NIL
)
elog
(
ERROR
,
"Attribute must be added to child tables too"
);
}
...
...
src/backend/tcop/utility.c
浏览文件 @
e49c1a92
...
...
@@ -10,7 +10,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/tcop/utility.c,v 1.1
79 2002/10/08 17:17:19 tgl
Exp $
* $Header: /cvsroot/pgsql/src/backend/tcop/utility.c,v 1.1
80 2002/10/21 20:31:52 momjian
Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -475,7 +475,6 @@ ProcessUtility(Node *parsetree,
*/
AlterTableAddColumn
(
relid
,
interpretInhOption
(
stmt
->
relation
->
inhOpt
),
false
,
(
ColumnDef
*
)
stmt
->
def
);
break
;
case
'T'
:
/* ALTER COLUMN DEFAULT */
...
...
src/include/commands/tablecmds.h
浏览文件 @
e49c1a92
...
...
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Id: tablecmds.h,v 1.
7 2002/09/04 20:31:4
2 momjian Exp $
* $Id: tablecmds.h,v 1.
8 2002/10/21 20:31:5
2 momjian Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -16,8 +16,7 @@
#include "nodes/parsenodes.h"
extern
void
AlterTableAddColumn
(
Oid
myrelid
,
bool
recurse
,
bool
recursing
,
ColumnDef
*
colDef
);
extern
void
AlterTableAddColumn
(
Oid
myrelid
,
bool
recurse
,
ColumnDef
*
colDef
);
extern
void
AlterTableAlterColumnDropNotNull
(
Oid
myrelid
,
bool
recurse
,
const
char
*
colName
);
...
...
src/test/regress/output/misc.source
浏览文件 @
e49c1a92
...
...
@@ -373,6 +373,7 @@ SELECT * FROM e_star*;
(23 rows)
ALTER TABLE a_star* ADD COLUMN a text;
NOTICE: ALTER TABLE: merging definition of column "a" for child d_star
--UPDATE b_star*
-- SET a = text 'gazpacho'
-- WHERE aa > 4;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录