Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Gpdb
提交
83653d55
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,发现更多精彩内容 >>
提交
83653d55
编写于
7月 04, 2016
作者:
K
Kenan Yao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Optimization to achieve at most one cdbRelMaxSegSize() call in function
ATExecAlterColumnType.
上级
c86c7246
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
59 addition
and
62 deletion
+59
-62
src/backend/commands/tablecmds.c
src/backend/commands/tablecmds.c
+59
-62
未找到文件。
src/backend/commands/tablecmds.c
浏览文件 @
83653d55
...
...
@@ -9076,12 +9076,13 @@ ATExecAlterColumnType(AlteredTableInfo *tab, Relation rel,
Relation
attrelation
;
Relation
depRel
;
HeapTuple
depTup
;
GpPolicy
*
policy
=
NULL
;
GpPolicy
*
policy
=
rel
->
rd_cdbpolicy
;
bool
sourceIsInt
=
false
;
bool
targetIsInt
=
false
;
bool
sourceIsVarlenA
=
false
;
bool
targetIsVarlenA
=
false
;
bool
hashCompatible
=
false
;
bool
relContainsTuples
=
false
;
cqContext
cqc
;
cqContext
cqc2
;
cqContext
*
pcqCtx
;
...
...
@@ -9172,6 +9173,14 @@ ATExecAlterColumnType(AlteredTableInfo *tab, Relation rel,
else
defaultexpr
=
NULL
;
if
(
Gp_role
==
GP_ROLE_DISPATCH
&&
policy
!=
NULL
&&
policy
->
ptype
==
POLICYTYPE_PARTITIONED
&&
!
hashCompatible
)
{
relContainsTuples
=
cdbRelMaxSegSize
(
rel
)
>
0
;
}
/*
* Find everything that depends on the column (constraints, indexes, etc),
* and record enough information to let us recreate the objects.
...
...
@@ -9223,33 +9232,28 @@ ATExecAlterColumnType(AlteredTableInfo *tab, Relation rel,
Assert
(
foundObject
.
objectSubId
==
0
);
if
(
!
list_member_oid
(
tab
->
changedIndexOids
,
foundObject
.
objectId
))
{
char
*
indexdefstring
=
pg_get_indexdef_string
(
foundObject
.
objectId
);
char
*
indexdefstring
=
pg_get_indexdef_string
(
foundObject
.
objectId
);
tab
->
changedIndexOids
=
lappend_oid
(
tab
->
changedIndexOids
,
foundObject
.
objectId
);
tab
->
changedIndexDefs
=
lappend
(
tab
->
changedIndexDefs
,
indexdefstring
);
if
(
Gp_role
==
GP_ROLE_DISPATCH
&&
indexdefstring
&&
if
(
indexdefstring
!=
NULL
&&
strstr
(
indexdefstring
,
" UNIQUE "
)
!=
0
&&
!
hashCompatible
)
relContainsTuples
)
{
policy
=
rel
->
rd_cdbpolicy
;
if
(
policy
!=
NULL
&&
policy
->
ptype
==
POLICYTYPE_PARTITIONED
)
{
int
ia
=
0
;
Assert
(
Gp_role
==
GP_ROLE_DISPATCH
&&
policy
!=
NULL
&&
policy
->
ptype
==
POLICYTYPE_PARTITIONED
&&
!
hashCompatible
)
;
if
(
cdbRelMaxSegSize
(
rel
)
!=
0
)
for
(
int
ia
=
0
;
ia
<
policy
->
nattrs
;
ia
++
)
{
if
(
attnum
==
policy
->
attrs
[
ia
])
{
for
(
ia
=
0
;
ia
<
policy
->
nattrs
;
ia
++
)
{
if
(
attnum
==
policy
->
attrs
[
ia
])
{
ereport
(
ERROR
,
(
errcode
(
ERRCODE_FEATURE_NOT_SUPPORTED
),
errmsg
(
"Changing the type of a column that is part of the "
"distribution policy and used in a unique index is "
"not allowed"
)));
}
}
ereport
(
ERROR
,
(
errcode
(
ERRCODE_FEATURE_NOT_SUPPORTED
),
errmsg
(
"Changing the type of a column that is part of the "
"distribution policy and used in a unique index is "
"not allowed"
)));
}
}
}
...
...
@@ -9278,27 +9282,22 @@ ATExecAlterColumnType(AlteredTableInfo *tab, Relation rel,
{
char
*
defstring
=
pg_get_constraintdef_string
(
foundObject
.
objectId
);
if
(
Gp_role
==
GP_ROLE_DISPATCH
&&
!
hashCompatible
)
if
(
strstr
(
defstring
,
" UNIQUE"
)
!=
0
||
strstr
(
defstring
,
"PRIMARY KEY"
)
!=
0
)
if
(
relContainsTuples
&&
(
strstr
(
defstring
,
" UNIQUE"
)
!=
0
||
strstr
(
defstring
,
"PRIMARY KEY"
)
!=
0
))
{
policy
=
rel
->
rd_cdbpolicy
;
if
(
policy
!=
NULL
&&
policy
->
ptype
==
POLICYTYPE_PARTITIONED
)
{
int
ia
=
0
;
Assert
(
Gp_role
==
GP_ROLE_DISPATCH
&&
!
hashCompatible
&&
policy
!=
NULL
&&
policy
->
ptype
==
POLICYTYPE_PARTITIONED
)
;
if
(
cdbRelMaxSegSize
(
rel
)
!=
0
)
for
(
int
ia
=
0
;
ia
<
policy
->
nattrs
;
ia
++
)
{
if
(
attnum
==
policy
->
attrs
[
ia
])
{
for
(
ia
=
0
;
ia
<
policy
->
nattrs
;
ia
++
)
{
if
(
attnum
==
policy
->
attrs
[
ia
])
{
ereport
(
ERROR
,
(
errcode
(
ERRCODE_FEATURE_NOT_SUPPORTED
),
errmsg
(
"Changing the type of a column that is used in a "
"UNIQUE or PRIMARY KEY constraint is not allowed"
)));
}
}
ereport
(
ERROR
,
(
errcode
(
ERRCODE_FEATURE_NOT_SUPPORTED
),
errmsg
(
"Changing the type of a column that is used in a "
"UNIQUE or PRIMARY KEY constraint is not allowed"
)));
}
}
}
...
...
@@ -9406,35 +9405,33 @@ ATExecAlterColumnType(AlteredTableInfo *tab, Relation rel,
caql_endscan
(
pcqCtx
);
heap_close
(
depRel
,
RowExclusiveLock
);
policy
=
rel
->
rd_cdbpolicy
;
if
(
policy
!=
NULL
&&
policy
->
ptype
==
POLICYTYPE_PARTITIONED
&&
!
hashCompatible
)
if
(
Gp_role
==
GP_ROLE_DISPATCH
&&
policy
!=
NULL
&&
policy
->
ptype
==
POLICYTYPE_PARTITIONED
&&
!
hashCompatible
)
{
if
(
Gp_role
!=
GP_ROLE_EXECUTE
)
ListCell
*
lc
;
List
*
partkeys
;
partkeys
=
rel_partition_key_attrs
(
rel
->
rd_id
);
foreach
(
lc
,
partkeys
)
{
int
ia
=
0
;
ListCell
*
lc
;
List
*
partkeys
;
partkeys
=
rel_partition_key_attrs
(
rel
->
rd_id
);
foreach
(
lc
,
partkeys
)
if
(
attnum
==
lfirst_int
(
lc
))
ereport
(
ERROR
,
(
errcode
(
ERRCODE_FEATURE_NOT_SUPPORTED
),
errmsg
(
"cannot alter type of a column used in "
"a partitioning key"
)));
}
if
(
relContainsTuples
)
{
for
(
int
ia
=
0
;
ia
<
policy
->
nattrs
;
ia
++
)
{
if
(
attnum
==
lfirst_int
(
lc
)
)
if
(
attnum
==
policy
->
attrs
[
ia
]
)
ereport
(
ERROR
,
(
errcode
(
ERRCODE_FEATURE_NOT_SUPPORTED
),
errmsg
(
"cannot alter type of a column used in "
"a partitioning key"
)));
}
if
(
cdbRelMaxSegSize
(
rel
)
!=
0
)
{
for
(
ia
=
0
;
ia
<
policy
->
nattrs
;
ia
++
)
{
if
(
attnum
==
policy
->
attrs
[
ia
])
ereport
(
ERROR
,
(
errcode
(
ERRCODE_FEATURE_NOT_SUPPORTED
),
errmsg
(
"cannot alter type of a column used in "
"a distribution policy"
)));
}
"a distribution policy"
)));
}
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录