Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Gpdb
提交
9ee48915
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,发现更多精彩内容 >>
提交
9ee48915
编写于
12月 09, 2002
作者:
T
Tom Lane
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Some quick fixes for ALTER DOMAIN patch. It still needs a lot of work,
but at least it doesn't generate gcc warnings.
上级
4ed6be54
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
76 addition
and
96 deletion
+76
-96
src/backend/commands/typecmds.c
src/backend/commands/typecmds.c
+76
-96
未找到文件。
src/backend/commands/typecmds.c
浏览文件 @
9ee48915
...
...
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/typecmds.c,v 1.2
0 2002/12/06 05:00:11 momjian
Exp $
* $Header: /cvsroot/pgsql/src/backend/commands/typecmds.c,v 1.2
1 2002/12/09 20:31:05 tgl
Exp $
*
* DESCRIPTION
* The "DefineFoo" routines take the parse tree and pick out the
...
...
@@ -63,7 +63,6 @@
static
Oid
findTypeIOFunction
(
List
*
procname
,
Oid
typeOid
,
bool
isOutput
);
static
List
*
get_rels_with_domain
(
Oid
domainOid
);
static
void
domainPermissionCheck
(
HeapTuple
tup
,
TypeName
*
typename
);
static
void
domainCheckForUnsupportedConstraints
(
Node
*
newConstraint
);
static
char
*
domainAddConstraint
(
Oid
domainOid
,
Oid
domainNamespace
,
Oid
baseTypeOid
,
int
typMod
,
Constraint
*
constr
,
...
...
@@ -519,24 +518,23 @@ DefineDomain(CreateDomainStmt *stmt)
Constraint
*
colDef
;
ParseState
*
pstate
;
/*
* Check for constraint types which are not supported by
* domains. Throws an error if it finds one.
*/
domainCheckForUnsupportedConstraints
(
newConstraint
);
/* Check for unsupported constraint types */
if
(
IsA
(
newConstraint
,
FkConstraint
))
elog
(
ERROR
,
"CREATE DOMAIN / FOREIGN KEY constraints not supported"
);
/* this case should not happen */
if
(
!
IsA
(
newConstraint
,
Constraint
))
elog
(
ERROR
,
"DefineDomain: unexpected constraint node type"
);
/* Assume its a CHECK, DEFAULT, NULL or NOT NULL constraint */
colDef
=
(
Constraint
*
)
newConstraint
;
switch
(
colDef
->
contype
)
{
case
CONSTR_DEFAULT
:
/*
* The inherited default value may be overridden by the
* user with the DEFAULT <expr> statement.
*
* We have to search the entire constraint tree returned as
* we don't want to cook or fiddle too much.
*/
case
CONSTR_DEFAULT
:
if
(
defaultExpr
)
elog
(
ERROR
,
"CREATE DOMAIN has multiple DEFAULT expressions"
);
/* Create a dummy ParseState for transformExpr */
...
...
@@ -563,9 +561,6 @@ DefineDomain(CreateDomainStmt *stmt)
defaultValueBin
=
nodeToString
(
defaultExpr
);
break
;
/*
* Find the NULL constraint.
*/
case
CONSTR_NOTNULL
:
if
(
nullDefined
)
elog
(
ERROR
,
"CREATE DOMAIN has conflicting NULL / NOT NULL constraint"
);
...
...
@@ -580,19 +575,34 @@ DefineDomain(CreateDomainStmt *stmt)
nullDefined
=
true
;
break
;
/*
* Check constraints are handled after domain creation, as they require
* the Oid of the domain
*/
case
CONSTR_CHECK
:
/*
* Check constraints are handled after domain creation, as they
* require the Oid of the domain
*/
break
;
/*
* All else are error cases
*/
case
CONSTR_UNIQUE
:
elog
(
ERROR
,
"CREATE DOMAIN / UNIQUE not supported"
);
break
;
case
CONSTR_PRIMARY
:
elog
(
ERROR
,
"CREATE DOMAIN / PRIMARY KEY not supported"
);
break
;
case
CONSTR_ATTR_DEFERRABLE
:
case
CONSTR_ATTR_NOT_DEFERRABLE
:
case
CONSTR_ATTR_DEFERRED
:
case
CONSTR_ATTR_IMMEDIATE
:
elog
(
ERROR
,
"CREATE DOMAIN: DEFERRABLE, NON DEFERRABLE, DEFERRED"
" and IMMEDIATE not supported"
);
break
;
/*
* If we reach this, then domainCheckForUnsupportedConstraints()
* doesn't have a complete list of unsupported domain constraints
*/
default:
elog
(
ERROR
,
"DefineDomain: unrecognized constraint
node
type"
);
elog
(
ERROR
,
"DefineDomain: unrecognized constraint
sub
type"
);
break
;
}
}
...
...
@@ -629,6 +639,8 @@ DefineDomain(CreateDomainStmt *stmt)
{
Constraint
*
constr
=
lfirst
(
listptr
);
/* it must be a Constraint, per check above */
switch
(
constr
->
contype
)
{
case
CONSTR_CHECK
:
...
...
@@ -642,7 +654,8 @@ DefineDomain(CreateDomainStmt *stmt)
}
break
;
/* Errors for other constraints are taken care of prior to domain creation */
/* Other constraint types were fully processed above */
default:
break
;
}
...
...
@@ -1262,21 +1275,21 @@ AlterDomainAddConstraint(List *names, Node *newConstraint)
elog
(
ERROR
,
"AlterDomain: type
\"
%s
\"
does not exist"
,
TypeNameToString
(
typename
));
typTup
=
(
Form_pg_type
)
GETSTRUCT
(
tup
);
/* Doesn't return if user isn't allowed to alter the domain */
domainPermissionCheck
(
tup
,
typename
);
typTup
=
(
Form_pg_type
)
GETSTRUCT
(
tup
);
/* Check for unsupported constraint types */
if
(
IsA
(
newConstraint
,
FkConstraint
))
elog
(
ERROR
,
"ALTER DOMAIN / FOREIGN KEY constraints not supported"
);
/*
* Check for constraint types which are not supported by
* domains. Throws an error if it finds one.
*/
domainCheckForUnsupportedConstraints
(
newConstraint
);
/* this case should not happen */
if
(
!
IsA
(
newConstraint
,
Constraint
))
elog
(
ERROR
,
"AlterDomainAddConstraint: unexpected constraint node type"
);
/* Assume its a CHECK, DEFAULT, NULL or NOT NULL constraint */
constr
=
(
Constraint
*
)
newConstraint
;
switch
(
constr
->
contype
)
{
case
CONSTR_DEFAULT
:
...
...
@@ -1288,32 +1301,42 @@ AlterDomainAddConstraint(List *names, Node *newConstraint)
elog
(
ERROR
,
"Use ALTER DOMAIN .. [ SET | DROP ] NOT NULL instead"
);
break
;
/*
* Check constraints are handled after domain creation, as they require
* the Oid of the domain
*/
case
CONSTR_CHECK
:
{
/* Returns the cooked constraint which is not needed during creation */
ccbin
=
domainAddConstraint
(
HeapTupleGetOid
(
tup
),
typTup
->
typnamespace
,
typTup
->
typbasetype
,
typTup
->
typtypmod
,
constr
,
&
counter
,
NameStr
(
typTup
->
typname
));
}
/* processed below */
break
;
/*
* If we reach this, then domainCheckForUnsupportedConstraints()
* doesn't have a complete list of unsupported domain constraints
*/
case
CONSTR_UNIQUE
:
elog
(
ERROR
,
"ALTER DOMAIN / UNIQUE indexes not supported"
);
break
;
case
CONSTR_PRIMARY
:
elog
(
ERROR
,
"ALTER DOMAIN / PRIMARY KEY indexes not supported"
);
break
;
case
CONSTR_ATTR_DEFERRABLE
:
case
CONSTR_ATTR_NOT_DEFERRABLE
:
case
CONSTR_ATTR_DEFERRED
:
case
CONSTR_ATTR_IMMEDIATE
:
elog
(
ERROR
,
"ALTER DOMAIN: DEFERRABLE, NON DEFERRABLE, DEFERRED"
" and IMMEDIATE not supported"
);
break
;
default:
elog
(
ERROR
,
"
DefineDomain
: unrecognized constraint node type"
);
elog
(
ERROR
,
"
AlterDomainAddConstraint
: unrecognized constraint node type"
);
break
;
}
/*
* Since all other constraint types throw errors, this must be
* a check constraint, and ccbin must be set.
*
* a check constraint.
*/
/* Returns the cooked constraint which is not needed during creation */
ccbin
=
domainAddConstraint
(
HeapTupleGetOid
(
tup
),
typTup
->
typnamespace
,
typTup
->
typbasetype
,
typTup
->
typtypmod
,
constr
,
&
counter
,
NameStr
(
typTup
->
typname
));
/*
* Test all values stored in the attributes based on the domain
* the constraint is being added to.
*/
...
...
@@ -1424,7 +1447,7 @@ get_rels_with_domain(Oid domainOid)
/* Scan through pg_class for tables */
while
((
classTup
=
heap_getnext
(
classScan
,
ForwardScanDirection
))
!=
NULL
)
{
bool
addToList
=
true
;
relToCheck
*
rtc
=
NULL
;
int
nkeys
=
0
;
HeapTuple
attTup
;
HeapScanDesc
attScan
;
...
...
@@ -1447,13 +1470,9 @@ get_rels_with_domain(Oid domainOid)
/* Scan through pg_attribute for attributes based on the domain */
while
((
attTup
=
heap_getnext
(
attScan
,
ForwardScanDirection
))
!=
NULL
)
{
relToCheck
*
rtc
;
/* Make the list entries for the relation */
if
(
addToList
)
if
(
rtc
==
NULL
)
{
addToList
=
false
;
/* First one found for this rel */
rtc
=
(
relToCheck
*
)
palloc
(
sizeof
(
relToCheck
));
rtc
->
atts
=
(
int
*
)
palloc
(
sizeof
(
int
)
*
pg_class
->
relnatts
);
rtc
->
relOid
=
HeapTupleGetOid
(
classTup
);
...
...
@@ -1625,42 +1644,3 @@ domainAddConstraint(Oid domainOid, Oid domainNamespace, Oid baseTypeOid,
*/
return
ccbin
;
}
/*
* domainCheckForUnsupportedConstraints
*
* Throws an error on constraints that are unsupported by the
* domains.
*/
void
domainCheckForUnsupportedConstraints
(
Node
*
newConstraint
)
{
Constraint
*
colDef
;
if
(
nodeTag
(
newConstraint
)
==
T_FkConstraint
)
elog
(
ERROR
,
"CREATE DOMAIN / FOREIGN KEY constraints not supported"
);
colDef
=
(
Constraint
*
)
newConstraint
;
switch
(
colDef
->
contype
)
{
case
CONSTR_UNIQUE
:
elog
(
ERROR
,
"CREATE DOMAIN / UNIQUE indexes not supported"
);
break
;
case
CONSTR_PRIMARY
:
elog
(
ERROR
,
"CREATE DOMAIN / PRIMARY KEY indexes not supported"
);
break
;
case
CONSTR_ATTR_DEFERRABLE
:
case
CONSTR_ATTR_NOT_DEFERRABLE
:
case
CONSTR_ATTR_DEFERRED
:
case
CONSTR_ATTR_IMMEDIATE
:
elog
(
ERROR
,
"DefineDomain: DEFERRABLE, NON DEFERRABLE, DEFERRED"
" and IMMEDIATE not supported"
);
break
;
default:
break
;
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录